Skip to content

Commit

Permalink
test: add regex in test_cyclic_link_protection
Browse files Browse the repository at this point in the history
PR-URL: #11622
Backport-PR-URL: #13785
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
clarenced authored and gibfahn committed Jun 19, 2017
1 parent a5b8d1b commit 8032e0a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions test/parallel/test-fs-realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,25 @@ function test_cyclic_link_protection(callback) {
common.skip('symlink test (no privs)');
return runNextTest();
}
const entry = common.tmpDir + '/cycles/realpath-3a';
const entry = path.join(common.tmpDir, '/cycles/realpath-3a');
[
[entry, '../cycles/realpath-3b'],
[common.tmpDir + '/cycles/realpath-3b', '../cycles/realpath-3c'],
[common.tmpDir + '/cycles/realpath-3c', '../cycles/realpath-3a']
[path.join(common.tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
[path.join(common.tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a']
].forEach(function(t) {
try { fs.unlinkSync(t[0]); } catch (e) {}
fs.symlinkSync(t[1], t[0], 'dir');
unlink.push(t[0]);
});
assert.throws(function() { fs.realpathSync(entry); });
asynctest(fs.realpath, [entry], callback, function(err, result) {
assert.ok(err && true);
return true;
});
assert.throws(() => {
fs.realpathSync(entry);
}, /^Error: ELOOP: too many symbolic links encountered, stat /);
asynctest(
fs.realpath, [entry], callback, common.mustCall(function(err, result) {
assert.strictEqual(err.path, entry);
assert.strictEqual(result, undefined);
return true;
}));
}

function test_cyclic_link_overprotection(callback) {
Expand Down

0 comments on commit 8032e0a

Please sign in to comment.