Skip to content

Commit 6fd7bbe

Browse files
committed
tests: create browser.test_sdl2_threads
1 parent 44aa6ad commit 6fd7bbe

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

tests/sdl2_threads.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <SDL.h>
2+
#include <assert.h>
3+
4+
#ifdef __EMSCRIPTEN__
5+
#include <emscripten.h>
6+
#endif
7+
8+
static int test_thread(void *data)
9+
{
10+
return 2 + 2;
11+
}
12+
13+
int main()
14+
{
15+
SDL_Thread *thread;
16+
int result;
17+
18+
thread = SDL_CreateThread(test_thread, "Test Thread", (void *)NULL);
19+
20+
if (NULL == thread) {
21+
return 1;
22+
} else {
23+
SDL_WaitThread(thread, &result);
24+
}
25+
26+
#ifdef REPORT_RESULT
27+
REPORT_RESULT(result);
28+
#endif
29+
return 0;
30+
}

tests/test_browser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,6 +2984,10 @@ def test_sdl2_mouse_offsets(self):
29842984
run_process([PYTHON, EMCC, 'sdl2_mouse.c', '-DTEST_SDL_MOUSE_OFFSETS=1', '-O2', '--minify', '0', '-o', 'sdl2_mouse.js', '--pre-js', 'pre.js', '-s', 'USE_SDL=2'])
29852985
self.run_browser('page.html', '', '/report_result?1')
29862986

2987+
@requires_threads
2988+
def test_sdl2_threads(self):
2989+
self.btest('sdl2_threads.c', expected='4', args=['-s', 'USE_PTHREADS=1', '-s', 'USE_SDL=2', '-s', 'PROXY_TO_PTHREAD=1'])
2990+
29872991
@requires_graphics_hardware
29882992
def test_sdl2glshader(self):
29892993
self.btest('sdl2glshader.c', reference='sdlglshader.png', args=['-s', 'USE_SDL=2', '-O2', '--closure', '1', '-g1', '-s', 'LEGACY_GL_EMULATION=1'])

0 commit comments

Comments
 (0)