Skip to content

Commit eb9912e

Browse files
committed
build: add check for static builds
tests/init needs glibc-static (or equivalent) available to run the test suite. update configure.ac to check for libtool ability to link statically update Makefile.am to build tests only if static linking is available update rpm/crun.spec to BuildRequires glibc-static update tests/*/Dockerfile to include glibc-static Signed-off-by: Fabio M. Di Nitto <[email protected]>
1 parent 20d4da7 commit eb9912e

File tree

8 files changed

+26
-5
lines changed

8 files changed

+26
-5
lines changed

Makefile.am

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ else
3232
noinst_LTLIBRARIES = libcrun.la
3333
endif
3434

35+
if BUILD_TESTS
3536
check_LTLIBRARIES = libcrun_testing.la
37+
endif
3638

3739
libcrun_SOURCES = src/libcrun/utils.c \
3840
src/libcrun/string_map.c \
@@ -87,9 +89,11 @@ libcrun_la_LIBADD = libocispec/libocispec.la $(FOUND_LIBS) $(maybe_libyajl.la)
8789
libcrun_la_LDFLAGS = -Wl,--version-script=$(abs_top_srcdir)/libcrun.lds
8890

8991
# build a version with all the symbols visible for testing
92+
if BUILD_TESTS
9093
libcrun_testing_la_SOURCES = $(libcrun_SOURCES)
9194
libcrun_testing_la_CFLAGS = -I $(abs_top_builddir)/libocispec/src -I $(abs_top_srcdir)/libocispec/src -fvisibility=default
9295
libcrun_testing_la_LIBADD = libocispec/libocispec.la $(maybe_libyajl.la)
96+
endif
9397

9498
if PYTHON_BINDINGS
9599
pyexec_LTLIBRARIES = python_crun.la
@@ -163,7 +167,9 @@ EXTRA_DIST = COPYING COPYING.libcrun README.md NEWS SECURITY.md rpm/crun.spec au
163167
krun.1.md krun.1 \
164168
lua/luacrun.rockspec
165169

170+
if BUILD_TESTS
166171
UNIT_TESTS = tests/tests_libcrun_utils tests/tests_libcrun_ring_buffer tests/tests_libcrun_errors tests/tests_libcrun_intelrdt
172+
endif
167173

168174
if ENABLE_CRUN
169175
bin_PROGRAMS = crun
@@ -172,6 +178,7 @@ else
172178
noinst_PROGRAMS = crun
173179
endif
174180

181+
if BUILD_TESTS
175182
check_PROGRAMS = tests/init $(UNIT_TESTS) tests/tests_libcrun_fuzzer
176183

177184
TESTS_LDADD = libcrun_testing.la $(FOUND_LIBS) $(maybe_libyajl.la)
@@ -205,6 +212,7 @@ tests_tests_libcrun_errors_SOURCES = tests/tests_libcrun_errors.c
205212
tests_tests_libcrun_errors_LDADD = $(TESTS_LDADD)
206213
tests_tests_libcrun_errors_LDFLAGS = $(crun_LDFLAGS)
207214

215+
endif
208216
TEST_EXTENSIONS = .py
209217
PY_LOG_COMPILER = $(PYTHON)
210218
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 \
236244
tests/test_time.py \
237245
tests/test_bpf_devices.py
238246

247+
if BUILD_TESTS
239248
TESTS = $(PYTHON_TESTS) $(UNIT_TESTS)
249+
endif
240250

241251
.version:
242252
$(AM_V_GEN)echo $(VERSION) > $@-t && mv $@-t $@

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ AC_CHECK_TYPES([atomic_int], [], [], [[#include <stdatomic.h>]])
3232

3333
AC_CHECK_FUNCS(eaccess hsearch_r copy_file_range fgetxattr statx fgetpwent_r issetugid memfd_create)
3434

35+
case "${lt_cv_prog_compiler_static_works}" in
36+
yes) build_tests=true ;;
37+
no)
38+
AC_MSG_WARN([Static compilation not working. Test suite cannot be built / executed. Make sure to install glibc-static or equivalent.])
39+
build_tests=false
40+
;;
41+
*) ;;
42+
esac
43+
AM_CONDITIONAL([BUILD_TESTS], [test "x${build_tests}" = xtrue])
44+
3545
AC_ARG_ENABLE(crun,
3646
AS_HELP_STRING([--enable-crun], [Include crun executable in installation (default: yes)]),
3747
[

rpm/crun.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Recommends: criu-libs
7373
BuildRequires: wasmedge-devel
7474
%endif
7575
BuildRequires: python
76+
BuildRequires: glibc-static
7677
Provides: oci-runtime
7778

7879
%description

tests/centos10-build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM quay.io/centos/centos:stream10-development
22

33
RUN yum --enablerepo='appstream' --enablerepo='baseos' --enablerepo='crb' install -y make \
44
automake autoconf gettext criu-devel libtool gcc libcap-devel systemd-devel \
5-
libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel xz
5+
libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel xz glibc-static
66

77
COPY run-tests.sh /usr/local/bin
88

tests/centos8-build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM quay.io/centos/centos:stream8
33
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && \
44
yum --enablerepo='powertools' install -y make automake autoconf gettext \
55
criu-devel libtool gcc libcap-devel systemd-devel yajl-devel \
6-
libseccomp-devel python36 libtool git
6+
libseccomp-devel python36 libtool git glibc-static
77

88
COPY run-tests.sh /usr/local/bin
99

tests/centos9-build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM quay.io/centos/centos:stream9
22

33
RUN yum --enablerepo='appstream' --enablerepo='baseos' --enablerepo='crb' install -y make \
44
automake autoconf gettext criu-devel libtool gcc libcap-devel systemd-devel yajl-devel \
5-
libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel
5+
libseccomp-devel python3 libtool git protobuf-c protobuf-c-devel glibc-static
66

77
COPY run-tests.sh /usr/local/bin
88

tests/clang-check/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM fedora:latest
22

3-
RUN dnf install -y awk git protobuf-c protobuf-c-devel make clang-tools-extra clang python3-pip 'dnf-command(builddep)' && \
3+
RUN dnf install -y awk git protobuf-c protobuf-c-devel make clang-tools-extra clang python3-pip glibc-static 'dnf-command(builddep)' && \
44
dnf builddep -y crun && pip install scan-build
55

66
COPY run-tests.sh /usr/local/bin

tests/clang-format/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM fedora:latest
22

3-
RUN dnf install -y awk git make clang-tools-extra 'dnf-command(builddep)' && dnf builddep -y crun
3+
RUN dnf install -y awk git make clang-tools-extra glibc-static 'dnf-command(builddep)' && dnf builddep -y crun
44

55
COPY run-tests.sh /usr/local/bin
66
ENTRYPOINT /usr/local/bin/run-tests.sh

0 commit comments

Comments
 (0)