summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGireesh Punathil <gpunathi@in.ibm.com>2018-12-17 02:52:43 -0500
committerGireesh Punathil <gpunathi@in.ibm.com>2019-01-29 18:27:59 +0530
commitc3fd50463f2d3b6be54ebf8b4dbb85157bc08c3f (patch)
treefe157964809aa16b32061baa6da1ffad729aafe7 /test
parent25e057e4f67a694d2bf0351126cfa2e4c46d0526 (diff)
downloadandroid-node-v8-c3fd50463f2d3b6be54ebf8b4dbb85157bc08c3f.tar.gz
android-node-v8-c3fd50463f2d3b6be54ebf8b4dbb85157bc08c3f.tar.bz2
android-node-v8-c3fd50463f2d3b6be54ebf8b4dbb85157bc08c3f.zip
test: exit sequence sanity tests
Execute many module loads in worker in a loop while exiting from the main thread at arbitrary execution points, and make sure that the workers quiesce without crashing. `worker_threads` are not necessarily the subject of testing, those are used for easy simulation of multi-thread scenarios. Refs: https://github.com/nodejs/node/issues/25007 PR-URL: https://github.com/nodejs/node/pull/25083 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-worker-cleanexit-with-moduleload.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-worker-cleanexit-with-moduleload.js b/test/parallel/test-worker-cleanexit-with-moduleload.js
new file mode 100644
index 0000000000..172544f50a
--- /dev/null
+++ b/test/parallel/test-worker-cleanexit-with-moduleload.js
@@ -0,0 +1,24 @@
+'use strict';
+require('../common');
+
+// Harden the thread interactions on the exit path.
+// Ensure workers are able to bail out safe at
+// arbitrary execution points. By using a number of
+// internal modules as load candidates, the expectation
+// is that those will be at various control flow points
+// preferrably in the C++ land.
+
+const { Worker } = require('worker_threads');
+for (let i = 0; i < 10; i++) {
+ new Worker("const modules = ['fs', 'assert', 'async_hooks'," +
+ "'buffer', 'child_process', 'net', 'http', 'https', 'os'," +
+ "'path', 'v8', 'vm'];" +
+ 'modules.forEach((module) => {' +
+ 'const m = require(module);' +
+ '});', { eval: true });
+}
+
+// Allow workers to go live.
+setTimeout(() => {
+ process.exit(0);
+}, 200);