aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnthony Pesch <inolen@gmail.com>2013-08-09 00:36:35 -0700
committerAnthony Pesch <inolen@gmail.com>2013-08-09 11:11:12 -0700
commita9bb2f0261fd88048d7e499df33808a23884cb02 (patch)
tree9fd6f9aebf7ca97f8220d914b2eecc20501f56f9 /tests
parentbd1d02e02cf0f39c8d7f672520910714d1c2d4e5 (diff)
- always throw an exception in exit
- remove default exit status prints - added EXITSTATUS global to enable exit callbacks to determine the status
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/runner.py b/tests/runner.py
index e77efffb..8122bc81 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -3185,6 +3185,25 @@ Exiting setjmp function, level: 0, prev_jmp: -1
'''
self.do_run(src, 'caught std::exception')
+ def test_async_exit(self):
+ open('main.c', 'w').write(r'''
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include "emscripten.h"
+
+ void main_loop() {
+ exit(EXIT_SUCCESS);
+ }
+
+ int main() {
+ emscripten_set_main_loop(main_loop, 60, 0);
+ return 0;
+ }
+ ''')
+
+ Popen([PYTHON, EMCC, 'main.c']).communicate()
+ self.assertNotContained('Reached an unreachable!', run_js(self.in_dir('a.out.js'), stderr=STDOUT))
+
def test_exit_stack(self):
if self.emcc_args is None: return self.skip('requires emcc')
if Settings.ASM_JS: return self.skip('uses report_stack without exporting')
@@ -3222,6 +3241,7 @@ Exiting setjmp function, level: 0, prev_jmp: -1
}
var Module = {
postRun: function() {
+ Module.print('Exit Status: ' + EXITSTATUS);
Module.print('postRun');
assert(initialStack == STACKTOP, [initialStack, STACKTOP]);
Module.print('ok.');
@@ -10219,13 +10239,19 @@ def process(filename):
printf("cleanup\n");
}
- int main()
- {
+ int main() {
atexit(cleanup); // this atexit should still be called
printf("hello, world!\n");
exit(118); // Unusual exit status to make sure it's working!
}
'''
+ open('post.js', 'w').write('''
+ Module.addOnExit(function () {
+ Module.print('Exit Status: ' + EXITSTATUS);
+ });
+ Module.callMain();
+ ''')
+ self.emcc_args += ['-s', 'INVOKE_RUN=0', '--post-js', 'post.js']
self.do_run(src, 'hello, world!\ncleanup\nExit Status: 118')
def test_gc(self):