Skip to content

Commit 1af2543

Browse files
committed
btrfs-progs: tests: add basic compression coverage
Create a source for --rootdir and then use it for mkfs with compression. Try a few levels, nothing special. Signed-off-by: David Sterba <[email protected]>
1 parent 794af7b commit 1af2543

File tree

1 file changed

+56
-0
lines changed
  • tests/mkfs-tests/037-basic-compression

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
# Basic test for mkfs.btrfs --compress --rootdir. Create a dataset and use it
3+
# for filesystem creation with various compression levels.
4+
5+
source "$TEST_TOP/common" || exit
6+
7+
check_prereq mkfs.btrfs
8+
check_prereq btrfs
9+
check_global_prereq du
10+
11+
setup_root_helper
12+
prepare_test_dev
13+
14+
tmp=$(_mktemp_dir mkfs-rootdir)
15+
limit=$((128*1024*1024))
16+
17+
# Create dataset of approximate size 256M so the repeated compression does not take that long
18+
for file in /usr/bin/[gx]*; do
19+
run_check cp -axf --update --no-preserve=ownership,context "$file" "$tmp"
20+
size=$(du -sb "$tmp" | awk '{print $1}')
21+
if [ "$size" -gt "$limit" ]; then
22+
break
23+
fi
24+
done
25+
26+
for file in /usr/lib*/lib[abcdef]*; do
27+
run_check cp -axf --update --no-preserve=ownership,context "$file" "$tmp"
28+
size=$(du -sb "$tmp" | awk '{print $1}')
29+
if [ "$size" -gt "$limit" ]; then
30+
break
31+
fi
32+
done
33+
34+
run_check du -sh "$tmp"
35+
36+
run_test()
37+
{
38+
local comp="$1"
39+
40+
run_check_mkfs_test_dev --rootdir "$tmp" --compress "$comp"
41+
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
42+
43+
run_check_mount_test_dev
44+
run_check du -sh "$TEST_MNT"
45+
run_check_umount_test_dev
46+
}
47+
48+
run_test lzo
49+
run_test zlib
50+
run_test zlib:1
51+
run_test zlib:9
52+
run_test zstd
53+
run_test zstd:1
54+
run_test zstd:15
55+
56+
run_check rm -rf -- "$tmp"

0 commit comments

Comments
 (0)