summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-07-16 13:14:06 -0400
committerTavian Barnes <tavianator@tavianator.com>2017-07-16 13:14:06 -0400
commitdfa5bbfa84f8177234e8ba46dd5596a8d0e1a0c4 (patch)
treed1ea64fbb507aa2dfdf8ec02cc209ddc4deb04d6
parent0fc17759476ca38f55b479a12d88f8a7614b7a3b (diff)
downloadbfs-dfa5bbfa84f8177234e8ba46dd5596a8d0e1a0c4.tar.xz
tests.sh: Close extraneous fds for tests that depend on ulimit
-rwxr-xr-xtests.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests.sh b/tests.sh
index b150046..9f95117 100755
--- a/tests.sh
+++ b/tests.sh
@@ -433,6 +433,19 @@ function bfs_diff() {
fi
}
+function closefrom() {
+ for fd in /dev/fd/*; do
+ if [ ! -e "$fd" ]; then
+ continue
+ fi
+
+ fd="${fd##*/}"
+ if [ "$fd" -gt "$1" ]; then
+ eval "exec ${fd}<&-"
+ fi
+ done
+}
+
cd "$TMP"
# Test cases
@@ -1160,11 +1173,15 @@ function test_colors() {
}
function test_deep() {
+ closefrom 2
+
ulimit -n 8
bfs_diff deep -mindepth 18
}
function test_deep_strict() {
+ closefrom 2
+
# Not even enough fds to keep the root open
ulimit -n 6
bfs_diff deep -mindepth 18