blob: 58499640583996cab1f0a6a8496746058717262a [file] [log] [blame]
#!/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 "1 2 3" "$CMD one two three" "one two three\n" "" ""
testing "with spaces" "$CMD 'one two three'" \
"one two three\n" "" ""
testing "-n" "$CMD -n" "" "" ""
testing "-n one" "$CMD -n one" "one" "" ""
testing "one -n" "$CMD one -n" "one -n\n" "" ""
testing "-en" "$CMD -en 'one\ntwo'" "one\ntwo" "" ""
testing "--hello" "$CMD --hello" "--hello\n" "" ""
testing "-e all" "$CMD -e '\a\b\c\f\n\r\t\v\\\0123'" \
"\a\b\c\f\n\r\t\v\\\0123\n" "" ""
testing "-nex hello" "$CMD -nex hello" "-nex hello\n" "" ""
# Octal formatting tests
testing "-e octal values" \
"$CMD -ne '\01234 \0060 \060 \0130\0131\0132 \077\012'" \
"S4 0 0 XYZ ?\n" "" ""
# Hexadecimal value tests
testing "-e hexadecimal values" \
"$CMD -ne '\x534 \x30 \x58\x59\x5a \x3F\x0A'"\
"S4 0 XYZ ?\n" "" ""
testing "-e \p" "$CMD -e '\\p'" "\\p\n" "" ""