diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index ae1b227bb..b2aa85776 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -124,7 +124,7 @@ class DataCollector(object): def __enter__(self): if self._tracing: output = os.path.abspath(os.path.join(self._logdir, '%s.dat' % (self._testname, ))) - self._trace_cmd = subprocess.Popen(['sudo', 'trace-cmd', 'record', '-o', output, '-e', 'mac80211', '-e', 'cfg80211', '-e', 'printk', 'sh', '-c', 'echo STARTED ; read l'], + self._trace_cmd = subprocess.Popen(['trace-cmd', 'record', '-o', output, '-e', 'mac80211', '-e', 'cfg80211', '-e', 'printk', 'sh', '-c', 'echo STARTED ; read l'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=open('/dev/null', 'w'), @@ -142,7 +142,7 @@ class DataCollector(object): self._trace_cmd.wait() if self._dmesg: output = os.path.join(self._logdir, '%s.dmesg' % (self._testname, )) - subprocess.call(['sudo', 'dmesg', '-c'], stdout=open(output, 'w')) + subprocess.call(['dmesg', '-c'], stdout=open(output, 'w')) def rename_log(logdir, basename, testname, dev): try: @@ -157,7 +157,7 @@ def rename_log(logdir, basename, testname, dev): os.rename(srcname, dstname) if dev: dev.relog() - subprocess.call(['sudo', 'chown', '-f', getpass.getuser(), srcname]) + subprocess.call(['chown', '-f', getpass.getuser(), srcname]) except Exception, e: logger.info("Failed to rename log files") logger.info(e) @@ -338,7 +338,7 @@ def main(): sys.exit(1) if args.dmesg: - subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w')) + subprocess.call(['dmesg', '-c'], stdout=open('/dev/null', 'w')) if conn and args.prefill: for t in tests_to_run: diff --git a/tests/hwsim/test_ap_acs.py b/tests/hwsim/test_ap_acs.py index bd714901b..6524ba5c8 100644 --- a/tests/hwsim/test_ap_acs.py +++ b/tests/hwsim/test_ap_acs.py @@ -124,7 +124,7 @@ def test_ap_acs_5ghz(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_acs_5ghz_40mhz(dev, apdev): @@ -161,7 +161,7 @@ def test_ap_acs_5ghz_40mhz(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_acs_vht(dev, apdev): @@ -200,7 +200,7 @@ def test_ap_acs_vht(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_acs_bias(dev, apdev): diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py index d439ec9c6..11778f515 100644 --- a/tests/hwsim/test_ap_ht.py +++ b/tests/hwsim/test_ap_ht.py @@ -16,10 +16,10 @@ import hwsim_utils from test_ap_csa import csa_supported def clear_scan_cache(ifname): - subprocess.call(['sudo', 'ifconfig', ifname, 'up']) - subprocess.call(['sudo', 'iw', ifname, 'scan', 'freq', '2412', 'flush']) + subprocess.call(['ifconfig', ifname, 'up']) + subprocess.call(['iw', ifname, 'scan', 'freq', '2412', 'flush']) time.sleep(0.1) - subprocess.call(['sudo', 'ifconfig', ifname, 'down']) + subprocess.call(['ifconfig', ifname, 'down']) def test_ap_ht40_scan(dev, apdev): """HT40 co-ex scan""" @@ -226,7 +226,7 @@ def test_ap_ht40_5ghz_match(dev, apdev): hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_ht40_5ghz_switch(dev, apdev): @@ -280,7 +280,7 @@ def test_ap_ht40_5ghz_switch(dev, apdev): hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) def test_ap_ht40_5ghz_switch2(dev, apdev): """HT40 co-ex scan on 5 GHz switching pri/sec channel (2)""" @@ -342,7 +342,7 @@ def test_ap_ht40_5ghz_switch2(dev, apdev): hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_obss_scan(dev, apdev): @@ -590,7 +590,7 @@ def test_olbc_5ghz(dev, apdev): hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) def test_ap_require_ht(dev, apdev): """Require HT""" @@ -761,7 +761,7 @@ def test_ap_ht40_csa(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_ht40_csa2(dev, apdev): @@ -805,7 +805,7 @@ def test_ap_ht40_csa2(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_ht40_csa3(dev, apdev): @@ -849,7 +849,7 @@ def test_ap_ht40_csa3(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_ht_smps(dev, apdev): diff --git a/tests/hwsim/test_ap_params.py b/tests/hwsim/test_ap_params.py index 5558ccf64..e91bfac57 100644 --- a/tests/hwsim/test_ap_params.py +++ b/tests/hwsim/test_ap_params.py @@ -74,7 +74,7 @@ def test_ap_country(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_acl_accept(dev, apdev): @@ -123,17 +123,17 @@ def test_ap_wds_sta(dev, apdev): hapd = hostapd.add_ap(apdev[0]['ifname'], params) try: - subprocess.call(['sudo', 'brctl', 'addbr', 'wds-br0']) - subprocess.call(['sudo', 'brctl', 'setfd', 'wds-br0', '0']) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'up']) - subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'on']) + subprocess.call(['brctl', 'addbr', 'wds-br0']) + subprocess.call(['brctl', 'setfd', 'wds-br0', '0']) + subprocess.call(['ip', 'link', 'set', 'dev', 'wds-br0', 'up']) + subprocess.call(['iw', dev[0].ifname, 'set', '4addr', 'on']) dev[0].connect(ssid, psk=passphrase, scan_freq="2412") hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0", max_tries=15) finally: - subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'off']) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'down']) - subprocess.call(['sudo', 'brctl', 'delbr', 'wds-br0']) + subprocess.call(['iw', dev[0].ifname, 'set', '4addr', 'off']) + subprocess.call(['ip', 'link', 'set', 'dev', 'wds-br0', 'down']) + subprocess.call(['brctl', 'delbr', 'wds-br0']) def test_ap_inactivity_poll(dev, apdev): """AP using inactivity poll""" @@ -209,7 +209,7 @@ def test_ap_spectrum_management_required(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_max_listen_interval(dev, apdev): diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index 966b4e8b6..df0d7b272 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -308,8 +308,8 @@ def test_ap_wpa2_bridge_fdb(dev, apdev): params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase) params['bridge'] = 'ap-br0' hostapd.add_ap(apdev[0]['ifname'], params) - subprocess.call(['sudo', 'brctl', 'setfd', 'ap-br0', '0']) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'up']) + subprocess.call(['brctl', 'setfd', 'ap-br0', '0']) + subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up']) dev[0].connect(ssid, psk=passphrase, scan_freq="2412", bssid=apdev[0]['bssid']) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", @@ -332,8 +332,8 @@ def test_ap_wpa2_bridge_fdb(dev, apdev): if addr0 in macs2 or addr1 in macs2: raise Exception("Bridge FDB entry was not removed") finally: - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'down']) - subprocess.call(['sudo', 'brctl', 'delbr', 'ap-br0']) + subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down']) + subprocess.call(['brctl', 'delbr', 'ap-br0']) def test_ap_wpa2_already_in_bridge(dev, apdev): """hostapd behavior with interface already in bridge""" diff --git a/tests/hwsim/test_ap_tdls.py b/tests/hwsim/test_ap_tdls.py index 64ed7db12..b2e458620 100644 --- a/tests/hwsim/test_ap_tdls.py +++ b/tests/hwsim/test_ap_tdls.py @@ -305,8 +305,8 @@ def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev): hapd = hostapd.add_ap(apdev[0]['ifname'], params) hostapd.add_ap(apdev[1]['ifname'], params) wlantest_setup() - subprocess.call(['sudo', 'brctl', 'setfd', 'ap-br0', '0']) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'up']) + subprocess.call(['brctl', 'setfd', 'ap-br0', '0']) + subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up']) dev[0].connect(ssid, psk=passphrase, scan_freq="2412", bssid=apdev[0]['bssid']) dev[1].connect(ssid, psk=passphrase, scan_freq="2412", @@ -320,8 +320,8 @@ def test_ap_wpa2_tdls_bssid_mismatch(dev, apdev): time.sleep(1) hwsim_utils.test_connectivity_sta(dev[0], dev[1]) finally: - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'down']) - subprocess.call(['sudo', 'brctl', 'delbr', 'ap-br0']) + subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down']) + subprocess.call(['brctl', 'delbr', 'ap-br0']) def test_ap_wpa2_tdls_responder_teardown(dev, apdev): """TDLS teardown from responder with WPA2-PSK AP""" @@ -356,7 +356,7 @@ def test_ap_open_tdls_vht(dev, apdev): dev[1].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() dev[1].flush_scan_cache() diff --git a/tests/hwsim/test_ap_vht.py b/tests/hwsim/test_ap_vht.py index cb229a90b..b3857a58e 100644 --- a/tests/hwsim/test_ap_vht.py +++ b/tests/hwsim/test_ap_vht.py @@ -49,7 +49,7 @@ def test_ap_vht80(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_vht80_params(dev, apdev): @@ -89,7 +89,7 @@ def test_ap_vht80_params(dev, apdev): dev[1].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() dev[1].flush_scan_cache() @@ -119,7 +119,7 @@ def test_ap_vht_20(devs, apdevs): dev.request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev.flush_scan_cache() def test_ap_vht_40(devs, apdevs): @@ -146,7 +146,7 @@ def test_ap_vht_40(devs, apdevs): dev.request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev.flush_scan_cache() def test_ap_vht_capab_not_supported(dev, apdev): @@ -171,7 +171,7 @@ def test_ap_vht_capab_not_supported(dev, apdev): if "OK" not in hapd.request("SET vht_capab [MAX-A-MPDU-LEN-EXP%d]" % i): raise Exception("Unexpected SET failure") finally: - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) def test_ap_vht160(dev, apdev): """VHT with 160 MHz channel width""" @@ -285,7 +285,7 @@ def test_ap_vht160(dev, apdev): hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() dev[1].flush_scan_cache() @@ -357,7 +357,7 @@ def test_ap_vht80plus80(dev, apdev): hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() dev[1].flush_scan_cache() @@ -411,7 +411,7 @@ def test_ap_vht80_csa(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_vht_on_24ghz(dev, apdev): diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py index e9a948e46..5132f6dd4 100644 --- a/tests/hwsim/test_ap_wps.py +++ b/tests/hwsim/test_ap_wps.py @@ -216,7 +216,7 @@ def test_ap_wps_conf_5ghz(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_wps_conf_chan14(dev, apdev): @@ -241,7 +241,7 @@ def test_ap_wps_conf_chan14(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_ap_wps_twice(dev, apdev): diff --git a/tests/hwsim/test_dfs.py b/tests/hwsim/test_dfs.py index 028f6938a..592736e3a 100644 --- a/tests/hwsim/test_dfs.py +++ b/tests/hwsim/test_dfs.py @@ -133,7 +133,7 @@ def test_dfs(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_dfs_radar(dev, apdev): @@ -213,7 +213,7 @@ def test_dfs_radar(dev, apdev): hapd.request("DISABLE") if hapd2: hapd2.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_dfs_radar_on_non_dfs_channel(dev, apdev): @@ -255,7 +255,7 @@ def test_dfs_radar_chanlist(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_dfs_radar_chanlist_vht80(dev, apdev): @@ -293,7 +293,7 @@ def test_dfs_radar_chanlist_vht80(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_dfs_radar_chanlist_vht20(dev, apdev): @@ -328,7 +328,7 @@ def test_dfs_radar_chanlist_vht20(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_dfs_radar_no_ht(dev, apdev): diff --git a/tests/hwsim/test_nfc_wps.py b/tests/hwsim/test_nfc_wps.py index b12c360d1..9a8255b17 100644 --- a/tests/hwsim/test_nfc_wps.py +++ b/tests/hwsim/test_nfc_wps.py @@ -245,7 +245,7 @@ def test_nfc_wps_handover_5ghz(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_nfc_wps_handover_chan14(dev, apdev): @@ -277,7 +277,7 @@ def test_nfc_wps_handover_chan14(dev, apdev): dev[0].request("DISCONNECT") if hapd: hapd.request("DISABLE") - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) dev[0].flush_scan_cache() def test_nfc_wps_handover_with_pw_token_set(dev, apdev): diff --git a/tests/hwsim/test_p2p_autogo.py b/tests/hwsim/test_p2p_autogo.py index 80c194dd7..033ff5b65 100644 --- a/tests/hwsim/test_p2p_autogo.py +++ b/tests/hwsim/test_p2p_autogo.py @@ -371,7 +371,7 @@ def test_autogo_ifdown(dev): wpas.interface_add("wlan5") res = autogo(wpas) wpas.dump_monitor() - subprocess.call(['sudo', 'ifconfig', res['ifname'], 'down']) + subprocess.call(['ifconfig', res['ifname'], 'down']) ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=10) if ev is None: raise Exception("Group removal not reported") @@ -438,16 +438,16 @@ def test_autogo_bridge(dev): if "OK" not in dev[0].request("AUTOSCAN periodic:1"): raise Exception("Failed to set autoscan") autogo(dev[0]) - subprocess.call(['sudo', 'brctl', 'addbr', 'p2p-br0']) - subprocess.call(['sudo', 'brctl', 'setfd', 'p2p-br0', '0']) - subprocess.call(['sudo', 'brctl', 'addif', 'p2p-br0', dev[0].ifname]) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'p2p-br0', 'up']) + subprocess.call(['brctl', 'addbr', 'p2p-br0']) + subprocess.call(['brctl', 'setfd', 'p2p-br0', '0']) + subprocess.call(['brctl', 'addif', 'p2p-br0', dev[0].ifname]) + subprocess.call(['ip', 'link', 'set', 'dev', 'p2p-br0', 'up']) time.sleep(0.1) - subprocess.call(['sudo', 'brctl', 'delif', 'p2p-br0', dev[0].ifname]) + subprocess.call(['brctl', 'delif', 'p2p-br0', dev[0].ifname]) time.sleep(0.1) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'p2p-br0', 'down']) + subprocess.call(['ip', 'link', 'set', 'dev', 'p2p-br0', 'down']) time.sleep(0.1) - subprocess.call(['sudo', 'brctl', 'delbr', 'p2p-br0']) + subprocess.call(['brctl', 'delbr', 'p2p-br0']) ev = dev[0].wait_global_event(["P2P-GROUP-REMOVED"], timeout=1) if ev is not None: raise Exception("P2P group removed unexpectedly") @@ -456,11 +456,11 @@ def test_autogo_bridge(dev): dev[0].remove_group() finally: dev[0].request("AUTOSCAN ") - subprocess.Popen(['sudo', 'brctl', 'delif', 'p2p-br0', dev[0].ifname], + subprocess.Popen(['brctl', 'delif', 'p2p-br0', dev[0].ifname], stderr=open('/dev/null', 'w')) - subprocess.Popen(['sudo', 'ip', 'link', 'set', 'dev', 'p2p-br0', 'down'], + subprocess.Popen(['ip', 'link', 'set', 'dev', 'p2p-br0', 'down'], stderr=open('/dev/null', 'w')) - subprocess.Popen(['sudo', 'brctl', 'delbr', 'p2p-br0'], + subprocess.Popen(['brctl', 'delbr', 'p2p-br0'], stderr=open('/dev/null', 'w')) def test_presence_req_on_group_interface(dev): diff --git a/tests/hwsim/test_p2p_channel.py b/tests/hwsim/test_p2p_channel.py index 521c53ad6..853e79626 100644 --- a/tests/hwsim/test_p2p_channel.py +++ b/tests/hwsim/test_p2p_channel.py @@ -22,7 +22,7 @@ from test_p2p_grpform import go_neg_pbc from test_p2p_autogo import autogo def set_country(country, dev=None): - subprocess.call(['sudo', 'iw', 'reg', 'set', country]) + subprocess.call(['iw', 'reg', 'set', country]) time.sleep(0.1) if dev: for i in range(10): diff --git a/tests/hwsim/test_pmksa_cache.py b/tests/hwsim/test_pmksa_cache.py index 45ca7a988..46bbcb18d 100644 --- a/tests/hwsim/test_pmksa_cache.py +++ b/tests/hwsim/test_pmksa_cache.py @@ -337,8 +337,8 @@ def test_pmksa_cache_preauth(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") params['bridge'] = 'ap-br0' hostapd.add_ap(apdev[0]['ifname'], params) - subprocess.call(['sudo', 'brctl', 'setfd', 'ap-br0', '0']) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'up']) + subprocess.call(['brctl', 'setfd', 'ap-br0', '0']) + subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'up']) eap_connect(dev[0], apdev[0], "PAX", "pax.user@example.com", password_hex="0123456789abcdef0123456789abcdef") @@ -383,8 +383,8 @@ def test_pmksa_cache_preauth(dev, apdev): raise Exception("Unexpected PMKID change") finally: - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'ap-br0', 'down']) - subprocess.call(['sudo', 'brctl', 'delbr', 'ap-br0']) + subprocess.call(['ip', 'link', 'set', 'dev', 'ap-br0', 'down']) + subprocess.call(['brctl', 'delbr', 'ap-br0']) def test_pmksa_cache_disabled(dev, apdev): """PMKSA cache disabling on AP""" diff --git a/tests/hwsim/test_radius.py b/tests/hwsim/test_radius.py index 4b64ca506..827f43d85 100644 --- a/tests/hwsim/test_radius.py +++ b/tests/hwsim/test_radius.py @@ -45,14 +45,13 @@ def test_radius_auth_unreachable(dev, apdev): def test_radius_auth_unreachable2(dev, apdev): """RADIUS Authentication server unreachable (2)""" - subprocess.call(['sudo', 'ip', 'ro', 'replace', '192.168.213.17', 'dev', - 'lo']) + subprocess.call(['ip', 'ro', 'replace', '192.168.213.17', 'dev', 'lo']) params = hostapd.wpa2_eap_params(ssid="radius-auth") params['auth_server_addr'] = "192.168.213.17" params['auth_server_port'] = "18139" hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.Hostapd(apdev[0]['ifname']) - subprocess.call(['sudo', 'ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) + subprocess.call(['ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) connect(dev[0], "radius-auth", wait_connect=False) ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED"]) if ev is None: @@ -86,15 +85,14 @@ def test_radius_acct_unreachable(dev, apdev): def test_radius_acct_unreachable2(dev, apdev): """RADIUS Accounting server unreachable(2)""" - subprocess.call(['sudo', 'ip', 'ro', 'replace', '192.168.213.17', 'dev', - 'lo']) + subprocess.call(['ip', 'ro', 'replace', '192.168.213.17', 'dev', 'lo']) params = hostapd.wpa2_eap_params(ssid="radius-acct") params['acct_server_addr'] = "192.168.213.17" params['acct_server_port'] = "18139" params['acct_server_shared_secret'] = "radius" hostapd.add_ap(apdev[0]['ifname'], params) hapd = hostapd.Hostapd(apdev[0]['ifname']) - subprocess.call(['sudo', 'ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) + subprocess.call(['ip', 'ro', 'del', '192.168.213.17', 'dev', 'lo']) connect(dev[0], "radius-acct") logger.info("Checking for RADIUS retries") time.sleep(4) @@ -627,8 +625,7 @@ def test_radius_macacl_acct(dev, apdev): def test_radius_failover(dev, apdev): """RADIUS Authentication and Accounting server failover""" - subprocess.call(['sudo', 'ip', 'ro', 'replace', '192.168.213.17', 'dev', - 'lo']) + subprocess.call(['ip', 'ro', 'replace', '192.168.213.17', 'dev', 'lo']) as_hapd = hostapd.Hostapd("as") as_mib_start = as_hapd.get_mib(param="radius_server") params = hostapd.wpa2_eap_params(ssid="radius-failover") @@ -653,14 +650,13 @@ def test_radius_failover(dev, apdev): raise Exception("AP startup failed") try: - subprocess.call(['sudo', 'ip', 'ro', 'replace', 'prohibit', - '192.168.213.17']) + subprocess.call(['ip', 'ro', 'replace', 'prohibit', '192.168.213.17']) dev[0].request("SET EAPOL::authPeriod 5") connect(dev[0], "radius-failover", wait_connect=False) dev[0].wait_connected(timeout=60) finally: dev[0].request("SET EAPOL::authPeriod 30") - subprocess.call(['sudo', 'ip', 'ro', 'del', '192.168.213.17']) + subprocess.call(['ip', 'ro', 'del', '192.168.213.17']) as_mib_end = as_hapd.get_mib(param="radius_server") req_s = int(as_mib_start['radiusAccServTotalRequests']) diff --git a/tests/hwsim/test_scan.py b/tests/hwsim/test_scan.py index 496199b20..914eb41a2 100644 --- a/tests/hwsim/test_scan.py +++ b/tests/hwsim/test_scan.py @@ -114,7 +114,7 @@ def test_scan_external_trigger(dev, apdev): """Avoid operations during externally triggered scan""" hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-scan" }) bssid = apdev[0]['bssid'] - subprocess.call(['sudo', 'iw', dev[0].ifname, 'scan', 'trigger']) + subprocess.call(['iw', dev[0].ifname, 'scan', 'trigger']) check_scan(dev[0], "use_id=1", other_started=True) def test_scan_bss_expiration_count(dev, apdev): diff --git a/tests/hwsim/test_sta_dynamic.py b/tests/hwsim/test_sta_dynamic.py index 15fb0a096..49c1ae4d9 100644 --- a/tests/hwsim/test_sta_dynamic.py +++ b/tests/hwsim/test_sta_dynamic.py @@ -41,7 +41,7 @@ def test_sta_ap_scan_0(dev, apdev): wpas.request("ENABLE_NETWORK " + str(id) + " no-connect") wpas.request("SCAN") time.sleep(0.5) - subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412']) + subprocess.call(['iw', wpas.ifname, 'connect', 'test', '2412']) wpas.wait_connected(timeout=10) wpas.request("SCAN") wpas.wait_connected(timeout=5) @@ -65,16 +65,15 @@ def test_sta_ap_scan_2(dev, apdev): id = wpas.connect("", key_mgmt="NONE", bssid=bssid, only_add_network=True) wpas.request("ENABLE_NETWORK " + str(id) + " no-connect") - subprocess.call(['sudo', 'iw', wpas.ifname, 'scan', 'trigger', - 'freq', '2412']) + subprocess.call(['iw', wpas.ifname, 'scan', 'trigger', 'freq', '2412']) time.sleep(1) - subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412']) + subprocess.call(['iw', wpas.ifname, 'connect', 'test', '2412']) wpas.wait_connected(timeout=10) wpas.request("SET disallow_aps bssid " + bssid) wpas.wait_disconnected(timeout=10) - subprocess.call(['sudo', 'iw', wpas.ifname, 'connect', 'test', '2412']) + subprocess.call(['iw', wpas.ifname, 'connect', 'test', '2412']) ev = wpas.wait_event(["CTRL-EVENT-CONNECTED"], timeout=1) if ev is not None: raise Exception("Unexpected connection reported") @@ -121,11 +120,11 @@ def test_sta_dynamic_down_up(dev, apdev): wpas.interface_add("wlan5") wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412") hwsim_utils.test_connectivity(wpas, hapd) - subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down']) + subprocess.call(['ifconfig', wpas.ifname, 'down']) wpas.wait_disconnected(timeout=10) if wpas.get_status_field("wpa_state") != "INTERFACE_DISABLED": raise Exception("Unexpected wpa_state") - subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'up']) + subprocess.call(['ifconfig', wpas.ifname, 'up']) wpas.wait_connected(timeout=15, error="Reconnection not reported") hwsim_utils.test_connectivity(wpas, hapd) @@ -139,16 +138,16 @@ def test_sta_dynamic_ext_mac_addr_change(dev, apdev): wpas.interface_add("wlan5") wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412") hwsim_utils.test_connectivity(wpas, hapd) - subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down']) + subprocess.call(['ifconfig', wpas.ifname, 'down']) wpas.wait_disconnected(timeout=10) if wpas.get_status_field("wpa_state") != "INTERFACE_DISABLED": raise Exception("Unexpected wpa_state") prev_addr = wpas.p2p_interface_addr() new_addr = '02:11:22:33:44:55' try: - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', wpas.ifname, + subprocess.call(['ip', 'link', 'set', 'dev', wpas.ifname, 'address', new_addr]) - subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'up']) + subprocess.call(['ifconfig', wpas.ifname, 'up']) wpas.wait_connected(timeout=15, error="Reconnection not reported") if wpas.get_driver_status_field('addr') != new_addr: raise Exception("Address change not reported") @@ -157,10 +156,10 @@ def test_sta_dynamic_ext_mac_addr_change(dev, apdev): if sta['addr'] != new_addr: raise Exception("STA association with new address not found") finally: - subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'down']) - subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', wpas.ifname, + subprocess.call(['ifconfig', wpas.ifname, 'down']) + subprocess.call(['ip', 'link', 'set', 'dev', wpas.ifname, 'address', prev_addr]) - subprocess.call(['sudo', 'ifconfig', wpas.ifname, 'up']) + subprocess.call(['ifconfig', wpas.ifname, 'up']) def test_sta_dynamic_random_mac_addr(dev, apdev): """Dynamically added wpa_supplicant interface and random MAC address""" diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index eb3220619..0730951ea 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/tests/hwsim/test_wpas_ctrl.py @@ -1026,7 +1026,7 @@ def test_wpas_ctrl_country(dev, apdev): if "init=CORE type=WORLD" not in ev: raise Exception("Unexpected event contents: " + ev) finally: - subprocess.call(['sudo', 'iw', 'reg', 'set', '00']) + subprocess.call(['iw', 'reg', 'set', '00']) def test_wpas_ctrl_suspend_resume(dev): """wpa_supplicant SUSPEND/RESUME""" diff --git a/tests/hwsim/wpasupplicant.py b/tests/hwsim/wpasupplicant.py index 0ee653b82..a7b115c63 100644 --- a/tests/hwsim/wpasupplicant.py +++ b/tests/hwsim/wpasupplicant.py @@ -133,13 +133,13 @@ class WpaSupplicant: logger.error(self.ifname + ": Driver scan state did not clear") print "Trying to clear cfg80211/mac80211 scan state" try: - cmd = ["sudo", "ifconfig", self.ifname, "down"] + cmd = ["ifconfig", self.ifname, "down"] subprocess.call(cmd) except subprocess.CalledProcessError, e: logger.info("ifconfig failed: " + str(e.returncode)) logger.info(e.output) try: - cmd = ["sudo", "ifconfig", self.ifname, "up"] + cmd = ["ifconfig", self.ifname, "up"] subprocess.call(cmd) except subprocess.CalledProcessError, e: logger.info("ifconfig failed: " + str(e.returncode))