{"thread":{"id":"2814","subject":"[PATCH 1/2] Add deltifier test.","startedAt":"2005-12-12T20:41:36Z","lastAt":"2005-12-12T20:41:36Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"13526","messageId":"7v4q5ehwu7.fsf@assigned-by-dhcp.cox.net","threadId":"2814","inReplyTo":null,"subject":"[PATCH 1/2] Add deltifier test.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-12T20:41:36Z","receivedAt":"2005-12-12T20:41:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This test kicks in only if you built test-delta executable, and\nmakes sure that the basic delta routine is working properly even\non empty files.\n\nThis commit is to make sure we have a test to catch the\nbreakage.  The delitifier code is still broken, which will be\nfixed with the next commit.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n * This is a more general reproduction recipe for the problem\n   Darrin Thompson reported.  We did not produce delta from or\n   to an empty blob.\n\n t/t0001-delta.sh |   43 +++++++++++++++++++++++++++++++++++++++++++\n test-delta.c     |   11 +++++++++--\n 2 files changed, 52 insertions(+), 2 deletions(-)\n create mode 100755 t/t0001-delta.sh\n\n9cfcbd609c42c08de54733e610846dc6dfd22495\ndiff --git a/t/t0001-delta.sh b/t/t0001-delta.sh\nnew file mode 100755\nindex 0000000..2dd88e5\n--- /dev/null\n+++ b/t/t0001-delta.sh\n@@ -0,0 +1,43 @@\n+#!/bin/sh\n+\n+test_description='Deltification regression test'\n+\n+../test-delta 2>/dev/null\n+test $? == 127 && {\n+\techo \"* Skipping test-delta regression test.\"\n+\texit 0\n+}\n+\n+. ./test-lib.sh\n+\n+>empty\n+echo small >small\n+echo smallish >smallish\n+cat ../../COPYING >large\n+sed -e 's/GNU/G.N.U/g' large >largish\n+\n+test_expect_success 'No regression in deltify code' \\\n+'\n+fail=0\n+for src in empty small smallish large largish\n+do\n+    for dst in empty small smallish large largish\n+    do\n+\tif  test-delta -d $src $dst delta-$src-$dst &&\n+\t    test-delta -p $src delta-$src-$dst out-$src-$dst &&\n+\t    cmp $dst out-$src-$dst\n+\tthen\n+\t    echo \"* OK ($src->$dst deitify and apply)\"\n+\telse\n+\t    echo \"* FAIL ($src->$dst deitify and apply)\"\n+\t    fail=1\n+\tfi\n+    done\n+done\n+case \"$fail\" in\n+0) (exit 0) ;;\n+*) (exit $fail) ;;\n+esac\n+'\n+\n+test_done\ndiff --git a/test-delta.c b/test-delta.c\nindex 1be8ee0..cc05794 100644\n--- a/test-delta.c\n+++ b/test-delta.c\n@@ -38,7 +38,10 @@ int main(int argc, char *argv[])\n \t\treturn 1;\n \t}\n \tfrom_size = st.st_size;\n-\tfrom_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0);\n+\tif (from_size)\n+\t\tfrom_buf = mmap(NULL, from_size, PROT_READ, MAP_PRIVATE, fd, 0);\n+\telse\n+\t\tfrom_buf = \"\";\n \tif (from_buf == MAP_FAILED) {\n \t\tperror(argv[2]);\n \t\tclose(fd);\n@@ -52,7 +55,11 @@ int main(int argc, char *argv[])\n \t\treturn 1;\n \t}\n \tdata_size = st.st_size;\n-\tdata_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0);\n+\n+\tif (data_size)\n+\t\tdata_buf = mmap(NULL, data_size, PROT_READ, MAP_PRIVATE, fd, 0);\n+\telse\n+\t\tdata_buf = \"\";\n \tif (data_buf == MAP_FAILED) {\n \t\tperror(argv[3]);\n \t\tclose(fd);\n-- \n0.99.9.GIT\n"}]}