From 5c5aea99a57d07c1d0e0ea471b62acf2852526c7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 30 Dec 2010 08:32:20 +0000 Subject: t0022: fix up broken/incomplete tests Tests for checking the Content-Range were totally broken, but fortunately the code itself works. --- t/t0022-copy_stream-byte-range.sh | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/t/t0022-copy_stream-byte-range.sh b/t/t0022-copy_stream-byte-range.sh index dd71893..0b14ee2 100755 --- a/t/t0022-copy_stream-byte-range.sh +++ b/t/t0022-copy_stream-byte-range.sh @@ -41,16 +41,21 @@ t_begin "setup and startup" && { check_content_range () { # Content-Range: bytes #{offset}-#{offset+count-1}/#{clen} - awk -F/ -v E=0 -v size=$random_blob_size ' - $2 == size && /^< Content-Range: bytes [0-9]+-[0-9]+\// { - split($1, a, /-/); - if (a[1] < size) { - E = 0; - exit(0); - } - } - END { exit(E) } - ' < $err + d='\([0-9]\+\)' + start= end= size= + eval $(< $err sed -n -e \ + "s/^< Content-Range: bytes $d-$d\/$d"'.*$/start=\1 end=\2 size=\3/p') + test -n "$start" + test -n "$end" + test -n "$size" + + # ensure we didn't screw up the sed invocation + expect="< Content-Range: bytes $start-$end/$size" + test x"$(grep -F "$expect" $err)" = x"$(grep '^< Content-Range:' $err)" + + test $start -le $end + test $end -lt $size + grep 'Range:' $err } t_begin "read random blob sha1s" && { @@ -113,19 +118,19 @@ t_begin "no fence post errors" && { } t_begin "head range matches" && { - sha1="$(curl -sSfv $range_head $url | rsha1)" + sha1="$(curl -sSfv 2>$err $range_head $url | rsha1)" check_content_range test x"$sha1_head" = x"$sha1" } t_begin "tail range matches" && { - sha1="$(curl -sSf $range_tail $url | rsha1)" + sha1="$(curl -sSfv 2>$err $range_tail $url | rsha1)" check_content_range test x"$sha1_tail" = x"$sha1" } t_begin "mid range matches" && { - sha1="$(curl -sSf $range_mid $url | rsha1)" + sha1="$(curl -sSfv 2>$err $range_mid $url | rsha1)" check_content_range test x"$sha1_mid" = x"$sha1" } -- cgit v1.2.3-24-ge0c7