Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/cli-tests/compression/levels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ datagen > file
# Note: command echoing differs between macos and linux, so it's disabled below
set +v
version_info=$(zstd -V)
# --max needs about 8.5 GB of memory. On Linux, find how much this test can use:
# the physical RAM, or the cgroup (e.g. container) memory limit if it is lower.
mem_kib=
if [ -r /proc/meminfo ]; then
mem_kib=$(awk '$1 == "MemTotal:" { print $2 }' /proc/meminfo)
for limit_file in /sys/fs/cgroup/memory.max /sys/fs/cgroup/memory/memory.limit_in_bytes; do
limit=$(cat "$limit_file" 2>/dev/null) || continue
case "$limit" in
''|*[!0-9]*) ;; # "max": no limit
*) if [ $((limit / 1024)) -lt "$mem_kib" ]; then mem_kib=$((limit / 1024)); fi ;;
esac
done
fi
set -v

# Compress with various levels and ensure that their sizes are ordered
Expand All @@ -19,6 +32,9 @@ zstd -19 file -o file-19.zst -q
if echo "$version_info" | grep -q '32-bit'; then
# skip --max test: not enough address space
cp file-19.zst file-max.zst
elif [ -n "$mem_kib" ] && [ "$mem_kib" -lt 9437184 ]; then
# skip --max test: not enough memory (less than 9 GiB)
cp file-19.zst file-max.zst
else
zstd --max file -o file-max.zst -q
fi
Expand Down
3 changes: 3 additions & 0 deletions tests/cli-tests/compression/levels.sh.stderr.exact
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ zstd -19 file -o file-19.zst -q
if echo "$version_info" | grep -q '32-bit'; then
# skip --max test: not enough address space
cp file-19.zst file-max.zst
elif [ -n "$mem_kib" ] && [ "$mem_kib" -lt 9437184 ]; then
# skip --max test: not enough memory (less than 9 GiB)
cp file-19.zst file-max.zst
else
zstd --max file -o file-max.zst -q
fi
Expand Down