diff options
Diffstat (limited to 'tests/runner.py')
-rw-r--r-- | tests/runner.py | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/tests/runner.py b/tests/runner.py index 82b46fac..2a050deb 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -62,11 +62,6 @@ class RunnerCore(unittest.TestCase): def get_stdout_path(self): return os.path.join(self.get_dir(), 'stdout') - def pick_llvm_opts(self, optimization_level, safe=True): - global LLVM_OPT_OPTS - - LLVM_OPT_OPTS = pick_llvm_opts(optimization_level, safe) - def prep_ll_run(self, filename, ll_file, force_recompile=False, build_ll_hook=None): if ll_file.endswith(('.bc', '.o')): if ll_file != filename + '.o': @@ -159,11 +154,11 @@ class RunnerCore(unittest.TestCase): def run_llvm_interpreter(self, args): return Popen([EXEC_LLVM] + args, stdout=PIPE, stderr=STDOUT).communicate()[0] - def build_native(self, filename, compiler='g++'): - Popen([compiler, '-O3', filename, '-o', filename+'.native'], stdout=PIPE, stderr=STDOUT).communicate()[0] + def build_native(self, filename): + Popen([CLANG, '-O2', filename, '-o', filename+'.native'], stdout=PIPE).communicate()[0] def run_native(self, filename, args): - Popen([filename+'.native'] + args, stdout=PIPE, stderr=STDOUT).communicate()[0] + Popen([filename+'.native'] + args, stdout=PIPE).communicate()[0] def assertIdentical(self, x, y): if x != y: @@ -401,6 +396,7 @@ if 'benchmark' not in str(sys.argv): # Stuff that only works in i64_mode = 1 Settings.I64_MODE = 1 + src = r''' #include <time.h> #include <stdio.h> @@ -463,6 +459,31 @@ if 'benchmark' not in str(sys.argv): '*18446744073709552000*\n*576460752303423500*\n' + 'm1: 127\n*123*\n*127*\n') + Settings.CORRECT_SIGNS = 1 + + src = r''' + #include <stdio.h> + #include <stdint.h> + + int main() + { + // i32 vs i64 + int32_t small = -1; + int64_t large = -1; + printf("*%d*\n", small == large); + small++; + printf("*%d*\n", small == large); + uint32_t usmall = -1; + uint64_t ularge = -1; + printf("*%d*\n", usmall == ularge); + usmall++; + printf("*%d*\n", usmall == ularge); + return 0; + } + ''' + + self.do_run(src, '*1*\n*0*\n*1*\n*0*') + def test_unaligned(self): if Settings.QUANTUM_SIZE == 1: return self.skip('No meaning to unaligned addresses in q1') if Settings.USE_TYPED_ARRAYS != 2: return self.skip('No meaning to unaligned addresses without t2') @@ -4401,8 +4422,7 @@ class %s(T): if Settings.QUANTUM_SIZE == 1 or Settings.USE_TYPED_ARRAYS == 2: Settings.RELOOP = 0 # XXX Would be better to use this, but it isn't really what we test in these cases, and is very slow - if Building.LLVM_OPTS: - self.pick_llvm_opts(3, safe=Building.LLVM_OPTS != 2) + Building.pick_llvm_opts(3, safe=Building.LLVM_OPTS != 2) Building.COMPILER_TEST_OPTS = ['-g'] @@ -4500,8 +4520,7 @@ else: Settings.FAST_MEMORY = 10*1024*1024 Building.LLVM_OPTS = 1 if Settings.USE_TYPED_ARRAYS != 2 else 2 - if Building.LLVM_OPTS: - self.pick_llvm_opts(2, safe=Building.LLVM_OPTS != 2) + Building.pick_llvm_opts(2, safe=Building.LLVM_OPTS != 2) super(benchmark, self).setUp() @@ -4525,8 +4544,8 @@ else: final /= len(times) print - print ' JavaScript : mean: %.3f (+-%.3f) seconds (max: %.3f, min: %.3f, noise/signal: %.3f) (%d runs)' % (mean, std, max(times), min(times), std/mean, TEST_REPS) - print ' Native (gcc): mean: %.3f (+-%.3f) seconds (max: %.3f, min: %.3f, noise/signal: %.3f) JS is %.2f X slower' % (mean_native, std_native, max(native_times), min(native_times), std_native/mean_native, final) + print ' JavaScript: mean: %.3f (+-%.3f) seconds (max: %.3f, min: %.3f, noise/signal: %.3f) (%d runs)' % (mean, std, max(times), min(times), std/mean, TEST_REPS) + print ' Native : mean: %.3f (+-%.3f) seconds (max: %.3f, min: %.3f, noise/signal: %.3f) JS is %.2f X slower' % (mean_native, std_native, max(native_times), min(native_times), std_native/mean_native, final) def do_benchmark(self, src, args=[], expected_output='FAIL', main_file=None): dirname = self.get_dir() |