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

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

Added path variables to test script.

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