]> granicus.if.org Git - libevent/commitdiff
Fix test.sh on shells without echo -n
authorNick Mathewson <nickm@torproject.org>
Tue, 12 Jan 2010 20:58:36 +0000 (15:58 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 12 Jan 2010 20:58:36 +0000 (15:58 -0500)
Some systems have a version of /bin/sh whose builtin echo doesn't
support the -n option used in test/test.sh.  /bin/echo, however,
usually does.  This patch makes us use /bin/echo for echo -n whenever
it is present.

Also, our use of echo -n really only made sense when suppressing all
test output.  Since test output isn't suppressed when logging to a
file, this pach makes us stop using echo -n when logging to a file.

test/test.sh

index b59c667f94a153e9938416008c631d4a63f1351d..be35f68436792858d5a9781c16b3fa2028997ef0 100755 (executable)
@@ -5,6 +5,14 @@ then
        TEST_OUTPUT_FILE=/dev/null
 fi
 
+# /bin/echo is a little more likely to support -n than sh's builtin echo.
+if test -x /bin/echo
+then
+       ECHO=/bin/echo
+else
+       ECHO=echo
+fi
+
 touch "$TEST_OUTPUT_FILE" || exit 1
 
 TEST_DIR=.
@@ -29,6 +37,12 @@ announce () {
        echo $@ >>"$TEST_OUTPUT_FILE"
 }
 
+announce_n () {
+       $ECHO -n $@
+       echo $@ >>"$TEST_OUTPUT_FILE"
+}
+
+
 run_tests () {
        if $TEST_DIR/test-init 2>>"$TEST_OUTPUT_FILE" ;
        then
@@ -38,28 +52,28 @@ run_tests () {
                return
        fi
 
-       announce -n " test-eof: "
+       announce_n " test-eof: "
        if $TEST_DIR/test-eof >>"$TEST_OUTPUT_FILE" ;
        then
                announce OKAY ;
        else
                announce FAILED ;
        fi
-       announce -n " test-weof: "
+       announce_n " test-weof: "
        if $TEST_DIR/test-weof >>"$TEST_OUTPUT_FILE" ;
        then
                announce OKAY ;
        else
                announce FAILED ;
        fi
-       announce -n " test-time: "
+       announce_n " test-time: "
        if $TEST_DIR/test-time >>"$TEST_OUTPUT_FILE" ;
        then
                announce OKAY ;
        else
                announce FAILED ;
        fi
-       announce -n " regress: "
+       announce_n " regress: "
        if $TEST_DIR/regress >>"$TEST_OUTPUT_FILE" ;
        then
                announce OKAY ;