diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:00:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:00:47 +0000 |
commit | 2cb7e0aaedad73b076ea18c6900b0e86c5760d79 (patch) | |
tree | da68ca54bb79f4080079bf0828acda937593a4e1 /test/units/testsuite-56-slowgrowth.sh | |
parent | Initial commit. (diff) | |
download | systemd-2cb7e0aaedad73b076ea18c6900b0e86c5760d79.tar.xz systemd-2cb7e0aaedad73b076ea18c6900b0e86c5760d79.zip |
Adding upstream version 247.3.upstream/247.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | test/units/testsuite-56-slowgrowth.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/units/testsuite-56-slowgrowth.sh b/test/units/testsuite-56-slowgrowth.sh new file mode 100755 index 0000000..ff5a747 --- /dev/null +++ b/test/units/testsuite-56-slowgrowth.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -eu -o pipefail + +PAGE_SIZE=$(getconf PAGE_SIZE) +BLOAT_ITERATION_TARGET=$(( 100 << 20 )) # 100 MB +BLOAT_HOLDER=() +PID="$$" + +function bloat { + local set_size=$(cat "/proc/$PID/statm" | cut -d " " -f2) + local mem_usage=$(( "$set_size" * "$PAGE_SIZE" )) + local target_mem_size=$(( "$mem_usage" + "$1" )) + + BLOAT_HOLDER=() + while [[ "$mem_usage" -lt "$target_mem_size" ]]; do + echo "target $target_mem_size" + echo "mem usage $mem_usage" + BLOAT_HOLDER+=( $(printf "%0.sg" {1..1000000}) ) + set_size=$(cat "/proc/$PID/statm" | cut -d " " -f2) + mem_usage=$(( "$set_size" * "$PAGE_SIZE" )) + done +} + +function run { + local arr=() + + while [[ true ]]; do + bloat "$BLOAT_ITERATION_TARGET" + arr+=( "$BLOAT_HOLDER" ) + sleep 1 + done +} + +run |