test: fix WASI link test

The WASI link test attempts to create a link in the temporary directory
to a file in the fixtures directory and can fail if those directories
are on different devices. Update the test so that both the source and
target of the link reside on the same device.

PR-URL: https://github.com/nodejs/node/pull/39485
Fixes: https://github.com/nodejs/node/issues/39484
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Richard Lau authored and Beth Griggs committed 2021-07-29 17:14:24 +01:00
1 parent 1fb0954202
commit 039f64f249
2 files changed
+6 -2

No files matched your search

+6 -1
View File
@@ -14,7 +14,8 @@ if (process.argv[2] === 'wasi-child') {
args: [],
env: process.env,
preopens: {
'/sandbox': process.argv[4]
'/sandbox': process.argv[4],
'/tmp': process.argv[5]
}
});
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
@@ -45,9 +46,11 @@ if (process.argv[2] === 'wasi-child') {
const escapingSymlink = path.join(sandboxedDir, 'outside.txt');
const loopSymlink1 = path.join(sandboxedDir, 'loop1');
const loopSymlink2 = path.join(sandboxedDir, 'loop2');
const sandboxedTmp = path.join(tmpdir.path, 'tmp');
fs.mkdirSync(sandbox);
fs.mkdirSync(sandboxedDir);
fs.mkdirSync(sandboxedTmp);
fs.writeFileSync(sandboxedFile, 'hello from input.txt', 'utf8');
fs.writeFileSync(externalFile, 'this should be inaccessible', 'utf8');
fs.symlinkSync(path.join('.', 'input.txt'), sandboxedSymlink, 'file');
@@ -66,6 +69,7 @@ if (process.argv[2] === 'wasi-child') {
'wasi-child',
options.test,
sandbox,
sandboxedTmp,
], opts);
console.log(child.stderr.toString());
assert.strictEqual(child.status, 0);
@@ -75,6 +79,7 @@ if (process.argv[2] === 'wasi-child') {
runWASI({ test: 'create_symlink', stdout: 'hello from input.txt' });
runWASI({ test: 'follow_symlink', stdout: 'hello from input.txt' });
runWASI({ test: 'link' });
runWASI({ test: 'symlink_escape' });
runWASI({ test: 'symlink_loop' });
}
-1
View File
@@ -78,7 +78,6 @@ if (process.argv[2] === 'wasi-child') {
runWASI({ test: 'getrusage' });
}
runWASI({ test: 'gettimeofday' });
runWASI({ test: 'link' });
runWASI({ test: 'main_args' });
runWASI({ test: 'notdir' });
runWASI({ test: 'poll' });