aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py139
1 files changed, 67 insertions, 72 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 126071a0..eb96160e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -126,7 +126,7 @@ process(sys.argv[1])
# Build JavaScript code from source code
def build(self, src, dirname, filename, output_processor=None, main_file=None, additional_files=[], libraries=[], includes=[], build_ll_hook=None, extra_emscripten_args=[], post_build=None):
- Building.pick_llvm_opts(3, safe=Building.LLVM_OPTS != 2) # pick llvm opts here, so we include changes to Settings in the test case code
+ Building.pick_llvm_opts(3) # pick llvm opts here, so we include changes to Settings in the test case code
# Copy over necessary files for compiling the source
if main_file is None:
@@ -420,6 +420,17 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
#include <stdio.h>
int main()
{
+ long long a = 0x2b00505c10;
+ long long b = a >> 29;
+ long long c = a >> 32;
+ long long d = a >> 34;
+ printf("*%Ld,%Ld,%Ld,%Ld*\\n", a, b, c, d);
+ unsigned long long ua = 0x2b00505c10;
+ unsigned long long ub = ua >> 29;
+ unsigned long long uc = ua >> 32;
+ unsigned long long ud = ua >> 34;
+ printf("*%Ld,%Ld,%Ld,%Ld*\\n", ua, ub, uc, ud);
+
long long x = 0x0000def123450789ULL; // any bigger than this, and we
long long y = 0x00020ef123456089ULL; // start to run into the double precision limit!
printf("*%Ld,%Ld,%Ld,%Ld,%Ld*\\n", x, y, x | y, x & y, x ^ y, x >> 2, y << 2);
@@ -436,7 +447,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
return 0;
}
'''
- self.do_run(src, '*245127260211081,579378795077769,808077213656969,16428841631881,791648372025088*\n*13.00,6.00,3.00,*3*')
+ self.do_run(src, '*184688860176,344,43,10*\n*184688860176,344,43,10*\n*245127260211081,579378795077769,808077213656969,16428841631881,791648372025088*\n*13.00,6.00,3.00,*3*')
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: i64 mode 1 for q1')
@@ -505,12 +516,26 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
// global structs with i64s
printf("*%d,%Ld*\n*%d,%Ld*\n", iub[0].c, iub[0].d, iub[1].c, iub[1].d);
+ // Bitshifts
+ {
+ int64_t a = -1;
+ int64_t b = a >> 29;
+ int64_t c = a >> 32;
+ int64_t d = a >> 34;
+ printf("*%Ld,%Ld,%Ld,%Ld*\n", a, b, c, d);
+ uint64_t ua = -1;
+ int64_t ub = ua >> 29;
+ int64_t uc = ua >> 32;
+ int64_t ud = ua >> 34;
+ printf("*%Ld,%Ld,%Ld,%Ld*\n", ua, ub, uc, ud);
+ }
+
// Math mixtures with doubles
{
uint64_t a = 5;
double b = 6.8;
uint64_t c = a * b;
- printf("*prod:%llu*\n*%d,%d,%d*", c, (int)&a, (int)&b, (int)&c); // printing addresses prevents optimizations
+ printf("*prod:%llu*\n*%d,%d,%d*\n", c, (int)&a, (int)&b, (int)&c); // printing addresses prevents optimizations
}
// Basic (rounded, for now) math. Just check compilation.
@@ -523,11 +548,21 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
return 0;
}
'''
- self.do_run(src, '*1311918518731868200\n0,0,0,1,1\n1,0,1,0,1*\n*245127260211081*\n*245127260209443*\n' +
- '*18446744073709552000*\n*576460752303423500*\n' +
- 'm1: 127\n*123*\n*127*\n' +
- '*55,17179869201*\n*122,25769803837*\n' +
- '*prod:34*\n')
+ self.do_run(src, '*1311918518731868200\n' +
+ '0,0,0,1,1\n' +
+ '1,0,1,0,1*\n' +
+ '*245127260211081*\n' +
+ '*245127260209443*\n' +
+ '*18446744073709552000*\n' +
+ '*576460752303423500*\n' +
+ 'm1: 127\n' +
+ '*123*\n' +
+ '*127*\n' +
+ '*55,17179869201*\n' +
+ '*122,25769803837*\n' +
+ '*-1,-1,-1,-1*\n' +
+ '*-1,34359738367,4294967295,1073741823*\n' +
+ '*prod:34*')
Settings.CORRECT_SIGNS = 1
@@ -713,7 +748,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv):
self.do_run(src, '*255*\n*65535*\n*-1*\n*-1*\n*-1*')
def test_bitfields(self):
- Settings.SAFE_HEAP = 0 # bitfields do loads on invalid areas, by design
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # bitfields do loads on invalid areas, by design
src = '''
#include <stdio.h>
struct bitty {
@@ -3877,7 +3912,7 @@ def process(filename):
if self.emcc_args is None:
if Building.LLVM_OPTS: return self.skip('optimizing bitcode before emcc can confuse libcxx inclusion')
self.emcc_args = [] # libc++ auto-inclusion is only done if we use emcc
- Settings.SAFE_HEAP = 0 # Some spurious warnings from libc++ internals
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # Some spurious warnings from libc++ internals
src = '''
#include <iostream>
@@ -4002,7 +4037,7 @@ def process(filename):
''', 'hello world');
def test_static_variable(self):
- Settings.SAFE_HEAP = 0 # LLVM mixes i64 and i8 in the guard check
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # LLVM mixes i64 and i8 in the guard check
src = '''
#include <stdio.h>
@@ -4069,7 +4104,7 @@ def process(filename):
self.emcc_args += ['--closure', '1'] # Use closure here for some additional coverage
Building.COMPILER_TEST_OPTS = [] # remove -g, so we have one test without it by default
- Settings.SAFE_HEAP = 0 # Has some actual loads of unwritten-to places, in the C++ code...
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # Has some actual loads of unwritten-to places, in the C++ code...
# Overflows happen in hash loop
Settings.CORRECT_OVERFLOWS = 1
@@ -4100,7 +4135,7 @@ def process(filename):
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: make this work')
# Overflows in luaS_newlstr hash loop
- Settings.SAFE_HEAP = 0 # Has various warnings, with copied HEAP_HISTORY values (fixed if we copy 'null' as the type)
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # Has various warnings, with copied HEAP_HISTORY values (fixed if we copy 'null' as the type)
Settings.CORRECT_OVERFLOWS = 1
Settings.CHECK_OVERFLOWS = 0
Settings.CORRECT_SIGNS = 1 # Not sure why, but needed
@@ -4159,7 +4194,7 @@ def process(filename):
Settings.CORRECT_SIGNS_LINES = pgo_data['signs_lines']
Settings.CORRECT_OVERFLOWS = 0
Settings.CORRECT_ROUNDINGS = 0
- Settings.SAFE_HEAP = 0 # uses time.h to set random bytes, other stuff
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # uses time.h to set random bytes, other stuff
Settings.DISABLE_EXCEPTION_CATCHING = 1
Settings.FAST_MEMORY = 4*1024*1024
Settings.EXPORTED_FUNCTIONS = ['_main', '_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlite3_free', '_callback'];
@@ -4204,7 +4239,7 @@ def process(filename):
force_c=True)
def test_the_bullet(self): # Called thus so it runs late in the alphabetical cycle... it is long
- if Building.LLVM_OPTS: Settings.SAFE_HEAP = 0 # Optimizations make it so we do not have debug info on the line we need to ignore
+ if Building.LLVM_OPTS and self.emcc_args is None: Settings.SAFE_HEAP = 0 # Optimizations make it so we do not have debug info on the line we need to ignore
# Note: this is also a good test of per-file and per-line changes (since we have multiple files, and correct specific lines)
if Settings.SAFE_HEAP:
@@ -4226,7 +4261,7 @@ def process(filename):
def test_poppler(self):
if not self.emcc_args == []: return self.skip('very slow, we only do this in default')
- Settings.SAFE_HEAP = 0 # Has variable object
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # Has variable object
Settings.CORRECT_OVERFLOWS = 1
Settings.CORRECT_SIGNS = 1
@@ -4371,7 +4406,7 @@ def process(filename):
# Overflows in string_hash
Settings.CORRECT_OVERFLOWS = 1
Settings.CHECK_OVERFLOWS = 0
- Settings.SAFE_HEAP = 0 # Has bitfields which are false positives. Also the PyFloat_Init tries to detect endianness.
+ if self.emcc_args is None: Settings.SAFE_HEAP = 0 # Has bitfields which are false positives. Also the PyFloat_Init tries to detect endianness.
Settings.CORRECT_SIGNS = 1 # Not sure why, but needed
Settings.EXPORTED_FUNCTIONS = ['_main', '_PyRun_SimpleStringFlags'] # for the demo
@@ -4500,58 +4535,6 @@ def process(filename):
self.do_run(src, '''Profiling data:
Block 0: ''', post_build=post1)
- # Part 2: old JS version
-
- Settings.PROFILE = 1
- Settings.INVOKE_RUN = 0
-
- src = '''
- #include <stdio.h>
-
- int inner1(int x) {
- for (int i = 0; i < 20; i++)
- x += x/3;
- return x;
- }
- int inner2(int x) {
- for (int i = 0; i < 10; i++)
- x -= x/4;
- return x;
- }
- int inner3(int x) {
- for (int i = 0; i < 5; i++)
- x += x/2;
- x = inner1(x) - inner2(x);
- for (int i = 0; i < 5; i++)
- x -= x/2;
- return x;
- }
-
- int main()
- {
- int total = 0;
- for (int i = 0; i < 5000; i++)
- total += inner1(i) - 4*inner3(i);
- printf("*%d*\\n", total);
- return 0;
- }
- '''
-
- post = '''
-def process(filename):
- src = open(filename, 'a')
- src.write(\'\'\'
- startProfiling();
- run();
- stopProfiling();
- printProfiling();
- print('*ok*');
- \'\'\')
- src.close()
-'''
-
- self.do_run(src, ': __Z6inner1i (5000)\n', post_build=post)
-
### Integration tests
def test_scriptaclass(self):
@@ -4790,6 +4773,8 @@ Child2:9
''', post_build=post2)
def test_typeinfo(self):
+ if self.emcc_args is not None and self.emcc_args != []: return self.skip('full LLVM opts optimize out all the code that uses the type')
+
Settings.RUNTIME_TYPE_INFO = 1
if Settings.QUANTUM_SIZE != 4: return self.skip('We assume normal sizes in the output here')
@@ -5001,6 +4986,8 @@ def process(filename):
assert 'Assertion failed' in str(e), str(e)
def test_linespecific(self):
+ if self.emcc_args: self.emcc_args += ['--llvm-opts', '0'] # llvm full opts make the expected failures here not happen
+
Settings.CHECK_SIGNS = 0
Settings.CHECK_OVERFLOWS = 0
@@ -5178,8 +5165,9 @@ def process(filename):
def check(output):
# TODO: check the line #
- assert 'Overflow|src.cpp:6 : 60 hits, %20 failures' in output, 'no indication of Overflow corrections: ' + output
- assert 'UnSign|src.cpp:13 : 6 hits, %17 failures' in output, 'no indication of Sign corrections: ' + output
+ if self.emcc_args is None or self.emcc_args == []: # LLVM full opts optimize out some corrections
+ assert 'Overflow|src.cpp:6 : 60 hits, %20 failures' in output, 'no indication of Overflow corrections: ' + output
+ assert 'UnSign|src.cpp:13 : 6 hits, %17 failures' in output, 'no indication of Sign corrections: ' + output
return output
self.do_run(src, '*186854335,63*\n', output_nicerizer=check)
@@ -5274,7 +5262,7 @@ class %s(T):
else:
Settings.I64_MODE = 0
- Building.pick_llvm_opts(3, safe=Building.LLVM_OPTS != 2)
+ Building.pick_llvm_opts(3)
TT = %s
''' % (fullname, fullname, fullname, compiler, str(emcc_args), llvm_opts, embetter, quantum_size, typed_arrays, fullname))
@@ -5594,6 +5582,13 @@ f.close()
output = Popen([NODE_JS, JS_OPTIMIZER, input] + passes, stdin=PIPE, stdout=PIPE).communicate()[0]
self.assertIdentical(expected, output.replace('\n\n', '\n'))
+ def test_reminder(self):
+ assert False, 'Optimize makeGet/SetValue to do 16-bit reads/writes when possible, not just 8'
+ assert False, 'Make sure unaligned loads are not done unnecessarily (add some comments and inspect the source)'
+ assert False, 'Why is libcxx/ created in e.g. test_python, with EMCC_DEBUG, when it does not need libcxx?'
+ assert False, 'Make sure Poppler builds with llvm full opts'
+ assert False, 'Check if we should use -Ox instead of -std-compile-opts'
+
elif 'benchmark' in str(sys.argv):
# Benchmarks. Run them with argument |benchmark|. To run a specific test, do
# |benchmark.test_X|.