Skip to content

Commit

Permalink
test: fix WASI link test
Browse files Browse the repository at this point in the history
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: #39485
Fixes: #39484
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
richardlau authored and BethGriggs committed Jul 29, 2021
1 parent 1fb0954 commit 039f64f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion test/wasi/test-wasi-symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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');
Expand All @@ -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);
Expand All @@ -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 change: 0 additions & 1 deletion test/wasi/test-wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down

0 comments on commit 039f64f

Please sign in to comment.