summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2010-10-16 21:26:47 +0200
committerDenys Vlasenko2010-10-16 21:26:47 +0200
commite8ee86250d78b7a9c59699aca597f392c1593225 (patch)
tree16e3bb1de014ee57bfcc8f1226c98e8f1180a99c
parentbcccad35318004922cc04487e1df4eade4545966 (diff)
downloadbusybox-e8ee86250d78b7a9c59699aca597f392c1593225.zip
busybox-e8ee86250d78b7a9c59699aca597f392c1593225.tar.gz
testsuite: add tests for {ms5,shaN}sum
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-xtestsuite/gunzip.tests2
-rwxr-xr-xtestsuite/md5sum.tests46
-rwxr-xr-xtestsuite/sha1sum.tests3
-rwxr-xr-xtestsuite/sha256sum.tests3
-rwxr-xr-xtestsuite/sha512sum.tests3
5 files changed, 56 insertions, 1 deletions
diff --git a/testsuite/gunzip.tests b/testsuite/gunzip.tests
index d781004..68c0755 100755
--- a/testsuite/gunzip.tests
+++ b/testsuite/gunzip.tests
@@ -1,3 +1,3 @@
#!/bin/sh
-. bunzip2.tests
+. ./bunzip2.tests
diff --git a/testsuite/md5sum.tests b/testsuite/md5sum.tests
new file mode 100755
index 0000000..5bbdb3b
--- /dev/null
+++ b/testsuite/md5sum.tests
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Used by {ms5,shaN}sum
+
+# We pipe texts 0...999 bytes long, {md5,shaN}sum them,
+# then {md5,shaN}sum the resulting list.
+# Then we compare the result with expected result.
+#
+# Here are the expected results:
+# efe30c482e0b687e0cca0612f42ca29b
+# d41337e834377140ae7f98460d71d908598ef04f
+# 8e1d3ed57ebc130f0f72508446559eeae06451ae6d61b1e8ce46370cfb8963c3
+# fe413e0f177324d1353893ca0772ceba83fd41512ba63895a0eebb703ef9feac2fb4e92b2cb430b3bda41b46b0cb4ea8307190a5cc795157cfb680a9cd635d0f
+
+if ! test "$1"; then
+ set -- md5sum efe30c482e0b687e0cca0612f42ca29b
+fi
+
+sum="$1"
+expected="$2"
+
+mkdir testdir 2>/dev/null
+
+result=`(
+cd testdir || { echo "cannot cd testdir!" >&2; exit 1; }
+
+text="The quick brown fox jumps over the lazy dog"
+
+n=0
+while test $n -le 999; do
+ yes "$text" | head -c $n | "$sum"
+ : $((n++))
+done | "$sum"
+
+)`
+
+rm -rf testdir
+
+FAILCOUNT=0
+
+if test x"$result" = x"$expected -"; then
+ echo "PASS: $sum"
+ exit 0
+fi
+
+echo "FAIL: $sum (r:$result exp:$expected)"
+exit 1
diff --git a/testsuite/sha1sum.tests b/testsuite/sha1sum.tests
new file mode 100755
index 0000000..a968fa8
--- /dev/null
+++ b/testsuite/sha1sum.tests
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+. ./md5sum.tests sha1sum d41337e834377140ae7f98460d71d908598ef04f
diff --git a/testsuite/sha256sum.tests b/testsuite/sha256sum.tests
new file mode 100755
index 0000000..d2dd78f
--- /dev/null
+++ b/testsuite/sha256sum.tests
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+. ./md5sum.tests sha256sum 8e1d3ed57ebc130f0f72508446559eeae06451ae6d61b1e8ce46370cfb8963c3
diff --git a/testsuite/sha512sum.tests b/testsuite/sha512sum.tests
new file mode 100755
index 0000000..3bc7cae
--- /dev/null
+++ b/testsuite/sha512sum.tests
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+. ./md5sum.tests sha512sum fe413e0f177324d1353893ca0772ceba83fd41512ba63895a0eebb703ef9feac2fb4e92b2cb430b3bda41b46b0cb4ea8307190a5cc795157cfb680a9cd635d0f