Browse Source

tests: Allow test case descriptions to be written into database

"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>
Jouni Malinen 11 years ago
parent
commit
f3be6eea9b
2 changed files with 19 additions and 5 deletions
  1. 1 0
      tests/hwsim/README
  2. 18 5
      tests/hwsim/run-tests.py

+ 1 - 0
tests/hwsim/README

@@ -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

+ 18 - 5
tests/hwsim/run-tests.py

@@ -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: