diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/browser_gc.cpp | 6 | ||||
-rw-r--r-- | tests/emscripten_api_browser.cpp | 24 | ||||
-rwxr-xr-x | tests/runner.py | 23 | ||||
-rw-r--r-- | tests/sdl_mouse.c | 6 |
4 files changed, 37 insertions, 22 deletions
diff --git a/tests/browser_gc.cpp b/tests/browser_gc.cpp index 75dea10a..4d6cc712 100644 --- a/tests/browser_gc.cpp +++ b/tests/browser_gc.cpp @@ -16,7 +16,7 @@ void finalizer(void *ptr, void *arg) { int stage = 0; float start = 0; -void waiter() { +void waiter(void*) { if (stage == 0) { // wait for a while, see no GCing assert(global); if (emscripten_get_now() - start > 2100) { @@ -58,7 +58,7 @@ void waiter() { } } - emscripten_async_call(waiter, 100); + emscripten_async_call(waiter, NULL, 100); } int main() { @@ -89,7 +89,7 @@ int main() { void **local2Data = (void**)local2; local2Data[0] = local4; // actually ignored, because local2 is atomic, so 4 is freeable - emscripten_async_call(waiter, 100); + emscripten_async_call(waiter, NULL, 100); return 0; } diff --git a/tests/emscripten_api_browser.cpp b/tests/emscripten_api_browser.cpp index 305265e5..c209550b 100644 --- a/tests/emscripten_api_browser.cpp +++ b/tests/emscripten_api_browser.cpp @@ -11,19 +11,22 @@ extern "C" { bool pre1ed = false; bool pre2ed = false; -void pre1() { +void pre1(void *arg) { assert(!pre1ed); assert(!pre2ed); + assert((int)arg == 123); pre1ed = true; } -void pre2() { +void pre2(void *arg) { assert(pre1ed); assert(!pre2ed); + assert((int)arg == 98); pre2ed = true; } bool fived = false; -void five() { +void five(void *arg) { + assert((int)arg == 55); fived = true; emscripten_resume_main_loop(); } @@ -33,11 +36,11 @@ void mainey() { printf("mainey: %d\n", counter++); if (counter == 20) { emscripten_pause_main_loop(); - emscripten_async_call(five, 1000); + emscripten_async_call(five, (void*)55, 1000); } else if (counter == 22) { // very soon after 20, so without pausing we fail assert(fived); - emscripten_push_main_loop_blocker(pre1); - emscripten_push_main_loop_blocker(pre2); + emscripten_push_main_loop_blocker(pre1, (void*)123); + emscripten_push_main_loop_blocker(pre2, (void*)98); } else if (counter == 23) { assert(pre1ed); assert(pre2ed); @@ -47,7 +50,8 @@ void mainey() { } } -void four() { +void four(void *arg) { + assert((int)arg == 43); printf("four!\n"); emscripten_set_main_loop(mainey, 0); } @@ -56,10 +60,10 @@ void __attribute__((used)) third() { int now = SDL_GetTicks(); printf("thard! %d\n", now); assert(fabs(now - last - 1000) < 500); - emscripten_async_call(four, -1); // triggers requestAnimationFrame + emscripten_async_call(four, (void*)43, -1); // triggers requestAnimationFrame } -void second() { +void second(void *arg) { int now = SDL_GetTicks(); printf("sacond! %d\n", now); assert(fabs(now - last - 500) < 250); @@ -81,7 +85,7 @@ int main() { atexit(never); // should never be called - it is wrong to exit the runtime orderly if we have async calls! - emscripten_async_call(second, 500); + emscripten_async_call(second, (void*)0, 500); return 1; } diff --git a/tests/runner.py b/tests/runner.py index e4aba0c9..792b8939 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7829,11 +7829,13 @@ elif 'browser' in str(sys.argv): var actual = actualCtx.getImageData(0, 0, actualImage.width, actualImage.height).data; var total = 0; - for (var x = 0; x < img.width; x++) { - for (var y = 0; y < img.height; y++) { - total += Math.abs(expected[y*img.width*4 + x*4 + 0] - actual[y*img.width*4 + x*4 + 0]); - total += Math.abs(expected[y*img.width*4 + x*4 + 1] - actual[y*img.width*4 + x*4 + 1]); - total += Math.abs(expected[y*img.width*4 + x*4 + 2] - actual[y*img.width*4 + x*4 + 2]); + var width = img.width; + var height = img.height; + for (var x = 0; x < width; x++) { + for (var y = 0; y < height; y++) { + total += Math.abs(expected[y*width*4 + x*4 + 0] - actual[y*width*4 + x*4 + 0]); + total += Math.abs(expected[y*width*4 + x*4 + 1] - actual[y*width*4 + x*4 + 1]); + total += Math.abs(expected[y*width*4 + x*4 + 2] - actual[y*width*4 + x*4 + 2]); } } var wrong = Math.floor(total / (img.width*img.height*3)); // floor, to allow some margin of error for antialiasing @@ -8805,7 +8807,7 @@ elif 'sanity' in str(sys.argv): assert (open(CONFIG_FILE).read() == open(path_from_root('settings.py')).read()), 'Settings should be copied from settings.py' # Second run, with bad EM_CONFIG - for settings in ['blah', 'LLVM_ROOT="blah"; JS_ENGINES=[]; COMPILER_ENGINE=NODE_JS=SPIDERMONKEY_ENGINE=[]']: + for settings in ['blah', 'LLVM_ROOT="blarg"; JS_ENGINES=[]; COMPILER_ENGINE=NODE_JS=SPIDERMONKEY_ENGINE=[]']: f = open(CONFIG_FILE, 'w') f.write(settings) f.close() @@ -8901,6 +8903,15 @@ elif 'sanity' in str(sys.argv): self.assertNotContained(SANITY_MESSAGE, output) self.assertNotContained(SANITY_FAIL_MESSAGE, output) + # but with EMCC_DEBUG=1 we should check + assert not os.environ.get('EMCC_DEBUG'), 'do not run sanity checks in debug mode!' + os.environ['EMCC_DEBUG'] = '1' + output = self.check_working(EMCC) + self.assertContained(SANITY_MESSAGE, output) + del os.environ['EMCC_DEBUG'] + output = self.check_working(EMCC) + self.assertNotContained(SANITY_MESSAGE, output) + # But the test runner should output = self.check_working(commands[1]) self.assertContained(SANITY_MESSAGE, output) diff --git a/tests/sdl_mouse.c b/tests/sdl_mouse.c index 0c10198a..f0282ab1 100644 --- a/tests/sdl_mouse.c +++ b/tests/sdl_mouse.c @@ -43,7 +43,7 @@ void one() { } } -void main_2(); +void main_2(void* arg); int main() { SDL_Init(SDL_INIT_VIDEO); @@ -52,12 +52,12 @@ int main() { SDL_Rect rect = { 0, 0, 600, 450 }; SDL_FillRect(screen, &rect, 0x2244ffff); - emscripten_async_call(main_2, 3000); // avoid startup delays and intermittent errors + emscripten_async_call(main_2, NULL, 3000); // avoid startup delays and intermittent errors return 0; } -void main_2() { +void main_2(void* arg) { emscripten_run_script("window.simulateMouseEvent(10, 20, -1)"); // move from 0,0 to 10,20 emscripten_run_script("window.simulateMouseEvent(10, 20, 0)"); // click emscripten_run_script("window.simulateMouseEvent(10, 20, 0)"); // click some more, but this one should be ignored through PeepEvent |