From 73b41762d0760bc728b3e7da27cd795c732591f9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 14 Apr 2022 11:59:22 +0300 Subject: [PATCH] tests: Fetch commitid on the host when running tests in a VM git has started rejecting repositories owned by other users and refusing to run the "git rev-parse HEAD" command in this type of cases. That resulted in issues with the VM testing model where the VM is practically running everything as root while the host is a normal development environment and likely a non-root user owned files. Fix this by fetching the commitid on the host and pass it to the VM so that no git operations need to be run within the VM itself. Signed-off-by: Jouni Malinen --- tests/hwsim/run-all.sh | 4 +++- tests/hwsim/vm/inside.sh | 6 ++++++ tests/hwsim/vm/vm-run.sh | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/hwsim/run-all.sh b/tests/hwsim/run-all.sh index 7c50edd79..75c3a58b5 100755 --- a/tests/hwsim/run-all.sh +++ b/tests/hwsim/run-all.sh @@ -16,7 +16,9 @@ if [ -z "$DBFILE" ]; then DB="" else DB="-S $DBFILE" - COMMITID="$(git rev-parse HEAD)" + if [ -z "$COMMITID" ]; then + COMMITID="$(git rev-parse HEAD)" + fi if [ -n "$COMMITID" ]; then DB="$DB --commit $COMMITID" fi diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh index bfcbda631..11ded93f4 100755 --- a/tests/hwsim/vm/inside.sh +++ b/tests/hwsim/vm/inside.sh @@ -37,6 +37,11 @@ EPATH=$(sed 's/.*EPATH=\([^ ]*\) .*/\1/' /proc/cmdline) TELNET=$(sed 's/.*TELNET=\([^ ]*\) .*/\1/' /proc/cmdline) ARGS=$(sed 's/.*ARGS=\([^ ]*\)\( \|$\).*/\1/' /proc/cmdline) LOGDIR=$(sed 's/.*LOGDIR=\([^ ]*\)\( \|$\).*/\1/' /proc/cmdline) +if grep -q "commitid=" /proc/cmdline; then + COMMITID=$(sed 's/.*commitid=\([^ ]*\)\( \|$\).*/\1/' /proc/cmdline) +else + COMMITID= +fi mount --bind "$TESTDIR/vm/regdb/" /lib/firmware @@ -146,6 +151,7 @@ else export LOGDIR=/tmp/logs export DBFILE=$LOGDIR/results.db export PREFILL_DB=y + export COMMITID # some tests need CRDA, install a simple uevent helper # and preload the 00 domain it will have asked for already diff --git a/tests/hwsim/vm/vm-run.sh b/tests/hwsim/vm/vm-run.sh index 06dee0689..7a0273ac4 100755 --- a/tests/hwsim/vm/vm-run.sh +++ b/tests/hwsim/vm/vm-run.sh @@ -154,6 +154,10 @@ A+="TELNET=$TELNET_ARG " A+="EPATH=$EPATH " A+="ARGS=$argsfile " A+="console=$KVMOUT " +COMMITID="$(git rev-parse HEAD)" +if [ -n "$COMMITID" ]; then + A+="commitid=$COMMITID " +fi A+="ro" if [ -z $KVM ]; then -- 2.47.2