Rob Landley | 1a221d9 | 2008-05-17 17:13:26 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | [ -f testing.sh ] && . testing.sh |
| 4 | |
| 5 | # This one's tricky both because echo is a shell builtin (so $PATH is |
| 6 | # irrelevant) and because the "result" field is parsed with echo -e. |
| 7 | # To make it work, "$CMD" is an explicit path to the command being tested, |
| 8 | # so "result" keeps using the shell builtin but we test the one in toybox. |
| 9 | |
Rob Landley | 1a221d9 | 2008-05-17 17:13:26 -0500 | [diff] [blame] | 10 | #testing "name" "command" "result" "infile" "stdin" |
| 11 | |
Rob Landley | aa1a5d2 | 2017-05-11 12:31:43 -0500 | [diff] [blame] | 12 | testcmd "echo" "&& echo yes" "\nyes\n" "" "" |
| 13 | testcmd "1 2 3" "one two three" "one two three\n" "" "" |
| 14 | testcmd "with spaces" "'one two three'" \ |
Rob Landley | 1a221d9 | 2008-05-17 17:13:26 -0500 | [diff] [blame] | 15 | "one two three\n" "" "" |
Rob Landley | aa1a5d2 | 2017-05-11 12:31:43 -0500 | [diff] [blame] | 16 | testcmd "" "-n" "" "" "" |
| 17 | testcmd "" "-n one" "one" "" "" |
| 18 | testcmd "" "one -n" "one -n\n" "" "" |
| 19 | testcmd "-en" "-en 'one\ntwo'" "one\ntwo" "" "" |
| 20 | testcmd "" "--hello" "--hello\n" "" "" |
| 21 | testcmd "-e all" "-e '\a\b\c\f\n\r\t\v\\\0123' | xxd -p" "0708\n" "" "" |
| 22 | testcmd "-e all but \\c" "-e '"'\a\b\f\n\r\t\v\\\0123'"' | xxd -p" \ |
| 23 | "07080c0a0d090b5c530a\n" "" "" |
| 24 | testcmd "-nex hello" "-nex hello" "-nex hello\n" "" "" |
Elie De Brauwer | ef3e528 | 2012-02-11 14:58:50 +0100 | [diff] [blame] | 25 | |
| 26 | # Octal formatting tests |
Rob Landley | aa1a5d2 | 2017-05-11 12:31:43 -0500 | [diff] [blame] | 27 | testcmd "-e octal values" \ |
| 28 | "-ne '\01234 \0060 \060 \0130\0131\0132 \077\012'" \ |
Elie De Brauwer | ef3e528 | 2012-02-11 14:58:50 +0100 | [diff] [blame] | 29 | "S4 0 0 XYZ ?\n" "" "" |
| 30 | |
| 31 | # Hexadecimal value tests |
Rob Landley | aa1a5d2 | 2017-05-11 12:31:43 -0500 | [diff] [blame] | 32 | testcmd "-e hexadecimal values" \ |
| 33 | "-ne '\x534 \x30 \x58\x59\x5a \x3F\x0A'"\ |
Elie De Brauwer | ef3e528 | 2012-02-11 14:58:50 +0100 | [diff] [blame] | 34 | "S4 0 XYZ ?\n" "" "" |
Rob Landley | 7339560 | 2012-03-02 08:27:50 -0600 | [diff] [blame] | 35 | |
Rob Landley | aa1a5d2 | 2017-05-11 12:31:43 -0500 | [diff] [blame] | 36 | testcmd "-e \p" "-e '\\p'" "\\p\n" "" "" |