From dfa5bbfa84f8177234e8ba46dd5596a8d0e1a0c4 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 16 Jul 2017 13:14:06 -0400 Subject: tests.sh: Close extraneous fds for tests that depend on ulimit --- tests.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 -- cgit v1.2.3