tests: Use proper SQL construction in hwsim test reporting
Don't construct SQL strings on the fly but instead use the argument placeholders. Signed-hostap: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
5fecc0f525
commit
781b65cfbb
1 changed files with 8 additions and 6 deletions
|
@ -38,13 +38,14 @@ def report(conn, build, commit, run, test, result, diff):
|
||||||
build = ''
|
build = ''
|
||||||
if not commit:
|
if not commit:
|
||||||
commit = ''
|
commit = ''
|
||||||
sql = "INSERT INTO results(test,result,run,time,duration,build,commitid) VALUES('" + test.replace('test_', '', 1) + "', '" + result + "', " + str(run) + ", " + str(time.time()) + ", " + str(diff.total_seconds()) + ", '" + build + "', '" + commit + "')"
|
sql = "INSERT INTO results(test,result,run,time,duration,build,commitid) VALUES(?, ?, ?, ?, ?, ?, ?)"
|
||||||
|
params = (test.replace('test_', '', 1), result, run, time.time(), diff.total_seconds(), build, commit)
|
||||||
try:
|
try:
|
||||||
conn.execute(sql)
|
conn.execute(sql, params)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "sqlite: " + str(e)
|
print "sqlite: " + str(e)
|
||||||
print "sql: " + sql
|
print "sql: %r" % (params, )
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test_file = None
|
test_file = None
|
||||||
|
@ -117,12 +118,13 @@ def main():
|
||||||
for t in tests:
|
for t in tests:
|
||||||
print t.__name__ + " - " + t.__doc__
|
print t.__name__ + " - " + t.__doc__
|
||||||
if conn:
|
if conn:
|
||||||
sql = 'INSERT OR REPLACE INTO tests(test,description) VALUES ("' + t.__name__.replace('test_', '', 1) + '", "' + t.__doc__ + '")';
|
sql = 'INSERT OR REPLACE INTO tests(test,description) VALUES (?, ?)'
|
||||||
|
params = (t.__name__.replace('test_', '', 1), t.__doc__)
|
||||||
try:
|
try:
|
||||||
conn.execute(sql)
|
conn.execute(sql, params)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "sqlite: " + str(e)
|
print "sqlite: " + str(e)
|
||||||
print "sql: " + sql
|
print "sql: %r" % (params,)
|
||||||
if conn:
|
if conn:
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
Loading…
Reference in a new issue