From 78b83193179ed530fba99781eb69b6ee68114f8e Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Wed, 30 Mar 2016 10:55:56 +0200 Subject: [PATCH] tests: Allow full apdev to be passed to add_ap() function This allows the full apdev dict to be passed to the add_ap() function instead of just ifname. This allows us to handle also remote hosts while we can check apdev['hostname'], apdev['port']. The old style ifname argument is still accepted to avoid having to convert all callers in a single commit. Signed-off-by: Janusz Dziedzic --- tests/hwsim/hostapd.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py index 5be029e40..47a3262a0 100644 --- a/tests/hwsim/hostapd.py +++ b/tests/hwsim/hostapd.py @@ -339,9 +339,22 @@ class Hostapd: return vals return None -def add_ap(ifname, params, wait_enabled=True, no_enable=False, timeout=30, - hostname=None, port=8878): - logger.info("Starting AP " + ifname) +def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30): + if isinstance(apdev, dict): + ifname = apdev['ifname'] + try: + hostname = apdev['hostname'] + port = apdev['port'] + logger.info("Starting AP " + hostname + "/" + port + " " + ifname) + except: + logger.info("Starting AP " + ifname) + hostname = None + port = 8878 + else: + ifname = apdev + logger.info("Starting AP " + ifname + " (old add_ap argument type)") + hostname = None + port = 8878 hapd_global = HostapdGlobal(hostname=hostname, port=port) hapd_global.remove(ifname) hapd_global.add(ifname)