test: Add infra to mark integration tests as slow

Some integration tests take much more time than others, let's add
a test param that can be used to configure this and integrate it
with the slow-tests meson option.
This commit is contained in:
Daan De Meyer 2024-05-07 15:20:44 +02:00
parent a77f65d0c9
commit f1f87f3b2e
2 changed files with 22 additions and 7 deletions

View file

@ -39,10 +39,6 @@ ExecStart=false
def main():
if not bool(int(os.getenv("SYSTEMD_INTEGRATION_TESTS", "0"))):
print("SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping", file=sys.stderr)
exit(77)
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--meson-source-dir', required=True, type=Path)
parser.add_argument('--meson-build-dir', required=True, type=Path)
@ -50,9 +46,18 @@ def main():
parser.add_argument('--test-number', required=True)
parser.add_argument('--storage', required=True)
parser.add_argument('--firmware', required=True)
parser.add_argument('--slow', action=argparse.BooleanOptionalAction)
parser.add_argument('mkosi_args', nargs="*")
args = parser.parse_args()
if not bool(int(os.getenv("SYSTEMD_INTEGRATION_TESTS", "0"))):
print(f"SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping {args.test_name}", file=sys.stderr)
exit(77)
if args.slow and not bool(int(os.getenv("SYSTEMD_SLOW_TESTS", "0"))):
print(f"SYSTEMD_SLOW_TESTS=1 not found in environment, skipping {args.test_name}", file=sys.stderr)
exit(77)
name = args.test_name + (f"-{i}" if (i := os.getenv("MESON_TEST_ITERATION")) else "")
test_unit = f"testsuite-{args.test_number}.service"

View file

@ -416,6 +416,7 @@ foreach test_number, dirname : integration_tests
'storage' : 'volatile',
'priority' : 0,
'firmware' : 'linux',
'slow' : false,
}
# TODO: This fs.exists call isn't included in rebuild logic
@ -432,13 +433,22 @@ foreach test_number, dirname : integration_tests
'--test-number', test_number,
'--storage', test_params['storage'],
'--firmware', test_params['firmware'],
'--',
] + test_params['mkosi_args']
]
if test_params['slow']
args += ['--slow']
endif
args += ['--'] + test_params['mkosi_args']
integration_test_env = {}
if want_integration_tests
integration_test_env = {'SYSTEMD_INTEGRATION_TESTS': '1'}
integration_test_env += {'SYSTEMD_INTEGRATION_TESTS': '1'}
endif
if want_slow_tests
integration_test_env += {'SYSTEMD_SLOW_TESTS': '1'}
endif
# We don't explicitly depend on the "mkosi" target because that means the image is rebuilt