def test_ap_bss_config_file(dev, apdev, params): """hostapd BSS config file""" pidfile = os.path.join(params['logdir'], "ap_bss_config_file-hostapd.pid") logfile = os.path.join(params['logdir'], "ap_bss_config_file-hostapd-log") prg = os.path.join(params['logdir'], 'alt-hostapd/hostapd/hostapd') if not os.path.exists(prg): prg = '../../hostapd/hostapd' phy = get_phy(apdev[0]) cmd = [ prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, '-S', '-T', '-b', phy + ':bss-1.conf', '-b', phy + ':bss-2.conf', '-b', phy + ':bss-3.conf' ] res = subprocess.check_call(cmd) if res != 0: raise Exception("Could not start hostapd: %s" % str(res)) multi_check(dev, [True, True, True]) for i in range(0, 3): dev[i].request("DISCONNECT") hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd.ping() if "OK" not in hapd.request("TERMINATE"): raise Exception("Failed to terminate hostapd process") ev = hapd.wait_event(["CTRL-EVENT-TERMINATING"], timeout=15) if ev is None: raise Exception("CTRL-EVENT-TERMINATING not seen") for i in range(30): time.sleep(0.1) if not os.path.exists(pidfile): break if os.path.exists(pidfile): raise Exception("PID file exits after process termination")
def test_ap_bss_config_file(dev, apdev, params): """hostapd BSS config file""" pidfile = os.path.join(params['logdir'], "ap_bss_config_file-hostapd.pid") logfile = os.path.join(params['logdir'], "ap_bss_config_file-hostapd-log") prg = os.path.join(params['logdir'], 'alt-hostapd/hostapd/hostapd') if not os.path.exists(prg): prg = '../../hostapd/hostapd' phy = get_phy(apdev[0]) cmd = [prg, '-B', '-dddt', '-P', pidfile, '-f', logfile, '-S', '-T', '-b', phy + ':bss-1.conf', '-b', phy + ':bss-2.conf', '-b', phy + ':bss-3.conf'] res = subprocess.check_call(cmd) if res != 0: raise Exception("Could not start hostapd: %s" % str(res)) multi_check(dev, [True, True, True]) for i in range(0, 3): dev[i].request("DISCONNECT") hapd = hostapd.Hostapd(apdev[0]['ifname']) hapd.ping() if "OK" not in hapd.request("TERMINATE"): raise Exception("Failed to terminate hostapd process") ev = hapd.wait_event(["CTRL-EVENT-TERMINATING"], timeout=15) if ev is None: raise Exception("CTRL-EVENT-TERMINATING not seen") for i in range(30): time.sleep(0.1) if not os.path.exists(pidfile): break if os.path.exists(pidfile): raise Exception("PID file exits after process termination")
def add_bss(apdev, ifname, confname, ignore_error=False): phy = utils.get_phy(apdev) try: hostname = apdev['hostname'] port = apdev['port'] logger.info("Starting BSS " + hostname + "/" + port + " phy=" + phy + " ifname=" + ifname) except: logger.info("Starting BSS phy=" + phy + " ifname=" + ifname) hostname = None port = 8878 hapd_global = HostapdGlobal(apdev) hapd_global.add_bss(phy, confname, ignore_error) port = hapd_global.get_ctrl_iface_port(ifname) hapd = Hostapd(ifname, hostname=hostname, port=port) if not hapd.ping(): raise Exception("Could not ping hostapd") return hapd