diff options
author | Derick Huth <derickhuth@gmail.com> | 2014-11-21 13:40:28 -0700 |
---|---|---|
committer | Derick Huth <derickhuth@gmail.com> | 2014-11-21 13:40:28 -0700 |
commit | 0bd379bd2d620e90f6ce35f874a5a7f7f3ec82c7 (patch) | |
tree | bedc5be7d1bdb8d32c1868caa496a8a1530d8d8a | |
parent | 8d73c8fcc75556c1df71dd39dd99783f8f86fc3e (diff) | |
parent | eb9236c5353785472ae132f27e1cfb9f1e4264a5 (diff) | |
download | chill-0bd379bd2d620e90f6ce35f874a5a7f7f3ec82c7.tar.gz chill-0bd379bd2d620e90f6ce35f874a5a7f7f3ec82c7.tar.bz2 chill-0bd379bd2d620e90f6ce35f874a5a7f7f3ec82c7.zip |
Merge pull request #3 from dhuth/master
Updating Makefile and test coverage.
-rw-r--r-- | .gitmodules | 0 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | test-chill/coverage.py | 53 | ||||
-rw-r--r-- | test-chill/testchill/__main__.py | 14 | ||||
-rw-r--r-- | test-chill/testchill/chill.py | 6 | ||||
-rw-r--r-- | test-chill/testchill/gcov.py | 61 | ||||
-rw-r--r-- | test-chill/testchill/util.py | 2 |
7 files changed, 107 insertions, 37 deletions
diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29..0000000 --- a/.gitmodules +++ /dev/null @@ -6,7 +6,7 @@ CC = g++ CFLAGS = -g -Wno-write-strings DEPENDENCE_CFLAGS = -M -OMEGAHOME = ./omega +OMEGAHOME=./omega ifdef TEST_COVERAGE CFLAGS := $(CFLAGS) -fprofile-arcs -ftest-coverage @@ -154,7 +154,11 @@ CHILL_OBJS = $(CHILL_SRCS:.cc=.o) CUDACHILL_OBJS = $(CUDACHILL_SRCS:.cc=.o) -all: cuda-chill chill +all: + $(MAKE) depend-chill + $(MAKE) chill + $(MAKE) depend-cuda-chill + $(MAKE) cuda-chill # can't these be combined to a superset of all source files? diff --git a/test-chill/coverage.py b/test-chill/coverage.py new file mode 100644 index 0000000..9941a9a --- /dev/null +++ b/test-chill/coverage.py @@ -0,0 +1,53 @@ +import argparse +import pickle + + +def loadcov(filename = 'coverage.pickle'): + with open(filename) as f: + return pickle.load(f) + + +def lines(covset, filename): + for line in covset.coverage_by_file[filename].lines: + yield line.lineno, line.count(), line.code + + +def nonexecuted(covset, filename): + return filter(lambda line: line[1] == 0, lines(covset, filename)) + + +def commented(covset, filename): + return filter(lambda line: line[1] is None, lines(covset, filename)) + + +def linerange(lineiter, minline, maxline): + return filter(lambda line: line[0] >= minline and line[0] <= maxline, lineiter) + + +def print_nonexec(argsns, cov): + if argsns.filename is None: + covlist = list((k, len(list(nonexecuted(cov, k)))) for k in cov.filenames) + covlist = sorted(covlist, key=lambda i: i[1]) + for i in reversed(range(len(covlist))): + print('{}: {}'.format(covlist[i][0].ljust(24), covlist[i][1])) + else: + minline, maxline = map(int,argsns.linerange) + for lineno, count, code in linerange(nonexecuted(cov, argsns.filename), minline, maxline): + print('{}: {}'.format(str(lineno).rjust(5), code)) + + +def make_argparser(): + arg_parser = argparse.ArgumentParser('coverage.py') + cmd_parser_set = arg_parser.add_subparsers() + nonexec_cmd = cmd_parser_set.add_parser('nonexec') + nonexec_cmd.add_argument('-f', dest='filename', default=None) + nonexec_cmd.add_argument('-r', dest='linerange', nargs=2, default=(0, 120000), metavar='STARTLINE ENDLINE') + nonexec_cmd.set_defaults(func=print_nonexec) + return arg_parser + + +if __name__ == '__main__': + argsns = make_argparser().parse_args() + cov = loadcov() + argsns.func(argsns, cov) + diff --git a/test-chill/testchill/__main__.py b/test-chill/testchill/__main__.py index ae9f29e..3e03e11 100644 --- a/test-chill/testchill/__main__.py +++ b/test-chill/testchill/__main__.py @@ -27,6 +27,8 @@ def make_local(argsns, arg_parser): 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 util.mkdir_p(argsns.wd) util.mkdir_p(argsns.bin_dir) @@ -35,7 +37,7 @@ def make_local(argsns, arg_parser): chill_version = argsns.chill_version for config in chill.ChillConfig.configs(argsns.omega_dir, argsns.chill_dir, argsns.bin_dir, version=chill_version): - build_testcase = chill.BuildChillTestCase(config, coverage_set=argsns.coverage_set) + 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') for tc in make_batch_testcaselist(argsns, arg_parser, batch_file): @@ -170,7 +172,7 @@ def add_local_args(arg_parser): Command line arguments for the local command @param arg_parser The local ArgumentParser object """ - arg_parser.add_argument('chill_dir', metavar='chill-home') + 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']) # - 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']) @@ -315,7 +317,7 @@ def add_global_args(arg_parser): 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('-C', '--chill-home', dest='chill_dir', default=os.getenv('CHILLHOME'), help='Chill home directory. (Defaults to CHILLHOME)', metavar='chill-home') - arg_parser.add_argument('-O', '--omega-home', dest='omega_dir', default=os.getenv('OMEGAHOME'), help='Omega home directory. (Defaults to OMEGAHOME)', metavar='omega-home') + arg_parser.add_argument('-O', '--omega-home', dest='omega_dir', default=os.joinpath(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') @util.callonce @@ -359,10 +361,10 @@ def args_to_tclist(args=sys.argv[1:], arg_parser=make_argparser(), argsns=None, @util.callonce def main(): - #coverage = gcov.GcovSet() - coverage=None + coverage = gcov.GcovSet() + #coverage=None results = list(test.run(args_to_tclist(coverage_set=coverage))) - test.pretty_print_results(results) + #test.pretty_print_results(results) #util.rmtemp() #coverage.pretty_print() diff --git a/test-chill/testchill/chill.py b/test-chill/testchill/chill.py index bfd9c81..b881ef4 100644 --- a/test-chill/testchill/chill.py +++ b/test-chill/testchill/chill.py @@ -54,11 +54,11 @@ class ChillConfig(object): def _buildfunc(self, cc, link=True): if not link: - compile_args = ['-c'] + compile_args = ['-c -Wuninitialized'] elif link and cc == 'nvcc': - compile_args = ['-L/usr/local/cuda/lib64/lib', '-lcuda', '-lcudart', '-lstdc++', '-lrt'] + compile_args = ['-L/usr/local/cuda/lib64/lib', '-lcuda', '-lcudart', '-lstdc++', '-lrt', '-Wuninitialized'] else: - compile_args = ['-lstdc++', '-lrt'] + compile_args = ['-lstdc++', '-lrt', '-Wuninitialized'] def build(src, dest, args=[], defines={}, wd=None): if wd is None: diff --git a/test-chill/testchill/gcov.py b/test-chill/testchill/gcov.py index caeb849..668c00e 100644 --- a/test-chill/testchill/gcov.py +++ b/test-chill/testchill/gcov.py @@ -186,28 +186,39 @@ class GcovSet(object): cov = self.coverage_by_program[prog_name] cov.merge(Gcov.parse(cov.srcdir, process_name)) - def unexecuted_lines(self): - covlist = sorted(self.coverage_by_program.values(), key=lambda c: c.srcdir) - for src, grp in itertools.groupby(covlist, lambda c: c.srcdir): - files = functools.reduce(lambda a, c: a | c, grp).files.values() - file_lines = iter((f.src_file_name, iter(l for l in f.lines if l.count() == 0)) for f in files) - yield src, file_lines - - def pretty_print(self, outfile=sys.stdout, width=60, stats=['unexecuted', 'unexecuted.bysrc']): - print('='*width, file=outfile) - print(' CODE COVERAGE', file=outfile) - - if 'unexecuted' in stats: - print('='*width, file=outfile) - print(' unexecuted lines', file=outfile) - if 'unexecuted.bysrc' in stats: - for src, file_lines in self.unexecuted_lines(): - print((src + ':'), file=outfile) - print('-'*width, file=outfile) - for src_file_name, lines in file_lines: - print(' ' + src_file_name + ':', file=outfile) - for line in lines: - print("{}:{}".format(str(line.lineno).rjust(5), line.code), file=outfile) - #print('='*width, file=outfile) - #print(prog, file=outfile) - #print('-'*width, file=outfile) + #def unexecuted_lines(self): + # covlist = sorted(self.coverage_by_program.values(), key=lambda c: c.srcdir) + # for src, grp in itertools.groupby(covlist, lambda c: c.srcdir): + # files = functools.reduce(lambda a, c: a | c, grp).files.values() + # file_lines = iter((f.src_file_name, iter(l for l in f.lines if l.count() == 0)) for f in files) + # yield src, file_lines + # + #def pretty_print(self, outfile=sys.stdout, width=60, stats=['unexecuted', 'unexecuted.bysrc']): + # print('='*width, file=outfile) + # print(' CODE COVERAGE', file=outfile) + # + # if 'unexecuted' in stats: + # print('='*width, file=outfile) + # print(' unexecuted lines', file=outfile) + # if 'unexecuted.bysrc' in stats: + # for src, file_lines in self.unexecuted_lines(): + # print((src + ':'), file=outfile) + # print('-'*width, file=outfile) + # for src_file_name, lines in file_lines: + # print(' ' + src_file_name + ':', file=outfile) + # for line in lines: + # print("{}:{}".format(str(line.lineno).rjust(5), line.code), file=outfile) + # #print('='*width, file=outfile) + # #print(prog, file=outfile) + # #print('-'*width, file=outfile) + + def _get_coverage_by_file(self): + return functools.reduce(lambda a,b: a|b, self.coverage_by_program.values()).files + + def _get_filenames(self): + return self.coverage_by_file.keys() + + coverage_by_file = property(_get_coverage_by_file) + filenames = property(_get_filenames) + + diff --git a/test-chill/testchill/util.py b/test-chill/testchill/util.py index cfb61dd..266a94d 100644 --- a/test-chill/testchill/util.py +++ b/test-chill/testchill/util.py @@ -138,7 +138,7 @@ def callonce(func): globals()[pred_name] = True return func(*args, **kwargs) else: - raise Exception + raise Exception('{} was invoked multiple times.'.format(func.__name___)) return wrapper def isdiff(strone, strtwo): |