source: trunk/symbol_table/test/gen_test_file.py @ 2084

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

Add file.

File size: 2.1 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 test.
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=''
20gid_test_file='[1_100_10][2_100_10][3_100_10][4_100_10][5_100_10][6_100_10][7_100_10][8_100_10][9_100_10][10_100_10][11_100_10][12_100_10][13_100_10][14_100_10][15_100_10][16_100_10][17_100_10][18_100_10][19_100_10]_1_1.test'
21rslt_dir_suffix='_rslts'
22#----------------------------------------------------------------------------
23import sys
24import subprocess
25import os
26import shutil
27import fnmatch                 
28from string import *
29
30usage='Usage: python ' + __file__ + ' <program> <test root>'
31
32def gen_test_file(lb, ub, O, U):
33        total = 0
34
35        command = ['python']
36        args = ['../st_test_file_generator.py']
37
38        L_O_U = ''
39        avg_gap = '1'
40        max_gap = '1'
41
42        for lgth in range(lb, ub):
43                L_O_U = "[" + str(lgth) + "," + str(O) + "," + str(U) + "]"
44                args.append(L_O_U)
45
46        print "Total: %d" % total
47
48        args.append(avg_gap)
49        args.append(max_gap)
50
51        command.extend(args)
52
53        subprocess.call(command)
54
55# Run a testcase, writing results
56#def run_testcase(program, input_file, outfile_root):
57#       (head, tail) = os.path.split(input_file)
58#       outputdir = os.path.join(outfile_root, tail)
59        #if os.path.exists(outputdir)==True:
60#       (head, tail) = os.path.split(outputdir)
61#       if os.path.exists(head)==False:         
62#               os.makedirs(head)
63#       out_f = open(head + os.path.sep + tail, 'w')
64#       call([program, input_file], stderr=None, stdout=out_f)
65#       out_f.close()
66
67if __name__ == "__main__":
68
69        if(len(sys.argv) < 3):
70                print usage
71                sys.exit()
72
73        program = os.path.join(program_dir_path,sys.argv[1])
74        testfile_dir = os.path.join(test_dir_path,sys.argv[2])
75        #outfile_root = testfile_dir + rslt_dir_suffix #os.path.basename(testfile_dir) + rslt_dir_suffix
76
77        gen_test_file(2,5,10,10)
78
79
80
81       
Note: See TracBrowser for help on using the repository browser.