diff options
author | Rob Landley <rob@landley.net> | 2008-05-17 17:13:26 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2008-05-17 17:13:26 -0500 |
commit | 1a221d9b4f058d05aa250691c381f0cfeaaeab9e (patch) | |
tree | b85ac9b5c79889e93f3fc9c612ce1524d56c6a5a /scripts/test | |
parent | da5709494710925cf9d35b91ba2690148031b840 (diff) | |
download | toybox-1a221d9b4f058d05aa250691c381f0cfeaaeab9e.tar.gz |
Fix command line option parsing so "echo -xen" actually prints "-xen". Add
echo.test while I'm at it.
Diffstat (limited to 'scripts/test')
-rwxr-xr-x | scripts/test/echo.test | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/test/echo.test b/scripts/test/echo.test new file mode 100755 index 00000000..3eac172f --- /dev/null +++ b/scripts/test/echo.test @@ -0,0 +1,25 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +# This one's tricky both because echo is a shell builtin (so $PATH is +# irrelevant) and because the "result" field is parsed with echo -e. +# To make it work, "$CMD" is an explicit path to the command being tested, +# so "result" keeps using the shell builtin but we test the one in toybox. + +CMD="$(which echo)" + +#testing "name" "command" "result" "infile" "stdin" + +testing "echo" "$CMD && echo yes" "\nyes\n" "" "" +testing "echo 1 2 3" "$CMD one two three" "one two three\n" "" "" +testing "echo with spaces" "$CMD 'one two three'" \ + "one two three\n" "" "" +testing "echo -n" "$CMD -n" "" "" "" +testing "echo -n one" "$CMD -n one" "one" "" "" +testing "echo one -n" "$CMD one -n" "one -n\n" "" "" +testing "echo -en" "$CMD -en 'one\ntwo'" "one\ntwo" "" "" +testing "echo --hello" "$CMD --hello" "--hello\n" "" "" +testing "echo -e all" "$CMD -e '\a\b\c\f\n\r\t\v\\\0123'" \ + "\a\b\c\f\n\r\t\v\\\0123\n" "" "" +testing "echo -nex hello" "$CMD -nex hello" "-nex hello\n" "" "" |