1
0
Fork 0

tests/dbusrunner: Use separate HOME, Temp and XDG Runtime dirs

We need to use a different $XDG_RUNTIME_DIR path to be able to start most
tests in parallel, and we can use a temporary directory for that which python
cleans up when done.

Also, given that most of settings are stored in HOME use temporary one
for that too, to prevent mutter to fail because it may load some local
configuration (e.g. monitors.xml) that don't meet the expectations or
that may change the test behavior in an unexpected way.

As per this, CI needs to be adapted for new args handling

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3793>
This commit is contained in:
Marco Trevisan (Treviño) 2023-05-17 17:04:57 +02:00 committed by Marge Bot
parent adc43ba001
commit fec38819ac
4 changed files with 36 additions and 2 deletions

View file

@ -518,6 +518,7 @@ build-wayland-only@x86_64:
./src/tests/meta-dbus-runner.py
--launch=pipewire
--launch=wireplumber
--
meson test
-C build
--setup plain
@ -680,6 +681,7 @@ dist-mutter:
./src/tests/meta-dbus-runner.py
--launch=pipewire
--launch=wireplumber
--
meson dist -C build
artifacts:
expire_in: 7 day

View file

@ -50,7 +50,7 @@ foreach test_case: privileged_tests
args: [
kernel_image_path,
meta_dbus_runner.full_path(),
'--kvm',
'--kvm --',
meson.current_build_dir(),
vm_env,
kvm_wrapper,

View file

@ -40,6 +40,10 @@ SCRIPT="\
$(printf "\"%s\" " "${@:6}")\
"
if [ -v "$MUTTER_TEST_ROOT" ]; then
ISOLATE_DIRS_ARGS="--rwdir=$MUTTER_TEST_ROOT"
fi
echo Running tests in virtual machine ...
virtme-run \
--memory=1024M \
@ -47,6 +51,7 @@ virtme-run \
--pwd \
--kimg "$IMAGE" \
--script-sh "sh -c \"$SCRIPT\"" \
$ISOLATE_DIRS_ARGS \
--qemu-opts -cpu host,pdcm=off -smp 2
VM_RESULT=$?
if [ $VM_RESULT != 0 ]; then

View file

@ -8,6 +8,7 @@ import subprocess
import getpass
import argparse
import logind_helpers
import tempfile
from collections import OrderedDict
from dbusmock import DBusTestCase
from dbus.mainloop.glib import DBusGMainLoop
@ -286,12 +287,38 @@ def meta_run(klass):
parser = argparse.ArgumentParser()
parser.add_argument('--kvm', action='store_true', default=False)
parser.add_argument('--launch', action='append', default=[])
parser.add_argument('--no-isolate-dirs', action='store_true', default=False)
(args, rest) = parser.parse_known_args(sys.argv)
rest.pop(0)
if not rest:
parser.error('Command or separator `--` not found')
if rest[0] == '--':
rest.pop(0)
else:
print('WARNING: Command or separator `--` not found', file=sys.stderr)
if args.no_isolate_dirs:
return meta_run_klass(klass, args, rest)
test_root = os.getenv('MUTTER_DBUS_RUNNER_TEST_ROOT')
if test_root:
print('Reusing MUTTER_DBUS_RUNNER_TEST_ROOT', test_root, file=sys.stderr)
return meta_run_klass(klass, args, rest)
with tempfile.TemporaryDirectory(prefix='mutter-testroot-',
ignore_cleanup_errors=True) as test_root:
env_dirs = ['HOME', 'TMPDIR', 'XDG_RUNTIME_DIR', 'XDG_CONFIG_DIR']
os.environ['MUTTER_DBUS_RUNNER_TEST_ROOT'] = test_root
print('Setup MUTTER_DBUS_RUNNER_TEST_ROOT as', test_root, file=sys.stderr)
for env_dir in env_dirs:
directory = os.path.join(test_root, env_dir.lower())
os.mkdir(directory, mode=0o700)
os.environ[env_dir] = directory
print('Setup', env_dir, 'as', directory, file=sys.stderr)
return meta_run_klass(klass, args, rest)
def meta_run_klass(klass, args, rest):
result = 1
if os.getenv('META_DBUS_RUNNER_ACTIVE') == None: