diff --git a/Makefile.am b/Makefile.am index 8ebf1c0e2e..f09afa20fd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,7 +32,9 @@ else noinst_LTLIBRARIES = libcrun.la endif +if BUILD_TESTS check_LTLIBRARIES = libcrun_testing.la +endif libcrun_SOURCES = src/libcrun/utils.c \ src/libcrun/string_map.c \ @@ -87,9 +89,11 @@ libcrun_la_LIBADD = libocispec/libocispec.la $(FOUND_LIBS) $(maybe_libyajl.la) libcrun_la_LDFLAGS = -Wl,--version-script=$(abs_top_srcdir)/libcrun.lds # build a version with all the symbols visible for testing +if BUILD_TESTS libcrun_testing_la_SOURCES = $(libcrun_SOURCES) libcrun_testing_la_CFLAGS = -I $(abs_top_builddir)/libocispec/src -I $(abs_top_srcdir)/libocispec/src -fvisibility=default libcrun_testing_la_LIBADD = libocispec/libocispec.la $(maybe_libyajl.la) +endif if PYTHON_BINDINGS pyexec_LTLIBRARIES = python_crun.la @@ -163,7 +167,9 @@ EXTRA_DIST = COPYING COPYING.libcrun README.md NEWS SECURITY.md rpm/crun.spec au krun.1.md krun.1 \ lua/luacrun.rockspec +if BUILD_TESTS UNIT_TESTS = tests/tests_libcrun_utils tests/tests_libcrun_ring_buffer tests/tests_libcrun_errors tests/tests_libcrun_intelrdt +endif if ENABLE_CRUN bin_PROGRAMS = crun @@ -172,6 +178,7 @@ else noinst_PROGRAMS = crun endif +if BUILD_TESTS check_PROGRAMS = tests/init $(UNIT_TESTS) tests/tests_libcrun_fuzzer TESTS_LDADD = libcrun_testing.la $(FOUND_LIBS) $(maybe_libyajl.la) @@ -205,6 +212,7 @@ tests_tests_libcrun_errors_SOURCES = tests/tests_libcrun_errors.c tests_tests_libcrun_errors_LDADD = $(TESTS_LDADD) tests_tests_libcrun_errors_LDFLAGS = $(crun_LDFLAGS) +endif TEST_EXTENSIONS = .py PY_LOG_COMPILER = $(PYTHON) PY_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh @@ -236,7 +244,9 @@ PYTHON_TESTS = tests/test_capabilities.py \ tests/test_time.py \ tests/test_bpf_devices.py +if BUILD_TESTS TESTS = $(PYTHON_TESTS) $(UNIT_TESTS) +endif .version: $(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@ diff --git a/configure.ac b/configure.ac index cbd3dc4ae0..5f39279d35 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,16 @@ AC_CHECK_TYPES([atomic_int], [], [], [[#include ]]) AC_CHECK_FUNCS(eaccess hsearch_r copy_file_range fgetxattr statx fgetpwent_r issetugid memfd_create) +case "${lt_cv_prog_compiler_static_works}" in + yes) build_tests=true ;; + no) + AC_MSG_WARN([Static compilation not working. Test suite cannot be built / executed. Make sure to install glibc-static or equivalent.]) + build_tests=false + ;; + *) ;; +esac +AM_CONDITIONAL([BUILD_TESTS], [test "x${build_tests}" = xtrue]) + AC_ARG_ENABLE(crun, AS_HELP_STRING([--enable-crun], [Include crun executable in installation (default: yes)]), [ diff --git a/rpm/crun.spec b/rpm/crun.spec index dcf0edc453..7881bb8954 100644 --- a/rpm/crun.spec +++ b/rpm/crun.spec @@ -73,6 +73,7 @@ Recommends: criu-libs BuildRequires: wasmedge-devel %endif BuildRequires: python +BuildRequires: glibc-static Provides: oci-runtime %description diff --git a/tests/centos10-build/Dockerfile b/tests/centos10-build/Dockerfile index c607881b1d..e4d1ceeb9c 100644 --- a/tests/centos10-build/Dockerfile +++ b/tests/centos10-build/Dockerfile @@ -2,7 +2,7 @@ FROM quay.io/centos/centos:stream10-development RUN yum --enablerepo='appstream' --enablerepo='baseos' --enablerepo='crb' install -y make \ automake autoconf gettext criu-devel libtool gcc libcap-devel systemd-devel \ - libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel xz + libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel xz glibc-static COPY run-tests.sh /usr/local/bin diff --git a/tests/centos8-build/Dockerfile b/tests/centos8-build/Dockerfile index b446dd452a..4b810e3fd2 100644 --- a/tests/centos8-build/Dockerfile +++ b/tests/centos8-build/Dockerfile @@ -3,7 +3,7 @@ FROM quay.io/centos/centos:stream8 RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && \ yum --enablerepo='powertools' install -y make automake autoconf gettext \ criu-devel libtool gcc libcap-devel systemd-devel yajl-devel \ - libseccomp-devel python36 libtool git + libseccomp-devel python36 libtool git glibc-static COPY run-tests.sh /usr/local/bin diff --git a/tests/centos9-build/Dockerfile b/tests/centos9-build/Dockerfile index e052d03a97..da3b22e3fd 100644 --- a/tests/centos9-build/Dockerfile +++ b/tests/centos9-build/Dockerfile @@ -2,7 +2,7 @@ FROM quay.io/centos/centos:stream9 RUN yum --enablerepo='appstream' --enablerepo='baseos' --enablerepo='crb' install -y make \ automake autoconf gettext criu-devel libtool gcc libcap-devel systemd-devel yajl-devel \ - libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel + libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel glibc-static COPY run-tests.sh /usr/local/bin diff --git a/tests/clang-check/Dockerfile b/tests/clang-check/Dockerfile index 5be6f7c662..5c0bfaa32a 100644 --- a/tests/clang-check/Dockerfile +++ b/tests/clang-check/Dockerfile @@ -1,6 +1,6 @@ FROM fedora:latest -RUN dnf install -y awk git protobuf-c protobuf-c-devel make clang-tools-extra clang python3-pip 'dnf-command(builddep)' && \ +RUN dnf install -y awk git protobuf-c protobuf-c-devel make clang-tools-extra clang python3-pip glibc-static 'dnf-command(builddep)' && \ dnf builddep -y crun && pip install scan-build COPY run-tests.sh /usr/local/bin diff --git a/tests/clang-format/Dockerfile b/tests/clang-format/Dockerfile index 7ffbd3fe00..5829ef9606 100644 --- a/tests/clang-format/Dockerfile +++ b/tests/clang-format/Dockerfile @@ -1,6 +1,6 @@ FROM fedora:latest -RUN dnf install -y awk git make clang-tools-extra 'dnf-command(builddep)' && dnf builddep -y crun +RUN dnf install -y awk git make clang-tools-extra glibc-static 'dnf-command(builddep)' && dnf builddep -y crun COPY run-tests.sh /usr/local/bin ENTRYPOINT /usr/local/bin/run-tests.sh