Skip to content

Commit ad7c40c

Browse files
authored
Run test_pthread_kill in test_other. NFC (#22465)
1 parent 915ca21 commit ad7c40c

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

test/pthread/test_pthread_kill.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <unistd.h>
1212
#include <errno.h>
1313
#include <signal.h>
14-
#include <emscripten.h>
1514

1615
_Atomic int sharedVar = 0;
1716

@@ -24,9 +23,8 @@ static void *thread_start(void *arg) {
2423
pthread_exit(0);
2524
}
2625

27-
void BusySleep(double msecs) {
28-
double t0 = emscripten_get_now();
29-
while (emscripten_get_now() < t0 + msecs);
26+
void BusySleep(long msecs) {
27+
usleep(msecs * 1000);
3028
}
3129

3230
int main() {
@@ -39,8 +37,10 @@ int main() {
3937
// Wait until thread kicks in and sets the shared variable.
4038
while (sharedVar == 0)
4139
BusySleep(10);
40+
printf("thread startd\n");
4241

4342
s = pthread_kill(thr, SIGKILL);
43+
printf("thread killed\n");
4444
assert(s == 0);
4545

4646
// Wait until we see the shared variable stop incrementing. (This is a bit heuristic and hacky)
@@ -55,7 +55,7 @@ int main() {
5555
sharedVar = 0;
5656

5757
// Wait for a long time, if the thread is still running, it should progress and set sharedVar by this time.
58-
BusySleep(3000);
58+
BusySleep(1000);
5959

6060
// Finally test that the thread is not doing any work and it is dead.
6161
assert(sharedVar == 0);

test/pthread/test_pthread_kill.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
thread startd
2+
thread killed
3+
Main: Done. Successfully killed thread. sharedVar: 0

test/test_other.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13412,6 +13412,10 @@ def test_pthread_trap(self):
1341213412
self.assertContained('sent an error!', output)
1341313413
self.assertContained('at (test_pthread_trap.wasm.)?thread_main', output, regex=True)
1341413414

13415+
@node_pthreads
13416+
def test_pthread_kill(self):
13417+
self.do_run_in_out_file_test('pthread/test_pthread_kill.c')
13418+
1341513419
@node_pthreads
1341613420
def test_emscripten_set_interval(self):
1341713421
self.do_runf('emscripten_set_interval.c', args=['-pthread', '-sPROXY_TO_PTHREAD'])

0 commit comments

Comments
 (0)