mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-03 23:37:53 +01:00
test(freeze): cheap link-chain budget test; name the path in the budget reason (#3623)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
1d90c1b0ef
commit
ea56924522
2 files changed
+8
-9
No files matched your search
@@ -319,7 +319,7 @@ _resolve_path() {
|
||||
printf '%s' "$GSTACK_HOOK_PATH"
|
||||
}
|
||||
|
||||
_FREEZE_WHY="a symlink loop, a chain over 40 links, link targets over 8192 characters in all, an unreadable link, or a Windows name that cannot be placed"
|
||||
_FREEZE_WHY="a symlink loop, a chain over 40 links, a path and link targets over 8192 characters in all, an unreadable link, or a Windows name that cannot be placed"
|
||||
FREEZE_DIR_RAW="$FREEZE_DIR"
|
||||
FREEZE_DIR=$(_resolve_path "$FREEZE_DIR_RAW" physical "$FREEZE_DIR_WIN") || _freeze_unresolved "the freeze boundary $FREEZE_DIR_RAW" "$_FREEZE_WHY"
|
||||
# Hosts disagree on '<link>/..': the OS means the target's parent, a lexical
|
||||
|
||||
@@ -1561,15 +1561,14 @@ describe('check-freeze.sh', () => {
|
||||
// of padded links must deny fast instead of running for minutes.
|
||||
test.skipIf(process.platform === 'win32')('a symlink chain whose targets add up past 8192 characters denies quickly', () => {
|
||||
withTree(({ base, home, src, outside }) => {
|
||||
let next = outside;
|
||||
for (let i = 40; i >= 1; i--) {
|
||||
const link = path.join(src, `S${i}`);
|
||||
fs.symlinkSync('.' + '/'.repeat(3990) + path.relative(src, next), link);
|
||||
next = link;
|
||||
}
|
||||
// Each target pads with 'name/..' pairs (few components, so the walk
|
||||
// itself stays cheap) to about 3,800 characters; three hops pass 8192.
|
||||
const pad = ('n'.repeat(250) + '/../').repeat(15);
|
||||
fs.symlinkSync(pad + path.relative(src, outside), path.join(src, 'p3'));
|
||||
fs.symlinkSync(pad + 'p3', path.join(src, 'p2'));
|
||||
fs.symlinkSync(pad + 'p2', path.join(src, 'p1'));
|
||||
const started = Date.now();
|
||||
const decision = decide(src, src + '/S1/' + '/'.repeat(3990) + 'x.ts', home, base);
|
||||
expect(decision).toBe('deny');
|
||||
expect(decide(src, src + '/p1/x.ts', home, base)).toBe('deny');
|
||||
expect(Date.now() - started).toBeLessThan(4000);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user