Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make the timeout test more resilient #510

Merged
merged 1 commit into from
Sep 9, 2024
Merged
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -128,6 +128,9 @@ add_link_options(
)
elseif(CONFIG_UBSAN)
message(STATUS "Building with UBSan")
add_compile_definitions(
__UBSAN__=1
)
add_compile_options(
-fsanitize=undefined
-fno-sanitize-recover=all
3 changes: 3 additions & 0 deletions qjs.c
Original file line number Diff line number Diff line change
@@ -140,6 +140,9 @@ static const JSCFunctionListEntry navigator_obj[] = {
static const JSCFunctionListEntry global_obj[] = {
JS_CFUNC_DEF("gc", 0, js_gc),
JS_OBJECT_DEF("navigator", navigator_obj, countof(navigator_obj), JS_PROP_C_W_E),
#if defined(__ASAN__) || defined(__UBSAN__)
JS_PROP_INT32_DEF("__running_with_sanitizer__", 1, JS_PROP_C_W_E ),
#endif
};

/* also used to initialize the worker context */
10 changes: 6 additions & 4 deletions tests/test_std.js
Original file line number Diff line number Diff line change
@@ -277,11 +277,13 @@ function test_timeout()

function test_timeout_order()
{
if (globalThis.__running_with_sanitizer__) return;

var s = "";
os.setTimeout(a, 1);
os.setTimeout(b, 2);
os.setTimeout(d, 5);
function a() { s += "a"; os.setTimeout(c, 0); }
os.setTimeout(a, 100);
os.setTimeout(b, 200);
os.setTimeout(d, 500);
function a() { s += "a"; os.setTimeout(c, 200); }
function b() { s += "b"; }
function c() { s += "c"; }
function d() { assert(s === "abc"); } // not "acb"
Loading