-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbmap-writer-test.sh
executable file
·123 lines (96 loc) · 3.87 KB
/
bmap-writer-test.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash -e
# This script tests the bmap-writer tool
export PATH=$PWD:$PATH
if [ ! -f test.img ]; then
echo "## Create a file with random data"
dd if=/dev/urandom of=test.img bs=1M count=10 > /dev/null 2>&1
dd if=/dev/urandom of=test.img bs=1M count=2 seek=12 conv=notrunc > /dev/null 2>&1
dd if=/dev/urandom of=test.img bs=1M count=5 seek=16 conv=notrunc > /dev/null 2>&1
dd if=/dev/urandom of=test.img bs=4k count=1 seek=131072 conv=notrunc > /dev/null 2>&1
dd if=/dev/zero of=test.img bs=1M count=5 seek=540 conv=notrunc > /dev/null 2>&1
dd if=/dev/urandom of=test.img bs=1M count=3 seek=540 conv=notrunc > /dev/null 2>&1
fi
if [ ! -f test.img.tar ]; then
echo "## Enclose the file inside tar"
tar -cf test.img.tar test.img
fi
if [ ! -f test.img.tar.gz ]; then
echo "## Enclose the file inside tar.gz"
tar -czf test.img.tar.gz test.img
fi
if [ ! -f test.img.bz2 ]; then
echo "## Compress the file with bzip2"
bzip2 -f -k -c test.img > test.img.bz2
fi
if [ ! -f test.img.gz ]; then
echo "## Compress the file with gzip"
gzip -9 test.img -c > test.img.gz
fi
if [ ! -f test.img.lz4 ]; then
echo "## Compress the file with lz4"
lz4 -f -k -c test.img > test.img.lz4
fi
if [ ! -f test.img.lzo ]; then
echo "## Compress the file with lzo"
lzop -f -k -c test.img > test.img.lzo
fi
if [ ! -f test.img.xz ]; then
echo "## Compress the file with xz"
xz -z test.img -c > test.img.xz
fi
if [ ! -f test.img.zst ]; then
echo "## Compress the file with zstd"
zstd -f -k -c test.img > test.img.zst
fi
if [ ! -f test.img.bmap ] ; then
echo "## Create a bmap file"
bmaptool create test.img -o test.img.bmap
fi
echo "## Write the file with bmaptool as reference"
bmaptool copy test.img test.img.out
echo "## Write the file with bmap-writer"
bmap-writer test.img test.img.bmap test.none.img.out
cmp test.img.out test.none.img.out
echo "## Write the file with bmap-writer and tar"
bmap-writer test.img.tar test.img.bmap test.tar.img.out
cmp test.img.out test.tar.img.out
echo "## Write the file with bmap-writer and tar+gzip"
bmap-writer test.img.tar.gz test.img.bmap test.tar.gz.img.out
cmp test.img.out test.tar.gz.img.out
echo "## Write the file with bmap-writer and bzip2"
bmap-writer test.img.bz2 test.img.bmap test.bz2.img.out
cmp test.img.out test.bz2.img.out
echo "## Write the file with bmap-writer and gzip"
bmap-writer test.img.gz test.img.bmap test.gz.img.out
cmp test.img.out test.gz.img.out
echo "## Write the file with bmap-writer and lz4"
bmap-writer test.img.lz4 test.img.bmap test.lz4.img.out
cmp test.img.out test.lz4.img.out
echo "## Write the file with bmap-writer and lzo"
bmap-writer test.img.lzo test.img.bmap test.lzo.img.out
cmp test.img.out test.lzo.img.out
echo "## Write the file with bmap-writer and xz"
bmap-writer test.img.xz test.img.bmap test.xz.img.out
cmp test.img.out test.xz.img.out
echo "## Write the file with bmap-writer and external xz (pipe mode)"
xzcat test.img.xz | bmap-writer - test.img.bmap test2.xz.img.out
cmp test.img.out test2.xz.img.out
echo "## Write the file with bmap-writer and zstd"
bmap-writer test.img.zst test.img.bmap test.zst.img.out
cmp test.img.out test.zst.img.out
echo "## Write the file with bmap-writer and zstd"
bmap-writer test.img.zst test2.zst.img.out
cmp test.img.out test2.zst.img.out
echo "## Write the file with bmap-writer and zstd (skip checksum)"
bmap-writer -n test.img.zst test3.zst.img.out
cmp test.img.out test3.zst.img.out
echo "## Write the file with bmap-writer and zstd (pipe mode)"
cat test.img.zst | bmap-writer - test.img.bmap test4.zst.img.out
cmp test.img.out test4.zst.img.out
echo "## Write the file with bmap-writer and zstd from HTTP server"
python3 -m http.server -d $(pwd) -b 127.0.0.1 8987 &
SERVER_PID=$!
sleep 2
bmap-writer-stream.sh http://127.0.0.1:8987/test.img.zst test5.zst.img.out
cmp test.img.out test5.zst.img.out
kill $SERVER_PID