1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-10-13 11:10:39 +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
commit fbed394404

View file

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