Skip to content

Commit

Permalink
lib.fileset: Don't use ulimit for testing tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil committed Oct 4, 2023
1 parent 692b752 commit 5b4e53a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/fileset/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -689,18 +689,23 @@ rm -rf -- *
# `(all files in directory)` should only be used if there's at least one file (otherwise it would be `(empty)`)
# and this should be determined without doing a full search
#
# Create a 100 level deep path, which would cause a stack overflow with the below limit
# if recursed into to figure out if the current directory is empty
mkdir -p "b/$(seq -s/ 100)"
# But that can be avoided by short-circuiting if the file a (here intentionally ordered before b) is checked first.
# a is intentionally ordered first here in order to allow triggering the short-circuit behavior
# We then check that b is not read
# In a more realistic scenario, some directories might need to be recursed into,
# but a file would be quickly found to trigger the short-circuit.
touch a
(
# Locally limit the stack to 100 * 1024 bytes, this would cause a stack overflow if the short-circuiting isn't implemented
ulimit -s 100
mkdir b
# We don't have lambda's in bash unfortunately,
# so we just define a function instead and then pass its name
# shellcheck disable=SC2317
run() {
# This shouldn't read b/
expectTrace './.' "$work"' (all files in directory)'
)
# Remove all files immediately after, triggering delete_self events for all of them
rmdir b
}
# Runs the function while checking that b isn't read
withFileMonitor run b
rm -rf -- *

# Partially included directories trace entries as they are evaluated
Expand Down

0 comments on commit 5b4e53a

Please sign in to comment.