1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00

Change add_test.py to output the concatenated raw/report to stdout.

Instead of appending it to test_stash.
This commit is contained in:
Veselin Georgiev 2014-07-15 17:55:39 +03:00
parent 0f17a01e9c
commit fbed394404

View file

@ -4,13 +4,14 @@ import os, sys, re
args = sys.argv
if not len(args) in (3, 4):
print "Usage: add_test.py <rawdata file> <report file> [tests stash file]"
print "If the last is not specified, `tests_stash.txt' is assumed"
if len(args) != 3:
print "Usage: create_test.py <rawdata file> <report file>"
print "The .test file is written to stdout."
sys.exit(1)
rawdata = []
for line in open(args[1], "rt").readlines():
def readRawFile():
rawdata = []
for line in open(args[1], "rt").readlines():
lookfor = ["basic_cpuid", "ext_cpuid", "intel_fn4", "intel_fn11"]
good = False
for match in lookfor:
@ -19,10 +20,12 @@ for line in open(args[1], "rt").readlines():
break
if good:
rawdata.append(line.strip())
return rawdata
repdata = []
rexp = re.compile('(-?[0-9]+).*')
for line in open(args[2], "rt").readlines():
def readResultFile():
repdata = []
rexp = re.compile('(-?[0-9]+).*')
for line in open(args[2], "rt").readlines():
s = line.strip()
if s.find(":") == -1:
continue
@ -49,12 +52,8 @@ for line in open(args[2], "rt").readlines():
if i != -1:
value = value[:i] + value[i + 5:]
repdata.append(value)
return repdata
stash = "tests_stash.txt"
if len(args) == 4:
stash = args[3]
fout = open(stash, "at")
delimiter = "-" * 80
lines = rawdata + [delimiter] + repdata + [delimiter]
fout.writelines(map(lambda s: s + "\n", lines))
fout.close()
lines = readRawFile() + [delimiter] + readResultFile()
sys.stdout.writelines(map(lambda s: s + "\n", lines))