tests: Use a helper function to rename wpa_supplicant/hostapd logs
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
61323e70e1
commit
57661377df
2 changed files with 23 additions and 31 deletions
|
@ -77,6 +77,23 @@ class DataCollector(object):
|
||||||
output = os.path.join(self._logdir, '%s.dmesg' % (self._testname, ))
|
output = os.path.join(self._logdir, '%s.dmesg' % (self._testname, ))
|
||||||
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open(output, 'w'))
|
subprocess.call(['sudo', 'dmesg', '-c'], stdout=open(output, 'w'))
|
||||||
|
|
||||||
|
def rename_log(logdir, basename, testname, dev):
|
||||||
|
try:
|
||||||
|
import getpass
|
||||||
|
srcname = os.path.join(logdir, basename)
|
||||||
|
dstname = os.path.join(logdir, testname + '.' + basename)
|
||||||
|
num = 0
|
||||||
|
while os.path.exists(dstname):
|
||||||
|
dstname = os.path.join(logdir,
|
||||||
|
testname + '.' + basename + '-' + str(num))
|
||||||
|
num = num + 1
|
||||||
|
os.rename(srcname, dstname)
|
||||||
|
dev.relog()
|
||||||
|
subprocess.call(['sudo', 'chown', '-f', getpass.getuser(), srcname])
|
||||||
|
except Exception, e:
|
||||||
|
logger.info("Failed to rename log files")
|
||||||
|
logger.info(e)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
tests = []
|
tests = []
|
||||||
test_modules = []
|
test_modules = []
|
||||||
|
@ -285,38 +302,10 @@ def main():
|
||||||
reset_devs(dev, apdev)
|
reset_devs(dev, apdev)
|
||||||
|
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
try:
|
rename_log(args.logdir, 'log' + str(i), name, dev[i])
|
||||||
import getpass
|
|
||||||
srcname = os.path.join(args.logdir, 'log' + str(i))
|
|
||||||
dstname = os.path.join(args.logdir, name + '.log' + str(i))
|
|
||||||
num = 0
|
|
||||||
while os.path.exists(dstname):
|
|
||||||
dstname = os.path.join(args.logdir, name + '.log' + str(i) + '-' + str(num))
|
|
||||||
num = num + 1
|
|
||||||
os.rename(srcname, dstname)
|
|
||||||
dev[i].request("RELOG")
|
|
||||||
subprocess.call(['sudo', 'chown', '-f', getpass.getuser(),
|
|
||||||
srcname])
|
|
||||||
except Exception, e:
|
|
||||||
logger.info("Failed to rename log files")
|
|
||||||
logger.info(e)
|
|
||||||
|
|
||||||
try:
|
hapd = HostapdGlobal()
|
||||||
import getpass
|
rename_log(args.logdir, 'hostapd', name, hapd)
|
||||||
srcname = os.path.join(args.logdir, 'hostapd')
|
|
||||||
dstname = os.path.join(args.logdir, name + '.hostapd')
|
|
||||||
num = 0
|
|
||||||
while os.path.exists(dstname):
|
|
||||||
dstname = os.path.join(args.logdir, name + '.hostapd-' + str(num))
|
|
||||||
num = num + 1
|
|
||||||
os.rename(srcname, dstname)
|
|
||||||
hapd = HostapdGlobal()
|
|
||||||
hapd.relog()
|
|
||||||
subprocess.call(['sudo', 'chown', '-f', getpass.getuser(),
|
|
||||||
srcname])
|
|
||||||
except Exception, e:
|
|
||||||
logger.info("Failed to rename hostapd log file")
|
|
||||||
logger.info(e)
|
|
||||||
|
|
||||||
end = datetime.now()
|
end = datetime.now()
|
||||||
diff = end - start
|
diff = end - start
|
||||||
|
|
|
@ -595,3 +595,6 @@ class WpaSupplicant:
|
||||||
ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
ev = self.wait_event(["CTRL-EVENT-CONNECTED"], timeout=15)
|
||||||
if ev is None:
|
if ev is None:
|
||||||
raise Exception("Association with the AP timed out")
|
raise Exception("Association with the AP timed out")
|
||||||
|
|
||||||
|
def relog(self):
|
||||||
|
self.request("RELOG")
|
||||||
|
|
Loading…
Reference in a new issue