]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Flag inside VM using an environment variable
authorBenjamin Berg <benjamin.berg@intel.com>
Mon, 25 Dec 2023 10:21:03 +0000 (12:21 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 13 Jan 2024 18:06:58 +0000 (20:06 +0200)
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>
tests/hwsim/run-all.sh
tests/hwsim/utils.py

index 75c3a58b52b98d6b1db7ecc887b617b7b904e30f..bee753bb69b141951e25b050fb1b7a3393948470 100755 (executable)
@@ -134,7 +134,7 @@ if [ "$(id -u)" != 0 ]; then
 else
        SUDO=
 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
 
index d01e1fbbfe8ad429b4ff19c3eb3c788e251384bf..7e36082843ac182f295c6d24fd3ee5e0629926b1 100644 (file)
@@ -79,10 +79,8 @@ def wait_fail_trigger(dev, cmd, note="Failure not triggered", max_iter=40,
         time.sleep(timeout)
 
 def require_under_vm():
-    with open('/proc/1/cmdline', 'r') as f:
-        cmd = f.read()
-        if "inside.sh" not in cmd:
-            raise HwsimSkip("Not running under VM")
+    if os.getenv('VM') != 'VM':
+        raise HwsimSkip("Not running under VM")
 
 def iface_is_in_bridge(bridge, ifname):
     fname = "/sys/class/net/"+ifname+"/brport/bridge"