From f30f3bcd60b6780bf23ddd2b7957e019f2d950d4 Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Thu, 13 Jun 2024 07:37:57 -0400 Subject: [PATCH] [tests,ci] Allow to build only tests Signed-off-by: Mariusz Zaborski --- .ci/lib/stage-build-test-only.jenkinsfile | 23 +++++++++++++ .ci/linux-tests-only.jenkinsfile | 14 ++++++++ libos/meson.build | 6 ++-- libos/test/regression/meson.build | 2 +- meson.build | 40 +++++++++++++++-------- meson_options.txt | 2 ++ pal/meson.build | 10 +++--- python/graminelibos/__init__.py | 3 +- 8 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 .ci/lib/stage-build-test-only.jenkinsfile create mode 100644 .ci/linux-tests-only.jenkinsfile diff --git a/.ci/lib/stage-build-test-only.jenkinsfile b/.ci/lib/stage-build-test-only.jenkinsfile new file mode 100644 index 0000000000..3c6770df1f --- /dev/null +++ b/.ci/lib/stage-build-test-only.jenkinsfile @@ -0,0 +1,23 @@ +stage('build') { + try { + sh ''' + meson setup build/ \ + --werror \ + --prefix="$PREFIX" \ + --buildtype="$BUILDTYPE" \ + -Dskeleton=disabled \ + -Ddirect=disabled \ + -Dsgx=disabled \ + -Dtests=enabled \ + $MESON_OPTIONS + ninja -vC build/ + ''' + } finally { + archiveArtifacts ''' + build/meson-logs/**/*, + ''' + } + + sh 'rm -rf build' + sh 'git clean -Xf subprojects' +} diff --git a/.ci/linux-tests-only.jenkinsfile b/.ci/linux-tests-only.jenkinsfile new file mode 100644 index 0000000000..ec6299bbb0 --- /dev/null +++ b/.ci/linux-tests-only.jenkinsfile @@ -0,0 +1,14 @@ +node('nonsgx_slave && aesni') { + checkout scm + + load '.ci/lib/config-docker.jenkinsfile' + docker.build( + "local:${env.BUILD_TAG}", + '-f .ci/ubuntu20.04.dockerfile .' + ).inside("${env.DOCKER_ARGS_COMMON} --security-opt seccomp=${env.WORKSPACE}/scripts/docker_seccomp_mar_2021.json") { + load '.ci/lib/config.jenkinsfile' + load '.ci/lib/config-clang.jenkinsfile' + + load '.ci/lib/stage-build-test-only.jenkinsfile' + } +} diff --git a/libos/meson.build b/libos/meson.build index f99fa39edc..9365f244d3 100644 --- a/libos/meson.build +++ b/libos/meson.build @@ -17,8 +17,10 @@ if host_machine.cpu_family() == 'x86_64' cflags_libos += ['-mfxsr', '-mxsave'] endif -subdir('include') -subdir('src') +if src_build + subdir('include') + subdir('src') +endif if enable_tests subdir('test') diff --git a/libos/test/regression/meson.build b/libos/test/regression/meson.build index c1270607e5..44c33a7a55 100644 --- a/libos/test/regression/meson.build +++ b/libos/test/regression/meson.build @@ -192,7 +192,7 @@ if host_machine.cpu_family() == 'x86_64' } endif -if sgx +if sgx or force_sgx_tests tests += { 'attestation': { # for `sgx_arch.h` diff --git a/meson.build b/meson.build index 329272b844..8e7f5db233 100644 --- a/meson.build +++ b/meson.build @@ -50,6 +50,9 @@ vtune = get_option('vtune') == 'enabled' enable_libgomp = get_option('libgomp') == 'enabled' enable_tests = get_option('tests') == 'enabled' +force_sgx_tests = get_option('force_sgx_tests') == 'enabled' + +src_build = skeleton or direct or sgx cc = meson.get_compiler('c') host_has_glibc = cc.get_define('__GLIBC__', prefix: '#include ') != '' @@ -230,19 +233,22 @@ endif # # Dependencies # +if src_build + tomlc99_proj = subproject('tomlc99-208203af46bdbdb29ba199660ed78d09c220b6c5') + tomlc99_dep = tomlc99_proj.get_variable('tomlc99_dep') + tomlc99_src = tomlc99_proj.get_variable('tomlc99_src') -tomlc99_proj = subproject('tomlc99-208203af46bdbdb29ba199660ed78d09c220b6c5') -tomlc99_dep = tomlc99_proj.get_variable('tomlc99_dep') -tomlc99_src = tomlc99_proj.get_variable('tomlc99_src') - -uthash_dep = subproject('uthash-2.1.0').get_variable('uthash_dep') + uthash_dep = subproject('uthash-2.1.0').get_variable('uthash_dep') +endif mbedtls_proj = subproject('mbedtls-3.6.0') mbedtls_static_dep = mbedtls_proj.get_variable('mbedtls_static_dep') mbedtls_pal_dep = mbedtls_proj.get_variable('mbedtls_pal_dep') -curl_proj = subproject('curl-8.8.0') -cjson_proj = subproject('cJSON-1.7.12') +if src_build + curl_proj = subproject('curl-8.8.0') + cjson_proj = subproject('cJSON-1.7.12') +endif if sgx # XXX: do not call subproject() from under "if sgx" conditional, because it @@ -288,16 +294,22 @@ endif # The compilation # -subdir('common') -subdir('pal') +if src_build + subdir('common') + subdir('pal') +endif subdir('libos') subdir('python') -subdir('tools') +if src_build + subdir('tools') +endif -if get_option('libc') == 'glibc' - subproject('glibc-2.39-1') -elif get_option('libc') == 'musl' - subproject('musl-1.2.4') +if src_build + if get_option('libc') == 'glibc' + subproject('glibc-2.39-1') + elif get_option('libc') == 'musl' + subproject('musl-1.2.4') + endif endif if enable_libgomp diff --git a/meson_options.txt b/meson_options.txt index e29929f6d7..4787eb5085 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -11,6 +11,8 @@ option('libc', type: 'combo', choices: ['none', 'glibc', 'musl'], option('tests', type: 'combo', choices: ['disabled', 'enabled'], description: 'Build test binaries') +option('force_sgx_tests', type: 'combo', choices: ['disabled', 'enabled'], + description: 'Build sgx tests even if sgx is not enabled') option('dcap', type: 'combo', choices: ['disabled', 'enabled'], description: 'Build additional utilities linked against DCAP library') diff --git a/pal/meson.build b/pal/meson.build index 8c5799ac8f..254d21dee7 100644 --- a/pal/meson.build +++ b/pal/meson.build @@ -1,8 +1,10 @@ -subdir('include') -subdir('src') +if src_build + subdir('include') + subdir('src') -if enable_tests - subdir('regression') + if enable_tests + subdir('regression') + endif endif if debug diff --git a/python/graminelibos/__init__.py b/python/graminelibos/__init__.py index a96d57e768..7e839e3a39 100644 --- a/python/graminelibos/__init__.py +++ b/python/graminelibos/__init__.py @@ -6,7 +6,8 @@ _CONFIG_PKGLIBDIR = '@PKGLIBDIR@' _CONFIG_LIBDIR = '@LIBDIR@' _CONFIG_SYSLIBDIR = '@SYSLIBDIR@' -_CONFIG_SGX_ENABLED = '@SGX_ENABLED@' == '1' +_CONFIG_SGX_ENABLED = _os.path.exists('@LIBDIR@/sgx/libpal.so') + if __version__.startswith('@') and not _os.getenv('GRAMINE_IMPORT_FOR_SPHINX_ANYWAY') == '1': raise RuntimeError(