From 387edf547eb09b27ca6d49772eb048d729f09cf4 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 20 Sep 2014 13:09:14 -0500 Subject: Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably. --- tests/echo.test | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 tests/echo.test (limited to 'tests/echo.test') diff --git a/tests/echo.test b/tests/echo.test new file mode 100755 index 00000000..3f562fd8 --- /dev/null +++ b/tests/echo.test @@ -0,0 +1,37 @@ +#!/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" "" "" + +# Octal formatting tests +testing "echo -e octal values" \ + "$CMD -ne '\01234 \0060 \060 \0130\0131\0132 \077\012'" \ + "S4 0 0 XYZ ?\n" "" "" + +# Hexadecimal value tests +testing "echo -e hexadecimal values" \ + "$CMD -ne '\x534 \x30 \x58\x59\x5a \x3F\x0A'"\ + "S4 0 XYZ ?\n" "" "" + +testing "echo -e \p" "$CMD -e '\\p'" "\\p\n" "" "" -- cgit v1.2.3