tests: Simplify Michael MIC test file writing

Since run-tests.py is now required to run as root, there is no need to
use the somewhat awkward "sudo tee" construction; instead, just write
directly to the file.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-11-29 15:44:57 +02:00
parent ae13ad6413
commit dc4c3dc4a2

View file

@ -5,7 +5,6 @@
# See README for more details. # See README for more details.
import time import time
import subprocess
import logging import logging
logger = logging.getLogger() logger = logging.getLogger()
import os.path import os.path
@ -47,22 +46,14 @@ def test_ap_cipher_tkip_countermeasures_ap(dev, apdev):
pairwise="TKIP", group="TKIP", scan_freq="2412") pairwise="TKIP", group="TKIP", scan_freq="2412")
dev[0].dump_monitor() dev[0].dump_monitor()
cmd = subprocess.Popen(["sudo", "tee", testfile], with open(testfile, "w") as f:
stdin=subprocess.PIPE, stdout=subprocess.PIPE) f.write(apdev[0]['bssid'])
cmd.stdin.write(apdev[0]['bssid'])
cmd.stdin.close()
cmd.stdout.read()
cmd.stdout.close()
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1)
if ev is not None: if ev is not None:
raise Exception("Unexpected disconnection on first Michael MIC failure") raise Exception("Unexpected disconnection on first Michael MIC failure")
cmd = subprocess.Popen(["sudo", "tee", testfile], with open(testfile, "w") as f:
stdin=subprocess.PIPE, stdout=subprocess.PIPE) f.write("ff:ff:ff:ff:ff:ff")
cmd.stdin.write("ff:ff:ff:ff:ff:ff")
cmd.stdin.close()
cmd.stdout.read()
cmd.stdout.close()
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
if ev is None: if ev is None:
raise Exception("No disconnection after two Michael MIC failures") raise Exception("No disconnection after two Michael MIC failures")
@ -89,22 +80,14 @@ def test_ap_cipher_tkip_countermeasures_sta(dev, apdev):
pairwise="TKIP", group="TKIP", scan_freq="2412") pairwise="TKIP", group="TKIP", scan_freq="2412")
dev[0].dump_monitor() dev[0].dump_monitor()
cmd = subprocess.Popen(["sudo", "tee", testfile], with open(testfile, "w") as f:
stdin=subprocess.PIPE, stdout=subprocess.PIPE) f.write(dev[0].p2p_dev_addr())
cmd.stdin.write(dev[0].p2p_dev_addr())
cmd.stdin.close()
cmd.stdout.read()
cmd.stdout.close()
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1)
if ev is not None: if ev is not None:
raise Exception("Unexpected disconnection on first Michael MIC failure") raise Exception("Unexpected disconnection on first Michael MIC failure")
cmd = subprocess.Popen(["sudo", "tee", testfile], with open(testfile, "w") as f:
stdin=subprocess.PIPE, stdout=subprocess.PIPE) f.write("ff:ff:ff:ff:ff:ff")
cmd.stdin.write("ff:ff:ff:ff:ff:ff")
cmd.stdin.close()
cmd.stdout.read()
cmd.stdout.close()
ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
if ev is None: if ev is None:
raise Exception("No disconnection after two Michael MIC failures") raise Exception("No disconnection after two Michael MIC failures")