diff options
author | Jouni Malinen <j@w1.fi> | 2015-09-07 16:53:23 +0300 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2015-09-07 16:53:23 +0300 |
commit | a302ee342cf259710157882abbc4d383cd728686 (patch) | |
tree | a18e477f05a3ad2df420cff3377b4a4b61896d4d | |
parent | eb95ced2d258913e4025eb5e57f58c5862aa6c16 (diff) | |
download | hostap-a302ee342cf259710157882abbc4d383cd728686.tar.gz |
tests: Use sqlite3.Binary() with the log files
This is needed to avoid issues in some cases where 8-bit bytestrings may
be present in the otherwise text debug log.
Signed-off-by: Jouni Malinen <j@w1.fi>
-rwxr-xr-x | tests/hwsim/run-tests.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index a1e860017..13e360b3a 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -18,6 +18,12 @@ import termios 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')) @@ -80,7 +86,7 @@ def add_log_file(conn, test, run, type, path): 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() @@ -231,7 +237,9 @@ def main(): 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)') |