1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-02 12:58:35 +03:00

Test improvements (#35955)

This commit is contained in:
Daan De Meyer 2025-01-10 21:30:58 +01:00 committed by GitHub
commit beca4655dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 4 deletions

View File

@ -151,6 +151,10 @@ that make use of `run_testcases`.
`TEST_SKIP_TESTCASE=testcase`: takes a space separated list of testcases to skip.
`TEST_JOURNAL_USE_TMP=1`: Write test journal to `/tmp` while the test is in
progress and only move the journal to its final location in the build directory
(`$BUILD_DIR/test/journal`) when the test is finished.
### SELinux AVCs
To have `TEST-06-SELINUX` check for SELinux denials, write the following to

View File

@ -13,6 +13,10 @@ lsmem
echo "Clock source: $(cat /sys/devices/system/clocksource/clocksource0/current_clocksource)"
# Bump inotify limits so nspawn containers don't run out of inotify file descriptors.
sysctl fs.inotify.max_user_watches=65536
sysctl fs.inotify.max_user_instances=1024
# Allow running the integration tests downstream in dist-git with something like
# the following snippet which makes the dist-git sources available in $TMT_SOURCE_DIR:
#
@ -112,6 +116,18 @@ if [[ ! -e /dev/kvm ]]; then
export TEST_NO_QEMU=1
fi
NPROC="$(nproc)"
if [[ "$NPROC" -ge 10 ]]; then
export TEST_JOURNAL_USE_TMP=1
NPROC="$((NPROC / 3))"
else
NPROC="$((NPROC - 1))"
fi
# This test is only really useful if we're building with sanitizers and takes a long time, so let's skip it
# for now.
export TEST_SKIP="TEST-21-DFUZZER"
# Create missing mountpoint for mkosi sandbox.
mkdir -p /etc/pacman.d/gnupg
@ -127,7 +143,7 @@ mkosi -f sandbox \
--suite integration-tests \
--print-errorlogs \
--no-stdsplit \
--num-processes "$(($(nproc) - 1))" && EC=0 || EC=$?
--num-processes "$NPROC" && EC=0 || EC=$?
find build/meson-logs -type f -exec mv {} "$TMT_TEST_DATA" \;
find build/test/journal -type f -exec mv {} "$TMT_TEST_DATA" \;

View File

@ -10,6 +10,7 @@ import json
import os
import re
import shlex
import shutil
import subprocess
import sys
import tempfile
@ -441,7 +442,11 @@ def main() -> None:
"""
)
journal_file = (args.meson_build_dir / (f'test/journal/{name}.journal')).absolute()
if os.getenv('TEST_JOURNAL_USE_TMP', '0') == '1':
journal_file = Path(f'/tmp/systemd-integration-tests/journal/{name.journal}')
else:
journal_file = (args.meson_build_dir / f'test/journal/{name}.journal').absolute()
journal_file.unlink(missing_ok=True)
if not sys.stderr.isatty():
@ -465,6 +470,7 @@ def main() -> None:
[Service]
ExecStartPre=/usr/lib/systemd/tests/testdata/integration-test-setup.sh setup
ExecStopPost=/usr/lib/systemd/tests/testdata/integration-test-setup.sh finalize
StateDirectory=%N
"""
)
@ -511,7 +517,7 @@ def main() -> None:
]
),
'--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}",
*(['--runtime-build-sources=no'] if not sys.stderr.isatty() else []),
*(['--runtime-build-sources=no', '--register=no'] if not sys.stderr.isatty() else []),
'vm' if args.vm or os.getuid() != 0 or os.getenv('TEST_PREFER_QEMU', '0') == '1' else 'boot',
] # fmt: skip
@ -551,6 +557,11 @@ def main() -> None:
):
journal_file.unlink(missing_ok=True)
if os.getenv('TEST_JOURNAL_USE_TMP', '0') == '1':
dst = args.meson_build_dir / f'test/journal/{name}.journal'
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.move(journal_file, dst)
if shell or (result.returncode in (args.exit_code, 77) and not coredumps and not sanitizer):
exit(0 if shell or result.returncode == args.exit_code else 77)

View File

@ -10,4 +10,3 @@ ExecStartPre=rm -f /failed /testok
ExecStart=@command@
Type=oneshot
MemoryAccounting=@memory-accounting@
StateDirectory=%N