[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: limits mem usage on potentially expensive test
From: |
Pádraig Brady |
Subject: |
[PATCH] tests: limits mem usage on potentially expensive test |
Date: |
Sat, 3 Aug 2024 14:23:30 +0100 |
* tests/misc/write-errors.sh: Limit mem usage if possible,
as some implementations may use unbounded memory for
the tests cases used here.
---
tests/misc/write-errors.sh | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tests/misc/write-errors.sh b/tests/misc/write-errors.sh
index ad963f23c..728301cd8 100755
--- a/tests/misc/write-errors.sh
+++ b/tests/misc/write-errors.sh
@@ -58,11 +58,21 @@ sort -k 1b,1 > built_programs || framework_failure_
join all_writers built_programs > built_writers || framework_failure_
while read writer; do
- timeout 10 $SHELL -c "$writer > /dev/full"
- test $? = 124 && { fail=1; echo "$writer: failed to exit" >&2; }
+ # Enforce mem usage limits if possible
+ cmd=$(printf '%s\n' "$writer" | cut -d ' ' -f1) || framework_failure_
+ base_mem=$(get_min_ulimit_v_ $cmd --version) \
+ && ulimit="ulimit -v $(($base_mem+8000))" \
+ || ulimit='true'
+ # Check /dev/full handling
+ rm -f full.err || framework_failure_
+ timeout 10 $SHELL -c "($ulimit && $writer 2>full.err >/dev/full)"
+ { test $? = 124 || ! grep 'space' full.err >/dev/null; } &&
+ { fail=1; cat full.err; echo "$writer: failed to exit" >&2; }
+
+ # Check closed pipe handling
rm -f pipe.err || framework_failure_
- timeout 10 $SHELL -c "$writer 2>pipe.err | :"
+ timeout 10 $SHELL -c "($ulimit && $writer 2>pipe.err | :)"
{ test $? != 0 || test -s pipe.err; } &&
{ fail=1; cat pipe.err; echo "$writer: failed to write to closed pipe" >&2;
}
done < built_writers
--
2.45.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] tests: limits mem usage on potentially expensive test,
Pádraig Brady <=