diff options
| author | Rob Landley <rob@landley.net> | 2021-06-01 22:07:25 -0500 | 
|---|---|---|
| committer | Rob Landley <rob@landley.net> | 2021-06-01 22:07:25 -0500 | 
| commit | 5166c7f455d55443b29e7b8e8a0782b18efb1011 (patch) | |
| tree | 9f44c16d773409b87b4beaedc8c6ad220bf9fe71 | |
| parent | e00b4c26553beae06e0a30365cba291921106a48 (diff) | |
| download | toybox-5166c7f455d55443b29e7b8e8a0782b18efb1011.tar.gz | |
Merge sha1sum and sha256sum tests.
| -rwxr-xr-x | tests/sha1sum.test | 72 | ||||
| l---------[-rwxr-xr-x] | tests/sha256sum.test | 47 | 
2 files changed, 27 insertions, 92 deletions
| diff --git a/tests/sha1sum.test b/tests/sha1sum.test index b4d4b753..e3cf2a22 100755 --- a/tests/sha1sum.test +++ b/tests/sha1sum.test @@ -1,57 +1,37 @@  #!/bin/bash  [ -f testing.sh ] && . testing.sh - +echo $CMDNAME  #testing "name" "command" "result" "infile" "stdin"  # These tests are based on RFC3174 which were based on FIPS PUB 180-1 -testing "TEST1" \ -        "sha1sum" \ -        "a9993e364706816aba3e25717850c26c9cd0d89d  -\n" \ -        "" "abc" - -testing "TEST2" \ -        "sha1sum" \ -        "84983e441c3bd26ebaae4aa1f95129e5e54670f1  -\n" \ +if [ "$CMDNAME" == sha1sum ]; then +  ABC=a9993e364706816aba3e25717850c26c9cd0d89d +  ABCLONG=84983e441c3bd26ebaae4aa1f95129e5e54670f1 +  MILNUL=34aa973cd4c4daa4f61eeb2bdbad27316534016f +  DIGITS=dea356a2cddd90c7a7ecedc5ebb563934f460452 +  DEF=589c22335a381f122d129225f5c0ba3056ed5811 +elif [ "$CMDNAME" == sha256sum ]; then +  ABC=ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad +  ABCLONG=248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 +  MILNUL=cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 +  DIGITS=594847328451bdfa85056225462cc1d867d877fb388df0ce35f25ab5562bfbb5 +  DEF=cb8379ac2098aa165029e3938a51da0bcecfc008fd6795f401178647f96c5b34 +fi +testcmd "abc" "" "$ABC  -\n" "" "abc" +testcmd "longer str" "" "$ABCLONG  -\n"\          "" "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" +testing "a million nulls" \ +        'dd if=/dev/zero bs=1000 count=1000 2>/dev/null|tr \\0 a|$CMDNAME' \ +        "$MILNUL  -\n" "" "" -testing "TEST3" \ -        'dd if=/dev/zero bs=1000 count=1000 2>/dev/null | tr \\0 a | sha1sum' \ -        "34aa973cd4c4daa4f61eeb2bdbad27316534016f  -\n" \ -        "" "" - -testing "TEST4" \ -        'for i in `seq 1 10`; do echo -n 0123456701234567012345670123456701234567012345670123456701234567 ; done | sha1sum' \ -        "dea356a2cddd90c7a7ecedc5ebb563934f460452  -\n" \ -        "" "" +testing "digits" 'for i in `seq 1 80`; do echo -n 01234567 ; done | $CMDNAME' \ +        "$DIGITS  -\n" "" "" -echo -n "abc" > file1  echo -n "def" > file2 -testing "sha1sum" \ -        "sha1sum" \ -        "a9993e364706816aba3e25717850c26c9cd0d89d  -\n" \ -        "" "abc" - -testing "-" \ -        "sha1sum -" \ -        "a9993e364706816aba3e25717850c26c9cd0d89d  -\n" \ -        "" "abc" - -testing "file" \ -        "sha1sum file1" \ -        "a9993e364706816aba3e25717850c26c9cd0d89d  file1\n" \ -        "" "" - -testing "file1 file2" \ -        "sha1sum file1 file2" \ -        "a9993e364706816aba3e25717850c26c9cd0d89d  file1\n589c22335a381f122d129225f5c0ba3056ed5811  file2\n" \ -        "" "" - -testing "file1 file2 -" \ -        "sha1sum file1 file2 -" \ -        "a9993e364706816aba3e25717850c26c9cd0d89d  file1\n589c22335a381f122d129225f5c0ba3056ed5811  file2\na9993e364706816aba3e25717850c26c9cd0d89d  -\n" \ -        "" "abc" - -rm -f file1 file2 - +testcmd "file" "input" "$ABC  input\n" "abc" "" +testcmd "file1 file2" "input file2" "$ABC  input\n$DEF  file2\n" "abc" "" +testcmd "file1 file2 -" "input file2 -" "$ABC  input\n$DEF  file2\n$ABC  -\n" \ +        "abc" "abc" +rm -f file2 diff --git a/tests/sha256sum.test b/tests/sha256sum.test index 05c66d60..bc02ebe0 100755..120000 --- a/tests/sha256sum.test +++ b/tests/sha256sum.test @@ -1,46 +1 @@ -#!/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 +sha1sum.test
\ No newline at end of file | 
