aboutsummaryrefslogtreecommitdiff
path: root/scripts/test/sha1sum.test
diff options
context:
space:
mode:
authorElie De Brauwer <eliedebrauwer@gmail.com>2012-12-08 14:40:17 +0100
committerElie De Brauwer <eliedebrauwer@gmail.com>2012-12-08 14:40:17 +0100
commit2a55ccb8c7948d453e64676116817a30572f71d8 (patch)
treee42a2016f2f846de9765796687683968ad88e811 /scripts/test/sha1sum.test
parent6c5762880c0347d831a01d7b89bb76537bd4b9c2 (diff)
downloadtoybox-2a55ccb8c7948d453e64676116817a30572f71d8.tar.gz
Adding sha1sum tests based on RFC 3174
Diffstat (limited to 'scripts/test/sha1sum.test')
-rw-r--r--scripts/test/sha1sum.test57
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/test/sha1sum.test b/scripts/test/sha1sum.test
new file mode 100644
index 00000000..cd621fd1
--- /dev/null
+++ b/scripts/test/sha1sum.test
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+# These tests are based on RFC3174 which were based on FIPS PUB 180-1
+
+testing "sha1sum TEST1" \
+ "sha1sum" \
+ "a9993e364706816aba3e25717850c26c9cd0d89d -\n" \
+ "" "abc"
+
+testing "sha1sum TEST2" \
+ "sha1sum" \
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1 -\n" \
+ "" "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+
+testing "sha1sum TEST3" \
+ 'dd if=/dev/zero bs=1000 count=1000 2>/dev/null | tr \\0 a | sha1sum' \
+ "34aa973cd4c4daa4f61eeb2bdbad27316534016f -\n" \
+ "" ""
+
+testing "sha1sum TEST4" \
+ 'for i in `seq 1 10`; do echo -n 0123456701234567012345670123456701234567012345670123456701234567 ; done | sha1sum' \
+ "dea356a2cddd90c7a7ecedc5ebb563934f460452 -\n" \
+ "" ""
+
+echo -n "abc" > file1
+echo -n "def" > file2
+testing "sha1sum" \
+ "sha1sum" \
+ "a9993e364706816aba3e25717850c26c9cd0d89d -\n" \
+ "" "abc"
+
+testing "sha1sum -" \
+ "sha1sum -" \
+ "a9993e364706816aba3e25717850c26c9cd0d89d -\n" \
+ "" "abc"
+
+testing "sha1sum file" \
+ "sha1sum file1" \
+ "a9993e364706816aba3e25717850c26c9cd0d89d file1\n" \
+ "" ""
+
+testing "sha1sum file1 file2" \
+ "sha1sum file1 file2" \
+ "a9993e364706816aba3e25717850c26c9cd0d89d file1\n589c22335a381f122d129225f5c0ba3056ed5811 file2\n" \
+ "" ""
+
+testing "sha1sum file1 file2 -" \
+ "sha1sum file1 file2 -" \
+ "a9993e364706816aba3e25717850c26c9cd0d89d file1\n589c22335a381f122d129225f5c0ba3056ed5811 file2\na9993e364706816aba3e25717850c26c9cd0d89d -\n" \
+ "" "abc"
+
+rm -f file1 file2
+