From e4d823f244c0c59fc430f811f80a872729c49443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20M=C3=ADchal?= Date: Sun, 29 May 2022 16:46:27 +0300 Subject: [PATCH] test/system: Connect system tests to Meson A bit of plumbing in the build files has been done to accommodate the change as much as possible. If we're to use meson.build in the 'test/system' subdir we better also install the data from there. This also adjust the CI playbooks to launch the tests via Meson by specifying the specific test suite ('system'). https://github.com/containers/toolbox/pull/1062 --- meson.build | 29 +------------------ playbooks/system-test.yaml | 4 +-- src/meson.build | 2 +- test/meson.build | 1 + test/system/libs/meson.build | 42 ++++++++++++++++++++++++++++ test/system/meson.build | 54 ++++++++++++++++++++++++++++++++++++ 6 files changed, 101 insertions(+), 31 deletions(-) create mode 100644 test/meson.build create mode 100644 test/system/libs/meson.build create mode 100644 test/system/meson.build diff --git a/meson.build b/meson.build index 70aa0a59c..fc4942f7b 100644 --- a/meson.build +++ b/meson.build @@ -16,7 +16,6 @@ endif go = find_program('go') go_md2man = find_program('go-md2man') shellcheck = find_program('shellcheck', required: false) -skopeo = find_program('skopeo', required: false) bash_completion = dependency('bash-completion', required: false) fish = dependency('fish', required: false) @@ -33,37 +32,11 @@ if tmpfilesdir == '' or not fs.exists('/run/.containerenv') endif endif -if not skopeo.found() - message('Running system tests requires Skopeo for OCI image manipulation.') -endif - -install_subdir( - 'test', - install_dir: join_paths(get_option('datadir'), meson.project_name()), - exclude_files: [ - 'system/libs/bats-assert/.git', - 'system/libs/bats-assert/.gitignore', - 'system/libs/bats-assert/.travis.yml', - 'system/libs/bats-assert/package.json', - 'system/libs/bats-support/.git', - 'system/libs/bats-support/.gitignore', - 'system/libs/bats-support/.travis.yml', - 'system/libs/bats-support/package.json' - ], - exclude_directories: [ - 'system/libs/bats-assert/.git', - 'system/libs/bats-assert/script', - 'system/libs/bats-assert/test', - 'system/libs/bats-support/.git', - 'system/libs/bats-support/script', - 'system/libs/bats-support/test' - ] -) - subdir('data') subdir('doc') subdir('profile.d') subdir('src') +subdir('test') if get_option('install_completions') subdir('completion') endif diff --git a/playbooks/system-test.yaml b/playbooks/system-test.yaml index 0249548ac..ce6513242 100644 --- a/playbooks/system-test.yaml +++ b/playbooks/system-test.yaml @@ -2,9 +2,9 @@ - hosts: all tasks: - name: Run system tests - command: bats --timing ./test/system + command: meson test --suite system environment: PODMAN: '/usr/bin/podman' TOOLBOX: '/usr/local/bin/toolbox' args: - chdir: '{{ zuul.project.src_dir }}' + chdir: '{{ zuul.project.src_dir }}/builddir' diff --git a/src/meson.build b/src/meson.build index 61fcc03a9..db9b1c771 100644 --- a/src/meson.build +++ b/src/meson.build @@ -47,7 +47,7 @@ endif message('Host machine dynamic linker:', dynamic_linker) -custom_target( +toolbox = custom_target( 'toolbox', build_by_default: true, command: [ diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 000000000..5d625b224 --- /dev/null +++ b/test/meson.build @@ -0,0 +1 @@ +subdir('system') diff --git a/test/system/libs/meson.build b/test/system/libs/meson.build new file mode 100644 index 000000000..f97f0cd0d --- /dev/null +++ b/test/system/libs/meson.build @@ -0,0 +1,42 @@ +system_tests_libs_dir = system_tests_dir / 'libs' + +system_tests_libs_files = files( + 'helpers.bash' +) + +install_data( + install_dir: system_tests_libs_dir, + sources: system_tests_libs_files +) + +install_subdir( + 'bats-support', + install_dir: system_tests_libs_dir, + exclude_files: [ + '.git', + '.gitignore', + '.travis.yml', + 'package.json' + ], + exclude_directories: [ + '.git', + 'script', + 'test' + ] +) + +install_subdir( + 'bats-assert', + install_dir: system_tests_libs_dir, + exclude_files: [ + '.git', + '.gitignore', + '.travis.yml', + 'package.json' + ], + exclude_directories: [ + '.git', + 'script', + 'test' + ] +) diff --git a/test/system/meson.build b/test/system/meson.build new file mode 100644 index 000000000..f06e70640 --- /dev/null +++ b/test/system/meson.build @@ -0,0 +1,54 @@ +system_tests_dir = get_option('datadir') / meson.project_name() / 'test' + +awk = find_program('awk', required: false) +bats = find_program('bats', required: false) +htpasswd = find_program('htpasswd', required: false) +openssl = find_program('openssl', required: false) +podman = find_program('podman', required: false) +skopeo = find_program('skopeo', required: false) + +system_tests_files = files( + '000-setup.bats', + '001-version.bats', + '002-help.bats', + '101-create.bats', + '102-list.bats', + '103-container.bats', + '104-run.bats', + '105-enter.bats', + '106-rm.bats', + '107-rmi.bats', + '999-teardown.bats', + 'README.md' +) + +if fs.exists('/run/.containerenv') + warning('System tests can not be run in a container.') +elif not awk.found() or not bats.found() or not htpasswd.found() or not openssl.found() or not podman.found() or not skopeo.found() + warning('System tests require: awk, bats, htpasswd, openssl, podman and skopeo being installed.') +else + system_tests_env = environment() + system_tests_env.set('TOOLBOX', toolbox.full_path()) + + test( + 'system tests', + bats, + args: [ + '--formatter', 'tap', + '--timing', + './'], + depends: toolbox, + env: system_tests_env, + protocol: 'tap', + suite: 'system', + timeout: 900, + workdir: meson.current_source_dir() + ) +endif + +install_data( + install_dir: system_tests_dir, + sources: system_tests_files +) + +subdir('libs')