summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGeremy Condra <gcondra@google.com>2013-11-18 17:25:49 -0800
committerGeremy Condra <gcondra@google.com>2013-11-18 17:29:36 -0800
commita87a07926b6c472893a032989a55442bd819223e (patch)
treef555d6bdc558e0ed47607dfaa7582a37457d5019 /test
parent50cf90ead3e4eaa183424759714a450a31931cc2 (diff)
downloadsyspatch-a87a07926b6c472893a032989a55442bd819223e.tar.gz
Initial commit for syspatch, a binary patching tool for large files.
Change-Id: I3519f6b1a40d95d36a0317e14d53bcbfc20eba6e
Diffstat (limited to 'test')
-rwxr-xr-xtest/big_syspatch_test/test.sh54
-rwxr-xr-xtest/real_syspatch_test/test.sh54
-rwxr-xr-xtest/simple_syspatch_test/test.sh46
3 files changed, 154 insertions, 0 deletions
diff --git a/test/big_syspatch_test/test.sh b/test/big_syspatch_test/test.sh
new file mode 100755
index 0000000..a78878f
--- /dev/null
+++ b/test/big_syspatch_test/test.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+
+# initial cleanup
+rm -f a
+rm -f b
+rm -f c
+rm -f a_to_b.patch
+rm -f a_to_b.patch.xz
+
+# build the files
+#./make_test_data.py
+dd if=/dev/urandom of=b bs=1M count=100
+dd if=/dev/full of=a bs=1M count=100
+
+# build the patch
+xdelta3 -0 -B 67108864 -e -s a b a_to_b.patch
+/usr/bin/time -v xdelta3 -B 67108864 -d -s a a_to_b.patch c
+cmp b c
+if [ $? -ne 0 ]; then
+ echo "Couldn't verify patch"
+else
+ echo "Built patch"
+fi
+rm c
+
+# 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 -f a_to_b.patch
+rm -f a_to_b.patch.orig
+
+# run the test
+cp a c
+$ANDROID_BUILD_TOP/out/host/linux-x86/bin/syspatch a a_to_b.patch.xz c
+cmp c b
+if [ $? -ne 0 ]; then
+ echo "Different file test failed"
+fi
+/usr/bin/time -v $ANDROID_BUILD_TOP/out/host/linux-x86/bin/syspatch a a_to_b.patch.xz a
+cmp a b
+if [ $? -ne 0 ]; then
+ echo "Same file test failed"
+fi
+
+# cleanup
+rm -f a
+rm -f b
+rm -f c
+rm -f a_to_b.patch.xz
diff --git a/test/real_syspatch_test/test.sh b/test/real_syspatch_test/test.sh
new file mode 100755
index 0000000..452bd82
--- /dev/null
+++ b/test/real_syspatch_test/test.sh
@@ -0,0 +1,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 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 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*
diff --git a/test/simple_syspatch_test/test.sh b/test/simple_syspatch_test/test.sh
new file mode 100755
index 0000000..08d91f1
--- /dev/null
+++ b/test/simple_syspatch_test/test.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+
+# preemptive cleanup
+rm a
+rm b
+rm a_to_b.patch
+rm a_to_b.patch.orig
+rm a_to_b.patch.xz
+
+# setup the files
+echo "hello world" > a
+echo "Hello, world" > b
+
+# make and verify the patch
+xdelta3 -e -s a b a_to_b.patch
+xdelta3 -d -s a a_to_b.patch c
+cmp b c
+if [ $? -ne 0 ]; then
+ echo "Couldn't verify patch"
+fi
+rm c
+
+# compress it and verify the compressed patch
+xz -zk -9 --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
+rm a_to_b.patch.orig
+
+# run the test
+$ANDROID_BUILD_TOP/out/host/linux-x86/bin/syspatch a a_to_b.patch.xz a
+cmp a b
+if [ $? -ne 0 ]; then
+ echo "Test failed"
+fi
+
+# cleanup
+rm a
+rm b
+rm a_to_b.patch
+rm a_to_b.patch.orig
+rm a_to_b.patch.xz