Skip to content

Commit c5d158c

Browse files
committed
Move test over to btest_exit()
We're also ensuring the test runs, not just silently exits.
1 parent 2efe1d6 commit c5d158c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

test/test_browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5478,7 +5478,7 @@ def test_audio_worklet(self, args):
54785478

54795479
# Tests that audioworklets and workers can be used at the same time
54805480
def test_audio_worklet_worker(self):
5481-
self.btest('webaudio/audioworklet_worker.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'], expected='1')
5481+
self.btest_exit('webaudio/audioworklet_worker.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'])
54825482

54835483
# Tests that posting functions between the main thread and the audioworklet thread works
54845484
@parameterized({

test/webaudio/audioworklet_worker.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <emscripten/webaudio.h>
22
#include <emscripten/wasm_worker.h>
33
#include <emscripten/threading.h>
4-
#include <stdio.h>
54
#include <stdlib.h>
65
#include <assert.h>
76

@@ -13,17 +12,19 @@
1312
int workletToWorkerFutexLocation = 0;
1413
int workletToWorkerFlag = 0;
1514

15+
void do_exit() {
16+
emscripten_terminate_all_wasm_workers();
17+
emscripten_force_exit(EXIT_SUCCESS);
18+
}
19+
1620
void run_in_worker() {
1721
while (0 == emscripten_futex_wait(&workletToWorkerFutexLocation, 0, 30000)) {
1822
if (workletToWorkerFlag == 1) {
19-
printf("Test success\n");
23+
emscripten_out("Test success");
24+
emscripten_wasm_worker_post_function_v(EMSCRIPTEN_WASM_WORKER_ID_PARENT, &do_exit);
2025
break;
2126
}
2227
}
23-
24-
#ifdef REPORT_RESULT
25-
REPORT_RESULT(workletToWorkerFlag == 1);
26-
#endif
2728
}
2829

2930
// This event will fire on the audio worklet thread.
@@ -45,4 +46,6 @@ int main() {
4546

4647
EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(0);
4748
emscripten_start_wasm_audio_worklet_thread_async(context, wasmAudioWorkletStack, sizeof(wasmAudioWorkletStack), WebAudioWorkletThreadInitialized, 0);
49+
50+
emscripten_exit_with_live_runtime();
4851
}

0 commit comments

Comments
 (0)