From f11005812ad1549a7e3b6053e1be6ff90a097349 Mon Sep 17 00:00:00 2001 From: Jonathan Afek Date: Thu, 23 Jun 2016 20:16:30 +0300 Subject: [PATCH] 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 --- tests/hwsim/hwsim_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/hwsim_utils.py b/tests/hwsim/hwsim_utils.py index fd5f70cf5..ca59c8363 100644 --- a/tests/hwsim/hwsim_utils.py +++ b/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")