import logging
logger = logging.getLogger()
+try:
+ import sqlite3
+ sqlite3_imported = True
+except ImportError:
+ sqlite3_imported = False
+
scriptsdir = os.path.dirname(os.path.realpath(sys.modules[__name__].__file__))
sys.path.append(os.path.join(scriptsdir, '..', '..', 'wpaspy'))
if contents is None:
return
sql = "INSERT INTO logs(test,run,type,contents) VALUES(?, ?, ?, ?)"
- params = (test, run, type, contents)
+ params = (test, run, type, sqlite3.Binary(contents))
try:
conn.execute(sql, params)
conn.commit()
sys.exit(2)
if args.database:
- import sqlite3
+ if not sqlite3_imported:
+ print "No sqlite3 module found"
+ sys.exit(2)
conn = sqlite3.connect(args.database)
conn.execute('CREATE TABLE IF NOT EXISTS results (test,result,run,time,duration,build,commitid)')
conn.execute('CREATE TABLE IF NOT EXISTS tests (test,description)')
# read the modules from the modules file
if args.mfile:
- args.testmodules = []
- with open(args.mfile) as f:
- for line in f.readlines():
- line = line.strip()
- if not line or line.startswith('#'):
- continue
- args.testmodules.append(line)
+ args.testmodules = []
+ with open(args.mfile) as f:
+ for line in f.readlines():
+ line = line.strip()
+ if not line or line.startswith('#'):
+ continue
+ args.testmodules.append(line)
tests_to_run = []
if args.tests:
t = tests_to_run.pop(0)
name = t.__name__.replace('test_', '', 1)
+ open('/dev/kmsg', 'w').write('running hwsim test case %s\n' % name)
if log_handler:
log_handler.stream.close()
logger.removeHandler(log_handler)
except HwsimSkip, e:
logger.info("Skip test case: %s" % e)
result = "SKIP"
+ except NameError, e:
+ import traceback
+ logger.info(e)
+ traceback.print_exc()
+ result = "FAIL"
except Exception, e:
+ import traceback
logger.info(e)
+ traceback.print_exc()
if args.loglevel == logging.WARNING:
print "Exception: " + str(e)
result = "FAIL"
logger.info("Failed to issue TEST-STOP after {} for {}".format(name, d.ifname))
logger.info(e)
result = "FAIL"
+ if args.no_reset:
+ print "Leaving devices in current state"
+ else:
+ reset_ok = reset_devs(dev, apdev)
wpas = None
try:
wpas = WpaSupplicant(global_iface="/tmp/wpas-wlan5")
pass
if wpas:
wpas.close_ctrl()
- if args.no_reset:
- print "Leaving devices in current state"
- else:
- reset_ok = reset_devs(dev, apdev)
for i in range(0, 3):
rename_log(args.logdir, 'log' + str(i), name, dev[i])
result = "FAIL"
hapd = None
rename_log(args.logdir, 'hostapd', name, hapd)
+ if hapd:
+ del hapd
+ hapd = None
+ # Use None here since this instance of Wlantest() will never be
+ # used for remote host hwsim tests on real hardware.
+ Wlantest.setup(None)
wt = Wlantest()
rename_log(args.logdir, 'hwsim0.pcapng', name, wt)
rename_log(args.logdir, 'hwsim0', name, wt)