aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-27 20:07:07 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-27 20:07:07 -0700
commited88bc7051a61e05c6e85e792d56513826722d2e (patch)
treed40113a39ebe21626cb193e1a5652f621052e942 /tests/runner.py
parentb1989519a9e66a8c2f5b2174a2eadb53bb8f9f56 (diff)
memory growth must be manually enabled with ALLOW_MEMORY_GROWTH, in which case the eliminator runs in safe mode
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 1f60e7fb..5780b910 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2742,6 +2742,8 @@ def process(filename):
self.do_run(src, 'Inline JS is very cool')
def test_memorygrowth(self):
+ if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays')
+
# With typed arrays in particular, it is dangerous to use more memory than TOTAL_MEMORY,
# since we then need to enlarge the heap(s).
src = r'''
@@ -2779,7 +2781,22 @@ def process(filename):
return 0;
}
'''
+
+ # Fail without memory growth
+ self.do_run(src, 'Cannot enlarge memory arrays. Adjust TOTAL_MEMORY or compile with ALLOW_MEMORY_GROWTH')
+ fail = open('src.cpp.o.js').read()
+
+ # Win with it
+ Settings.ALLOW_MEMORY_GROWTH = 1
self.do_run(src, '*pre: hello,4.955*\n*hello,4.955*\n*hello,4.955*')
+ win = open('src.cpp.o.js').read()
+
+ if self.emcc_args and '-O2' in self.emcc_args:
+ # Make sure ALLOW_MEMORY_GROWTH generates different code (should be less optimized)
+ code_start = 'var TOTAL_MEMORY = '
+ fail = fail[fail.find(code_start):]
+ win = win[win.find(code_start):]
+ assert len(fail) < len(win), 'failing code - without memory growth on - is more optimized, and smaller'
def test_ssr(self): # struct self-ref
src = '''