diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/tests/runner.py b/tests/runner.py index cc3811a2..9c29dc96 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -2898,6 +2898,45 @@ def process(filename): extra_emscripten_args=['-H', 'libc/time.h']) #extra_emscripten_args=['-H', 'libc/fcntl.h,libc/sys/unistd.h,poll.h,libc/math.h,libc/langinfo.h,libc/time.h']) + def test_intentional_fault(self): + # Some programs intentionally segfault themselves, we should compile that into a throw + src = r''' + int main () { + *(volatile char *)0 = 0; + return 0; + } + ''' + self.do_run(src, 'fault on write to 0') + + def test_trickystring(self): + src = r''' + #include <stdio.h> + + typedef struct + { + int (*f)(void *); + void *d; + char s[16]; + } LMEXFunctionStruct; + + int f(void *user) + { + return 0; + } + + static LMEXFunctionStruct const a[] = + { + {f, (void *)(int)'a', "aa"} + }; + + int main() + { + printf("ok\n"); + return a[0].f(a[0].d); + } + ''' + self.do_run(src, 'ok\n') + def test_statics(self): # static initializers save i16 but load i8 for some reason if Settings.SAFE_HEAP: @@ -5496,6 +5535,7 @@ def process(filename): int value; public: Parent(int val); + Parent(Parent *p, Parent *q); // overload constructor int getVal() { return value; }; // inline should work just fine here, unlike Way 1 before void mulVal(int mul); }; @@ -5533,6 +5573,7 @@ def process(filename): #include "header.h" Parent::Parent(int val) : value(val) { printf("Parent:%d\\n", val); } + Parent::Parent(Parent *p, Parent *q) : value(p->value + q->value) { printf("Parent:%d\\n", value); } void Parent::mulVal(int mul) { value *= mul; } #include "bindingtest.cpp" @@ -8114,9 +8155,10 @@ elif 'sanity' in str(sys.argv): assert os.path.exists(EMCC_CACHE) assert os.path.exists(os.path.join(EMCC_CACHE, libname + '.bc')) if libname == 'libcxx': - assert os.stat(os.path.join(EMCC_CACHE, libname + '.bc')).st_size > 3500000, 'libc++ is big' - assert os.stat(basebc_name).st_size > 3500000, 'libc++ is indeed big' - assert os.stat(dcebc_name).st_size < 2000000, 'Dead code elimination must remove most of libc++' + print os.stat(os.path.join(EMCC_CACHE, libname + '.bc')).st_size, os.stat(basebc_name).st_size, os.stat(dcebc_name).st_size + assert os.stat(os.path.join(EMCC_CACHE, libname + '.bc')).st_size > 2000000, 'libc++ is big' + assert os.stat(basebc_name).st_size > 2000000, 'libc++ is indeed big' + assert os.stat(dcebc_name).st_size < 1500000, 'Dead code elimination must remove most of libc++' finally: if emcc_debug: os.environ['EMCC_DEBUG'] = emcc_debug |