From b36235131e0b5517fc5070c02c72be01c4b7f1f9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Nov 2009 08:08:18 +0000 Subject: tests: allow use of alternative sha1 implementations sha1sum(1) is only common GNU systems, and it may be installed as gsha1sum on *BSDs. We'll also try using the openssl sha1 implementation, too. And finally, we'll provide our own Ruby sha1sum.rb implementation as a last resort. We go to great lengths to avoid our own Ruby version because we want to avoid putting too much trust in ourselves, our Ruby skills, and even the Ruby implementations. This is especially with regard to our knowledge and correct usage of Ruby 1.9 encoding support. It would actually be *easier* to only use sha1sum.rb and call it a day. We just choose to support SHA1 implementations provided by third parties if possible. Performance is not a factor since sha1sum.rb performance is very close to the C implementations. --- t/test-lib.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't/test-lib.sh') diff --git a/t/test-lib.sh b/t/test-lib.sh index 9e67d1d..d28eaa0 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -134,6 +134,16 @@ rainbows_wait_start () { rainbows_pid=$(cat $pid) } +rsha1 () { + _cmd="$(which sha1sum 2>/dev/null || :)" + test -n "$_cmd" || _cmd="$(which openssl 2>/dev/null || :) sha1" + test "$_cmd" != " sha1" || _cmd="$(which gsha1sum 2>/dev/null || :)" + + # last resort, see comments in sha1sum.rb for reasoning + test -n "$_cmd" || _cmd=sha1sum.rb + expr "$($_cmd < random_blob)" : '\([a-f0-9]\{40\}\)' +} + case $model in Rev) require_check rev Rev::VERSION ;; Revactor) require_check revactor Revactor::VERSION ;; -- cgit v1.2.3-24-ge0c7