From 043a6959e02f6d1440fe0b46e3e87030a0bd4384 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Sat, 9 Jul 2022 02:23:34 +0200 Subject: [PATCH] test-runner: Mark source directory as safe for git Since we use git ls-files to produce the list of all tests for -A, if the source directory is owned by somebody other than root one might get: fatal: unsafe repository ('/home/balrog/repos/iwd' is owned by someone else) To add an exception for this directory, call: git config --global --add safe.directory /home/balrog/repos/iwd Starting /home/balrog/repos/iwd/tools/..//autotests/ threw an uncaught exception Traceback (most recent call last): File "/home/balrog/repos/iwd/tools/run-tests", line 966, in run_auto_tests subtests = pre_test(ctx, test, copied) File "/home/balrog/repos/iwd/tools/run-tests", line 814, in pre_test raise Exception("No hw.conf found for %s" % test) Exception: No hw.conf found for /home/balrog/repos/iwd/tools/..//autotests/ Mark args.testhome as a safe directory on every run. --- tools/run-tests | 4 +++- tools/runner.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/run-tests b/tools/run-tests index 716672c8..8f84c844 100755 --- a/tools/run-tests +++ b/tools/run-tests @@ -628,8 +628,10 @@ def build_test_list(args): # Run all tests if not args.autotests: # Get list of all autotests (committed in git) + Process(['git', 'config', '--system', '--add', 'safe.directory', + os.path.normpath(args.testhome)]).wait() tests = os.popen('git -C %s ls-files autotests/ | cut -f2 -d"/" \ - | grep "test*" | uniq' % args.testhome).read() \ + | grep "^test" | uniq' % args.testhome).read() \ .strip().split('\n') tests = [test_root + '/' + t for t in tests] else: diff --git a/tools/runner.py b/tools/runner.py index cf904412..f5667959 100644 --- a/tools/runner.py +++ b/tools/runner.py @@ -36,6 +36,7 @@ mounts_common = [ MountInfo('tmpfs', 'tmpfs', '/run', 'mode=0755', MS_NOSUID|MS_NODEV|MS_STRICTATIME), MountInfo('tmpfs', 'tmpfs', '/tmp', '', 0), + MountInfo('tmpfs', 'tmpfs', '/etc', '', 0), MountInfo('tmpfs', 'tmpfs', '/usr/share/dbus-1', 'mode=0755', MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME), ]