2004-10-15 09:45:59 +01:00
|
|
|
#!/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.
|
|
|
|
#
|
2004-10-15 09:45:59 +01:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import time
|
2004-10-18 14:45:35 +01:00
|
|
|
#import datetime
|
2004-10-15 09:45:59 +01:00
|
|
|
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"
|
2004-10-15 09:45:59 +01:00
|
|
|
print "#"
|
|
|
|
print "# Test list generated by gen-tests.py"
|
2004-10-18 14:45:35 +01:00
|
|
|
#print "# at ", time.asctime()
|
2004-10-15 09:45:59 +01:00
|
|
|
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 + "-"
|
2004-10-15 09:45:59 +01:00
|
|
|
namelist = string.split (tuple)
|
|
|
|
for name in namelist:
|
2004-10-15 15:46:23 +01:00
|
|
|
rt = rt + "[" + removespdl(name) + "]"
|
2004-10-15 09:45:59 +01:00
|
|
|
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"
|
|
|
|
|
2004-10-15 09:45:59 +01:00
|
|
|
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
|
2004-10-15 09:45:59 +01:00
|
|
|
|
|
|
|
# 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.
|