Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions test/pthread/emscripten_thread_sleep.c

This file was deleted.

41 changes: 41 additions & 0 deletions test/pthread/test_emscripten_thread_sleep.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <assert.h>
#include <emscripten.h>
#include <emscripten/console.h>
#include <emscripten/threading.h>
#include <pthread.h>
#include <stdio.h>

void do_sleep(double msecs) {
double t1 = emscripten_get_now();
emscripten_thread_sleep(msecs);
double t2 = emscripten_get_now();
emscripten_outf("emscripten_thread_sleep() slept for %f msecs.\n", t2 - t1);

assert(t2 - t1 >= 0.9 * msecs); // Should have slept ~ the requested time.
}

void* thread_main(void* arg) {
emscripten_out("hello from thread!");

do_sleep(1);
do_sleep(10);
do_sleep(100);
do_sleep(1000);
do_sleep(5000);

emscripten_force_exit(0);
return NULL;
}

int main() {
// Bad bad bad to sleep on the main thread, but test that it works.
do_sleep(1);
do_sleep(10);
do_sleep(100);
do_sleep(1000);
do_sleep(5000);
pthread_t thread;
pthread_create(&thread, NULL, thread_main, NULL);
emscripten_exit_with_live_runtime();
__builtin_trap();
}
2 changes: 1 addition & 1 deletion test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4815,7 +4815,7 @@ def test_unicode_html_shell(self):

# Tests the functionality of the emscripten_thread_sleep() function.
def test_emscripten_thread_sleep(self):
self.btest_exit('pthread/emscripten_thread_sleep.c', cflags=['-pthread'])
self.btest_exit('pthread/test_emscripten_thread_sleep.c', cflags=['-pthread'])

# Tests that Emscripten-compiled applications can be run from a relative path in browser that is different than the address of the current page
def test_browser_run_from_different_directory(self):
Expand Down
Loading