#!/usr/local/bin/python import os, sys # get services from stat import ST_SIZE # file stat record from glob import glob # file-names from posixpath import exists # file exists test from time import time, ctime # time functions print 'RegTest start.' print 'user:', os.environ['USER'] # environment print 'path:', os.getcwd() # directory print 'time:', ctime(time()), '\n' program = sys.argv[1] # command args testdir = sys.argv[2] for test in glob(testdir + '/*.in'): # for all files if not exists('%s.out' % test): # no prior results os.system('%s < %s > %s.out 2>&1' % (program, test, test)) print 'GENERATED:', test else: # backup, run, compare os.rename(test + '.out', test + '.out.bkp') os.system('%s < %s > %s.out 2>&1' % (program, test, test)) os.system('diff %s.out %s.out.bkp > %s.diffs' % ((test,)*3) ) if os.stat(test + '.diffs')[ST_SIZE] == 0: print 'PASSED:', test os.unlink(test + '.diffs') else: print 'FAILED:', test, '(see %s.diffs)' % test print 'RegTest done:', ctime(time())