Closed
Description
After spending a lot of time going through all the tests, here is a summary of my findings towards running the regression test suite on Emscripten/nodejs:
The command line I used and exclude list I used are here: https://gist.github.com/ethanhs/656637de570cc2c239c8728c4aa1e731
The list of tests excluded also includes a brief description of each test's failure(s). A quick summary:
- almost half of the test either directly import
subprocess
(51 tests) or indirectly does so via e.g.unitest.mock
(97 tests) - despite pthread being compiled in, I seem unable to create threads under nodejs (6 tests), I am getting EAGAIN...
- there are some locale issues which I presume are Emscripten bugs
- it also requires a couple of small changes to CPython, to patch around an Emscripten bug and also to disable the faulthandler thread because it won't start and causes the test runner to crash after a successful run.
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index fc3c2b9692..0879bb6baa 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -659,7 +659,9 @@ def main(self, tests=None, **kwargs):
except SystemExit as exc:
# bpo-38203: Python can hang at exit in Py_Finalize(), especially
# on threading._shutdown() call: put a timeout
- faulthandler.dump_traceback_later(EXIT_TIMEOUT, exit=True)
+ # Emscripten has issues starting threads
+ if sys.platform != 'emscripten':
+ faulthandler.dump_traceback_later(EXIT_TIMEOUT, exit=True)
sys.exit(exc.code)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 89e93c5818..dbd7d4dc63 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -5114,6 +5114,7 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
&family, &type, &proto, &fdobj))
return -1;
+
#ifdef MS_WINDOWS
/* In this case, we don't use the family, type and proto args */
if (fdobj == NULL || fdobj == Py_None)
@@ -7926,7 +7927,7 @@ PyInit__socket(void)
#ifdef IPPROTO_VRRP
PyModule_AddIntMacro(m, IPPROTO_VRRP);
#endif
-#ifdef IPPROTO_SCTP
+#if defined(IPPROTO_SCTP) && !defined(__EMSCRIPTEN__)
PyModule_AddIntMacro(m, IPPROTO_SCTP);
#endif
#ifdef IPPROTO_BIP
Huge thanks to @tiran for helping figure out the IPPROTO_SCTP
issue which was causing test_socket
to crash the test runner!
With this I think the steps towards adding a build bot for Emscripten/nodejs:
- Have bpo-40280: Add build target for Emscripten/node.js python/cpython#30495 merged
- Figure out why threads aren't starting - EDIT: It seems that WASM_STANDALONE doesn't work with pthread? strange...
- Patch Python around the
IPPROTO_SCTP
for now - Set up build bot
Want to run things yourself? Here are the steps:
- Do a normal checkout of this repo, pull my above mentioned PR
- Apply the above patches
- Grab the tests.txt file in the above gist and put it in the top level of the checkout
- Run the command in the gist to run the test suite!
Metadata
Metadata
Assignees
Labels
No labels