From dc4c3dc4a26a630973e4479b8ba46e50d3836a30 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 29 Nov 2014 15:44:57 +0200 Subject: [PATCH] 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 --- tests/hwsim/test_ap_ciphers.py | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/tests/hwsim/test_ap_ciphers.py b/tests/hwsim/test_ap_ciphers.py index 5054e9318..94679657e 100644 --- a/tests/hwsim/test_ap_ciphers.py +++ b/tests/hwsim/test_ap_ciphers.py @@ -5,7 +5,6 @@ # See README for more details. import time -import subprocess import logging logger = logging.getLogger() import os.path @@ -47,22 +46,14 @@ def test_ap_cipher_tkip_countermeasures_ap(dev, apdev): pairwise="TKIP", group="TKIP", scan_freq="2412") dev[0].dump_monitor() - cmd = subprocess.Popen(["sudo", "tee", testfile], - stdin=subprocess.PIPE, stdout=subprocess.PIPE) - cmd.stdin.write(apdev[0]['bssid']) - cmd.stdin.close() - cmd.stdout.read() - cmd.stdout.close() + with open(testfile, "w") as f: + f.write(apdev[0]['bssid']) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected disconnection on first Michael MIC failure") - cmd = subprocess.Popen(["sudo", "tee", testfile], - stdin=subprocess.PIPE, stdout=subprocess.PIPE) - cmd.stdin.write("ff:ff:ff:ff:ff:ff") - cmd.stdin.close() - cmd.stdout.read() - cmd.stdout.close() + with open(testfile, "w") as f: + f.write("ff:ff:ff:ff:ff:ff") ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) if ev is None: 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") dev[0].dump_monitor() - cmd = subprocess.Popen(["sudo", "tee", testfile], - stdin=subprocess.PIPE, stdout=subprocess.PIPE) - cmd.stdin.write(dev[0].p2p_dev_addr()) - cmd.stdin.close() - cmd.stdout.read() - cmd.stdout.close() + with open(testfile, "w") as f: + f.write(dev[0].p2p_dev_addr()) ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected disconnection on first Michael MIC failure") - cmd = subprocess.Popen(["sudo", "tee", testfile], - stdin=subprocess.PIPE, stdout=subprocess.PIPE) - cmd.stdin.write("ff:ff:ff:ff:ff:ff") - cmd.stdin.close() - cmd.stdout.read() - cmd.stdout.close() + with open(testfile, "w") as f: + f.write("ff:ff:ff:ff:ff:ff") ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10) if ev is None: raise Exception("No disconnection after two Michael MIC failures")