Skip to content

Commit 1278c47

Browse files
committed
test,win: add NODE_OPTIONS --no-maglev allowlist and CET regression test
Verify that --no-maglev and --maglev are accepted in NODE_OPTIONS (regression guard for the kAllowedInEnvvar addition in the previous commit). Add a Windows-specific test that confirms the process starts cleanly when those flags are passed via the environment variable. The actual CET hardware auto-disable path requires OS-level shadow stack enforcement and is covered by manual testing on Windows 11 Insider builds; this test covers the observable envvar interface.
1 parent cc61b03 commit 1278c47

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

test/parallel/test-cli-node-options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ expect('--abort_on-uncaught_exception', 'B\n');
7777
expect('--disallow-code-generation-from-strings', 'B\n');
7878
expect('--expose-gc', 'B\n');
7979
expect('--jitless', 'B\n');
80+
expect('--no-maglev', 'B\n');
81+
expect('--maglev', 'B\n');
8082
expect('--max-old-space-size=0', 'B\n');
8183
expect('--max-semi-space-size=0', 'B\n');
8284
expect('--stack-trace-limit=100',
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
// Verify that the --no-maglev V8 flag is accepted via NODE_OPTIONS on Windows,
3+
// and that the CET shadow stack auto-detection path compiles correctly.
4+
//
5+
// The actual CET auto-disable behavior (in InitializeNodeWithArgsInternal) can
6+
// only be exercised on hardware that has CET shadow stacks enabled by the OS,
7+
// so that path is covered by manual testing on Windows 11 Insider builds.
8+
// This test covers the observable surface: --no-maglev is accepted via
9+
// NODE_OPTIONS without error, and the process exits cleanly.
10+
11+
const common = require('../common');
12+
13+
if (!common.isWindows)
14+
common.skip('Windows-specific CET / Maglev regression test');
15+
16+
if (process.config.variables.node_without_node_options)
17+
common.skip('missing NODE_OPTIONS support');
18+
19+
const assert = require('assert');
20+
const { execFile } = require('child_process');
21+
22+
const cases = [
23+
// --no-maglev must be accepted in NODE_OPTIONS (regression: previously it
24+
// was a pure V8 passthrough not whitelisted for envvar use).
25+
{ env: 'NODE_OPTIONS=--no-maglev', desc: '--no-maglev via NODE_OPTIONS' },
26+
// --maglev must also be accepted so users can explicitly opt back in.
27+
{ env: 'NODE_OPTIONS=--maglev', desc: '--maglev via NODE_OPTIONS' },
28+
];
29+
30+
for (const { env: envStr, desc } of cases) {
31+
const [key, value] = envStr.split('=');
32+
const env = { ...process.env, [key]: value };
33+
34+
execFile(
35+
process.execPath,
36+
['-e', 'process.exitCode = 0;'],
37+
{ env },
38+
common.mustCall((err, stdout, stderr) => {
39+
assert.ifError(err);
40+
assert.strictEqual(stderr, '', `${desc}: unexpected stderr: ${stderr}`);
41+
})
42+
);
43+
}

0 commit comments

Comments
 (0)