summaryrefslogtreecommitdiff
path: root/tests/cantrbry.sh.in
blob: 1ef84e6abac4138cb0223afdab82cca920bde23c (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
#!/bin/sh

set -e

CORPUS="@abs_top_srcdir@/tests/corpus/cantrbry.tar.xz"
SHA512FILE="@abs_top_srcdir@/tests/corpus/cantrbry.sha512"
TAR2SQFS="@abs_top_builddir@/tar2sqfs"

if [ ! -f "$TAR2SQFS" -a -f "${TAR2SQFS}.exe" ]; then
	TAR2SQFS="${TAR2SQFS}.exe"
fi

COMPRESSORS=$("$TAR2SQFS" --help | grep $'\t' | sed 's/ (default)//' | \
	      tr -d '\011' | sort | uniq | sed '/uncompressed/d' | \
	      sed '/bzip2/d' | sed '/zstd/d' | sed '/lz4/d')

for size in 4k 8k 16k 32k 64k 128k 256k 512k 1M; do
	for cmp in $COMPRESSORS; do
		for threads in 1 2 3 4; do
			name="cantrbry_${cmp}_${size}_${threads}.sqfs"

			xzcat "$CORPUS" | \
				"$TAR2SQFS" -q -c "$cmp" -b "$size" \
					    -j "$threads" --defaults mtime=0 \
					    "$name"

			name="cantrbry_${cmp}_${size}_${threads}_T.sqfs"

			xzcat "$CORPUS" | \
				"$TAR2SQFS" -qT -c "$cmp" -b "$size" \
					    -j "$threads" --defaults mtime=0 \
					    "$name"
		done

		# check that the ones with > 1 thread are identical,
		# then remove them.
		for threads in 2 3 4; do
			name="cantrbry_${cmp}_${size}_${threads}.sqfs"
			ref="cantrbry_${cmp}_${size}_1.sqfs"
			diff "$name" "$ref"
			rm "$name"

			name="cantrbry_${cmp}_${size}_${threads}_T.sqfs"
			ref="cantrbry_${cmp}_${size}_1_T.sqfs"
			diff "$name" "$ref"
			rm "$name"
		done
	done
done

sha512sum --ignore-missing -c "$SHA512FILE"
rm cantrbry_*.sqfs