summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d28c8af)
raw | patch | inline | side by side (parent: d28c8af)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 12 Dec 2005 20:28:34 +0000 (12:28 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 12 Dec 2005 20:57:25 +0000 (12:57 -0800) |
This test kicks in only if you built test-delta executable, and
makes sure that the basic delta routine is working properly even
on empty files.
This commit is to make sure we have a test to catch the
breakage. The delitifier code is still broken, which will be
fixed with the next commit.
Signed-off-by: Junio C Hamano <junkio@cox.net>
makes sure that the basic delta routine is working properly even
on empty files.
This commit is to make sure we have a test to catch the
breakage. The delitifier code is still broken, which will be
fixed with the next commit.
Signed-off-by: Junio C Hamano <junkio@cox.net>
t/t0001-delta.sh | [new file with mode: 0755] | patch | blob |
test-delta.c | patch | blob | history |
diff --git a/t/t0001-delta.sh b/t/t0001-delta.sh
--- /dev/null
+++ b/t/t0001-delta.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description='Deltification regression test'
+
+../test-delta 2>/dev/null
+test $? == 127 && {
+ echo "* Skipping test-delta regression test."
+ exit 0
+}
+
+. ./test-lib.sh
+
+>empty
+echo small >small
+echo smallish >smallish
+cat ../../COPYING >large
+sed -e 's/GNU/G.N.U/g' large >largish
+
+test_expect_success 'No regression in deltify code' \
+'
+fail=0
+for src in empty small smallish large largish
+do
+ for dst in empty small smallish large largish
+ do
+ if test-delta -d $src $dst delta-$src-$dst &&
+ test-delta -p $src delta-$src-$dst out-$src-$dst &&
+ cmp $dst out-$src-$dst
+ then
+ echo "* OK ($src->$dst deitify and apply)"
+ else
+ echo "* FAIL ($src->$dst deitify and apply)"
+ fail=1
+ fi
+ done
+done
+case "$fail" in
+0) (exit 0) ;;
+*) (exit $fail) ;;
+esac
+'
+
+test_done
diff --git a/test-delta.c b/test-delta.c
index 1be8ee0c721ec35372fee4e686d9664b143b4345..cc05794ec0b69aa2a05f7d02a412e18c87687047 100644 (file)
--- a/test-delta.c
+++ b/test-delta.c
return 1;
}
from_size = st.st_size;
- from_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (from_size)
+ from_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ else
+ from_buf = "";
if (from_buf == MAP_FAILED) {
perror(argv[2]);
close(fd);
return 1;
}
data_size = st.st_size;
- data_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0);
+
+ if (data_size)
+ data_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ else
+ data_buf = "";
if (data_buf == MAP_FAILED) {
perror(argv[3]);
close(fd);