Re: [PATCH v2 13/22] t5313: make test hash independent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"brian m. carlson" <sandals@xxxxxxxxxxxxxxxxxxxx> writes:

> Make this test hash independent by computing the length of the object
> offsets and looking up values which will hash to object IDs with the
> right properties.
>
> Signed-off-by: brian m. carlson <sandals@xxxxxxxxxxxxxxxxxxxx>
> ---
>  t/t5313-pack-bounds-checks.sh | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/t/t5313-pack-bounds-checks.sh b/t/t5313-pack-bounds-checks.sh
> index f1708d415e..8d805f845a 100755
> --- a/t/t5313-pack-bounds-checks.sh
> +++ b/t/t5313-pack-bounds-checks.sh
> @@ -38,16 +38,27 @@ munge () {
>  # for the initial, and another ofs(4*nr) past that for the extended.
>  #
>  ofs_table () {
> -	echo $((4 + 4 + 4*256 + 20*$1 + 4*$1))
> +	echo $((4 + 4 + 4*256 + $(test_oid rawsz)*$1 + 4*$1))
>  }
>  extended_table () {
>  	echo $(($(ofs_table "$1") + 4*$1))
>  }
>  
> +test_expect_success 'setup' '
> +	test_oid_init &&
> +	test_oid_cache <<-EOF
> +	oid000 sha1:1485
> +	oid000 sha256:4222
> +
> +	oidfff sha1:74
> +	oidfff sha256:1350
> +	EOF
> +'
> +
>  test_expect_success 'set up base packfile and variables' '
>  	# the hash of this content starts with ff, which
>  	# makes some later computations much simpler
> -	echo 74 >file &&
> +	echo $(test_oid oidfff) >file &&
>  	git add file &&
>  	git commit -m base &&
>  	git repack -ad &&
> @@ -140,10 +151,10 @@ test_expect_success 'bogus offset inside v2 extended table' '
>  	# an extended table (if the first object were larger than 2^31).
>  	#
>  	# Note that the value is important here. We want $object as
> -	# the second entry in sorted-sha1 order. The sha1 of 1485 starts
> +	# the second entry in sorted-sha1 order. The hash of this object starts

Micronit: "shorted-hash order", no?

>  	# with "000", which sorts before that of $object (which starts
>  	# with "fff").
> -	second=$(echo 1485 | git hash-object -w --stdin) &&
> +	second=$(test_oid oid000 | git hash-object -w --stdin) &&
>  	do_pack "$object $second" --index-version=2 &&
>  
>  	# We have to make extra room for the table, so we cannot



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux