Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,29 @@
prefix known_issues
# If a known issue does not apply to a platform, list the test name in the
# appropriate section below, without ".js", followed by ": SKIP". Example:
# sample-test : SKIP
[true] # This section applies to all platforms
# This issue is unfixable with the current implementations of V8 and
# Node.js. Changes to make this fixable are unlikely to happen in the
# foreseeable future. The test itself is flaky and skipped. It
# serves as a demonstration of the issue only.
test-vm-timeout-escape-queuemicrotask: SKIP
[$system==win32]
[$system==linux]
[$system==macos]
[$system==solaris]
[$system==freebsd]
[$system==aix]
[$arch==arm]
[$system==ibmi]

View File

@ -0,0 +1,21 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) {
assert.fail('When Node.js is compiled without OpenSSL, overriding the global ' +
'crypto is allowed on string eval');
}
const child = require('child_process');
const nodejs = `"${process.execPath}"`;
// Trying to define a variable named `crypto` using `var` triggers an exception.
child.exec(
`${nodejs} ` +
'-p "var crypto = {randomBytes:1};typeof crypto.randomBytes"',
common.mustSucceed((stdout) => {
assert.match(stdout, /^number/);
}));

View File

@ -0,0 +1,34 @@
'use strict';
// Refs: https://github.com/nodejs/node/pull/12022
// If the cwd is deleted, Node cannot run files because the module system
// relies on uv_cwd(). The -e and -p flags still work though.
const common = require('../common');
const assert = require('assert');
if (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi) {
// The current working directory cannot be removed on these platforms.
// Change this to common.skip() when this is no longer a known issue test.
assert.fail('cannot rmdir current working directory');
}
const cp = require('child_process');
const fs = require('fs');
if (process.argv[2] === 'child') {
// Do nothing.
} else {
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const dir = fs.mkdtempSync(`${tmpdir.path}/`);
process.chdir(dir);
fs.rmdirSync(dir);
assert.throws(process.cwd,
/^Error: ENOENT: no such file or directory, uv_cwd$/);
const r = cp.spawnSync(process.execPath, [__filename, 'child']);
assert.strictEqual(r.status, 0);
assert.strictEqual(r.signal, null);
assert.strictEqual(r.stdout.toString().trim(), '');
assert.strictEqual(r.stderr.toString().trim(), '');
}

View File

@ -0,0 +1,56 @@
'use strict';
const common = require('../common');
// This test should fail because at present `cluster` does not know how to share
// a socket when `worker1` binds with `port: 0`, and others try to bind to the
// assigned port number from `worker1`
//
// *Note*: since this is a `known_issue` we try to swallow all errors except
// the one we are interested in
const assert = require('assert');
const cluster = require('cluster');
const dgram = require('dgram');
const BYE = 'bye';
if (cluster.isPrimary) {
const worker1 = cluster.fork();
// Verify that Windows doesn't support this scenario
worker1.on('error', (err) => {
if (err.code === 'ENOTSUP') throw err;
});
worker1.on('message', (msg) => {
if (typeof msg !== 'object') process.exit(0);
if (msg.message !== 'success') process.exit(0);
if (typeof msg.port1 !== 'number') process.exit(0);
const worker2 = cluster.fork({ PRT1: msg.port1 });
worker2.on('message', () => process.exit(0));
worker2.on('exit', (code, signal) => {
// This is the droid we are looking for
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
});
// cleanup anyway
process.on('exit', () => {
worker1.send(BYE);
worker2.send(BYE);
});
});
// end primary code
} else {
// worker code
process.on('message', (msg) => msg === BYE && process.exit(0));
// First worker will bind to '0', second will try the assigned port and fail
const PRT1 = process.env.PRT1 || 0;
const socket1 = dgram.createSocket('udp4', () => {});
socket1.on('error', PRT1 === 0 ? () => {} : assert.fail);
socket1.bind(
{ address: common.localhostIPv4, port: PRT1, exclusive: false },
() => process.send({ message: 'success', port1: socket1.address().port }),
);
}

View File

@ -0,0 +1,21 @@
'use strict';
const common = require('../common');
// Test that using an invalid file name with writeFileSync() on Windows returns
// EINVAL. With libuv 1.x, it returns ENOTFOUND. This should be fixed when we
// update to libuv 2.x.
//
// Refs: https://github.com/nodejs/node/issues/8987
const assert = require('assert');
const fs = require('fs');
if (!common.isWindows) {
// Change to `common.skip()` when the test is moved out of `known_issues`.
assert.fail('Windows-only test');
}
assert.throws(() => {
fs.writeFileSync('fhqwhgads??', 'come on');
}, { code: 'EINVAL' });

View File

@ -0,0 +1,51 @@
'use strict';
// Refs: https://github.com/nodejs/node/pull/34066
const common = require('../common');
const assert = require('assert');
const http = require('http');
// Test that ClientRequest#end with default options
// computes and sends a Content-Length header
const upload = 'PUT / HTTP/1.1\r\n\r\n';
const response = 'content-length: 19\r\n';
// Test that the upload is properly received with the same headers,
// regardless of request method
const methods = [ 'GET', 'HEAD', 'DELETE', 'POST', 'PATCH', 'PUT', 'OPTIONS' ];
const server = http.createServer(common.mustCall(function(req, res) {
req.on('data', function(chunk) {
assert.strictEqual(chunk, Buffer.from(upload));
});
res.setHeader('Content-Type', 'text/plain');
let payload = `${req.method}\r\n`;
for (let i = 0; i < req.rawHeaders.length; i += 2) {
// Ignore a couple headers that may vary
if (req.rawHeaders[i].toLowerCase() === 'host') continue;
if (req.rawHeaders[i].toLowerCase() === 'connection') continue;
payload += `${req.rawHeaders[i]}: ${req.rawHeaders[i + 1]}\r\n`;
}
res.end(payload);
}), methods.length);
server.listen(0, function tryNextRequest() {
const method = methods.pop();
if (method === undefined) return;
const port = server.address().port;
const req = http.request({ method, port }, function(res) {
const chunks = [];
res.on('data', function(chunk) {
chunks.push(chunk);
});
res.on('end', function() {
const received = Buffer.concat(chunks).toString();
const expected = method.toLowerCase() + '\r\n' + response;
assert.strictEqual(received.toLowerCase(), expected);
tryNextRequest();
});
});
req.end(upload);
}).unref();

View File

@ -0,0 +1,52 @@
'use strict';
// Refs: https://github.com/nodejs/node/pull/34066
const common = require('../common');
const assert = require('assert');
const http = require('http');
// Test that ClientRequest#end with default options
// and empty payload sends neither Content-Length nor Transfer-Encoding.
// Sending Content-Length: 0 would be acceptable, but is unnecessary.
const upload = 'PUT / HTTP/1.1\r\n\r\n';
const response = '';
// Test that the upload is properly received with the same headers,
// regardless of request method.
const methods = [ 'GET', 'HEAD', 'DELETE', 'POST', 'PATCH', 'PUT', 'OPTIONS' ];
const server = http.createServer(common.mustCall(function(req, res) {
req.on('data', function(chunk) {
assert.strictEqual(chunk.toString(), upload);
});
res.setHeader('Content-Type', 'text/plain');
res.write(`${req.method}\r\n`);
for (let i = 0; i < req.rawHeaders.length; i += 2) {
// Ignore a couple headers that may vary
if (req.rawHeaders[i].toLowerCase() === 'host') continue;
if (req.rawHeaders[i].toLowerCase() === 'connection') continue;
res.write(`${req.rawHeaders[i]}: ${req.rawHeaders[i + 1]}\r\n`);
}
res.end();
}), methods.length);
server.listen(0, function tryNextRequest() {
const method = methods.pop();
if (method === undefined) return;
const port = server.address().port;
const req = http.request({ method, port }, function(res) {
const chunks = [];
res.on('data', function(chunk) {
chunks.push(chunk);
});
res.on('end', function() {
const received = Buffer.concat(chunks).toString();
const expected = method.toLowerCase() + '\r\n' + response;
assert.strictEqual(received.toLowerCase(), expected);
tryNextRequest();
});
});
req.end();
}).unref();

View File

@ -0,0 +1,52 @@
'use strict';
// Refs: https://github.com/nodejs/node/pull/34066
const common = require('../common');
const assert = require('assert');
const http = require('http');
// Test that ClientRequest#write with default options
// uses a chunked Transfer-Encoding
const upload = 'PUT / HTTP/1.1\r\n\r\n';
const response = 'transfer-encoding: chunked\r\n';
// Test that the upload is properly received with the same headers,
// regardless of request method.
const methods = [ 'GET', 'HEAD', 'DELETE', 'POST', 'PATCH', 'PUT', 'OPTIONS' ];
const server = http.createServer(common.mustCall(function(req, res) {
req.on('data', function(chunk) {
assert.strictEqual(chunk.toString(), upload);
});
res.setHeader('Content-Type', 'text/plain');
res.write(`${req.method}\r\n`);
for (let i = 0; i < req.rawHeaders.length; i += 2) {
// Ignore a couple headers that may vary
if (req.rawHeaders[i].toLowerCase() === 'host') continue;
if (req.rawHeaders[i].toLowerCase() === 'connection') continue;
res.write(`${req.rawHeaders[i]}: ${req.rawHeaders[i + 1]}\r\n`);
}
res.end();
}), methods.length);
server.listen(0, function tryNextRequest() {
const method = methods.pop();
if (method === undefined) return;
const port = server.address().port;
const req = http.request({ method, port }, function(res) {
const chunks = [];
res.on('data', function(chunk) {
chunks.push(chunk);
});
res.on('end', function() {
const received = Buffer.concat(chunks).toString();
const expected = method.toLowerCase() + '\r\n' + response;
assert.strictEqual(received.toLowerCase(), expected);
tryNextRequest();
});
});
req.write(upload);
req.end();
}).unref();

View File

@ -0,0 +1,36 @@
'use strict';
const common = require('../common');
// This test ensures that Unicode characters in the URL get handled correctly
// by `http`
// Refs: https://github.com/nodejs/node/issues/13296
const assert = require('assert');
const http = require('http');
const expected = '/café🐶';
assert.strictEqual(expected, '/caf\u{e9}\u{1f436}');
const server = http.createServer(common.mustCall(function(req, res) {
assert.strictEqual(req.url, expected);
req.on('data', common.mustCall()).on('end', common.mustCall(function() {
server.close();
res.writeHead(200);
res.end('hello world\n');
}));
}));
server.listen(0, () => {
http.request({
port: server.address().port,
path: expected,
method: 'GET',
}, common.mustCall(function(res) {
res.resume();
})).on('error', function(e) {
console.log(e.message);
process.exit(1);
}).end();
});

View File

@ -0,0 +1,70 @@
// Flags: --inspect=0
'use strict';
const common = require('../common');
const assert = require('assert');
// With the current behavior of Node.js (at least as late as 8.1.0), this
// test fails with the following error:
// `AssertionError [ERR_ASSERTION]: worker 2 failed to bind port`
// Ideally, there would be a way for the user to opt out of sequential port
// assignment.
//
// Refs: https://github.com/nodejs/node/issues/13343
// This following check should be replaced by common.skipIfInspectorDisabled()
// if moved out of the known_issues directory.
if (!process.features.inspector) {
// When the V8 inspector is disabled, using either --without-inspector or
// --without-ssl, this test will not fail which it is expected to do.
// The following fail will allow this test to be skipped by failing it.
assert.fail('skipping as V8 inspector is disabled');
}
const cluster = require('cluster');
const net = require('net');
const ports = [process.debugPort];
const clashPort = process.debugPort + 2;
function serialFork() {
return new Promise((res) => {
const worker = cluster.fork();
worker.on('error', (err) => assert.fail(err));
// No common.mustCall since 1 out of 3 should fail.
worker.on('online', () => {
worker.on('message', common.mustCall((message) => {
ports.push(message.debugPort);
}));
});
worker.on('exit', common.mustCall((code, signal) => {
assert.strictEqual(signal, null);
// worker 2 should fail because of port clash with `server`
if (code === 12) {
return assert.fail(`worker ${worker.id} failed to bind port`);
}
assert.strictEqual(code, 0);
}));
worker.on('disconnect', common.mustCall(res));
});
}
if (cluster.isPrimary) {
cluster.on('online', common.mustCall((worker) => worker.send('dbgport'), 2));
// Block one of the ports with a listening socket.
const server = net.createServer();
server.listen(clashPort, common.localhostIPv4, common.mustCall(() => {
// Try to fork 3 workers. No.2 should fail.
Promise.all([serialFork(), serialFork(), serialFork()])
.then(common.mustNotCall())
.catch((err) => console.error(err));
}));
server.unref();
} else {
const sentinel = common.mustCall();
process.on('message', (message) => {
if (message !== 'dbgport') return;
process.send({ debugPort: process.debugPort });
sentinel();
process.disconnect();
});
}

View File

