From 6c3b4a4d8e2a192e23e81b3d52438bfa3c744be7 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Thu, 22 Jul 2021 08:11:57 -0400 Subject: [PATCH] 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. --- test/wasi/test-wasi-symlinks.js | 7 ++++++- test/wasi/test-wasi.js | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/wasi/test-wasi-symlinks.js b/test/wasi/test-wasi-symlinks.js index 7dd9ae746b0886..1389707671adcb 100644 --- a/test/wasi/test-wasi-symlinks.js +++ b/test/wasi/test-wasi-symlinks.js @@ -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' }); } diff --git a/test/wasi/test-wasi.js b/test/wasi/test-wasi.js index 26002a7e5536ed..8d99a91b4af570 100644 --- a/test/wasi/test-wasi.js +++ b/test/wasi/test-wasi.js @@ -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' });