Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests,ci] Allow to build only tests #1913

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .ci/lib/stage-build-test-only.jenkinsfile
Original file line number Diff line number Diff line change
@@ -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'
}
15 changes: 15 additions & 0 deletions .ci/linux-tests-only.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
node('nonsgx_slave') {
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'
# XXX: we should also run test
}
}
6 changes: 4 additions & 2 deletions libos/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
24 changes: 11 additions & 13 deletions libos/test/regression/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,18 @@ if host_machine.cpu_family() == 'x86_64'
}
endif

if sgx
tests += {
'attestation': {
# for `sgx_arch.h`
'include_directories': include_directories('../../../pal/src/host/linux-sgx'),
'source': [
'attestation.c',
'../../../pal/src/host/linux-sgx/enclave_api.S',
],
tests += {
'attestation': {
# for `sgx_arch.h`
'include_directories': include_directories('../../../pal/src/host/linux-sgx'),
'source': [
'attestation.c',
'../../../pal/src/host/linux-sgx/enclave_api.S',
],

'dependencies': mbedtls_static_dep,
},
}
endif
'dependencies': mbedtls_static_dep,
},
}

install_dir = pkglibdir / 'tests' / 'libos' / 'regression'

Expand Down
45 changes: 29 additions & 16 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ project(
# We can't change to c23 for any supported versions yet (requires at
# least gcc 14).
if meson.get_compiler('c').has_argument('-std=c23')
add_project_arguments('-std=c23', language: 'c')
add_project_arguments('-std=c23', language: 'c')
elif meson.get_compiler('c').has_argument('-std=c2x')
add_project_arguments('-std=c2x', language: 'c')
add_project_arguments('-std=c2x', language: 'c')
endif

# we need this subdir() early, because we need scripts defined there for setting up global vars
Expand All @@ -51,6 +51,8 @@ vtune = get_option('vtune') == 'enabled'
enable_libgomp = get_option('libgomp') == 'enabled'
enable_tests = get_option('tests') == 'enabled'

src_build = skeleton or direct or sgx

cc = meson.get_compiler('c')
host_has_glibc = cc.get_define('__GLIBC__', prefix: '#include <features.h>') != ''
objcopy = find_program('objcopy')
Expand Down Expand Up @@ -230,19 +232,24 @@ 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

# Build Mbed TLS even if !src_build because some tests (attestation tests)
# require it.
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
Expand Down Expand Up @@ -288,16 +295,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
Expand Down
10 changes: 6 additions & 4 deletions pal/meson.build
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion python/graminelibos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('@PKGLIBDIR@/sgx/libpal.so')


if __version__.startswith('@') and not _os.getenv('GRAMINE_IMPORT_FOR_SPHINX_ANYWAY') == '1':
raise RuntimeError(
Expand Down
3 changes: 2 additions & 1 deletion subprojects/packagefiles/mbedtls/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ pkgconfig.generate(
if get_option('libc') == 'glibc' and host_has_glibc
foreach output : mbedtls_libs_output
meson.add_install_script('/bin/sh', '-c',
('ln -sf ../../../@0@ ' +
('mkdir -p "$MESON_INSTALL_DESTDIR_PREFIX"/@1@/gramine/runtime/@2@ && ' +
'ln -sf ../../../@0@ ' +
'"$MESON_INSTALL_DESTDIR_PREFIX"/@1@/gramine/runtime/@2@/').format(
output, get_option('libdir'), get_option('libc')))
endforeach
Expand Down