Changeset 2094 for trunk/symbol_table


Ignore:
Timestamp:
May 10, 2012, 11:52:34 AM (7 years ago)
Author:
ksherdy
Message:

Updated test scripts.

Location:
trunk/symbol_table/test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/symbol_table/test/gen_test_file.py

    r2076 r2094  
    11#
    2 # run_tests.py
    3 #
    4 # Symbol Table Tests
     2# gen_test_file.py
    53#
    64# Quick-and-dirty Python symbol table test script
    7 # to generates expected output files for diff test.
     5# to generate length sorted symbol table file.
    86#
    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
    159#
    1610#----------------------------------------------------------------------------
    1711# 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'
    2212#----------------------------------------------------------------------------
    2313import sys
     
    2717import fnmatch                 
    2818from string import *
     19#----------------------------------------------------------------------------
     20# Edit:
     21program_path_dir='./'
     22#
     23#----------------------------------------------------------------------------
     24# Command line args.
     25#----------------------------------------------------------------------------
     26import optparse
     27def get_option_parser():
     28        """Return an C{optparse.OptionParser} instance tied to this configuration."""
    2929
    30 usage='Usage: python ' + __file__ + ' <program> <test root>'
     30        parser = optparse.OptionParser(usage='python %prog',
     31                                        version='1.0',
     32                                        )
    3133
     34        return parser
     35#----------------------------------------------------------------------------
    3236def gen_test_file(lb, ub, O, U):
    3337        total = 0
    3438
    3539        command = ['python']
    36         args = ['../st_test_file_generator.py']
     40        args = [program_path_dir + 'st_test_file_generator.py']
    3741
    3842        L_O_U = ''
     
    5357        subprocess.call(command)
    5458
    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()
    6659
    6760if __name__ == "__main__":
    6861
    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:])
    7264
    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
     65        if len(args) != 0:
     66            option_parser.print_usage()
     67            sys.exit()
    7668
    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)
    7875
    7976
  • trunk/symbol_table/test/run_tests.py

    r2092 r2094  
    11#
    2 # run_tests.py
    3 #
    4 # Symbol Table Tests
     2# run_tests.py - Length Sorted Symbol Table Tests
    53#
    64# Quick-and-dirty Python symbol table test script
    75# to generates expected output files for diff and gid tests.
    86#
    9 # Ken Herdy
    10 # April 12, 2012
     7# Created on: April 12, 2012
     8# Author: Ken Herdy
    119#
    1210#----------------------------------------------------------------------------
     
    1614out_dir_path='../test/out'
    1715#----------------------------------------------------------------------------
    18 
    1916import sys
    2017import os
     
    2320import fnmatch                 
    2421import string
    25 import optparse
    26 
     22#----------------------------------------------------------------------------
     23# Test cases. Quick and dirty.
     24#----------------------------------------------------------------------------
    2725def gid_testcase(program, input_file):
    2826    file_name = os.path.basename(input_file)
     
    6260
    6361#----------------------------------------------------------------------------
     62# Command line args.
     63#----------------------------------------------------------------------------
     64import optparse
    6465def get_option_parser():
    6566        """Return an C{optparse.OptionParser} instance tied to this configuration."""
     
    8586
    8687        return parser
    87 
    8888#----------------------------------------------------------------------------
    8989
     
    9393        options, args = option_parser.parse_args(sys.argv[1:])
    9494
    95         # Positional arguments
    9695        if len(args) != 1:
    9796            option_parser.print_usage()
Note: See TracChangeset for help on using the changeset viewer.