]> xenbits.xensource.com Git - people/aperard/osstest.git/commitdiff
mfi-common: Provide stripy_rand
authorIan Jackson <iwj@xenproject.org>
Fri, 22 Jan 2021 15:09:45 +0000 (15:09 +0000)
committerIan Jackson <iwj@xenproject.org>
Fri, 22 Jan 2021 15:41:14 +0000 (15:41 +0000)
We will use this in a moment.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
mfi-common

index 34b0c116be59e6eee99e37ee23aa28d32d0974d7..35efd2334ea02a5baacc65a0322d2c7377b27899 100644 (file)
@@ -31,6 +31,18 @@ stripy () {
   eval "$out_vn=\"\$out_$out_val\""
 }
 
+stripy_rand () {
+  # feel free to pass not-real values for $job
+  # if desired to perturb the hash, etc.
+  local job="$1"; shift
+  local out_vn="$1"; shift
+  local hash="$( echo "$job $out_vn" | sha256sum )"
+  hash="${hash:0:7}"
+  local ix=$(( (0x$hash * $#) / 0x10000000 + 1 ))
+  out_val="${@:$ix:1}"
+  eval "$out_vn=\"\$out_val\""
+}
+
 branch_wants_migrupgrade_tests () {
   case "$branch" in
     xen-3.*-testing) return 1 ;;