Skip to content
Merged
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
22 changes: 22 additions & 0 deletions tests/pthread/test_pthread_stack_bounds.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <thread>
#include <emscripten.h>

void thread(void) {
bool passed;
size_t stack_base = EM_ASM_INT({ return STACK_BASE; });
size_t stack_max = EM_ASM_INT({ return STACK_MAX; });
size_t current = (size_t) &passed;
#if __asmjs__
passed = stack_base < current && current < stack_max;
#else
passed = stack_base > current && current > stack_max;
#endif
#ifdef REPORT_RESULT
REPORT_RESULT(passed ? 1 : 0);
#endif
}

int main(void) {
std::thread t(thread);
t.detach();
}
5 changes: 5 additions & 0 deletions tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3885,6 +3885,11 @@ def test_pthread_utf8_funcs(self):
def test_pthread_wake_all(self):
self.btest(path_from_root('tests', 'pthread', 'test_futex_wake_all.cpp'), expected='0', args=['-O3', '-s', 'USE_PTHREADS=1', '-s', 'TOTAL_MEMORY=64MB', '-s', 'NO_EXIT_RUNTIME=1'], also_asmjs=True)

# Test that STACK_BASE and STACK_MAX correctly bound the stack on pthreads.
@requires_threads
def test_pthread_stack_bounds(self):
self.btest(path_from_root('tests', 'pthread', 'test_pthread_stack_bounds.cpp'), expected='1', args=['-s', 'USE_PTHREADS', '-std=c++11'])

# Test that real `thread_local` works.
@no_fastcomp('thread_local is only supported on WASM backend')
@requires_threads
Expand Down