diff options
Diffstat (limited to 'tests/sha256sum.test')
-rwxr-xr-x | tests/sha256sum.test | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/sha256sum.test b/tests/sha256sum.test new file mode 100755 index 00000000..05c66d60 --- /dev/null +++ b/tests/sha256sum.test @@ -0,0 +1,46 @@ +#!/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 + +testcmd "abc" "" \ + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad -\n"\ + "" "abc" + +testcmd "longer str" "" \ + "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 -\n"\ + "" "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" + +testing "a million nulls" \ + 'dd if=/dev/zero bs=1000 count=1000 2>/dev/null|tr \\0 a|sha256sum' \ + "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 -\n"\ + "" "" + +testing "bunch of digits" \ + 'for i in `seq 1 10`; do echo -n 0123456701234567012345670123456701234567012345670123456701234567 ; done | sha256sum' \ + "594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5 -\n"\ + "" "" + +echo -n "def" > file2 +testcmd "-" "-" \ + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad -\n"\ + "" "abc" + +testcmd "file" "input" \ + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad input\n" \ + "abc" "" + +testcmd "file1 file2" \ + "input file2" \ + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad input\ncb8379ac2098aa165029e3938a51da0bcecfc008fd6795f401178647f96c5b34 file2\n" \ + "abc" "" + +testcmd "file1 file2 -" \ + "input file2 -" \ + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad input\ncb8379ac2098aa165029e3938a51da0bcecfc008fd6795f401178647f96c5b34 file2\nba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad -\n" \ + "abc" "abc" + +rm -f file2 |