aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/runner.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 23614cf0..866424d8 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -164,7 +164,7 @@ class RunnerCore(unittest.TestCase):
def do_emscripten(self, filename, output_processor=None):
# Run Emscripten
exported_settings = {}
- for setting in ['QUANTUM_SIZE', 'RELOOP', 'OPTIMIZE', 'GUARD_MEMORY', 'USE_TYPED_ARRAYS', 'SAFE_HEAP', 'CHECK_OVERFLOWS', 'CORRECT_OVERFLOWS']:
+ for setting in ['QUANTUM_SIZE', 'RELOOP', 'OPTIMIZE', 'GUARD_MEMORY', 'USE_TYPED_ARRAYS', 'SAFE_HEAP', 'CHECK_OVERFLOWS', 'CORRECT_OVERFLOWS', 'GUARD_SIGNS']:
exported_settings[setting] = eval(setting)
out = open(filename + '.o.js', 'w') if not OUTPUT_TO_SCREEN else None
timeout_run(Popen([EMSCRIPTEN, filename + '.o.ll', COMPILER_ENGINE[0], str(exported_settings).replace("'", '"')], stdout=out, stderr=STDOUT), TIMEOUT, 'Compiling')
@@ -302,20 +302,14 @@ if 'benchmark' not in sys.argv:
printf("*\\n");
printf("*%.1d,%.2d*\\n", 56, 9);
- // zext issue - see mathop in jsifier
- unsigned char x8 = -10;
- unsigned long hold = 0;
- hold += x8;
- int y32 = hold+50;
- printf("*%u,%u*\\n", hold, y32);
-
printf("*%ld*%p\\n", (long)21, &hash); // The %p should not enter an infinite loop!
return 0;
}
'''
- self.do_test(src, '*5,23,10,19,121,1,37,1,0*\n0:-1,1:134217727,2:4194303,3:131071,4:4095,5:127,6:3,7:0,8:0*\n*56,09*\n*246,296*\n*21*')
+ self.do_test(src, '*5,23,10,19,121,1,37,1,0*\n0:-1,1:134217727,2:4194303,3:131071,4:4095,5:127,6:3,7:0,8:0*\n*56,09*\n*21*')
def test_sintvars(self):
+ global GUARD_SIGNS; GUARD_SIGNS = 1 # Relevant to this test
src = '''
#include <stdio.h>
struct S {
@@ -346,6 +340,7 @@ if 'benchmark' not in sys.argv:
self.do_test(src, output, force_c=True)
def test_unsigned(self):
+ global GUARD_SIGNS; GUARD_SIGNS = 1 # We test for exactly this sort of thing here
src = '''
#include <stdio.h>
const signed char cvals[2] = { -1, -2 }; // compiler can store this is a string, so -1 becomes \FF, and needs re-signing
@@ -359,10 +354,18 @@ if 'benchmark' not in sys.argv:
printf("*%d,%d,%d,%d*\\n", cvals[0], cvals[0] < 0, y, y < 0);
y = cvals[1];
printf("*%d,%d,%d,%d*\\n", cvals[1], cvals[1] < 0, y, y < 0);
+
+ // zext issue - see mathop in jsifier
+ unsigned char x8 = -10;
+ unsigned long hold = 0;
+ hold += x8;
+ int y32 = hold+50;
+ printf("*%u,%u*\\n", hold, y32);
+
return 0;
}
'''
- self.do_test(src, '*4294967295,0,4294967219*\n*-1,1,-1,1*\n*-2,1,-2,1*')
+ self.do_test(src, '*4294967295,0,4294967219*\n*-1,1,-1,1*\n*-2,1,-2,1*\n*246,296*')
def test_bitfields(self):
global SAFE_HEAP; SAFE_HEAP = 0 # bitfields do loads on invalid areas, by design
@@ -1425,6 +1428,7 @@ if 'benchmark' not in sys.argv:
self.do_test(src, '*16,0,4,8,8,12|20,0,4,4,8,12,12,16|24,0,20,0,4,4,8,12,12,16*\n*0,0,0,1,2,64,68,69,72*\n*2*')
def test_files(self):
+ global GUARD_SIGNS; GUARD_SIGNS = 1 # Just so our output is what we expect. Can flip them both.
def post(filename):
src = open(filename, 'r').read().replace(
'// {{PRE_RUN_ADDITIONS}}',
@@ -1450,6 +1454,7 @@ if 'benchmark' not in sys.argv:
def test_dlmalloc(self):
# XXX Warning: Running this in SpiderMonkey can lead to an extreme amount of memory being
# used, see Mozilla bug 593659.
+ global GUARD_SIGNS; GUARD_SIGNS = 1 # Not sure why, but needed
src = open(path_from_root('tests', 'dlmalloc.c'), 'r').read()
self.do_test(src, '*1,0*')
@@ -1512,6 +1517,7 @@ if 'benchmark' not in sys.argv:
# Overflows in luaS_newlstr hash loop
global SAFE_HEAP; SAFE_HEAP = 0 # Has various warnings, with copied HEAP_HISTORY values (fixed if we copy 'null' as the type)
global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 1
+ global GUARD_SIGNS; GUARD_SIGNS = 1 # Not sure why, but needed
self.do_ll_test(path_from_root('tests', 'lua', 'lua.ll'),
'hello lua world!\n17.00000000000\n1.00000000000\n2.00000000000\n3.00000000000\n4.00000000000\n7.00000000000',
@@ -1545,6 +1551,7 @@ if 'benchmark' not in sys.argv:
def test_freetype(self):
if COMPILER != LLVM_GCC: return # TODO: Build in both clang and llvm-gcc. emmaken currently only does llvm-gcc
if LLVM_OPTS: global RELOOP; RELOOP = 0 # Too slow; we do care about typed arrays and OPTIMIZE though
+ global GUARD_SIGNS; GUARD_SIGNS = 1 # Not sure why, but needed
def post(filename):
# Embed the font into the document
@@ -1567,6 +1574,7 @@ if 'benchmark' not in sys.argv:
def test_zlib(self):
if COMPILER != LLVM_GCC: return # TODO: Build in both clang and llvm-gcc. emmaken currently only does llvm-gcc
global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 1 # Overflows in inflate_table() getelementptr (in phi)
+ global GUARD_SIGNS; GUARD_SIGNS = 1
self.do_test(open(path_from_root('tests', 'zlib', 'example.c'), 'r').read(),
open(path_from_root('tests', 'zlib', 'ref.txt'), 'r').read(),
@@ -1595,9 +1603,9 @@ if 'benchmark' not in sys.argv:
def test_python(self):
# Overflows in string_hash
global CORRECT_OVERFLOWS; CORRECT_OVERFLOWS = 1
-
global RELOOP; RELOOP = 0 # Too slow; we do care about typed arrays and OPTIMIZE though
global SAFE_HEAP; SAFE_HEAP = 0 # Has bitfields which are false positives. Also the PyFloat_Init tries to detect endianness.
+ global GUARD_SIGNS; GUARD_SIGNS = 1 # Not sure why, but needed
self.do_ll_test(path_from_root('tests', 'python', 'python.ll'),
'hello python world!\n\n[0, 2, 4, 6]\n\n5\n\n22\n\n5.470',
args=['-S', '-c' '''print "hello python world!"; print [x*2 for x in range(4)]; t=2; print 10-3-t; print (lambda x: x*2)(11); print '%f' % 5.47'''],
@@ -1700,7 +1708,7 @@ if 'benchmark' not in sys.argv:
exec('''
class %s(T):
def setUp(self):
- global COMPILER, QUANTUM_SIZE, RELOOP, OPTIMIZE, GUARD_MEMORY, USE_TYPED_ARRAYS, LLVM_OPTS, SAFE_HEAP, CHECK_OVERFLOWS, CORRECT_OVERFLOWS
+ global COMPILER, QUANTUM_SIZE, RELOOP, OPTIMIZE, GUARD_MEMORY, USE_TYPED_ARRAYS, LLVM_OPTS, SAFE_HEAP, CHECK_OVERFLOWS, CORRECT_OVERFLOWS, GUARD_SIGNS
COMPILER = '%s'
QUANTUM_SIZE = %d
llvm_opts = %d
@@ -1711,6 +1719,7 @@ class %s(T):
LLVM_OPTS = llvm_opts
CHECK_OVERFLOWS = 1-(embetter or llvm_opts)
CORRECT_OVERFLOWS = 1-(embetter and llvm_opts)
+ GUARD_SIGNS = 0
if LLVM_OPTS:
self.pick_llvm_opts(3, True)
shutil.rmtree(self.get_dir())
@@ -1743,6 +1752,7 @@ else:
RELOOP = OPTIMIZE = 1
USE_TYPED_ARRAYS = 0
GUARD_MEMORY = SAFE_HEAP = CHECK_OVERFLOWS = CORRECT_OVERFLOWS = 0
+ GUARD_SIGNS = 0
LLVM_OPTS = 1
USE_CLOSURE_COMPILER = 1