Skip to content

Commit 5696bcf

Browse files
richardlautargos
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 c1782ea commit 5696bcf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

test/wasi/test-wasi-symlinks.js

Lines changed: 6 additions & 1 deletion
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');
@@ -67,6 +70,7 @@ if (process.argv[2] === 'wasi-child') {
6770
'wasi-child',
6871
options.test,
6972
sandbox,
73+
sandboxedTmp,
7074
], opts);
7175
console.log(child.stderr.toString());
7276
assert.strictEqual(child.status, 0);
@@ -76,6 +80,7 @@ if (process.argv[2] === 'wasi-child') {
7680

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

test/wasi/test-wasi.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ if (process.argv[2] === 'wasi-child') {
7979
runWASI({ test: 'getrusage' });
8080
}
8181
runWASI({ test: 'gettimeofday' });
82-
runWASI({ test: 'link' });
8382
runWASI({ test: 'main_args' });
8483
runWASI({ test: 'notdir' });
8584
runWASI({ test: 'poll' });

0 commit comments

Comments
 (0)