Skip to content

Commit

Permalink
Merge pull request #256 from michaelolbrich/ext-cleanup
Browse files Browse the repository at this point in the history
tests: ext: use different output files to compare to instead of trying to patch the output
  • Loading branch information
michaelolbrich authored Jun 28, 2024
2 parents 0fc8b3b + 0887e44 commit 68608a3
Show file tree
Hide file tree
Showing 12 changed files with 478 additions and 23 deletions.
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ EXTRA_DIST += \
test/ext2.config \
test/ext2test.0.dump \
test/ext2test.1.dump \
test/ext2test.2.dump \
test/ext2percent.config \
test/ext2test-percent.0.dump \
test/ext2test-percent.1.dump \
test/ext2test-percent.2.dump \
test/ext3.config \
test/ext3test.0.dump \
test/ext3test.1.dump \
test/ext3test.2.dump \
test/ext4.config \
test/ext4test.0.dump \
test/ext4test.1.dump \
test/ext4test.2.dump \
test/f2fs.config \
test/fip.config \
test/fit.its \
Expand Down Expand Up @@ -126,6 +130,9 @@ EXTRA_DIST += \
test/mke2fs.conf \
test/mke2fs.config \
test/mke2fs.0.dump \
test/mke2fs.1.dump \
test/mke2fs.2.dump \
test/mke2fs.3.dump \
test/qemu.config \
test/qemu.qcow.gz \
test/rauc-openssl-ca/ca.cert.pem \
Expand Down
38 changes: 27 additions & 11 deletions test/ext.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ compare_label() {
fi
}

version_leq() {
first="$(printf "${1}\n${2}" | sort -V | head -n1)"
test "${first}" == "${1}"
}