@ -0,0 +1,54 @@
// This test validates inspector's Debugger.setInstrumentationBreakpoint method.
// Refs: https://github.com/nodejs/node/issues/31138
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const assert = require('assert');
const { resolve: UrlResolve } = require('url');
const fixtures = require('../common/fixtures');
const { NodeInstance } = require('../common/inspector-helper.js');
async function testBreakpointBeforeScriptExecution(session) {
console.log('[test]',
'Verifying debugger stops on start of each script ' +
'(Debugger.setInstrumentationBreakpoint with beforeScriptExecution)');
const commands = [
{ 'method': 'Runtime.enable' },
{ 'method': 'Debugger.enable' },
{ 'method': 'Debugger.setInstrumentationBreakpoint',
'params': { 'instrumentation': 'beforeScriptExecution' } },
{ 'method': 'Runtime.runIfWaitingForDebugger' },
];
await session.send(commands);
// Break on start
await session.waitForBreakOnLine(
0, UrlResolve(session.scriptURL().toString(), 'main.js'));
await session.send([{ 'method': 'Debugger.resume' }]);
// Script loaded
await session.waitForBreakOnLine(
0, UrlResolve(session.scriptURL().toString(), 'main.js'));
await session.send([{ 'method': 'Debugger.resume' }]);
// Script loaded
await session.waitForBreakOnLine(
0, UrlResolve(session.scriptURL().toString(), 'dep.js'));
await session.send([{ 'method': 'Debugger.resume' }]);
}
async function runTest() {
const main = fixtures.path('inspector-instrumentation-breakpoint', 'main.js');
const child = new NodeInstance(['--inspect-brk=0'], '', main);
const session = await child.connectInspectorSession();
await testBreakpointBeforeScriptExecution(session);
await session.runToCompletion();
assert.strictEqual((await child.expectShutdown()).exitCode, 0);
}
runTest();

View File

@ -0,0 +1,30 @@
'use strict';
// Refs: https://github.com/nodejs/node/issues/7788
const common = require('../common');
const assert = require('assert');
const path = require('../common/fixtures').path;
const repl = require('repl');
const stream = require('stream');
const inputStream = new stream.PassThrough();
const outputStream = new stream.PassThrough();
const fixture = path('is-object.js');
const r = repl.start({
input: inputStream,
output: outputStream,
useGlobal: false,
});
let output = '';
outputStream.setEncoding('utf8');
outputStream.on('data', (data) => output += data);
r.on('exit', common.mustCall(() => {
const results = output.replace(/^> /mg, '').split('\n');
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
}));
inputStream.write('const isObject = (obj) => obj.constructor === Object;\n');
inputStream.write('isObject({});\n');
inputStream.write(`require('${fixture}').isObject({});\n`);
r.close();

View File

@ -0,0 +1,23 @@
'use strict';
// Refs: https://github.com/nodejs/node/pull/5916
const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;
const net = require('net');
if (process.argv[2] === 'child') {
assert(process.stdin instanceof net.Socket);
return;
}
const proc = spawn(
process.execPath,
[__filename, 'child'],
{ stdio: 'ignore' },
);
// To double-check this test, set stdio to 'pipe' and uncomment the line below.
// proc.stderr.pipe(process.stderr);
proc.on('exit', common.mustCall(function(exitCode) {
assert.strictEqual(exitCode, 0);
}));

View File

@ -0,0 +1,44 @@
'use strict';
const common = require('../common');
// Tests for the regression in _stream_writable discussed in
// https://github.com/nodejs/node/pull/31756
// Specifically, when a write callback is invoked synchronously
// with an error, and autoDestroy is not being used, the error
// should still be emitted on nextTick.
const { Writable } = require('stream');
class MyStream extends Writable {
#cb = undefined;
constructor() {
super({ autoDestroy: false });
}
_write(_, __, cb) {
this.#cb = cb;
}
close() {
// Synchronously invoke the callback with an error.
this.#cb(new Error('foo'));
}
}
const stream = new MyStream();
const mustError = common.mustCall(2);
stream.write('test', () => {});
// Both error callbacks should be invoked.
stream.on('error', mustError);
stream.close();
// Without the fix in #31756, the error handler
// added after the call to close will not be invoked.
stream.on('error', mustError);

View File

