| 13 | volatile int32_t addr = 0; |
| 14 | |
| 15 | void run_test() { |
| 16 | emscripten_out("worker_main"); |
| 17 | emscripten_atomic_store_u32((void*)&addr, 1); |
| 18 | |
| 19 | emscripten_out("Waiting on address with unexpected value should return 'not-equal'"); |
| 20 | ATOMICS_WAIT_RESULT_T ret = emscripten_atomic_wait_u32((int32_t*)&addr, 2, /*timeout=*/-1); |
| 21 | assert(ret == ATOMICS_WAIT_NOT_EQUAL); |
| 22 | |
| 23 | emscripten_out("Waiting on address with unexpected value should return 'not-equal' also if timeout==0"); |
| 24 | ret = emscripten_atomic_wait_u32((int32_t*)&addr, 2, /*timeout=*/0); |
| 25 | assert(ret == ATOMICS_WAIT_NOT_EQUAL); |
| 26 | |
| 27 | emscripten_out("Waiting for 0 nanoseconds should return 'timed-out'"); |
| 28 | ret = emscripten_atomic_wait_u32((int32_t*)&addr, 1, /*timeout=*/0); |
| 29 | assert(ret == ATOMICS_WAIT_TIMED_OUT); |
| 30 | |
| 31 | emscripten_out("Waiting for >0 nanoseconds should return 'timed-out'"); |
| 32 | ret = emscripten_atomic_wait_u32((int32_t*)&addr, 1, /*timeout=*/1000); |
| 33 | assert(ret == ATOMICS_WAIT_TIMED_OUT); |
| 34 | |
| 35 | emscripten_out("Waiting for infinitely long should return 'ok'"); |
| 36 | emscripten_atomic_store_u32((void*)&addr, 3); |
| 37 | ret = emscripten_atomic_wait_u32((int32_t*)&addr, 3, /*timeout=*/-1); |
| 38 | assert(ret == ATOMICS_WAIT_OK); |
| 39 | |
| 40 | emscripten_out("Test finished"); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | // This test run in both wasm workers and pthreads mode |
no test coverage detected