diff mbox series

[v3,4/4] test-runner: Mark source directory as safe for git

Message ID 20220709002334.3329502-4-andrew.zaborowski@intel.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [v3,1/4] test-runner: Support running hostapd in namespaces | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint fail [v3,4/4] test-runner: Mark source directory as safe for git 9: B3 Line contains hard tab characters (\t): " git config --global --add safe.directory /home/balrog/repos/iwd"

Commit Message

Andrew Zaborowski July 9, 2022, 12:23 a.m. UTC
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 mbox series

Patch

diff --git a/tools/run-tests b/tools/run-tests
index 76784aa3..5617552a 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 d39b560f..164bc881 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),
 ]