tests: Flag inside VM using an environment variable

It is possible to execute the tests directly inside the a VM without
necessarily running the repository wrapper script to do so. In these
cases, passing the VM flag using an environment variable allows
correctly flagging this fact to the tests.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
This commit is contained in:
Benjamin Berg 2023-12-25 12:21:03 +02:00 committed by Jouni Malinen
parent ab98ad397b
commit 1e08a8990d
2 changed files with 3 additions and 5 deletions

View file

@ -134,7 +134,7 @@ if [ "$(id -u)" != 0 ]; then
else else
SUDO= SUDO=
fi fi
${SUDO} ./run-tests.py -D --logdir "$LOGDIR" $TRACE_ARGS -q $DB $RUN_TEST_ARGS || errors=1 ${SUDO} env VM=$VM ./run-tests.py -D --logdir "$LOGDIR" $TRACE_ARGS -q $DB $RUN_TEST_ARGS || errors=1
./stop.sh ./stop.sh

View file

@ -79,9 +79,7 @@ def wait_fail_trigger(dev, cmd, note="Failure not triggered", max_iter=40,
time.sleep(timeout) time.sleep(timeout)
def require_under_vm(): def require_under_vm():
with open('/proc/1/cmdline', 'r') as f: if os.getenv('VM') != 'VM':
cmd = f.read()
if "inside.sh" not in cmd:
raise HwsimSkip("Not running under VM") raise HwsimSkip("Not running under VM")
def iface_is_in_bridge(bridge, ifname): def iface_is_in_bridge(bridge, ifname):