mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
tests: dd: ensure memory exhaustion is handled gracefully
* tests/dd/no-allocate.sh: Ensure we exit 1 upon mem allocation failure. Also check other buffer size edge cases. https://github.com/uutils/coreutils/issues/11436 https://github.com/uutils/coreutils/issues/11580 https://github.com/coreutils/coreutils/pull/235
This commit is contained in:
1 parent
178c48154d
commit
3558839bdd
1 file changed
+10
@@ -25,6 +25,16 @@ vm=$(get_min_ulimit_v_ timeout 10 dd if=f of=f2 status=none) \
|
||||
|| skip_ 'shell lacks ulimit, or ASAN enabled'
|
||||
rm f f2 || framework_failure_
|
||||
|
||||
# Ensure dd exits with 1 if memory exhausted
|
||||
(ulimit -v $vm && returns_ 1 \
|
||||
dd if=/dev/null of=/dev/null bs=$(($SSIZE_MAX-1))) || fail=1
|
||||
# Ensure dd exits with 1 on numeric overflow
|
||||
(ulimit -v $vm && returns_ 1 \
|
||||
dd if=/dev/null of=/dev/null bs=$SIZE_OFLOW) || fail=1
|
||||
# Ensure dd exits with 1 on invalid number
|
||||
(ulimit -v $vm && returns_ 1 \
|
||||
dd if=/dev/null of=/dev/null bs=0) || fail=1
|
||||
|
||||
# count and skip are zero, we don't need to allocate memory
|
||||
(ulimit -v $vm && dd bs=30M count=0) || fail=1
|
||||
(ulimit -v $vm && dd ibs=30M count=0) || fail=1
|
||||
|
||||
Reference in new issue
Block a user