tests: Allow test case descriptions to be written into database
authorJouni Malinen <j@w1.fi>
Sun, 27 Oct 2013 10:16:36 +0000 (12:16 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 27 Oct 2013 10:41:10 +0000 (12:41 +0200)
"run-tests.py -S <db file> -L" can now be used to update a database
table with the current set of test cases and their descriptions.

Signed-hostap: Jouni Malinen <j@w1.fi>

tests/hwsim/README
tests/hwsim/run-tests.py

index 8110a7a..91aa6f9 100644 (file)
@@ -189,4 +189,5 @@ cat | sqlite3 /tmp/example.db <<EOF
 CREATE TABLE results (test,result,run,time,duration,build,commitid);
 CREATE INDEX results_idx ON results (test);
 CREATE INDEX results_idx2 ON results (run);
+CREATE TABLE tests (test,description);
 EOF
index 9aaec02..4b1750b 100755 (executable)
@@ -90,10 +90,13 @@ def main():
 
     if conn:
         run = str(int(time.time()))
-        with open("commit") as f:
-            val = f.readlines()
-            if len(val) > 0:
-                commit = val[0].rstrip()
+        try:
+            with open("commit") as f:
+                val = f.readlines()
+                if len(val) > 0:
+                    commit = val[0].rstrip()
+        except IOError:
+            pass
 
     tests = []
     for t in os.listdir("."):
@@ -108,9 +111,19 @@ def main():
                     func = mod.__dict__.get(s)
                     tests.append(func)
 
-    if len(sys.argv) > 1 and sys.argv[1] == '-L':
+    if len(sys.argv) > idx and sys.argv[idx] == '-L':
         for t in tests:
             print t.__name__ + " - " + t.__doc__
+            if conn:
+                sql = 'INSERT OR REPLACE INTO tests(test,description) VALUES ("' + t.__name__.replace('test_', '', 1) + '", "' + t.__doc__ + '")';
+                try:
+                    conn.execute(sql)
+                except Exception, e:
+                    print "sqlite: " + str(e)
+                    print "sql: " + sql
+        if conn:
+            conn.commit()
+            conn.close()
         sys.exit(0)
 
     if len(sys.argv) > idx: