scyther/test/gen-tests.py

80 lines
1.7 KiB
Python
Raw Normal View History

#!/usr/bin/python
#
# Generate a test suite
#
# argv[1] tuple width
# stdin list of protocol file names
#
2004-11-18 13:07:10 +00:00
#TODO:
# The tests should be more confined: testing a three-tuple multiprotocol
# should clean up after itself, and only leave stuff that is actually
# _new_. As a base, we can (first compute and then leave the results)
# have the single-protocol results as a reference to speed things up.
# However, in general, the three-tuple stuff just generates too much
# crap in the current setup.
#
import sys
import os
import time
#import datetime
import string
tempfile = 'generated-test-list.tmp'
# Derive tuple list
count = sys.argv[1]
lstatus=os.system('./tuples.py ' + count + ' >' + tempfile)
# Header
2004-10-15 13:11:13 +01:00
print "#!/bin/sh"
print "#"
print "# Test list generated by gen-tests.py"
#print "# at ", time.asctime()
print "#"
# Functions to assist
def getline (inputfile):
return string.strip(inputfile.readline())
2004-10-15 15:46:23 +01:00
def removespdl (str):
return string.replace(str,".spdl","")
2004-10-15 13:11:13 +01:00
def makefilepart (tuple):
rt = count + "-"
namelist = string.split (tuple)
for name in namelist:
2004-10-15 15:46:23 +01:00
rt = rt + "[" + removespdl(name) + "]"
return rt
2004-10-15 13:11:13 +01:00
def makefileline (tuple):
return "results/combined" + makefilepart(tuple) + ".txt"
def makefileerror (tuple):
return "results/errors" + makefilepart(tuple) + ".txt"
def processline (l):
print "./mp.sh ",
print l,
2004-10-15 13:11:13 +01:00
# redirect stderr
print " 2>>", makefileerror(l),
# redirect stdout
print " >", makefileline(l),
# new line
print
# Process lines
inp = open(tempfile, 'r')
line = getline(inp)
lines = 0
while line:
# process the line
processline(line)
lines = lines + 1
# get next
line = getline(inp)
inp.close()
print "#"
print "# ", lines, " lines processed."
2004-10-15 15:46:23 +01:00
# TODO Add code to clean up the mess: delete all files of zero length.