summaryrefslogtreecommitdiff
path: root/test/real_syspatch_test/test.sh
blob: 5188029d7db95c58723f2ee450f3c5e98f7d6402 (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
#! /bin/sh

rm temp.img
rm to.img
rm from.img
rm *patch*

cp from.orig from.img
cp to.orig to.img

# build the patch
xdelta3 -0 -B 67108864 -e -s from.img to.img a_to_b.patch
/usr/bin/time -v xdelta3 -B 67108864 -d -s from.img a_to_b.patch temp.img
cmp to.img temp.img
if [ $? -ne 0 ]; then
	echo "Couldn't verify patch"
else
	echo "Built patch"
fi

# compress it and verify the compressed patch
xz -zk --check=crc32 a_to_b.patch
mv a_to_b.patch a_to_b.patch.orig
xz -dk a_to_b.patch.xz
cmp a_to_b.patch a_to_b.patch.orig
if [ $? -ne 0 ]; then
	echo "Couldn't verify compression"
fi
rm a_to_b.patch.orig

# run the test
STARTTIME=$(date +%s)
$ANDROID_BUILD_TOP/out/host/linux-x86/bin/syspatch_host from.img a_to_b.patch.xz temp.img
ENDTIME=$(date +%s)
cmp to.img temp.img
if [ $? -ne 0 ]; then
	echo "Different file test failed"
else
	echo "Different file test passed, took $((ENDTIME - STARTTIME)) seconds"
fi
STARTTIME=$(date +%s)
/usr/bin/time -v $ANDROID_BUILD_TOP/out/host/linux-x86/bin/syspatch_host from.img a_to_b.patch.xz from.img
ENDTIME=$(date +%s)
cmp from.img to.img
if [ $? -ne 0 ]; then
	echo "Same file test failed"
else
	echo "Same file test passed, took $((ENDTIME - STARTTIME)) seconds"
fi

rm temp.img
rm to.img
rm from.img
rm *patch*