diff --git a/tests/misc/cksum-raw.sh b/tests/misc/cksum-raw.sh
index de27732f0..0f50c78b6 100755
--- a/tests/misc/cksum-raw.sh
+++ b/tests/misc/cksum-raw.sh
@@ -38,14 +38,18 @@ date > file.in || framework_failure_
 while read algo type; do
   # Binary converted back to text
   cksum --raw --algorithm $algo file.in > digest.bin || fail=1
+  d=digest.bin.txt
   od --endian=big -An -w1024 -t$type < digest.bin | tr -d ' ' \
-    > digest.bin.txt || framework_failure_
+    > $d || framework_failure_
+
+  # Pad the bsd checksum with leading 0's, if needed.
+  case $algo in bsd) n=$(cat $d); printf '%05d\n' "$n" > $d ;; esac

   # Standard text output
   cksum --untagged --algorithm $algo < file.in | cut -d ' ' -f1 \
     > digest.txt || fail=1

-  compare digest.txt digest.bin.txt || fail=1
+  compare digest.txt $d || fail=1
 done < digest_types

 # Ensure --base64 and --raw not used together
