Browse Source

tests: Use cmd_execute() in set_powersave()

hwsim_utils.set_powersace() used to do file operations locally in
python. Start using the cmd_execute() general function for file
operations so that this would also work on remote setups.

Signed-off-by: Jonathan Afek <jonathanx.afek@intel.com>
Jonathan Afek 8 years ago
parent
commit
f11005812a
1 changed files with 5 additions and 3 deletions
  1. 5 3
      tests/hwsim/hwsim_utils.py

+ 5 - 3
tests/hwsim/hwsim_utils.py

@@ -174,6 +174,8 @@ def test_connectivity_sta(dev1, dev2, dscp=None, tos=None):
 
 def set_powersave(dev, val):
     phy = dev.get_driver_status_field("phyname")
-    psf = open('/sys/kernel/debug/ieee80211/%s/hwsim/ps' % phy, 'w')
-    psf.write('%d\n' % val)
-    psf.close()
+    fname = '/sys/kernel/debug/ieee80211/%s/hwsim/ps' % phy
+    data = '%d' % val
+    (res, data) = dev.cmd_execute(["echo", data, ">", fname], shell=True)
+    if res != 0:
+        raise Exception("Failed to set power save for device")