-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Cleanup the emscripten tests relating to the event loop. NFC #23760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
#include <emscripten/emscripten.h> | ||
#include <emscripten/html5.h> | ||
#include <emscripten/em_asm.h> | ||
#include <assert.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
double previousSetTimeouTime = 0; | ||
int funcExecuted = 0; | ||
|
||
void testDone(void *userData) { | ||
printf("testDone\n"); | ||
assert((long)userData == 2); | ||
assert(funcExecuted == 10); | ||
emscripten_runtime_keepalive_pop(); | ||
exit(0); | ||
} | ||
|
||
bool tick(double time, void *userData) { | ||
printf("tick: %d\n", funcExecuted); | ||
assert(time >= previousSetTimeouTime); | ||
previousSetTimeouTime = time; | ||
assert((long)userData == 1); | ||
++funcExecuted; | ||
if (funcExecuted == 10) | ||
{ | ||
if (funcExecuted == 10) { | ||
emscripten_set_timeout(testDone, 300, (void*)2); | ||
} | ||
return funcExecuted < 10; | ||
} | ||
|
||
int main() { | ||
emscripten_set_timeout_loop(tick, 100, (void*)1); | ||
emscripten_exit_with_live_runtime(); | ||
emscripten_runtime_keepalive_push(); | ||
return 99; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13883,9 +13883,8 @@ def test_pthread_trap(self): | |
def test_pthread_kill(self): | ||
self.do_run_in_out_file_test('pthread/test_pthread_kill.c') | ||
|
||
@node_pthreads | ||
def test_emscripten_set_interval(self): | ||
self.do_runf('emscripten_set_interval.c', args=['-pthread', '-sPROXY_TO_PTHREAD']) | ||
self.do_runf('emscripten_set_interval.c') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously this was tested with pthreads, but now it isn't, if I read this diff correctly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, see the PR description. There is a typo here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Should we fix the typo and test it with pthreads, or not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't think of a reason to use pthreads on this myself. lgtm either way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We test with and without threads in the browser already. |
||
|
||
# Test emscripten_console_log(), emscripten_console_warn() and emscripten_console_error() | ||
def test_emscripten_console_log(self): | ||
|
@@ -13895,13 +13894,11 @@ def test_emscripten_console_log(self): | |
def test_emscripten_unwind_to_js_event_loop(self): | ||
self.do_runf('test_emscripten_unwind_to_js_event_loop.c') | ||
|
||
@node_pthreads | ||
def test_emscripten_set_timeout(self): | ||
self.do_runf('emscripten_set_timeout.c', args=['-pthread', '-sPROXY_TO_PTHREAD']) | ||
self.do_runf('emscripten_set_timeout.c') | ||
|
||
@node_pthreads | ||
def test_emscripten_set_timeout_loop(self): | ||
self.do_runf('emscripten_set_timeout_loop.c', args=['-pthread', '-sPROXY_TO_PTHREAD']) | ||
self.do_runf('emscripten_set_timeout_loop.c') | ||
|
||
# Verify that we are able to successfully compile a script when the Windows 7 | ||
# and Python workaround env. vars are enabled. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This did not always test with OFFSCREEN_FRAMEBUFFER before. Do we not error on that being used without pthreads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think think its harmlessly ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should error ? But we don't today.