aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/funcptr.ll2
-rw-r--r--tests/cases/gepoverflow.txt2
-rwxr-xr-xtests/runner.py57
3 files changed, 59 insertions, 2 deletions
diff --git a/tests/cases/funcptr.ll b/tests/cases/funcptr.ll
index 07e2bf91..0aa03fcf 100644
--- a/tests/cases/funcptr.ll
+++ b/tests/cases/funcptr.ll
@@ -9,7 +9,7 @@ define i32 @main() {
entry:
%retval = alloca i32, align 4 ; [#uses=1 type=i32*]
store i32 0, i32* %retval
- %access_virt_barray = bitcast i32 0 to [64 x i16]* (i32*, i32)**
+ %access_virt_barray = bitcast i32 100 to [64 x i16]* (i32*, i32)**
store [64 x i16]* (i32*, i32)* @access_virt_barray, [64 x i16]* (i32*, i32)** %access_virt_barray, align 4
%wakaptr = bitcast [64 x i16]* (i32*, i32)** %access_virt_barray to i32*
%waka = load i32* %wakaptr
diff --git a/tests/cases/gepoverflow.txt b/tests/cases/gepoverflow.txt
index 164e5c0c..90772c33 100644
--- a/tests/cases/gepoverflow.txt
+++ b/tests/cases/gepoverflow.txt
@@ -1,2 +1,2 @@
-*5246494,5247064*
+*5246502,5247072*
*-514,56*
diff --git a/tests/runner.py b/tests/runner.py
index b81cee9a..e4aba0c9 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2108,6 +2108,39 @@ c5,de,15,8a
'''
self.do_run(src, '*11,74,32,1012*\n*11*\n*22*')
+ def test_segfault(self):
+ if self.emcc_args is None: return self.skip('SAFE_HEAP without ta2 means we check types too, which hide segfaults')
+
+ Settings.SAFE_HEAP = 1
+
+ for addr in ['0', '7', 'new D2()']:
+ print addr
+ src = r'''
+ #include <stdio.h>
+
+ struct Classey {
+ virtual void doIt() = 0;
+ };
+
+ struct D1 : Classey {
+ virtual void doIt() { printf("fleefl\n"); }
+ };
+
+ struct D2 : Classey {
+ virtual void doIt() { printf("marfoosh\n"); }
+ };
+
+ int main(int argc, char **argv)
+ {
+ Classey *p = argc == 100 ? new D1() : (Classey*)%s;
+
+ p->doIt();
+
+ return 0;
+ }
+ ''' % addr
+ self.do_run(src, 'segmentation fault' if addr.isdigit() else 'marfoosh')
+
def test_dynamic_cast(self):
if self.emcc_args is None: return self.skip('need libcxxabi')
@@ -2435,6 +2468,30 @@ c5,de,15,8a
'''
self.do_run(src, '*70,97,15,3,3029,90*')
+ def test_bigarray(self):
+ if self.emcc_args is None: return self.skip('need ta2 to compress type data on zeroinitializers')
+
+ # avoid "array initializer too large" errors
+ src = r'''
+ #include <stdio.h>
+ #include <assert.h>
+
+ #define SIZE (1024*100)
+ struct Struct {
+ char x;
+ int y;
+ };
+ Struct buffy[SIZE];
+
+ int main() {
+ for (int i = 0; i < SIZE; i++) { assert(buffy[i].x == 0 && buffy[i].y == 0); } // we were zeroinitialized
+ for (int i = 0; i < SIZE; i++) { buffy[i].x = i*i; buffy[i].y = i*i*i; } // we can save data
+ printf("*%d*\n", buffy[SIZE/3].x);
+ return 0;
+ }
+ '''
+ self.do_run(src, '*57*')
+
def test_mod_globalstruct(self):
src = '''
#include <stdio.h>