test_fst_config.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. # FST configuration tests
  2. # Copyright (c) 2015, Qualcomm Atheros, Inc.
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import logging
  7. logger = logging.getLogger()
  8. import subprocess
  9. import time
  10. import os
  11. import signal
  12. import hostapd
  13. import wpasupplicant
  14. import utils
  15. import fst_test_common
  16. class FstLauncherConfig:
  17. """FstLauncherConfig class represents configuration to be used for
  18. FST config tests related hostapd/wpa_supplicant instances"""
  19. def __init__(self, iface, fst_group, fst_pri, fst_llt=None):
  20. self.iface = iface
  21. self.fst_group = fst_group
  22. self.fst_pri = fst_pri
  23. self.fst_llt = fst_llt # None llt means no llt parameter will be set
  24. def ifname(self):
  25. return self.iface
  26. def is_ap(self):
  27. """Returns True if the configuration is for AP, otherwise - False"""
  28. raise Exception("Virtual is_ap() called!")
  29. def to_file(self, pathname):
  30. """Creates configuration file to be used by FST config tests related
  31. hostapd/wpa_supplicant instances"""
  32. raise Exception("Virtual to_file() called!")
  33. class FstLauncherConfigAP(FstLauncherConfig):
  34. """FstLauncherConfigAP class represents configuration to be used for
  35. FST config tests related hostapd instance"""
  36. def __init__(self, iface, ssid, mode, chan, fst_group, fst_pri,
  37. fst_llt=None):
  38. self.ssid = ssid
  39. self.mode = mode
  40. self.chan = chan
  41. FstLauncherConfig.__init__(self, iface, fst_group, fst_pri, fst_llt)
  42. def is_ap(self):
  43. return True
  44. def get_channel(self):
  45. return self.chan
  46. def to_file(self, pathname):
  47. """Creates configuration file to be used by FST config tests related
  48. hostapd instance"""
  49. with open(pathname, "w") as f:
  50. f.write("country_code=US\n"
  51. "interface=%s\n"
  52. "ctrl_interface=/var/run/hostapd\n"
  53. "ssid=%s\n"
  54. "channel=%s\n"
  55. "hw_mode=%s\n"
  56. "ieee80211n=1\n" % (self.iface, self.ssid, self.chan,
  57. self.mode))
  58. if len(self.fst_group) != 0:
  59. f.write("fst_group_id=%s\n"
  60. "fst_priority=%s\n" % (self.fst_group, self.fst_pri))
  61. if self.fst_llt is not None:
  62. f.write("fst_llt=%s\n" % self.fst_llt)
  63. with open(pathname, "r") as f:
  64. logger.debug("wrote hostapd config file %s:\n%s" % (pathname,
  65. f.read()))
  66. class FstLauncherConfigSTA(FstLauncherConfig):
  67. """FstLauncherConfig class represents configuration to be used for
  68. FST config tests related wpa_supplicant instance"""
  69. def __init__(self, iface, fst_group, fst_pri, fst_llt=None):
  70. FstLauncherConfig.__init__(self, iface, fst_group, fst_pri, fst_llt)
  71. def is_ap(self):
  72. return False
  73. def to_file(self, pathname):
  74. """Creates configuration file to be used by FST config tests related
  75. wpa_supplicant instance"""
  76. with open(pathname, "w") as f:
  77. f.write("ctrl_interface=DIR=/var/run/wpa_supplicant\n"
  78. "p2p_no_group_iface=1\n")
  79. if len(self.fst_group) != 0:
  80. f.write("fst_group_id=%s\n"
  81. "fst_priority=%s\n" % (self.fst_group, self.fst_pri))
  82. if self.fst_llt is not None:
  83. f.write("fst_llt=%s\n" % self.fst_llt)
  84. with open(pathname, "r") as f:
  85. logger.debug("wrote wpa_supplicant config file %s:\n%s" % (pathname, f.read()))
  86. class FstLauncher:
  87. """FstLauncher class is responsible for launching and cleaning up of FST
  88. config tests related hostapd/wpa_supplicant instances"""
  89. def __init__(self, logpath):
  90. self.logger = logging.getLogger()
  91. self.fst_logpath = logpath
  92. self.cfgs_to_run = []
  93. self.hapd_fst_global = '/var/run/hostapd-fst-global'
  94. self.wsup_fst_global = '/tmp/fststa'
  95. self.nof_aps = 0
  96. self.nof_stas = 0
  97. self.reg_ctrl = fst_test_common.HapdRegCtrl()
  98. self.test_is_supported()
  99. def __del__(self):
  100. self.cleanup()
  101. @staticmethod
  102. def test_is_supported():
  103. h = hostapd.HostapdGlobal()
  104. resp = h.request("FST-MANAGER TEST_REQUEST IS_SUPPORTED")
  105. if not resp.startswith("OK"):
  106. raise utils.HwsimSkip("FST not supported")
  107. w = wpasupplicant.WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  108. resp = w.global_request("FST-MANAGER TEST_REQUEST IS_SUPPORTED")
  109. if not resp.startswith("OK"):
  110. raise utils.HwsimSkip("FST not supported")
  111. def get_cfg_pathname(self, cfg):
  112. """Returns pathname of ifname based configuration file"""
  113. return self.fst_logpath +'/'+ cfg.ifname() + '.conf'
  114. def add_cfg(self, cfg):
  115. """Adds configuration to be used for launching hostapd/wpa_supplicant
  116. instances"""
  117. if cfg not in self.cfgs_to_run:
  118. self.cfgs_to_run.append(cfg)
  119. if cfg.is_ap() == True:
  120. self.nof_aps += 1
  121. else:
  122. self.nof_stas += 1
  123. def remove_cfg(self, cfg):
  124. """Removes configuration previously added with add_cfg"""
  125. if cfg in self.cfgs_to_run:
  126. self.cfgs_to_run.remove(cfg)
  127. if cfg.is_ap() == True:
  128. self.nof_aps -= 1
  129. else:
  130. self.nof_stas -= 1
  131. config_file = self.get_cfg_pathname(cfg)
  132. if os.path.exists(config_file):
  133. os.remove(config_file)
  134. def run_hostapd(self):
  135. """Lauches hostapd with interfaces configured according to
  136. FstLauncherConfigAP configurations added"""
  137. if self.nof_aps == 0:
  138. raise Exception("No FST APs to start")
  139. pidfile = self.fst_logpath + '/' + 'myhostapd.pid'
  140. mylogfile = self.fst_logpath + '/' + 'fst-hostapd'
  141. prg = os.path.join(self.fst_logpath,
  142. 'alt-hostapd/hostapd/hostapd')
  143. if not os.path.exists(prg):
  144. prg = '../../hostapd/hostapd'
  145. cmd = [ prg, '-B', '-dddt',
  146. '-P', pidfile, '-f', mylogfile, '-g', self.hapd_fst_global]
  147. for i in range(0, len(self.cfgs_to_run)):
  148. cfg = self.cfgs_to_run[i]
  149. if cfg.is_ap() == True:
  150. cfgfile = self.get_cfg_pathname(cfg)
  151. cfg.to_file(cfgfile)
  152. cmd.append(cfgfile)
  153. self.reg_ctrl.add_ap(cfg.ifname(), cfg.get_channel())
  154. self.logger.debug("Starting fst hostapd: " + ' '.join(cmd))
  155. res = subprocess.call(cmd)
  156. self.logger.debug("fst hostapd start result: %d" % res)
  157. if res == 0:
  158. self.reg_ctrl.start()
  159. return res
  160. def run_wpa_supplicant(self):
  161. """Lauches wpa_supplicant with interfaces configured according to
  162. FstLauncherConfigSTA configurations added"""
  163. if self.nof_stas == 0:
  164. raise Exception("No FST STAs to start")
  165. pidfile = self.fst_logpath + '/' + 'mywpa_supplicant.pid'
  166. mylogfile = self.fst_logpath + '/' + 'fst-wpa_supplicant'
  167. prg = os.path.join(self.fst_logpath,
  168. 'alt-wpa_supplicant/wpa_supplicant/wpa_supplicant')
  169. if not os.path.exists(prg):
  170. prg = '../../wpa_supplicant/wpa_supplicant'
  171. cmd = [ prg, '-B', '-dddt',
  172. '-P' + pidfile, '-f', mylogfile, '-g', self.wsup_fst_global ]
  173. sta_no = 0
  174. for i in range(0, len(self.cfgs_to_run)):
  175. cfg = self.cfgs_to_run[i]
  176. if cfg.is_ap() == False:
  177. cfgfile = self.get_cfg_pathname(cfg)
  178. cfg.to_file(cfgfile)
  179. cmd.append('-c' + cfgfile)
  180. cmd.append('-i' + cfg.ifname())
  181. cmd.append('-Dnl80211')
  182. if sta_no != self.nof_stas -1:
  183. cmd.append('-N') # Next station configuration
  184. sta_no += 1
  185. self.logger.debug("Starting fst supplicant: " + ' '.join(cmd))
  186. res = subprocess.call(cmd)
  187. self.logger.debug("fst supplicant start result: %d" % res)
  188. return res
  189. def cleanup(self):
  190. """Terminates hostapd/wpa_supplicant processes previously launched with
  191. run_hostapd/run_wpa_supplicant"""
  192. pidfile = self.fst_logpath + '/' + 'myhostapd.pid'
  193. self.kill_pid(pidfile, self.nof_aps > 0)
  194. pidfile = self.fst_logpath + '/' + 'mywpa_supplicant.pid'
  195. self.kill_pid(pidfile, self.nof_stas > 0)
  196. self.reg_ctrl.stop()
  197. while len(self.cfgs_to_run) != 0:
  198. cfg = self.cfgs_to_run[0]
  199. self.remove_cfg(cfg)
  200. def kill_pid(self, pidfile, try_again=False):
  201. """Kills process by PID file"""
  202. if not os.path.exists(pidfile):
  203. if not try_again:
  204. return
  205. # It might take some time for the process to write the PID file,
  206. # so wait a bit longer before giving up.
  207. self.logger.info("kill_pid: pidfile %s does not exist - try again after a second" % pidfile)
  208. time.sleep(1)
  209. if not os.path.exists(pidfile):
  210. self.logger.info("kill_pid: pidfile %s does not exist - could not kill the process" % pidfile)
  211. return
  212. pid = -1
  213. try:
  214. for i in range(3):
  215. pf = file(pidfile, 'r')
  216. pidtxt = pf.read().strip()
  217. self.logger.debug("kill_pid: %s: '%s'" % (pidfile, pidtxt))
  218. pf.close()
  219. try:
  220. pid = int(pidtxt)
  221. break
  222. except Exception, e:
  223. self.logger.debug("kill_pid: No valid PID found: %s" % str(e))
  224. time.sleep(1)
  225. self.logger.debug("kill_pid %s --> pid %d" % (pidfile, pid))
  226. os.kill(pid, signal.SIGTERM)
  227. for i in range(10):
  228. try:
  229. # Poll the pid (Is the process still existing?)
  230. os.kill(pid, 0)
  231. except OSError:
  232. # No, already done
  233. break
  234. # Wait and check again
  235. time.sleep(1)
  236. except Exception, e:
  237. self.logger.debug("Didn't stop the pid=%d. Was it stopped already? (%s)" % (pid, str(e)))
  238. def parse_ies(iehex, el=-1):
  239. """Parses the information elements hex string 'iehex' in format
  240. "0a0b0c0d0e0f". If no 'el' defined just checks the IE string for integrity.
  241. If 'el' is defined returns the list of hex values of the specific IE (or
  242. empty list if the element is not in the string."""
  243. iel = [iehex[i:i + 2] for i in range(0, len(iehex), 2)]
  244. for i in range(0, len(iel)):
  245. iel[i] = int(iel[i], 16)
  246. # Sanity check
  247. i = 0
  248. res = []
  249. while i < len(iel):
  250. logger.debug("IE found: %x" % iel[i])
  251. if el != -1 and el == iel[i]:
  252. res = iel[i + 2:i + 2 + iel[i + 1]]
  253. i += 2 + iel[i + 1]
  254. if i != len(iel):
  255. logger.error("Bad IE string: " + iehex)
  256. res = []
  257. return res
  258. def scan_and_get_bss(dev, frq):
  259. """Issues a scan on given device on given frequency, returns the bss info
  260. dictionary ('ssid','ie','flags', etc.) or None. Note, the function
  261. implies there is only one AP on the given channel. If not a case,
  262. the function must be changed to call dev.get_bss() till the AP with the
  263. [b]ssid that we need is found"""
  264. dev.scan(freq=frq)
  265. return dev.get_bss('0')
  266. # AP configuration tests
  267. def run_test_ap_configuration(apdev, test_params,
  268. fst_group = fst_test_common.fst_test_def_group,
  269. fst_pri = fst_test_common.fst_test_def_prio_high,
  270. fst_llt = fst_test_common.fst_test_def_llt):
  271. """Runs FST hostapd where the 1st AP configuration is fixed, the 2nd fst
  272. configuration is provided by the parameters. Returns the result of the run:
  273. 0 - no errors discovered, an error otherwise. The function is used for
  274. simplek "bad configuration" tests."""
  275. logdir = test_params['logdir']
  276. fst_launcher = FstLauncher(logdir)
  277. ap1 = FstLauncherConfigAP(apdev[0]['ifname'], 'fst_goodconf', 'a',
  278. fst_test_common.fst_test_def_chan_a,
  279. fst_test_common.fst_test_def_group,
  280. fst_test_common.fst_test_def_prio_low,
  281. fst_test_common.fst_test_def_llt)
  282. ap2 = FstLauncherConfigAP(apdev[1]['ifname'], 'fst_badconf', 'b',
  283. fst_test_common.fst_test_def_chan_g, fst_group,
  284. fst_pri, fst_llt)
  285. fst_launcher.add_cfg(ap1)
  286. fst_launcher.add_cfg(ap2)
  287. res = fst_launcher.run_hostapd()
  288. return res
  289. def run_test_sta_configuration(test_params,
  290. fst_group = fst_test_common.fst_test_def_group,
  291. fst_pri = fst_test_common.fst_test_def_prio_high,
  292. fst_llt = fst_test_common.fst_test_def_llt):
  293. """Runs FST wpa_supplicant where the 1st STA configuration is fixed, the
  294. 2nd fst configuration is provided by the parameters. Returns the result of
  295. the run: 0 - no errors discovered, an error otherwise. The function is used
  296. for simple "bad configuration" tests."""
  297. logdir = test_params['logdir']
  298. fst_launcher = FstLauncher(logdir)
  299. sta1 = FstLauncherConfigSTA('wlan5',
  300. fst_test_common.fst_test_def_group,
  301. fst_test_common.fst_test_def_prio_low,
  302. fst_test_common.fst_test_def_llt)
  303. sta2 = FstLauncherConfigSTA('wlan6', fst_group, fst_pri, fst_llt)
  304. fst_launcher.add_cfg(sta1)
  305. fst_launcher.add_cfg(sta2)
  306. res = fst_launcher.run_wpa_supplicant()
  307. return res
  308. def test_fst_ap_config_llt_neg(dev, apdev, test_params):
  309. """FST AP configuration negative LLT"""
  310. res = run_test_ap_configuration(apdev, test_params, fst_llt = '-1')
  311. if res == 0:
  312. raise Exception("hostapd started with a negative llt")
  313. def test_fst_ap_config_llt_zero(dev, apdev, test_params):
  314. """FST AP configuration zero LLT"""
  315. res = run_test_ap_configuration(apdev, test_params, fst_llt = '0')
  316. if res == 0:
  317. raise Exception("hostapd started with a zero llt")
  318. def test_fst_ap_config_llt_too_big(dev, apdev, test_params):
  319. """FST AP configuration LLT is too big"""
  320. res = run_test_ap_configuration(apdev, test_params,
  321. fst_llt = '4294967296') #0x100000000
  322. if res == 0:
  323. raise Exception("hostapd started with llt that is too big")
  324. def test_fst_ap_config_llt_nan(dev, apdev, test_params):
  325. """FST AP configuration LLT is not a number"""
  326. res = run_test_ap_configuration(apdev, test_params, fst_llt = 'nan')
  327. if res == 0:
  328. raise Exception("hostapd started with llt not a number")
  329. def test_fst_ap_config_pri_neg(dev, apdev, test_params):
  330. """FST AP configuration Priority negative"""
  331. res = run_test_ap_configuration(apdev, test_params, fst_pri = '-1')
  332. if res == 0:
  333. raise Exception("hostapd started with a negative fst priority")
  334. def test_fst_ap_config_pri_zero(dev, apdev, test_params):
  335. """FST AP configuration Priority zero"""
  336. res = run_test_ap_configuration(apdev, test_params, fst_pri = '0')
  337. if res == 0:
  338. raise Exception("hostapd started with a zero fst priority")
  339. def test_fst_ap_config_pri_large(dev, apdev, test_params):
  340. """FST AP configuration Priority too large"""
  341. res = run_test_ap_configuration(apdev, test_params, fst_pri = '256')
  342. if res == 0:
  343. raise Exception("hostapd started with too large fst priority")
  344. def test_fst_ap_config_pri_nan(dev, apdev, test_params):
  345. """FST AP configuration Priority not a number"""
  346. res = run_test_ap_configuration(apdev, test_params, fst_pri = 'nan')
  347. if res == 0:
  348. raise Exception("hostapd started with fst priority not a number")
  349. def test_fst_ap_config_group_len(dev, apdev, test_params):
  350. """FST AP configuration Group max length"""
  351. res = run_test_ap_configuration(apdev, test_params,
  352. fst_group = 'fstg5678abcd34567')
  353. if res == 0:
  354. raise Exception("hostapd started with fst_group length too big")
  355. def test_fst_ap_config_good(dev, apdev, test_params):
  356. """FST AP configuration good parameters"""
  357. res = run_test_ap_configuration(apdev, test_params)
  358. if res != 0:
  359. raise Exception("hostapd didn't start with valid config parameters")
  360. def test_fst_ap_config_default(dev, apdev, test_params):
  361. """FST AP configuration default parameters"""
  362. res = run_test_ap_configuration(apdev, test_params, fst_llt = None)
  363. if res != 0:
  364. raise Exception("hostapd didn't start with valid config parameters")
  365. # STA configuration tests
  366. def test_fst_sta_config_llt_neg(dev, apdev, test_params):
  367. """FST STA configuration negative LLT"""
  368. res = run_test_sta_configuration(test_params, fst_llt = '-1')
  369. if res == 0:
  370. raise Exception("wpa_supplicant started with a negative llt")
  371. def test_fst_sta_config_llt_zero(dev, apdev, test_params):
  372. """FST STA configuration zero LLT"""
  373. res = run_test_sta_configuration(test_params, fst_llt = '0')
  374. if res == 0:
  375. raise Exception("wpa_supplicant started with a zero llt")
  376. def test_fst_sta_config_llt_large(dev, apdev, test_params):
  377. """FST STA configuration LLT is too large"""
  378. res = run_test_sta_configuration(test_params,
  379. fst_llt = '4294967296') #0x100000000
  380. if res == 0:
  381. raise Exception("wpa_supplicant started with llt that is too large")
  382. def test_fst_sta_config_llt_nan(dev, apdev, test_params):
  383. """FST STA configuration LLT is not a number"""
  384. res = run_test_sta_configuration(test_params, fst_llt = 'nan')
  385. if res == 0:
  386. raise Exception("wpa_supplicant started with llt not a number")
  387. def test_fst_sta_config_pri_neg(dev, apdev, test_params):
  388. """FST STA configuration Priority negative"""
  389. res = run_test_sta_configuration(test_params, fst_pri = '-1')
  390. if res == 0:
  391. raise Exception("wpa_supplicant started with a negative fst priority")
  392. def test_fst_sta_config_pri_zero(dev, apdev, test_params):
  393. """FST STA configuration Priority zero"""
  394. res = run_test_sta_configuration(test_params, fst_pri = '0')
  395. if res == 0:
  396. raise Exception("wpa_supplicant started with a zero fst priority")
  397. def test_fst_sta_config_pri_big(dev, apdev, test_params):
  398. """FST STA configuration Priority too large"""
  399. res = run_test_sta_configuration(test_params, fst_pri = '256')
  400. if res == 0:
  401. raise Exception("wpa_supplicant started with too large fst priority")
  402. def test_fst_sta_config_pri_nan(dev, apdev, test_params):
  403. """FST STA configuration Priority not a number"""
  404. res = run_test_sta_configuration(test_params, fst_pri = 'nan')
  405. if res == 0:
  406. raise Exception("wpa_supplicant started with fst priority not a number")
  407. def test_fst_sta_config_group_len(dev, apdev, test_params):
  408. """FST STA configuration Group max length"""
  409. res = run_test_sta_configuration(test_params,
  410. fst_group = 'fstg5678abcd34567')
  411. if res == 0:
  412. raise Exception("wpa_supplicant started with fst_group length too big")
  413. def test_fst_sta_config_good(dev, apdev, test_params):
  414. """FST STA configuration good parameters"""
  415. res = run_test_sta_configuration(test_params)
  416. if res != 0:
  417. raise Exception("wpa_supplicant didn't start with valid config parameters")
  418. def test_fst_sta_config_default(dev, apdev, test_params):
  419. """FST STA configuration default parameters"""
  420. res = run_test_sta_configuration(test_params, fst_llt = None)
  421. if res != 0:
  422. raise Exception("wpa_supplicant didn't start with valid config parameters")
  423. def test_fst_scan_mb(dev, apdev, test_params):
  424. """FST scan valid MB IE presence with normal start"""
  425. logdir = test_params['logdir']
  426. # Test valid MB IE in scan results
  427. fst_launcher = FstLauncher(logdir)
  428. ap1 = FstLauncherConfigAP(apdev[0]['ifname'], 'fst_11a', 'a',
  429. fst_test_common.fst_test_def_chan_a,
  430. fst_test_common.fst_test_def_group,
  431. fst_test_common.fst_test_def_prio_high)
  432. ap2 = FstLauncherConfigAP(apdev[1]['ifname'], 'fst_11g', 'b',
  433. fst_test_common.fst_test_def_chan_g,
  434. fst_test_common.fst_test_def_group,
  435. fst_test_common.fst_test_def_prio_low)
  436. fst_launcher.add_cfg(ap1)
  437. fst_launcher.add_cfg(ap2)
  438. res = fst_launcher.run_hostapd()
  439. if res != 0:
  440. raise Exception("hostapd didn't start properly")
  441. try:
  442. mbie1=[]
  443. flags1 = ''
  444. mbie2=[]
  445. flags2 = ''
  446. # Scan 1st AP
  447. vals1 = scan_and_get_bss(dev[0], fst_test_common.fst_test_def_freq_a)
  448. if vals1 != None:
  449. if 'ie' in vals1:
  450. mbie1 = parse_ies(vals1['ie'], 0x9e)
  451. if 'flags' in vals1:
  452. flags1 = vals1['flags']
  453. # Scan 2nd AP
  454. vals2 = scan_and_get_bss(dev[2], fst_test_common.fst_test_def_freq_g)
  455. if vals2 != None:
  456. if 'ie' in vals2:
  457. mbie2 = parse_ies(vals2['ie'],0x9e)
  458. if 'flags' in vals2:
  459. flags2 = vals2['flags']
  460. finally:
  461. fst_launcher.cleanup()
  462. if len(mbie1) == 0:
  463. raise Exception("No MB IE created by 1st AP")
  464. if len(mbie2) == 0:
  465. raise Exception("No MB IE created by 2nd AP")
  466. def test_fst_scan_nomb(dev, apdev, test_params):
  467. """FST scan no MB IE presence with 1 AP start"""
  468. logdir = test_params['logdir']
  469. # Test valid MB IE in scan results
  470. fst_launcher = FstLauncher(logdir)
  471. ap1 = FstLauncherConfigAP(apdev[0]['ifname'], 'fst_11a', 'a',
  472. fst_test_common.fst_test_def_chan_a,
  473. fst_test_common.fst_test_def_group,
  474. fst_test_common.fst_test_def_prio_high)
  475. fst_launcher.add_cfg(ap1)
  476. res = fst_launcher.run_hostapd()
  477. if res != 0:
  478. raise Exception("Hostapd didn't start properly")
  479. try:
  480. time.sleep(2)
  481. mbie1=[]
  482. flags1 = ''
  483. vals1 = scan_and_get_bss(dev[0], fst_test_common.fst_test_def_freq_a)
  484. if vals1 != None:
  485. if 'ie' in vals1:
  486. mbie1 = parse_ies(vals1['ie'], 0x9e)
  487. if 'flags' in vals1:
  488. flags1 = vals1['flags']
  489. finally:
  490. fst_launcher.cleanup()
  491. if len(mbie1) != 0:
  492. raise Exception("MB IE exists with 1 AP")