aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2014-12-26 15:44:24 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-02 20:50:27 (GMT)
commitb0839232fa0221d11063d0aa5c9efe72405b124f (patch)
treeb89d76a6e32256f09ad53286f019e41593337a15 /tests
parentfa0d99c4b2c200fa0a64d83651c8e1cd66801b13 (diff)
downloadhostap-b0839232fa0221d11063d0aa5c9efe72405b124f.zip
hostap-b0839232fa0221d11063d0aa5c9efe72405b124f.tar.gz
hostap-b0839232fa0221d11063d0aa5c9efe72405b124f.tar.bz2
tests: Enable wpa_supplicant D-Bus support for hwsim tests
This allows automated testing of the wpa_supplicant D-Bus interface. The instance controlling wlan0 registers with D-Bus if dbus-daemon was started successfully. This is only used in VM testing, i.e., not when run-tests.sh is used on the host system with D-Bus running for normal system purposes. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'tests')
-rw-r--r--tests/hwsim/example-wpa_supplicant.config6
-rwxr-xr-xtests/hwsim/start.sh8
-rw-r--r--tests/hwsim/vm/dbus.conf37
-rwxr-xr-xtests/hwsim/vm/inside.sh17
4 files changed, 61 insertions, 7 deletions
diff --git a/tests/hwsim/example-wpa_supplicant.config b/tests/hwsim/example-wpa_supplicant.config
index 14a1796..225ac24 100644
--- a/tests/hwsim/example-wpa_supplicant.config
+++ b/tests/hwsim/example-wpa_supplicant.config
@@ -52,9 +52,9 @@ CONFIG_OCSP=y
#CONFIG_ELOOP_POLL=y
-#CONFIG_CTRL_IFACE_DBUS=y
-#CONFIG_CTRL_IFACE_DBUS_NEW=y
-#CONFIG_CTRL_IFACE_DBUS_INTRO=y
+CONFIG_CTRL_IFACE_DBUS=y
+CONFIG_CTRL_IFACE_DBUS_NEW=y
+CONFIG_CTRL_IFACE_DBUS_INTRO=y
CONFIG_PEERKEY=y
CONFIG_IEEE80211W=y
diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh
index 602e4b8..9ffb482 100755
--- a/tests/hwsim/start.sh
+++ b/tests/hwsim/start.sh
@@ -104,8 +104,14 @@ test -f /proc/modules && sudo modprobe mac80211_hwsim radios=6 channels=$NUM_CH
sudo ifconfig hwsim0 up
sudo $WLANTEST -i hwsim0 -n $LOGDIR/hwsim0.pcapng -c -dt -L $LOGDIR/hwsim0 &
for i in 0 1 2; do
+ DBUSARG=""
+ if [ $i = "0" -a -r /var/run/dbus/pid -a -r /var/run/dbus/hwsim-test ]; then
+ if $WPAS | grep -q -- -u; then
+ DBUSARG="-u"
+ fi
+ fi
sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $LOGDIR/p2p$i.conf \
- -ddKt$TRACE -f $LOGDIR/log$i &
+ -ddKt$TRACE -f $LOGDIR/log$i $DBUSARG &
done
sudo $(printf -- "$VALGRIND_WPAS" 5) $WPAS -g /tmp/wpas-wlan5 -G$GROUP \
-ddKt$TRACE -f $LOGDIR/log5 &
diff --git a/tests/hwsim/vm/dbus.conf b/tests/hwsim/vm/dbus.conf
new file mode 100644
index 0000000..e64e44f
--- /dev/null
+++ b/tests/hwsim/vm/dbus.conf
@@ -0,0 +1,37 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <type>system</type>
+ <user>messagebus</user>
+ <fork/>
+ <standard_system_servicedirs/>
+ <servicehelper>/usr/lib/dbus-1.0/dbus-daemon-launch-helper</servicehelper>
+ <pidfile>/var/run/dbus/pid</pidfile>
+ <auth>EXTERNAL</auth>
+ <listen>unix:path=/var/run/dbus/system_bus_socket</listen>
+ <policy context="default">
+ <allow user="*"/>
+ <deny own="*"/>
+ <deny send_type="method_call"/>
+ <allow send_type="signal"/>
+ <allow send_requested_reply="true" send_type="method_return"/>
+ <allow send_requested_reply="true" send_type="error"/>
+ <allow receive_type="method_call"/>
+ <allow receive_type="method_return"/>
+ <allow receive_type="error"/>
+ <allow receive_type="signal"/>
+ <allow send_destination="org.freedesktop.DBus"/>
+ <deny send_destination="org.freedesktop.DBus"
+ send_interface="org.freedesktop.DBus"
+ send_member="UpdateActivationEnvironment"/>
+ </policy>
+ <policy user="root">
+ <allow own="fi.epitest.hostap.WPASupplicant"/>
+ <allow send_destination="fi.epitest.hostap.WPASupplicant"/>
+ <allow send_interface="fi.epitest.hostap.WPASupplicant"/>
+ <allow own="fi.w1.wpa_supplicant1"/>
+ <allow send_destination="fi.w1.wpa_supplicant1"/>
+ <allow send_interface="fi.w1.wpa_supplicant1"/>
+ <allow receive_sender="fi.w1.wpa_supplicant1" receive_type="signal"/>
+ </policy>
+</busconfig>
diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh
index b610d58..ffab4ee 100755
--- a/tests/hwsim/vm/inside.sh
+++ b/tests/hwsim/vm/inside.sh
@@ -45,10 +45,16 @@ chmod +x /tmp/bin/sudo
export PATH=/tmp/bin:$EPATH:$PATH
# some tests assume adm/admin group(s) exist(s)
-echo 'adm:x:0:' > /etc/group
-echo 'admin:x:0:' >> /etc/group
+cat > /etc/group <<EOF
+adm:x:0:
+admin:x:0:
+messagebus:x:106:
+EOF
# root should exist
-echo 'root:x:0:0:root:/tmp:/bin/bash' > /etc/passwd
+cat > /etc/passwd <<EOF
+root:x:0:0:root:/tmp:/bin/bash
+messagebus:x:102:106::/var/run/dbus:/bin/false
+EOF
cat > /etc/ethertypes <<EOF
IPv4 0800 ip ip4
ARP 0806 ether-arp
@@ -92,6 +98,11 @@ else
echo $TESTDIR/vm/uevent.sh > /sys/kernel/uevent_helper
COUNTRY=00 crda
+ mkdir -p /var/run/dbus
+ touch /var/run/dbus/hwsim-test
+ chown messagebus.messagebus /var/run/dbus
+ dbus-daemon --config-file=$TESTDIR/vm/dbus.conf --fork
+
cd $TESTDIR
./run-all.sh $ARGS </dev/ttyS0 >/dev/ttyS0 2>&1
if test -d /sys/kernel/debug/gcov ; then