check_ext() {
[ "$verbose" = "t" ] && set -x
# UUID is randomly generated
Expand All @@ -36,24 +41,35 @@ check_ext() {
dumpe2fs "${1}" | grep -v "^\($uuid\|$seed\|$csum1\|$csum2\)" > "dump" &&
# some architectures (including arm64) use unsigned char
sed -i 's/un\(signed_directory_hash\)/\1/' "dump" &&
# fixup for ext3 journal size with old tune2fs
sed -i 's/^\(Journal size: \)1029k$/\11024k/' "dump" &&
# output format changed with some version
sed -i 's/^\( Block bitmap at .*\),\( Inode bitmap.*\)$/\1\n \2/' "dump" &&
# convert to latest dump2fs output
sed -i -e 's/^J\(ournal size:\) /Total j\1/' \
-e 's/^Journal length: \( *\)\(.*\)$/Total journal blocks:\1\2\nMax transaction length: \2\nFast commit length: 0/' \
-e '/^Overhead clusters:/d' \
"dump" &&
if [ "${4}" = "genext2fs" ]; then
if [ "$(genext2fs --version)" = "genext2fs 1.4.1" ]; then
version=0
else
version=1
dumpe2fs_version="$(dumpe2fs -V |& sed -n 's/^dumpe2fs \([^ ]*\) .*/\1/p')"
if version_leq "${dumpe2fs_version}" "1.46.2"; then
# Debian Bullseye
version=1
else
version=2
fi
fi
else
version=0
mke2fs_version="$(mke2fs -V |& sed -n 's/^mke2fs \([^ ]*\) .*/\1/p')"
if version_leq "${mke2fs_version}" "1.45.5"; then
# Ubuntu 20.04
version=0
elif version_leq "${mke2fs_version}" "1.46.5"; then
# Ubuntu 22.04
version=1
elif version_leq "${mke2fs_version}" "1.47.0"; then
# Ubuntu 24.04
version=2
else
# at least 1.47.0
version=3
fi
fi
export TEST_CMP="diff --ignore-space-change -u" &&
test_cmp "${testdir}/${2}.${version}.dump" "dump" &&
e2fsck -nf "${1}" &&
# old versions of debugfs cannot dump '/'
Expand Down
42 changes: 42 additions & 0 deletions test/ext2test-percent.2.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Filesystem volume name: ext2test
Last mounted on: <not available>
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: (none)
Default mount options: (none)
Filesystem state: clean
Errors behavior: Unknown (continue)
Filesystem OS type: Linux
Inode count: 56
Block count: 68
Reserved block count: 3
Free blocks: 22
Free inodes: 5
First block: 1
Block size: 1024
Fragment size: 1024
Blocks per group: 72
Fragments per group: 72
Inodes per group: 56
Inode blocks per group: 7
Filesystem created: Sat Jan 1 00:00:00 2000
Last mount time: n/a
Last write time: Sat Jan 1 00:00:00 2000
Mount count: 0
Maximum mount count: 20
Last checked: Sat Jan 1 00:00:00 2000
Check interval: 0 (<none>)
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128


Group 0: (Blocks 1-67)
Primary superblock at 1, Group descriptors at 2-2
Block bitmap at 3 (+2)
Inode bitmap at 4 (+3)
Inode table at 5-11 (+4)
22 free blocks, 5 free inodes, 18 directories
Free blocks: 46-67
Free inodes: 52-56
42 changes: 42 additions & 0 deletions test/ext2test.2.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Filesystem volume name: ext2test
Last mounted on: <not available>
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: (none)
Default mount options: (none)
Filesystem state: clean
Errors behavior: Unknown (continue)
Filesystem OS type: Linux
Inode count: 256
Block count: 4096
Reserved block count: 204
Free blocks: 4025
Free inodes: 205
First block: 1
Block size: 1024
Fragment size: 1024
Blocks per group: 4096
Fragments per group: 4096
Inodes per group: 256
Inode blocks per group: 32
Filesystem created: Sat Jan 1 00:00:00 2000
Last mount time: n/a
Last write time: Sat Jan 1 00:00:00 2000
Mount count: 0
Maximum mount count: 20
Last checked: Sat Jan 1 00:00:00 2000
Check interval: 0 (<none>)
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128


Group 0: (Blocks 1-4095)
Primary superblock at 1, Group descriptors at 2-2
Block bitmap at 3 (+2)
Inode bitmap at 4 (+3)
Inode table at 5-36 (+4)
4025 free blocks, 205 free inodes, 18 directories
Free blocks: 71-4095
Free inodes: 52-256
6 changes: 2 additions & 4 deletions test/ext3test.0.dump
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ Inode size: 128
Journal inode: 8
Journal backup: inode blocks
Journal features: (none)
Total journal size: 1024k
Total journal blocks: 1024
Max transaction length: 1024
Fast commit length: 0
Journal size: 1024k
Journal length: 1024
Journal sequence: 0x00000001
Journal start: 0

Expand Down
52 changes: 52 additions & 0 deletions test/ext3test.2.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Filesystem volume name: ext3test
Last mounted on: <not available>
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal
Default mount options: (none)
Filesystem state: clean
Errors behavior: Unknown (continue)
Filesystem OS type: Linux
Inode count: 256
Block count: 4096
Reserved block count: 204
Overhead clusters: 1024
Free blocks: 2996
Free inodes: 205
First block: 1
Block size: 1024
Fragment size: 1024
Blocks per group: 4096
Fragments per group: 4096
Inodes per group: 256
Inode blocks per group: 32
Filesystem created: Sat Jan 1 00:00:00 2000
Last mount time: n/a
Last write time: Sat Jan 1 00:00:00 2000
Mount count: 0
Maximum mount count: 20
Last checked: Sat Jan 1 00:00:00 2000
Check interval: 0 (<none>)
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Journal backup: inode blocks
Journal features: (none)
Total journal size: 1024k
Total journal blocks: 1024
Max transaction length: 1024
Fast commit length: 0
Journal sequence: 0x00000001
Journal start: 0


Group 0: (Blocks 1-4095)
Primary superblock at 1, Group descriptors at 2-2
Block bitmap at 3 (+2)
Inode bitmap at 4 (+3)
Inode table at 5-36 (+4)
2996 free blocks, 205 free inodes, 18 directories
Free blocks: 1100-4095
Free inodes: 52-256
6 changes: 2 additions & 4 deletions test/ext4test.0.dump
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Journal features: (none)
Total journal size: 1024k
Total journal blocks: 1024
Max transaction length: 1024
Fast commit length: 0
Journal size: 1024k
Journal length: 1024
Journal sequence: 0x00000001
Journal start: 0

Expand Down
53 changes: 53 additions & 0 deletions test/ext4test.2.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Filesystem volume name: ext4test
Last mounted on: <not available>
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal dir_index extent uninit_bg
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Unknown (continue)
Filesystem OS type: Linux
Inode count: 256
Block count: 4096
Reserved block count: 204
Overhead clusters: 1024
Free blocks: 3001
Free inodes: 205
First block: 1
Block size: 1024
Fragment size: 1024
Blocks per group: 4096
Fragments per group: 4096
Inodes per group: 256
Inode blocks per group: 32
Filesystem created: Sat Jan 1 00:00:00 2000
Last mount time: n/a
Last write time: Sat Jan 1 00:00:00 2000
Mount count: 0
Maximum mount count: 20
Last checked: Sat Jan 1 00:00:00 2000
Check interval: 0 (<none>)
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: half_md4
Journal backup: inode blocks
Journal features: (none)
Total journal size: 1024k
Total journal blocks: 1024
Max transaction length: 1024
Fast commit length: 0
Journal sequence: 0x00000001
Journal start: 0


Primary superblock at 1, Group descriptors at 2-2
Block bitmap at 3 (+2)
Inode bitmap at 4 (+3)
Inode table at 5-36 (+4)
3001 free blocks, 205 free inodes, 18 directories, 205 unused inodes
Free blocks: 1095-4095
Free inodes: 52-256
6 changes: 2 additions & 4 deletions test/mke2fs.0.dump
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ Default directory hash: half_md4
Journal backup: inode blocks
Checksum type: crc32c
Journal features: (none)
Total journal size: 4096k
Total journal blocks: 4096
Max transaction length: 4096
Fast commit length: 0
Journal size: 4096k
Journal length: 4096
Journal sequence: 0x00000001
Journal start: 0

Expand Down
Loading

0 comments on commit 68608a3

Please sign in to comment.