source: trunk/symbol_table/test/run_tests.py @ 2019

Last change on this file since 2019 was 2019, checked in by ksherdy, 7 years ago

Added test file script to automate symbol table testing.

File size: 1.6 KB
Line 
1#
2# run_tests.py
3#
4# Symbol Table Tests
5#
6# Quick-and-dirty Python symbol table test script
7# to generates expected output files for diff.
8#
9# Ken Herdy
10# April 12, 2012
11#
12#----------------------------------------------------------------------------
13#
14# Use:
15#
16# 1. Use st_test_file_generator.py to generate 'st_test_UNIFORM_*' CSV symbol files.
17# 2. Execute test script.
18# 3. diff -r 'results' directory against input symbol files.
19#
20#----------------------------------------------------------------------------
21#
22
23import sys
24from subprocess import *
25import os
26import shutil
27import fnmatch                 
28from string import *
29
30usage='Usage: python ' + __file__ + ' <program> <test root>'
31
32# Run a testcase, writing results
33def run_testcase(program, input_file, outfile_root):
34        (head, tail) = os.path.split(input_file)
35        outputdir = os.path.join(outfile_root, tail)
36        #if os.path.exists(outputdir)==True:
37        (head, tail) = os.path.split(outputdir)
38        if os.path.exists(head)==False:         
39                os.makedirs(head)
40        out_f = open(head + os.path.sep + tail, 'w')
41        call([program, input_file], stderr=None, stdout=out_f)
42        out_f.close()
43
44if __name__ == "__main__":
45
46        if(len(sys.argv) < 3):
47                print usage
48                sys.exit()
49
50        program = sys.argv[1]
51        testfile_root = sys.argv[2]
52        (head, tail) = os.path.split(testfile_root)
53        outfile_root = head + '_rslts'
54
55        for dirname, dirnames, filenames in os.walk(testfile_root):
56                for filename in filenames:
57                        if filename.startswith('st_test_') and not filename.endswith('.svn-base'):
58                                relfile = os.path.relpath(os.path.join(dirname, filename))
59                                run_testcase(program, relfile, outfile_root)
60
61       
Note: See TracBrowser for help on using the repository browser.