MCPcopy Index your code
hub / github.com/nodejs/node / test_cyclic_link_protection

Function test_cyclic_link_protection

test/parallel/test-fs-realpath.js:222–249  ·  view source on GitHub ↗
(realpath, realpathSync, callback)

Source from the content-addressed store, hash-verified

220}
221
222function test_cyclic_link_protection(realpath, realpathSync, callback) {
223 console.log('test_cyclic_link_protection');
224 if (skipSymlinks) {
225 common.printSkipMessage('symlink test (no privs)');
226 return callback();
227 }
228 const entry = path.join(tmpDir, '/cycles/realpath-3a');
229 [
230 [entry, '../cycles/realpath-3b'],
231 [path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'],
232 [path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a'],
233 ].forEach(function(t) {
234 try { fs.unlinkSync(t[0]); } catch {
235 // Continue regardless of error.
236 }
237 fs.symlinkSync(t[1], t[0], 'dir');
238 unlink.push(t[0]);
239 });
240 assert.throws(() => {
241 realpathSync(entry);
242 }, { code: 'ELOOP', name: 'Error' });
243 asynctest(
244 realpath, [entry], callback, common.mustCall(function(err, result) {
245 assert.strictEqual(err.path, entry);
246 assert.strictEqual(result, undefined);
247 return true;
248 }));
249}
250
251function test_cyclic_link_overprotection(realpath, realpathSync, callback) {
252 console.log('test_cyclic_link_overprotection');

Callers

nothing calls this directly

Calls 9

asynctestFunction · 0.85
callbackFunction · 0.70
forEachMethod · 0.65
realpathSyncFunction · 0.50
logMethod · 0.45
joinMethod · 0.45
unlinkSyncMethod · 0.45
symlinkSyncMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…