Rob Landley | 4d904aa | 2012-11-28 22:56:16 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | [ -f testing.sh ] && . testing.sh |
| 4 | |
| 5 | #testing "name" "command" "result" "infile" "stdin" |
| 6 | |
| 7 | # These tests are from RFC 1321 appendix 5, reshuffled slightly to test |
| 8 | # varying argument numbers |
| 9 | |
Rob Landley | 336c44a | 2016-03-02 15:20:04 -0600 | [diff] [blame] | 10 | testing "''" "md5sum" "d41d8cd98f00b204e9800998ecf8427e -\n" "" "" |
| 11 | testing "infile" "md5sum input" \ |
Rob Landley | 4d904aa | 2012-11-28 22:56:16 -0600 | [diff] [blame] | 12 | "0cc175b9c0f1b6a831c399e269772661 input\n" "a" "" |
Rob Landley | 336c44a | 2016-03-02 15:20:04 -0600 | [diff] [blame] | 13 | testing "two files" "md5sum - input" \ |
Rob Landley | 4d904aa | 2012-11-28 22:56:16 -0600 | [diff] [blame] | 14 | "900150983cd24fb0d6963f7d28e17f72 -\nf96b697d7cb7938d525a2f31aaf161d0 input\n" \ |
| 15 | "message digest" "abc" |
Rob Landley | 336c44a | 2016-03-02 15:20:04 -0600 | [diff] [blame] | 16 | testing "4" "md5sum" "c3fcd3d76192e4007dfb496cca67e13b -\n" \ |
Rob Landley | 4d904aa | 2012-11-28 22:56:16 -0600 | [diff] [blame] | 17 | "" "abcdefghijklmnopqrstuvwxyz" |
Rob Landley | 336c44a | 2016-03-02 15:20:04 -0600 | [diff] [blame] | 18 | testing "5" "md5sum" "d174ab98d277d9f5a5611c2c9f419d9f -\n" \ |
Rob Landley | 4d904aa | 2012-11-28 22:56:16 -0600 | [diff] [blame] | 19 | "" "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" |
Rob Landley | 336c44a | 2016-03-02 15:20:04 -0600 | [diff] [blame] | 20 | testing "6" "md5sum" "57edf4a22be3c955ac49da2e2107b67a -\n" \ |
Rob Landley | 4d904aa | 2012-11-28 22:56:16 -0600 | [diff] [blame] | 21 | "" "12345678901234567890123456789012345678901234567890123456789012345678901234567890" |
| 22 | |
Rob Landley | c06ed8d | 2016-07-14 16:53:33 -0500 | [diff] [blame] | 23 | echo -n "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" > "te st" |
| 24 | touch empty |
| 25 | testing "-c spaces" "md5sum -c input || echo ok" \ |
| 26 | "te st: OK\nempty: FAILED\n-: OK\nok\n" \ |
| 27 | "$(printf "d174ab98d277d9f5a5611c2c9f419d9f te st\n12345678901234567890123456789012 empty\nd41d8cd98f00b204e9800998ecf8427e -\n")" "" |
| 28 | rm "te st" empty |
| 29 | |
| 30 | testing "-c nolines" "md5sum -c input 2>/dev/null || echo ok" "ok\n" "" "" |