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 <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2022-04-14 11:59:22 +03:00 committed by Jouni Malinen
parent 58701128e8
commit 73b41762d0
3 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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