Skip to content

Commit 039f64f

Browse files
richardlauBethGriggs
authored andcommitted
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: #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>
1 parent 1fb0954 commit 039f64f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

test/wasi/test-wasi-symlinks.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ if (process.argv[2] === 'wasi-child') {
1414
args: [],
1515
env: process.env,
1616
preopens: {
17-
'/sandbox': process.argv[4]
17+
'/sandbox': process.argv[4],
18+
'/tmp': process.argv[5]
1819
}
1920
});
2021
const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
@@ -45,9 +46,11 @@ if (process.argv[2] === 'wasi-child') {
4546
const escapingSymlink = path.join(sandboxedDir, 'outside.txt');
4647
const loopSymlink1 = path.join(sandboxedDir, 'loop1');
4748
const loopSymlink2 = path.join(sandboxedDir, 'loop2');
49+
const sandboxedTmp = path.join(tmpdir.path, 'tmp');
4850

4951
fs.mkdirSync(sandbox);
5052
fs.mkdirSync(sandboxedDir);
53+
fs.mkdirSync(sandboxedTmp);
5154
fs.writeFileSync(sandboxedFile, 'hello from input.txt', 'utf8');
5255
fs.writeFileSync(externalFile, 'this should be inaccessible', 'utf8');
5356
fs.symlinkSync(path.join('.', 'input.txt'), sandboxedSymlink, 'file');
@@ -66,6 +69,7 @@ if (process.argv[2] === 'wasi-child') {
6669
'wasi-child',
6770
options.test,
6871
sandbox,
72+
sandboxedTmp,
6973
], opts);
7074
console.log(child.stderr.toString());
7175
assert.strictEqual(child.status, 0);
@@ -75,6 +79,7 @@ if (process.argv[2] === 'wasi-child') {
7579

7680
runWASI({ test: 'create_symlink', stdout: 'hello from input.txt' });
7781
runWASI({ test: 'follow_symlink', stdout: 'hello from input.txt' });
82+
runWASI({ test: 'link' });
7883
runWASI({ test: 'symlink_escape' });
7984
runWASI({ test: 'symlink_loop' });
8085
}

test/wasi/test-wasi.js

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ if (process.argv[2] === 'wasi-child') {
7878
runWASI({ test: 'getrusage' });
7979
}
8080
runWASI({ test: 'gettimeofday' });
81-
runWASI({ test: 'link' });
8281
runWASI({ test: 'main_args' });
8382
runWASI({ test: 'notdir' });
8483
runWASI({ test: 'poll' });

0 commit comments

Comments
 (0)