Skip to content

Make more use of emscripten_out/emscripten_err in test code. NFC - #19524

Merged
sbc100 merged 1 commit into
mainfrom
test_out_err
Aug 3, 2023
Merged

sbc100 merged 1 commit into
mainfrom
test_out_err

Conversation

@sbc100

@sbc100 sbc100 commented Jun 5, 2023

Copy link
Copy Markdown
Collaborator

Using these emscripten wrappers has some advantages. In particular, with workers we have seen issues with writes to
console.log/console.error being lost in some cases.

@sbc100
sbc100 force-pushed the test_out_err branch 2 times, most recently from 7891f79 to 0150478 Compare August 3, 2023 14:43
@sbc100
sbc100 requested review from kripken and tlively August 3, 2023 14:46
Comment thread test/test_core.py Outdated
Comment on lines -2136 to -2137
if self.is_wasm():
self.skipTest('wasm requires a proper asm module')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a wildly outdated requirement?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I opened a seperate PR for this actually: #19967

Comment thread test/test_other.py Outdated
#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE void foo() {
EM_ASM({ console.log("bar") });
EM_ASM({ log("bar") });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be out rather than log?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops good catch

int main()
{
EM_ASM(console.log(`Main thread stack base=0x${$0.toString(16)}, end=0x${$1.toString(16)}`), emscripten_stack_get_base(), emscripten_stack_get_end());
EM_ASM(out(`Main thread stack base=0x${$0.toString(16)}, end=0x${$1.toString(16)}`), emscripten_stack_get_base(), emscripten_stack_get_end());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to standardize on using emscripten_outf rather than EM_ASM(out(...))?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think yes. However, there are cases where EM_ASM is used instead to avoid pulling in the sprintf code form libc.. I'm not sure this is worth it for all most the most minimal tests.

I'll convert these ones here.

Using these emscripten wrappers has some advantages. In particular,
with workers we have seen issues with writes to
console.log/console.error being lost in some cases.
@sbc100
sbc100 enabled auto-merge (squash) August 3, 2023 17:27
@sbc100
sbc100 merged commit bb233ad into main Aug 3, 2023
@sbc100
sbc100 deleted the test_out_err branch August 3, 2023 18:17
sbc100 added a commit that referenced this pull request Aug 3, 2023
sbc100 added a commit that referenced this pull request Aug 3, 2023
sbc100 added a commit that referenced this pull request Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants