summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xt/t0000-basic.sh11
-rw-r--r--t/test-lib-functions.sh12
2 files changed, 22 insertions, 1 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 2ff176cd5d..2599d026a2 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -928,6 +928,17 @@ test_expect_success 'test_oid can look up data for SHA-256' '
test "$hexsz" -eq 64
'
+test_expect_success 'test_oid can look up data for a specified algorithm' '
+ rawsz="$(test_oid --hash=sha1 rawsz)" &&
+ hexsz="$(test_oid --hash=sha1 hexsz)" &&
+ test "$rawsz" -eq 20 &&
+ test "$hexsz" -eq 40 &&
+ rawsz="$(test_oid --hash=sha256 rawsz)" &&
+ hexsz="$(test_oid --hash=sha256 hexsz)" &&
+ test "$rawsz" -eq 32 &&
+ test "$hexsz" -eq 64
+'
+
test_expect_success 'test_bool_env' '
(
sane_unset envvar &&
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 3103be8a32..2608e80f11 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1468,7 +1468,17 @@ test_oid_cache () {
# Look up a per-hash value based on a key ($1). The value must have been loaded
# by test_oid_init or test_oid_cache.
test_oid () {
- local var="test_oid_${test_hash_algo}_$1" &&
+ local algo="${test_hash_algo}" &&
+
+ case "$1" in
+ --hash=*)
+ algo="${1#--hash=}" &&
+ shift;;
+ *)
+ ;;
+ esac &&
+
+ local var="test_oid_${algo}_$1" &&
# If the variable is unset, we must be missing an entry for this
# key-hash pair, so exit with an error.