scyther/spdl/gen-tests.py
2004-11-18 13:07:10 +00:00

80 lines
1.7 KiB
Python
Executable File

#!/usr/bin/python
#
# Generate a test suite
#
# argv[1] tuple width
# stdin list of protocol file names
#
#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
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())
def removespdl (str):
return string.replace(str,".spdl","")
def makefilepart (tuple):
rt = count + "-"
namelist = string.split (tuple)
for name in namelist:
rt = rt + "[" + removespdl(name) + "]"
return rt
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,
# 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."
# TODO Add code to clean up the mess: delete all files of zero length.