diff options
Diffstat (limited to 'test-chill/testchill')
-rw-r--r-- | test-chill/testchill/__main__.py | 121 | ||||
-rw-r--r-- | test-chill/testchill/chill.py | 113 |
2 files changed, 101 insertions, 133 deletions
diff --git a/test-chill/testchill/__main__.py b/test-chill/testchill/__main__.py index 8af5b9c..86415c3 100644 --- a/test-chill/testchill/__main__.py +++ b/test-chill/testchill/__main__.py @@ -9,7 +9,6 @@ import textwrap from . import chill from . import gcov -from . import omega from . import test from . import util @@ -26,7 +25,6 @@ def make_local(argsns, arg_parser): argsns.bin_dir = os.path.join(os.getcwd(), '.staging/bin') argsns.chill_tc_dir = os.path.join(os.getcwd(), 'test-cases') # formally from the commandline argsns.chill_dir = os.path.abspath(argsns.chill_dir) - argsns.omega_dir = os.path.abspath(argsns.omega_dir) argsns.chill_build_coverage = argsns.coverage_set is not None #TODO: make arg passed to local. argsns.chill_test_coverage = argsns.coverage_set is not None @@ -35,60 +33,59 @@ def make_local(argsns, arg_parser): util.shell('cp', [os.path.join(argsns.chill_dir, 'examples/cuda-chill/cudaize.lua'), argsns.wd]) util.shell('cp', [os.path.join(argsns.chill_dir, 'examples/cuda-chill/cudaize.py'), argsns.wd]) - chill_version = argsns.chill_version - for config in chill.ChillConfig.configs(argsns.omega_dir, argsns.chill_dir, argsns.bin_dir, version=chill_version): + for config in chill.ChillConfig.configs(argsns.chill_dir, argsns.bin_dir): build_testcase = chill.BuildChillTestCase(config, options={'coverage': argsns.chill_build_coverage}, coverage_set=argsns.coverage_set) yield build_testcase - batch_file = os.path.join(argsns.chill_tc_dir, config.name() + '.tclist') + batch_file = os.path.join(argsns.chill_tc_dir, config.name + '.tclist') for tc in make_batch_testcaselist(argsns, arg_parser, batch_file): yield tc -def make_repo(argsns, arg_parser): +#def make_repo(argsns, arg_parser): """ Make the repo test case list. A convinience function for testing chill from the repsitory. @params argsns Command line arguments @params arg_parser The ArgumentParser object """ - util.mkdir_p(os.path.join(os.getcwd(), '.staging'), temp=True) - argsns.bin_dir = os.path.join(os.getcwd(), '.staging/bin') - argsns.repo_dir = os.path.join(os.getcwd(), '.staging/repo') - argsns.chill_tc_dir = os.path.join(os.getcwd(), 'test-cases') # formally from the commandline - argsns.wd = os.path.join(os.getcwd(), '.staging/wd') - - util.mkdir_p(argsns.bin_dir) - util.mkdir_p(argsns.repo_dir) - util.mkdir_p(argsns.wd) - - #TODO: Should these be hard coded? - repo_root = 'shell.cs.utah.edu/uusoc/facility/res/hallresearch/svn_repo/resRepo/projects' - for version in ['release', 'dev']: - new_args = util.copy(argsns) - if version == 'dev': - chill_repo = 'svn+ssh://{}@{}/chill/branches/cuda-chill-rose'.format(new_args.svnuser, repo_root) - chill_repo_name = 'chill' - omega_repo = 'svn+ssh://{}@{}/omega/branches/cuda-omega-rose'.format(new_args.svnuser, repo_root) - omega_repo_name = 'omega' - elif version == 'release': - chill_repo = 'svn+ssh://{}@{}/chill/release'.format(new_args.svnuser, repo_root) - chill_repo_name = 'chill-release' - omega_repo = 'svn+ssh://{}@{}/omega/release'.format(new_args.svnuser, repo_root) - omega_repo_name = 'omega-release' - new_args.omega_dir = os.path.join(new_args.repo_dir, omega_repo_name) - new_args.chill_dir = os.path.join(new_args.repo_dir, chill_repo_name) - util.shell('svn', ['export', '--force', omega_repo, new_args.omega_dir]) - util.shell('svn', ['export', '--force', chill_repo, new_args.chill_dir]) - util.shell('cp', [os.path.join(new_args.chill_dir, 'examples/cuda-chill/cudaize.lua'), new_args.wd]) - if version == 'dev': - util.shell('cp', [os.path.join(new_args.chill_dir, 'examples/cuda-chill/cudaize.py'), new_args.wd]) - # do omega: (just build it for now) - yield omega.BuildOmegaTestCase(new_args.omega_dir ,version) - # do chill - for config in chill.ChillConfig.configs(new_args.omega_dir, new_args.chill_dir, new_args.bin_dir, version=version): - yield chill.BuildChillTestCase(config, coverage_set=argsns.coverage_set) - batch_file = os.path.join(argsns.chill_tc_dir, config.name() + '.tclist') - if os.path.exists(batch_file): - for tc in make_batch_testcaselist(new_args, arg_parser, batch_file): - yield tc +# util.mkdir_p(os.path.join(os.getcwd(), '.staging'), temp=True) +# argsns.bin_dir = os.path.join(os.getcwd(), '.staging/bin') +# argsns.repo_dir = os.path.join(os.getcwd(), '.staging/repo') +# argsns.chill_tc_dir = os.path.join(os.getcwd(), 'test-cases') # formally from the commandline +# argsns.wd = os.path.join(os.getcwd(), '.staging/wd') +# +# util.mkdir_p(argsns.bin_dir) +# util.mkdir_p(argsns.repo_dir) +# util.mkdir_p(argsns.wd) +# +# #TODO: Should these be hard coded? +# repo_root = 'shell.cs.utah.edu/uusoc/facility/res/hallresearch/svn_repo/resRepo/projects' +# for version in ['release', 'dev']: +# new_args = util.copy(argsns) +# if version == 'dev': +# chill_repo = 'svn+ssh://{}@{}/chill/branches/cuda-chill-rose'.format(new_args.svnuser, repo_root) +# chill_repo_name = 'chill' +# omega_repo = 'svn+ssh://{}@{}/omega/branches/cuda-omega-rose'.format(new_args.svnuser, repo_root) +# omega_repo_name = 'omega' +# elif version == 'release': +# chill_repo = 'svn+ssh://{}@{}/chill/release'.format(new_args.svnuser, repo_root) +# chill_repo_name = 'chill-release' +# omega_repo = 'svn+ssh://{}@{}/omega/release'.format(new_args.svnuser, repo_root) +# omega_repo_name = 'omega-release' +# new_args.omega_dir = os.path.join(new_args.repo_dir, omega_repo_name) +# new_args.chill_dir = os.path.join(new_args.repo_dir, chill_repo_name) +# util.shell('svn', ['export', '--force', omega_repo, new_args.omega_dir]) +# util.shell('svn', ['export', '--force', chill_repo, new_args.chill_dir]) +# util.shell('cp', [os.path.join(new_args.chill_dir, 'examples/cuda-chill/cudaize.lua'), new_args.wd]) +# if version == 'dev': +# util.shell('cp', [os.path.join(new_args.chill_dir, 'examples/cuda-chill/cudaize.py'), new_args.wd]) +# # do omega: (just build it for now) +# yield omega.BuildOmegaTestCase(new_args.omega_dir ,version) +# # do chill +# for config in chill.ChillConfig.configs(new_args.omega_dir, new_args.chill_dir, new_args.bin_dir, version=version): +# yield chill.BuildChillTestCase(config, coverage_set=argsns.coverage_set) +# batch_file = os.path.join(argsns.chill_tc_dir, config.name() + '.tclist') +# if os.path.exists(batch_file): +# for tc in make_batch_testcaselist(new_args, arg_parser, batch_file): +# yield tc def make_runchill_testcase(argsns): """ @@ -116,12 +113,10 @@ def make_runchill_testcase(argsns): argsns.chill_script_lang = chill.ChillConfig.ext_to_script_lang(chill_script.split('.')[-1]) config = chill.ChillConfig( - omega_dir = os.path.abspath(argsns.omega_dir) if argsns.omega_dir != None else None, chill_dir = os.path.abspath(argsns.chill_dir) if argsns.chill_dir != None else None, bin_dir = os.path.abspath(argsns.bin_dir) if argsns.bin_dir != None else None, build_cuda = argsns.build_cuda, - script_lang = argsns.chill_script_lang, - version = argsns.chill_version) + script_lang = argsns.chill_script_lang) return chill.RunChillTestCase(config, chill_script, chill_src, wd=wd, options=options, coverage_set=coverage_set) @@ -131,7 +126,6 @@ def make_buildchill_testcase(argsns): @param argsns Command line arguments """ assert argsns.chill_dir != None - assert argsns.omega_dir != None coverage_set = argsns.coverage_set @@ -139,12 +133,10 @@ def make_buildchill_testcase(argsns): options['coverage'] = argsns.chill_build_coverage config = chill.ChillConfig( - omega_dir = os.path.abspath(argsns.omega_dir) if argsns.omega_dir != None else None, chill_dir = os.path.abspath(argsns.chill_dir) if argsns.chill_dir != None else None, bin_dir = os.path.abspath(argsns.bin_dir) if argsns.bin_dir != None else None, build_cuda = argsns.build_cuda, - script_lang = argsns.chill_script_lang, - version = argsns.chill_version) + script_lang = argsns.chill_script_lang) return chill.BuildChillTestCase(config, options=options, coverage_set=coverage_set) @@ -173,12 +165,12 @@ def add_local_args(arg_parser): @param arg_parser The local ArgumentParser object """ arg_parser.add_argument('chill_dir', metavar='chill-home', default='../') - arg_parser.add_argument('-v', '--chill-branch', dest='chill_version', default='dev', choices=['release','dev']) + #arg_parser.add_argument('-v', '--chill-branch', dest='chill_version', default='dev', choices=['release','dev']) # - Testing should consider all interface languages. Will uncomment if testing takes too long # arg_parser.add_argument('-i', '--interface-lang', nargs=1, action='append', dest='chill_script_lang_list', choices=['script','lua','python']) # arg_parser.add_argument('-t', '--testcase-dir', dest='chill_tc_dir', default=os.path.join(os.getcwd(), 'test-cases/')) - arg_parser.set_defaults(wd=os.path.join(os.getcwd(), '.staging/wd')) # - These don't seem to work - arg_parser.set_defaults(bin_dir=os.path.join(os.getcwd(), '.staging/bin')) # - + arg_parser.set_defaults(wd=os.path.join(os.getcwd(), '.staging/wd')) + arg_parser.set_defaults(bin_dir=os.path.join(os.getcwd(), '.staging/bin')) @util.callonce def add_repo_args(arg_parser): @@ -207,7 +199,6 @@ def add_chill_common_args(arg_parser): Common chill command line arguments. @param arg_parser The ArgumentParser object """ - arg_parser.add_argument('-v', '--chill-branch', dest='chill_version', default='dev', choices=['release','dev']) cuda_group = arg_parser.add_mutually_exclusive_group() cuda_group.add_argument('-u', '--target-cuda', action='store_const', const=True, dest='build_cuda', default=False, help='Test cuda-chill. (Default is chill)') cuda_group.add_argument('-c', '--target-c', action='store_const', const=False, dest='build_cuda', default=False, help='Test chill. (Default is chill)') @@ -225,7 +216,7 @@ def add_chill_run_args(arg_parser): add_boolean_option(arg_parser, 'run-script', dest='chill_test_run_script', default=True, help_on='Run chill script.', help_off='Do not run chill script.') add_boolean_option(arg_parser, 'compile-gensrc', dest='chill_test_compile_gensrc', default=True, help_on='Compile generated source file', help_off='Do not compile generated source file.') add_boolean_option(arg_parser, 'check-run-script', dest='chill_test_check_run_script', default=False, help_on='Diff stdout from chill script against a benchmark.') - add_boolean_option(arg_parser, 'test-coverage', 'chill_test_coverage', default=True, help_on='Run chill and record code coverage (default).', help_off='Run chill normally without recording code coverage.') + add_boolean_option(arg_parser, 'test-coverage', 'chill_test_coverage', default=False, help_on='Run chill and record code coverage (default).', help_off='Run chill normally without recording code coverage.') @util.callonce def add_chill_build_args(arg_parser): @@ -233,7 +224,7 @@ def add_chill_build_args(arg_parser): Command line arguments specific to building chill and testing the build process @params arg_parser The ArgumentParser object """ - add_boolean_option(arg_parser, 'build-coverage', 'chill_build_coverage', default=True, help_on='Build chill for code coverage flags (default).', help_off='Build chill normally without code coverage flags.') + add_boolean_option(arg_parser, 'build-coverage', 'chill_build_coverage', default=False, help_on='Build chill for code coverage flags (default).', help_off='Build chill normally without code coverage flags.') @util.callonce def add_local_command(command_group): @@ -303,7 +294,7 @@ def add_commands(arg_parser): """ command_group = arg_parser.add_subparsers(title='commands') add_local_command(command_group) - add_repo_command(command_group) + #add_repo_command(command_group) add_chill_command(command_group) add_buildchill_command(command_group) add_batch_command(command_group) @@ -315,10 +306,9 @@ def add_global_args(arg_parser): @param arg_parser The ArgumentParser object """ arg_parser.add_argument('-w', '--working-dir', dest='wd', default=os.getcwd(), help='The working directory. (Defaults to the current directory)', metavar='working-directory') - arg_parser.add_argument('-R', '--rose-home', dest='rose_dir', default=os.getenv('ROSEHOME'), help='Rose home directory. (Defaults to ROSEHOME)', metavar='rose-home') + arg_parser.add_argument('-R', '--rose-home', dest='rose_dir', default=os.getenv('ROSEHOME'), help='Rose home directory. (Defaults to ROSEHOME)', metavar='rose-home') arg_parser.add_argument('-C', '--chill-home', dest='chill_dir', default=os.path.join(os.getcwd(), '..'), help='Chill home directory. (Defaults to CHILLHOME)', metavar='chill-home') - arg_parser.add_argument('-O', '--omega-home', dest='omega_dir', default=os.path.join(os.getcwd(), '../omega'), help='Omega home directory. (Defaults to ../omega)', metavar='omega-home') - arg_parser.add_argument('-b', '--binary-dir', dest='bin_dir', default=None, help='Binary directory.', metavar='bin-dir') + arg_parser.add_argument('-b', '--binary-dir', dest='bin_dir', default=os.path.join(os.getcwd(), '..'), help='Binary directory.', metavar='bin-dir') @util.callonce def make_argparser(): @@ -331,8 +321,7 @@ def make_argparser(): To test a local working copy of chill (from the development branch): -------------------------------------------------------------------- - - Set $OMEGAHOME and compile omega. - - Run `python -m testchill local <path-to-chill>` + - Run `python -m testchill local` '''), epilog='EPILOG', @@ -362,11 +351,9 @@ def args_to_tclist(args=sys.argv[1:], arg_parser=make_argparser(), argsns=None, @util.callonce def main(): coverage = gcov.GcovSet() - #coverage=None results = list(test.run(args_to_tclist(coverage_set=coverage))) test.pretty_print_results(results) util.rmtemp() - #coverage.pretty_print() with open('coverage.pickle', 'wb') as f: pickle.dump(coverage, f, 2) diff --git a/test-chill/testchill/chill.py b/test-chill/testchill/chill.py index 05f3b4f..b6d39cf 100644 --- a/test-chill/testchill/chill.py +++ b/test-chill/testchill/chill.py @@ -11,46 +11,16 @@ from . import cpp_validate class ChillConfig(object): - _config_map = dict(('-'.join(map(str,k)),v) for k,v in [ - (('dev',False,'script'), ('chill', 'depend-chill', 'chill', '')), - (('dev',False,'lua'), ('chill-lua', 'depend-chill', 'chill', 'SCRIPT_LANG=lua')), - (('dev',False,'python'), ('chill-python', 'depend-chill', 'chill', 'SCRIPT_LANG=python')), - (('dev',True,'lua'), ('cuda-chill', 'depend-cuda-chill', 'cuda-chill', '')), - (('dev',True,'python'), ('cuda-chill-python', 'depend-cuda-chill', 'cuda-chill', 'SCRIPT_LANG=python')), - (('release',False,'script'), ('chill-release', 'depend', 'chill', '')), - (('release',True,'lua'), ('cuda-chill-release', 'depend-cuda-chill', 'cuda-chill', '')) - ]) - - def __init__(self, omega_dir=None, chill_dir=None, bin_dir=None, build_cuda=False, script_lang=None, version='dev'): - self.version = version + def __init__(self, chill_dir=None, bin_dir=None, build_cuda=False, script_lang=None): self.build_cuda = build_cuda self.script_lang = script_lang - self.omega_dir = omega_dir self.chill_dir = chill_dir self.bin_dir = bin_dir if self.script_lang is None: self.script_lang = self.default_script_lang() - def _get(self, index): - return ChillConfig._config_map[self.version + '-' + str(self.build_cuda) + '-' + self.script_lang][index] - def default_script_lang(self): - if self.build_cuda: - return 'lua' - else: - return 'script' - - def name(self): - return self._get(0) - - def make_depend_target(self): - return self._get(1) - - def make_target(self): - return self._get(2) - - def make_args(self): - return self._get(3) + return 'python' def _buildfunc(self, cc, link=True): if not link: @@ -87,38 +57,51 @@ class ChillConfig(object): else: return self._buildfunc('gcc') - def env(self): - chill_env = {'OMEGAHOME':self.omega_dir} - if self.version == 'release' and self.build_cuda: - chill_env['CUDACHILL']='true' - return chill_env + @property + def config_args(self): + args = [] + if self.build_cuda: + args += ['--enable-cuda'] + if self.script_lang is not None: + args += ['--with-' + self.script_lang] + return args + + @property + def buildname(self): + if self.build_cuda: + return 'cudachill' + else: + return 'chill' + + @property + def name(self): + if self.buildname == 'cudachill': + return 'cuda-chill-' + self.script_lang + else: + return 'chill-' + self.script_lang @staticmethod def ext_to_script_lang(ext): return {'script':'script', 'lua':'lua', 'py':'python'}[ext] @staticmethod - def configs(omega_dir, chill_dir, bin_dir, build_cuda=None, script_lang=None, version=None): + def configs(chill_dir, bin_dir, build_cuda=None, script_lang=None): all_configs = [ - (False, 'script', 'dev'), - (False, 'script', 'release'), - (False, 'lua', 'dev'), - (False, 'python', 'dev'), - (True, 'lua', 'dev'), - (True, 'lua', 'release'), - (True, 'python', 'dev')] + (False, 'script'), + (False, 'lua'), + (False, 'python'), + (True, 'lua'), + (True, 'python')] pred_list = [lambda x: True] if not build_cuda is None: pred_list += [lambda x: x[0] == build_cuda] if not script_lang is None: pred_list += [lambda x: x[1] == script_lang] - if not version is None: - pred_list += [lambda x: x[2] == version] cond = lambda x: all(p(x) for p in pred_list) - return iter(ChillConfig(omega_dir, chill_dir, bin_dir, *conf) for conf in filter(cond, all_configs)) + return iter(ChillConfig(chill_dir, bin_dir, *conf) for conf in filter(cond, all_configs)) # - - # @@ -143,18 +126,15 @@ class BuildChillTestCase(test.TestCase): if config.script_lang == None: config.script_lang = config.default_script_lang() self.config = config - super(BuildChillTestCase,self).__init__(self.config.name()) + super(BuildChillTestCase,self).__init__(self.config.name) self._set_options(options, coverage_set) def _set_options(self, options, coverage_set): self.options = dict(BuildChillTestCase.default_options) self.options.update(options) - self.build_env = self.config.env() - self.build_args = self.config.make_args() if self.options['coverage']: - self.build_args += ' "TEST_COVERAGE=1"' - coverage_set.addprogram(self.config.name(), self.config.chill_dir) + coverage_set.addprogram(self.config.name, self.config.chill_dir) def setUp(self): """ @@ -166,18 +146,19 @@ class BuildChillTestCase(test.TestCase): util.shell('rm', ['-f', '*.gcda'], wd=self.config.chill_dir) util.shell('make clean', wd=self.config.chill_dir) - util.shell('make veryclean', wd=self.config.chill_dir) def run(self): """ Build chill """ - depend_target = self.config.make_depend_target() - target = self.config.make_target() - util.shell('make', ['clean'], wd=self.config.chill_dir) - util.shell('make', ['veryclean'], wd=self.config.chill_dir) - util.shell('make', [depend_target] + [self.build_args], env=self.build_env, wd=self.config.chill_dir) - util.shell('make', [target] + [self.build_args], env=self.build_env, wd=self.config.chill_dir) + util.shell('make', ['distclean'], wd=self.config.chill_dir) + util.shell('./configure', self.config.config_args, wd=self.config.chill_dir) + util.shell('make', [], wd=self.config.chill_dir) + + #util.shell('make', ['clean'], wd=self.config.chill_dir) + #util.shell('make', ['veryclean'], wd=self.config.chill_dir) + #util.shell('make', [depend_target] + [self.build_args], env=self.build_env, wd=self.config.chill_dir) + #util.shell('make', [target] + [self.build_args], env=self.build_env, wd=self.config.chill_dir) return self.make_pass() def tearDown(self): @@ -187,9 +168,9 @@ class BuildChillTestCase(test.TestCase): """ if self.test_result.passed(): if self.config.bin_dir: - util.shell('mv', [os.path.join(self.config.chill_dir, self.config.make_target()), os.path.join(self.config.bin_dir, self.config.name())]) - elif not self.config.make_target() == self.config.name(): - util.shell('mv', [os.path.join(self.config.chill_dir, self.config.make_target()), os.path.join(self.config.chill_dir, self.config.name())]) + util.shell('mv', [os.path.join(self.config.chill_dir, self.config.buildname), os.path.join(self.config.bin_dir, self.config.name)]) + elif not self.config.buildname == self.config.name: + util.shell('mv', [os.path.join(self.config.chill_dir, self.config.buildname), os.path.join(self.config.chill_dir, self.config.name)]) # - - # @@ -225,14 +206,14 @@ class RunChillTestCase(test.SequencialTestCase): assert isinstance(config, ChillConfig) - super(RunChillTestCase,self).__init__(config.name() + ':' + os.path.basename(chill_script)) + super(RunChillTestCase,self).__init__(config.name + ':' + os.path.basename(chill_script)) self.config = config self.wd = wd if (wd != None) else os.getcwd() self.chill_src_path = os.path.abspath(chill_src) self.chill_script_path = os.path.abspath(chill_script) - self.chill_bin = os.path.join(self.config.bin_dir, self.config.name()) + self.chill_bin = os.path.join(self.config.bin_dir, self.config.name) self.chill_src = os.path.basename(self.chill_src_path) self.chill_script = os.path.basename(self.chill_script_path) self.chill_gensrc = self._get_gensrc(self.chill_src) @@ -291,7 +272,7 @@ class RunChillTestCase(test.SequencialTestCase): util.shell('rm', ['-f', self.chill_script], wd=self.wd) util.shell('rm', ['-f', self.chill_gensrc], wd=self.wd) if self.options['coverage'] and self.coverage_set is not None: - self.coverage_set.addcoverage(self.config.name(), self.name) + self.coverage_set.addcoverage(self.config.name, self.name) # - - # # - Chill Tests - # |