From db83fe0e9beddd356c302892606a2092e04c2fb5 Mon Sep 17 00:00:00 2001 From: Mateusz Majewski Date: Fri, 7 Feb 2020 10:37:49 +0100 Subject: [PATCH] Add exit code propagation to the integration tests Now, if any of the tests fails, the dlog_test script will return a nonzero error code. You can use this, for example, to execute `dlog_test pipe && dlog_test logger`. Note that, if you are using SDB, running `sdb shell dlog_test pipe` or a similar command will NOT pass the exit code to the local shell. This is because SDB always returns 0 as the exit code, no matter what was the code of the underlying command; the nonzero exit codes are reserved for, for example, connection failures. Change-Id: I935ad63170ce7e02d27b496d1cf62f8c755bc3ab --- tests/dlog_test.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/dlog_test.in b/tests/dlog_test.in index b7afd5f..d6ddb99 100644 --- a/tests/dlog_test.in +++ b/tests/dlog_test.in @@ -678,7 +678,12 @@ if [ $type == "pipe" ]; then [ `ls -la /proc/$LOGGER/fd | grep fifo | wc -l` -eq 0 -a `ls -la /proc/$LOGGER/fd | grep pipe | wc -l` -eq 0 ] && ok || fail fi -# show results and clean up +# show results, clean up and return an exit code echo "$OKS / $TOTAL tests passed" echo "$FAILS / $TOTAL tests failed" + +[[ "$FAILS" -eq 0 ]] +# THE LINE ABOVE MUST STAY THE LAST COMMAND IN THE FILE! +# This is because it is used to pass the exit code. If another command +# is executed after it, its exit code will be propagated instead. -- 2.7.4