summaryrefslogtreecommitdiffstats
path: root/tests/m_roottar/script
blob: 701e8c834aced00518adedc641c9e2c7a98d2e51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# vim: filetype=sh

test_description="create fs image from tarball"
if ! test -x "$DEBUGFS_EXE"; then
	echo "$test_name: $test_description: skipped (no debugfs)"
	return 0
fi
if [ "$(grep -c 'define HAVE_ARCHIVE_H' ../lib/config.h)" -eq 0 ]; then
	echo "$test_name: skipped (no libarchive)"
	exit 0
fi

OUT="$test_name.log"
EXP="$test_dir/expect"

perl "$test_dir/mktar.pl" \
	| $MKE2FS -q -F -o Linux -T ext4 -O metadata_csum,64bit -E lazy_itable_init=1 -b 1024 -d - "$TMPFILE" 16384 > "$OUT" 2>&1

$DUMPE2FS "$TMPFILE" >> "$OUT" 2>&1
cat > "$TMPFILE.cmd" << 'ENDL'
stat /dev/
stat /dev/console
stat /dev/fd
stat /dev/full
stat /dev/null
stat /dev/ptmx
stat /dev/pts/
stat /dev/random
stat /dev/shm/
stat /dev/stderr
stat /dev/stdin
stat /dev/stdout
stat /dev/tty
stat /dev/urandom
stat /dev/zero
ENDL
$DEBUGFS -f "$TMPFILE.cmd" "$TMPFILE" 2>&1 | grep -E -v "(time|checksum):" >> "$OUT"

$FSCK -f -n "$TMPFILE" >> "$OUT" 2>&1

sed -f "$cmd_dir/filter.sed" -f "$test_dir/output.sed" -e "s;$TMPFILE;test.img;" < "$OUT" > "$OUT.tmp"
mv "$OUT.tmp" "$OUT"

# Do the verification
cmp -s "$OUT" "$EXP"
status=$?

if [ "$status" = 0 ] ; then
	echo "$test_name: $test_description: ok"
	touch "$test_name.ok"
else
	echo "$test_name: $test_description: failed"
	diff $DIFF_OPTS "$EXP" "$OUT" > "$test_name.failed"
fi

rm -rf "$TMPFILE.cmd"
unset OUT EXP