@ -0,0 +1,57 @@
'use strict';
// Refs: https://github.com/nodejs/node/issues/5832
require('../common');
const url = require('url');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const tests = require(
fixtures.path('wpt', 'url', 'resources', 'urltestdata.json'),
);
let failed = 0;
let attempted = 0;
tests.forEach((test) => {
attempted++;
// Skip comments
if (typeof test === 'string') return;
let parsed;
try {
// Attempt to parse
parsed = url.parse(url.resolve(test.base, test.input));
if (test.failure) {
// If the test was supposed to fail and we didn't get an
// error, treat it as a failure.
failed++;
} else {
// Test was not supposed to fail, so we're good so far. Now
// check the results of the parse.
let username, password;
try {
assert.strictEqual(test.href, parsed.href);
assert.strictEqual(test.protocol, parsed.protocol);
username = parsed.auth ? parsed.auth.split(':', 2)[0] : '';
password = parsed.auth ? parsed.auth.split(':', 2)[1] : '';
assert.strictEqual(test.username, username);
assert.strictEqual(test.password, password);
assert.strictEqual(test.host, parsed.host);
assert.strictEqual(test.hostname, parsed.hostname);
assert.strictEqual(+test.port, +parsed.port);
assert.strictEqual(test.pathname, parsed.pathname || '/');
assert.strictEqual(test.search, parsed.search || '');
assert.strictEqual(test.hash, parsed.hash || '');
} catch {
// For now, we're just interested in the number of failures.
failed++;
}
}
} catch {
// If Parse failed and it wasn't supposed to, treat it as a failure.
if (!test.failure)
failed++;
}
});
assert.ok(failed === 0, `${failed} failed tests (out of ${attempted})`);

View File

@ -0,0 +1,21 @@
'use strict';
// https://github.com/nodejs/node/issues/31808
// function declarations currently call [[Set]] instead of [[DefineOwnProperty]]
// in VM contexts, which violates the ECMA-262 specification:
// https://tc39.es/ecma262/#sec-createglobalfunctionbinding
const common = require('../common');
const vm = require('vm');
const assert = require('assert');
const ctx = vm.createContext();
Object.defineProperty(ctx, 'x', {
enumerable: true,
configurable: true,
get: common.mustNotCall('ctx.x getter must not be called'),
set: common.mustNotCall('ctx.x setter must not be called'),
});
vm.runInContext('function x() {}', ctx);
assert.strictEqual(typeof ctx.x, 'function');

View File

@ -0,0 +1,46 @@
'use strict';
// https://github.com/nodejs/node/issues/3020
// Promises, nextTick, and queueMicrotask allow code to escape the timeout
// set for runInContext, runInNewContext, and runInThisContext
const common = require('../common');
const assert = require('assert');
const vm = require('vm');
const NS_PER_MS = 1000000n;
const hrtime = process.hrtime.bigint;
const nextTick = process.nextTick;
const waitDuration = common.platformTimeout(200n);
function loop() {
const start = hrtime();
while (1) {
const current = hrtime();
const span = (current - start) / NS_PER_MS;
if (span >= waitDuration) {
throw new Error(
`escaped timeout at ${span} milliseconds!`);
}
}
}
// The bug won't happen 100% reliably so run the test a small number of times to
// make sure we catch it if the bug exists.
for (let i = 0; i < 4; i++) {
assert.throws(() => {
vm.runInNewContext(
'nextTick(loop); loop();',
{
hrtime,
nextTick,
loop,
},
{ timeout: common.platformTimeout(100) },
);
}, {
code: 'ERR_SCRIPT_EXECUTION_TIMEOUT',
});
}

View File

@ -0,0 +1,43 @@
'use strict';
// https://github.com/nodejs/node/issues/3020
// Promises, nextTick, and queueMicrotask allow code to escape the timeout
// set for runInContext, runInNewContext, and runInThisContext
const common = require('../common');
const assert = require('assert');
const vm = require('vm');
const NS_PER_MS = 1000000n;
const hrtime = process.hrtime.bigint;
const loopDuration = common.platformTimeout(1000n);
const timeout = common.platformTimeout(100);
function loop() {
const start = hrtime();
while (1) {
const current = hrtime();
const span = (current - start) / NS_PER_MS;
if (span >= loopDuration) {
throw new Error(
`escaped ${timeout}ms timeout at ${span}ms`);
}
}
}
assert.throws(() => {
vm.runInNewContext(
'queueMicrotask(loop); loop();',
{
hrtime,
queueMicrotask,
loop,
},
{ timeout, microtaskMode: 'afterScriptRun' },
);
}, {
code: 'ERR_SCRIPT_EXECUTION_TIMEOUT',
message: `Script execution timed out after ${timeout}ms`,
});

View File

@ -0,0 +1,9 @@
import sys, os
import copy
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import testpy
def GetConfiguration(context, root):
myContext = copy.copy(context)
myContext.expect_fail = 1
return testpy.SimpleTestConfiguration(myContext, root, 'known_issues')