testing: Also capture stderr during test cases
authorTobias Brunner <tobias@strongswan.org>
Fri, 14 Jul 2017 09:22:27 +0000 (11:22 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 7 Aug 2017 08:44:05 +0000 (10:44 +0200)
The output was not correct otherwise due to the reordering of commands.

testing/do-tests

index 97d7e45..ba2abb6 100755 (executable)
@@ -424,6 +424,7 @@ do
                {
                        next
                }
+               printf("cmd_err=\044(tempfile -p test -s err); ")
                if (command == "tcpdump")
                {
                        printf("if [ \044TDUP_%s == \"true\" ]; then stop_tcpdump %s; fi; \n", host, host)
@@ -431,7 +432,7 @@ do
                }
                else
                {
-                       printf("cmd_out=\044(ssh \044SSHCONF root@\044ipv4_%s %s | grep \"%s\"); ",  host, command, pattern)
+                       printf("cmd_out=\044(ssh \044SSHCONF root@\044ipv4_%s %s 2>\044cmd_err | grep \"%s\"); ",  host, command, pattern)
                }
                printf("cmd_exit=\044?; ")
                printf("cmd_fail=0; ")
@@ -456,6 +457,7 @@ do
                        printf("echo \"%s# %s | grep \047%s\047  [%s]\"; ", host, command, pattern, hit)
                }
                printf("if [ -n \"\044cmd_out\" ]; then echo \"\044cmd_out\"; fi; \n")
+               printf("cat \044cmd_err; rm -f -- \044cmd_err; \n")
                printf("if [ \044cmd_fail -ne 0 ]; then echo \"~~~~~~~~~~~~~~~~~~~~\"; fi; \n")
                printf("echo; ")
        }' $TESTDIR/evaltest.dat` >> $CONSOLE_LOG 2>&1