t0013: add a basic sha1 collision detection test

We don't actually have a Git-object collision, so the best we can do is to run one of the shattered PDFs through test-sha1. This should trigger the collision check and die. In a sense this isn't really checking anything that the upstream sha1collisiondetection project doesn't cover already. But it at least makes sure that our build correctly uses the library. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 16, 2017 at 18:09 UTC f5f5e7f06c210e833632c8f4cb907d0af581f473
3 files changed +20
Makefile
+1
@@ -2236,6 +2236,7 @@ GIT-BUILD-OPTIONS: FORCE
2236 @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@+
2237 @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
2238 @echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
2239 + @echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2240 ifdef TEST_OUTPUT_DIRECTORY
2241 @echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
2242 endif
t/t0013-sha1dc.sh new
+19
@@ -0,0 +1,19 @@
1 +#!/bin/sh
2 +
3 +test_description='test sha1 collision detection'
4 +. ./test-lib.sh
5 +TEST_DATA="$TEST_DIRECTORY/t0013"
6 +
7 +if test -z "$DC_SHA1"
8 +then
9 + skip_all='skipping sha1 collision tests, DC_SHA1 not set'
10 + test_done
11 +fi
12 +
13 +test_expect_success 'test-sha1 detects shattered pdf' '
14 + test_must_fail test-sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
15 + test_i18ngrep collision err &&
16 + grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err
17 +'
18 +
19 +test_done
t/t0013/shattered-1.pdf
Binary files /dev/null and b/t/t0013/shattered-1.pdf differ