- Timestamp:
- May 10, 2012, 11:52:34 AM (7 years ago)
- Location:
- trunk/symbol_table/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/symbol_table/test/gen_test_file.py
r2076 r2094 1 1 # 2 # run_tests.py 3 # 4 # Symbol Table Tests 2 # gen_test_file.py 5 3 # 6 4 # Quick-and-dirty Python symbol table test script 7 # to generate s expected output files for diff test.5 # to generate length sorted symbol table file. 8 6 # 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 7 # Created on: April 12, 2012 8 # Author: Ken Herdy 15 9 # 16 10 #---------------------------------------------------------------------------- 17 11 # Edit: 18 program_dir_path='../../src'19 test_dir_path=''20 gid_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'21 rslt_dir_suffix='_rslts'22 12 #---------------------------------------------------------------------------- 23 13 import sys … … 27 17 import fnmatch 28 18 from string import * 19 #---------------------------------------------------------------------------- 20 # Edit: 21 program_path_dir='./' 22 # 23 #---------------------------------------------------------------------------- 24 # Command line args. 25 #---------------------------------------------------------------------------- 26 import optparse 27 def get_option_parser(): 28 """Return an C{optparse.OptionParser} instance tied to this configuration.""" 29 29 30 usage='Usage: python ' + __file__ + ' <program> <test root>' 30 parser = optparse.OptionParser(usage='python %prog', 31 version='1.0', 32 ) 31 33 34 return parser 35 #---------------------------------------------------------------------------- 32 36 def gen_test_file(lb, ub, O, U): 33 37 total = 0 34 38 35 39 command = ['python'] 36 args = [ '../st_test_file_generator.py']40 args = [program_path_dir + 'st_test_file_generator.py'] 37 41 38 42 L_O_U = '' … … 53 57 subprocess.call(command) 54 58 55 # Run a testcase, writing results56 #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 59 67 60 if __name__ == "__main__": 68 61 69 if(len(sys.argv) < 3): 70 print usage 71 sys.exit() 62 option_parser = get_option_parser() 63 options, args = option_parser.parse_args(sys.argv[1:]) 72 64 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_suffix65 if len(args) != 0: 66 option_parser.print_usage() 67 sys.exit() 76 68 77 gen_test_file(2,5,10,10) 69 min_lgth = 1 70 max_lgth = 20 71 occurences = 1000 72 unique = 10 73 74 gen_test_file(min_lgth,max_lgth,occurences,unique) 78 75 79 76 -
trunk/symbol_table/test/run_tests.py
r2092 r2094 1 1 # 2 # run_tests.py 3 # 4 # Symbol Table Tests 2 # run_tests.py - Length Sorted Symbol Table Tests 5 3 # 6 4 # Quick-and-dirty Python symbol table test script 7 5 # to generates expected output files for diff and gid tests. 8 6 # 9 # Ken Herdy10 # A pril 12, 20127 # Created on: April 12, 2012 8 # Author: Ken Herdy 11 9 # 12 10 #---------------------------------------------------------------------------- … … 16 14 out_dir_path='../test/out' 17 15 #---------------------------------------------------------------------------- 18 19 16 import sys 20 17 import os … … 23 20 import fnmatch 24 21 import string 25 import optparse 26 22 #---------------------------------------------------------------------------- 23 # Test cases. Quick and dirty. 24 #---------------------------------------------------------------------------- 27 25 def gid_testcase(program, input_file): 28 26 file_name = os.path.basename(input_file) … … 62 60 63 61 #---------------------------------------------------------------------------- 62 # Command line args. 63 #---------------------------------------------------------------------------- 64 import optparse 64 65 def get_option_parser(): 65 66 """Return an C{optparse.OptionParser} instance tied to this configuration.""" … … 85 86 86 87 return parser 87 88 88 #---------------------------------------------------------------------------- 89 89 … … 93 93 options, args = option_parser.parse_args(sys.argv[1:]) 94 94 95 # Positional arguments96 95 if len(args) != 1: 97 96 option_parser.print_usage()
Note: See TracChangeset
for help on using the changeset viewer.