]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Add forgotten new files to the repository
authorJouni Malinen <j@w1.fi>
Wed, 27 Mar 2013 12:40:10 +0000 (14:40 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 27 Mar 2013 12:40:49 +0000 (14:40 +0200)
Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/ap-wpa2-psk.conf [new file with mode: 0644]
tests/hwsim/run-ap-wpa2-tests.py [new file with mode: 0755]
tests/hwsim/start-ap-wpa2-psk.sh [new file with mode: 0755]

diff --git a/tests/hwsim/ap-wpa2-psk.conf b/tests/hwsim/ap-wpa2-psk.conf
new file mode 100644 (file)
index 0000000..dcf7d5f
--- /dev/null
@@ -0,0 +1,15 @@
+driver=nl80211
+interface=wlan2
+
+hw_mode=g
+channel=1
+ieee80211n=1
+
+ctrl_interface=/var/run/hostapd
+ctrl_interface_group=admin
+
+ssid=test-wpa2-psk
+wpa=2
+wpa_key_mgmt=WPA-PSK
+wpa_pairwise=CCMP
+wpa_passphrase=12345678
diff --git a/tests/hwsim/run-ap-wpa2-tests.py b/tests/hwsim/run-ap-wpa2-tests.py
new file mode 100755 (executable)
index 0000000..3a18cbf
--- /dev/null
@@ -0,0 +1,89 @@
+#!/usr/bin/python
+#
+# AP WPA2-PSK tests
+# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
+#
+# This software may be distributed under the terms of the BSD license.
+# See README for more details.
+
+import os
+import re
+import sys
+import time
+
+import logging
+
+from wpasupplicant import WpaSupplicant
+
+def main():
+    idx = 1
+    if len(sys.argv) > 1 and sys.argv[1] == '-d':
+        logging.basicConfig(level=logging.DEBUG)
+        idx = idx + 1
+    elif len(sys.argv) > 1 and sys.argv[1] == '-q':
+        logging.basicConfig(level=logging.WARNING)
+        idx = idx + 1
+    else:
+        logging.basicConfig(level=logging.INFO)
+
+    if len(sys.argv) > idx:
+        test_filter = sys.argv[idx]
+    else:
+        test_filter = None
+
+    dev0 = WpaSupplicant('wlan0')
+    dev1 = WpaSupplicant('wlan1')
+    dev = [ dev0, dev1 ]
+
+    for d in dev:
+        if not d.ping():
+            print d.ifname + ": No response from wpa_supplicant"
+            return
+        d.reset()
+        print "DEV: " + d.ifname + ": " + d.p2p_dev_addr()
+
+    tests = []
+    for t in os.listdir("."):
+        m = re.match(r'(test_ap_wpa2.*)\.py$', t)
+        if m:
+            print "Import test cases from " + t
+            mod = __import__(m.group(1))
+            mod.add_tests(tests)
+
+    passed = []
+    failed = []
+
+    for t in tests:
+        if test_filter:
+            #if test_filter not in t.__name__:
+            if test_filter != t.__name__:
+                continue
+        for d in dev:
+            d.reset()
+        print "START " + t.__name__
+        if t.__doc__:
+            print "Test: " + t.__doc__
+        for d in dev:
+            d.request("NOTE TEST-START " + t.__name__)
+        try:
+            t(dev)
+            passed.append(t.__name__)
+            print "PASS " + t.__name__
+        except Exception, e:
+            print e
+            failed.append(t.__name__)
+            print "FAIL " + t.__name__
+        for d in dev:
+            d.request("NOTE TEST-STOP " + t.__name__)
+
+    if not test_filter:
+        for d in dev:
+            d.reset()
+
+    print "passed tests: " + str(passed)
+    print "failed tests: " + str(failed)
+    if len(failed):
+        sys.exit(1)
+
+if __name__ == "__main__":
+    main()
diff --git a/tests/hwsim/start-ap-wpa2-psk.sh b/tests/hwsim/start-ap-wpa2-psk.sh
new file mode 100755 (executable)
index 0000000..c5be87f
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+DIR="$( cd "$( dirname "$0" )" && pwd )"
+WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
+HAPD=$DIR/../../hostapd/hostapd
+WLANTEST=$DIR/../../wlantest/wlantest
+
+$DIR/stop-wifi.sh
+sudo modprobe mac80211_hwsim radios=3
+mkdir -p $DIR/logs
+DATE=`date +%s`
+sudo ifconfig hwsim0 up
+sudo $WLANTEST -i hwsim0 -c -d > $DIR/logs/$DATE-hwsim0 &
+sudo $WPAS -Dnl80211 -iwlan0 -c $DIR/p2p0.conf -ddKt > $DIR/logs/$DATE-log0 &
+sudo $WPAS -Dnl80211 -iwlan1 -c $DIR/p2p1.conf -ddKt > $DIR/logs/$DATE-log1 &
+sudo $HAPD -ddKt $DIR/ap-wpa2-psk.conf -ddKt > $DIR/logs/$DATE-log2 &
+sleep 1