2017-06-02 07:09:49 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-11-06 15:13:30 +00:00
|
|
|
// Check that spawn child doesn't create duplicated entries
|
2020-03-14 23:16:50 +00:00
|
|
|
const common = require('../common');
|
2021-04-04 04:14:41 +00:00
|
|
|
|
2022-04-07 16:40:46 +00:00
|
|
|
if (common.isPi) {
|
|
|
|
common.skip('Too slow for Raspberry Pi devices');
|
2021-06-26 15:40:27 +00:00
|
|
|
}
|
2021-04-04 04:14:41 +00:00
|
|
|
|
2020-03-14 23:16:50 +00:00
|
|
|
const kRepetitions = 2;
|
2017-06-02 07:09:49 +00:00
|
|
|
const assert = require('assert');
|
2017-11-06 15:13:30 +00:00
|
|
|
const fixtures = require('../common/fixtures');
|
2020-03-14 23:16:50 +00:00
|
|
|
const { promisify, debuglog } = require('util');
|
|
|
|
const debug = debuglog('test');
|
|
|
|
|
|
|
|
const { execFile } = require('child_process');
|
|
|
|
const execFilePromise = promisify(execFile);
|
2017-11-06 15:13:30 +00:00
|
|
|
const targetScript = fixtures.path('guess-hash-seed.js');
|
2017-06-02 07:09:49 +00:00
|
|
|
|
2020-03-14 23:16:50 +00:00
|
|
|
const requiredCallback = common.mustCall((results) => {
|
|
|
|
const seeds = results.map((val) => val.stdout.trim());
|
|
|
|
debug(`Seeds: ${seeds}`);
|
2019-01-15 18:31:12 +00:00
|
|
|
assert.strictEqual(new Set(seeds).size, seeds.length);
|
2020-03-14 23:16:50 +00:00
|
|
|
assert.strictEqual(seeds.length, kRepetitions);
|
|
|
|
});
|
2019-01-15 18:31:12 +00:00
|
|
|
|
2022-07-11 14:08:02 +00:00
|
|
|
function generateSeed() {
|
|
|
|
return execFilePromise(process.execPath, [
|
|
|
|
// Needed for %NeverOptimizeFunction.
|
|
|
|
'--allow-natives-syntax',
|
|
|
|
targetScript,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2020-03-14 23:16:50 +00:00
|
|
|
const subprocesses = [...new Array(kRepetitions)].map(generateSeed);
|
2017-06-02 07:09:49 +00:00
|
|
|
|
2020-03-14 23:16:50 +00:00
|
|
|
Promise.all(subprocesses)
|
|
|
|
.then(requiredCallback);
|