]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Store the correct PID in hostapd-test.pid file
authorAndrei Otcheretianski <andrei.otcheretianski@intel.com>
Tue, 23 Oct 2018 11:07:05 +0000 (14:07 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 22 Nov 2018 13:53:30 +0000 (15:53 +0200)
The hwsim's start.sh script spawns hostapd process using "sudo".
Since sudo forks a child process, $! holds the pid of sudo itself.
Fix that by storing the PID of the child process instead.
Since in VM "sudo" is replaced with a dummy script, pass an additional
argument to run-all.sh and start.sh scripts to indicate that they are
running inside a VM.

This is needed to fix ap_config_reload and ap_config_reload_file test
cases on some platforms where sudo is apparently not relaying the
signals properly.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
tests/hwsim/run-all.sh
tests/hwsim/start.sh
tests/hwsim/vm/inside.sh

index 5cf56a91086c4c43033d9b622098b7e7171d2a32..94aa19082cf8a9c442c96a4562e8da2f2e94d9bf 100755 (executable)
@@ -39,6 +39,7 @@ unset RUN_TEST_ARGS
 unset BUILD
 unset BUILD_ARGS
 unset CODECOV
+unset VM
 while [ "$1" != "" ]; do
        case $1 in
                -v | --valgrind | valgrind)
@@ -71,6 +72,12 @@ while [ "$1" != "" ]; do
                -h | --help)
                        usage
                        ;;
+               -V | --vm)
+                       shift
+                       echo "$0: running inside a VM"
+                       VM=VM
+                       ;;
+
                *)
                        RUN_TEST_ARGS="$RUN_TEST_ARGS$1 "
                        shift
@@ -108,7 +115,7 @@ if [ ! -z "$BUILD" ]; then
     fi
 fi
 
-if ! ./start.sh $VALGRIND $TRACE channels=$NUM_CH; then
+if ! ./start.sh $VM $VALGRIND $TRACE channels=$NUM_CH; then
        if ! [ -z "$LOGBASEDIR" ] ; then
                echo "Could not start test environment" > $LOGDIR/run
        fi
index 038426c8ed7651ad79527bc1b859d5fa945cc20c..77e9791ab5d07f7d31321e8075aca9b46a4bd7c4 100755 (executable)
@@ -71,6 +71,12 @@ done
 sed "s/group=admin/group=$GROUP/;s%LOGDIR%$LOGDIR%g" "$DIR/auth_serv/as.conf" > "$LOGDIR/as.conf"
 sed "s/group=admin/group=$GROUP/;s%LOGDIR%$LOGDIR%g" "$DIR/auth_serv/as2.conf" > "$LOGDIR/as2.conf"
 
+unset VM
+if [ "$1" = "VM" ]; then
+    VM="y"
+    shift
+fi
+
 if [ "$1" = "valgrind" ]; then
     VALGRIND=y
     VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
@@ -121,7 +127,14 @@ sudo $(printf -- "$VALGRIND_WPAS" 5) $WPAS -g /tmp/wpas-wlan5 -G$GROUP \
     -ddKt$TRACE -f $LOGDIR/log5 &
 sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -f $LOGDIR/hostapd &
 HPID=$!
-echo $HPID > $LOGDIR/hostapd-test.pid
+
+if [ -z "$VM" ]; then
+    # Sleep a bit, otherwise pgrep may run before the child is forked
+    sleep 0.1
+    pgrep -P $HPID > $LOGDIR/hostapd-test.pid
+else
+    echo $HPID > $LOGDIR/hostapd-test.pid
+fi
 
 if [ -x $HLR_AUC_GW ]; then
     cp $DIR/auth_serv/hlr_auc_gw.milenage_db $LOGDIR/hlr_auc_gw.milenage_db
index 30b938712b98d3b67f01a19c306951b32b4eddaa..c97a284e8db670c918b54cc67388dd3eaed65497 100755 (executable)
@@ -113,7 +113,7 @@ else
        dbus-daemon --config-file=$TESTDIR/vm/dbus.conf --fork
 
        cd $TESTDIR
-       ./run-all.sh $(cat /tmp/host$ARGS) </dev/ttyS0 >/dev/ttyS0 2>&1
+       ./run-all.sh --vm $(cat /tmp/host$ARGS) </dev/ttyS0 >/dev/ttyS0 2>&1
        if test -d /sys/kernel/debug/gcov ; then
                cp -ar /sys/kernel/debug/gcov /tmp/logs/
                # these are broken as they're updated while being read ...