nodejs/debian/patches/upstream-fix-test-worker-pr...

94 lines
3.2 KiB
Diff

From 04fb597996455d0abbe7b12bbc2d2a5ce16fbb3d Mon Sep 17 00:00:00 2001
From: Rich Trott <rtrott@gmail.com>
Date: Sun, 14 Feb 2021 15:52:54 -0800
Subject: [PATCH] test: fix flaky test-worker-prof
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes: https://github.com/nodejs/node/issues/26401
Co-authored-by: Gireesh Punathil <gpunathi@in.ibm.com>
PR-URL: https://github.com/nodejs/node/pull/37372
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
---
test/sequential/sequential.status | 4 ----
test/sequential/test-worker-prof.js | 15 ++++++++-------
2 files changed, 8 insertions(+), 11 deletions(-)
--- a/test/sequential/sequential.status
+++ b/test/sequential/sequential.status
@@ -24,8 +24,6 @@
[$system==win32]
# https://github.com/nodejs/node/issues/22327
test-http2-large-file: PASS, FLAKY
-# https://github.com/nodejs/node/issues/26401
-test-worker-prof: PASS, FLAKY
[$system==linux]
@@ -45,10 +43,6 @@
# https://github.com/nodejs/node/pull/30819
test-perf-hooks: SKIP
-[$arch==arm]
-# https://github.com/nodejs/node/issues/26401#issuecomment-613095719
-test-worker-prof: PASS, FLAKY
-
[$arch==mipsel]
test-inspector-async-hook-setup-at-inspect-brk: SKIP
test-inspector-async-hook-setup-at-signal: SKIP
--- a/test/sequential/test-worker-prof.js
+++ b/test/sequential/test-worker-prof.js
@@ -23,17 +23,17 @@
const fs = require('fs');
const { Worker, parentPort } = require('worker_threads');
parentPort.on('message', (m) => {
- if (counter++ === 10)
+ if (counter++ === 1024)
process.exit(0);
- parentPort.postMessage(
- fs.readFileSync(m.toString()).slice(0, 1024 * 1024));
+ parentPort.postMessage(
+ fs.readFileSync(m.toString()).slice(0, 1024 * 1024));
});
`;
const { Worker } = require('worker_threads');
const w = new Worker(pingpong, { eval: true });
w.on('message', (m) => {
- w.postMessage(process.execPath);
+ w.postMessage(__filename);
});
w.on('exit', common.mustCall(() => {
@@ -46,12 +46,13 @@
}
process.exit(0);
}));
- w.postMessage(process.execPath);
+ w.postMessage(__filename);
} else {
tmpdir.refresh();
+ const timeout = common.platformTimeout(30_000);
const spawnResult = spawnSync(
process.execPath, ['--prof', __filename, 'child'],
- { cwd: tmpdir.path, encoding: 'utf8', timeout: 30_000 });
+ { cwd: tmpdir.path, encoding: 'utf8', timeout });
assert.strictEqual(spawnResult.stderr.toString(), '',
`child exited with an error: \
${util.inspect(spawnResult)}`);
@@ -72,7 +73,7 @@
// Test that at least 15 ticks have been recorded for both parent and child
// threads. When not tracking Worker threads, only 1 or 2 ticks would
// have been recorded.
- // When running locally on x64 Linux, this number is usually at least 200
+ // When running locally, this number is usually around 200
// for both threads, so 15 seems like a very safe threshold.
assert(ticks >= 15, `${ticks} >= 15`);
}