* tests/pr/bounded-memory.sh: New file. * tests/local.mk (all_tests): Add the test. --- tests/local.mk | 1 + tests/pr/bounded-memory.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 tests/pr/bounded-memory.sh
diff --git a/tests/local.mk b/tests/local.mk index 8f58693af..fd484476a 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -277,6 +277,7 @@ all_tests = \ tests/od/od-float.sh \ tests/misc/mktemp.pl \ tests/misc/arch.sh \ + tests/pr/bounded-memory.sh \ tests/pr/pr-tests.pl \ tests/pwd/pwd-option.sh \ tests/chcon/chcon-fail.sh \ diff --git a/tests/pr/bounded-memory.sh b/tests/pr/bounded-memory.sh new file mode 100755 index 000000000..b5225a624 --- /dev/null +++ b/tests/pr/bounded-memory.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Test that 'pr' can work on files larger than the systems memory. + +# Copyright (C) 2025 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ pr + +vm=$(get_min_ulimit_v_ pr < /dev/null) || + skip_ 'failed to determine memory limit' + +timeout 0.5 $SHELL -c \ + "(ulimit -v $(($vm+6000)) \ + && pr < /dev/zero > /dev/null 2>err)" +ret=$? +test -f err || skip_ 'shell ulimit failure' +test $ret = 124 || { + fail=1 + cat err + echo "pr used too much memory" >&2 +} + +Exit $fail -- 2.51.1
