diff mbox series

[4/6] tests: mesh: use common utility function to clear regdomain

Message ID 20200501210211.647-5-thomas@adapt-ip.com
State Superseded
Headers show
Series fix varous tests | expand

Commit Message

Thomas Pedersen May 1, 2020, 9:02 p.m. UTC
Using clear_regdom_dev() instead of open coding the logic
saves a few lines here and there.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
---
 tests/hwsim/test_wpas_mesh.py | 49 ++++++-----------------------------
 1 file changed, 8 insertions(+), 41 deletions(-)
diff mbox series

Patch

diff --git a/tests/hwsim/test_wpas_mesh.py b/tests/hwsim/test_wpas_mesh.py
index baea71501f0b..e93647ed129c 100644
--- a/tests/hwsim/test_wpas_mesh.py
+++ b/tests/hwsim/test_wpas_mesh.py
@@ -403,19 +403,12 @@  def set_reg(dev, country):
             if "alpha2=" + country in ev:
                 break
 
-def clear_reg_setting(dev):
-    dev[0].request("MESH_GROUP_REMOVE " + dev[0].ifname)
-    dev[1].request("MESH_GROUP_REMOVE " + dev[1].ifname)
-    subprocess.call(['iw', 'reg', 'set', '00'])
-    dev[0].flush_scan_cache()
-    dev[1].flush_scan_cache()
-
 def test_mesh_secure_ocv_mix_legacy(dev, apdev):
     """Mesh network with a VHT STA and a legacy STA under OCV"""
     try:
         run_mesh_secure_ocv_mix_legacy(dev, apdev)
     finally:
-        clear_reg_setting(dev)
+        clear_regdom_dev(dev)
 
 def run_mesh_secure_ocv_mix_legacy(dev, apdev):
     check_mesh_support(dev[0], secure=True)
@@ -441,7 +434,7 @@  def test_mesh_secure_ocv_mix_ht(dev, apdev):
     try:
         run_mesh_secure_ocv_mix_ht(dev, apdev)
     finally:
-        clear_reg_setting(dev)
+        clear_regdom_dev(dev)
 
 def run_mesh_secure_ocv_mix_ht(dev, apdev):
     check_mesh_support(dev[0], secure=True)
@@ -906,11 +899,7 @@  def test_wpas_mesh_open_5ghz(dev, apdev):
     try:
         _test_wpas_mesh_open_5ghz(dev, apdev)
     finally:
-        dev[0].request("MESH_GROUP_REMOVE " + dev[0].ifname)
-        dev[1].request("MESH_GROUP_REMOVE " + dev[1].ifname)
-        subprocess.call(['iw', 'reg', 'set', '00'])
-        dev[0].flush_scan_cache()
-        dev[1].flush_scan_cache()
+        clear_regdom_dev(dev)
 
 def _test_wpas_mesh_open_5ghz(dev, apdev):
     check_mesh_support(dev[0])
@@ -989,13 +978,7 @@  def test_wpas_mesh_open_ht40(dev, apdev):
     try:
         _test_wpas_mesh_open_ht40(dev, apdev)
     finally:
-        dev[0].request("MESH_GROUP_REMOVE " + dev[0].ifname)
-        dev[1].request("MESH_GROUP_REMOVE " + dev[1].ifname)
-        dev[2].request("MESH_GROUP_REMOVE " + dev[2].ifname)
-        subprocess.call(['iw', 'reg', 'set', '00'])
-        dev[0].flush_scan_cache()
-        dev[1].flush_scan_cache()
-        dev[2].flush_scan_cache()
+        clear_regdom_dev(dev, 3)
 
 def _test_wpas_mesh_open_ht40(dev, apdev):
     check_mesh_support(dev[0])
@@ -1037,11 +1020,7 @@  def test_wpas_mesh_open_vht40(dev, apdev):
     try:
         _test_wpas_mesh_open_vht40(dev, apdev)
     finally:
-        dev[0].request("MESH_GROUP_REMOVE " + dev[0].ifname)
-        dev[1].request("MESH_GROUP_REMOVE " + dev[1].ifname)
-        subprocess.call(['iw', 'reg', 'set', '00'])
-        dev[0].flush_scan_cache()
-        dev[1].flush_scan_cache()
+        clear_regdom_dev(dev)
 
 def _test_wpas_mesh_open_vht40(dev, apdev):
     check_mesh_support(dev[0])
@@ -1089,11 +1068,7 @@  def test_wpas_mesh_open_vht20(dev, apdev):
     try:
         _test_wpas_mesh_open_vht20(dev, apdev)
     finally:
-        dev[0].request("MESH_GROUP_REMOVE " + dev[0].ifname)
-        dev[1].request("MESH_GROUP_REMOVE " + dev[1].ifname)
-        subprocess.call(['iw', 'reg', 'set', '00'])
-        dev[0].flush_scan_cache()
-        dev[1].flush_scan_cache()
+        clear_regdom_dev(dev)
 
 def _test_wpas_mesh_open_vht20(dev, apdev):
     check_mesh_support(dev[0])
@@ -1133,11 +1108,7 @@  def test_wpas_mesh_open_vht_80p80(dev, apdev):
     try:
         _test_wpas_mesh_open_vht_80p80(dev, apdev)
     finally:
-        dev[0].request("MESH_GROUP_REMOVE " + dev[0].ifname)
-        dev[1].request("MESH_GROUP_REMOVE " + dev[1].ifname)
-        subprocess.call(['iw', 'reg', 'set', '00'])
-        dev[0].flush_scan_cache()
-        dev[1].flush_scan_cache()
+        clear_regdom_dev(dev)
 
 def _test_wpas_mesh_open_vht_80p80(dev, apdev):
     check_mesh_support(dev[0])
@@ -1181,11 +1152,7 @@  def test_mesh_open_vht_160(dev, apdev):
     try:
         _test_mesh_open_vht_160(dev, apdev)
     finally:
-        dev[0].request("MESH_GROUP_REMOVE " + dev[0].ifname)
-        dev[1].request("MESH_GROUP_REMOVE " + dev[1].ifname)
-        subprocess.call(['iw', 'reg', 'set', '00'])
-        dev[0].flush_scan_cache()
-        dev[1].flush_scan_cache()
+        clear_regdom_dev(dev)
 
 def _test_mesh_open_vht_160(dev, apdev):
     check_mesh_support(dev[0])