]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1574] use dhcp_test_lib.sh in src/lib/log
authorAndrei Pavel <andrei@isc.org>
Sun, 13 Dec 2020 18:19:17 +0000 (20:19 +0200)
committerAndrei Pavel <andrei@isc.org>
Mon, 14 Dec 2020 10:08:39 +0000 (12:08 +0200)
src/lib/log/tests/Makefile.am
src/lib/log/tests/buffer_logger_test.sh.in
src/lib/log/tests/console_test.sh.in
src/lib/log/tests/destination_test.sh.in
src/lib/log/tests/init_logger_test.sh.in
src/lib/log/tests/local_file_test.sh.in
src/lib/log/tests/logger_lock_test.sh.in
src/lib/log/tests/severity_test.sh.in

index 3a3d1bfc99ede9c0e4835fa18944eb2a2bb03dde..4d0c2dfb4a06068d66475390ff66441cf9fa3e6f 100644 (file)
@@ -112,7 +112,9 @@ initializer_unittests_1_LDFLAGS  = $(TESTSLDFLAGS)
 noinst_PROGRAMS += $(TESTS)
 endif
 
-noinst_SCRIPTS  = console_test.sh
+noinst_SCRIPTS  =
+noinst_SCRIPTS += buffer_logger_test.sh
+noinst_SCRIPTS += console_test.sh
 noinst_SCRIPTS += destination_test.sh
 noinst_SCRIPTS += init_logger_test.sh
 noinst_SCRIPTS += local_file_test.sh
@@ -124,10 +126,10 @@ noinst_SCRIPTS += severity_test.sh
 # output needs to be compared with stored output (where "cut" and
 # "diff" are useful utilities).
 check-local:
+       $(SHELL) $(abs_builddir)/buffer_logger_test.sh
        $(SHELL) $(abs_builddir)/console_test.sh
        $(SHELL) $(abs_builddir)/destination_test.sh
        $(SHELL) $(abs_builddir)/init_logger_test.sh
-       $(SHELL) $(abs_builddir)/buffer_logger_test.sh
        $(SHELL) $(abs_builddir)/local_file_test.sh
        $(SHELL) $(abs_builddir)/logger_lock_test.sh
        $(SHELL) $(abs_builddir)/severity_test.sh
index a9b70396caaa433fb25f9d8f1101a5b02c998f1d..975df97ceb2f1aebb69a9667a63eb9c7967ea7be 100644 (file)
 # used.
 set -eu
 
-# Allow non-zero exit codes to be explicitly checked in this test.
-set +e
+# Include common test library.
+# shellcheck disable=SC1091
+# SC1091: Not following: ... was not specified as input (see shellcheck -x).
+. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
 
-testname="bufferLogger test"
-printf '%s\n' "${testname}"
-
-failcount=0
 tempfile="@abs_builddir@/buffer_logger_test_tempfile_$$"
 
-passfail() {
-    if [ "${1}" -eq 0 ]; then
-        printf ' pass\n'
-    else
-        printf ' FAIL\n'
-        failcount=$((failcount + $1))
-    fi
-}
-
-printf '1. Checking that buffer initialization works\n'
+printf 'Checking that buffer initialization works:\n'
 
-printf '   - Buffer including process() call: '
+test_start 'buffer-logger.buffer-including-process()-call'
 cat > $tempfile << .
 INFO  [buffertest.log] LOG_BAD_SEVERITY unrecognized log severity: info
 INFO  [buffertest.log] LOG_BAD_SEVERITY unrecognized log severity: info
@@ -41,18 +30,16 @@ INFO  [buffertest.log] LOG_BAD_SEVERITY unrecognized log severity: info
 ./buffer_logger_test 2>&1 | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
+test_finish 0
 
-printf '   - Buffer excluding process() call: '
+test_start 'buffer-logger.buffer-excluding-process()-call'
 cat > $tempfile << .
 INFO [buffertest.log]: LOG_BAD_SEVERITY unrecognized log severity: info
 DEBUG [buffertest.log]: LOG_BAD_DESTINATION unrecognized log destination: debug-50
 INFO [buffertest.log]: LOG_BAD_SEVERITY unrecognized log severity: info
 .
 ./buffer_logger_test -n 2>&1 | diff $tempfile -
-passfail $?
+test_finish 0
 
 # Tidy up.
 rm -f $tempfile
-
-exit $failcount
index c0605ced3095a5d740febadb08e31e4a3f9cf2ae..f0dff65dace96ab6b42f7a1ef1b8e19011d1bd13 100644 (file)
 # used.
 set -eu
 
-testname="Console output test"
-printf '%s\n' "${testname}"
+# Include common test library.
+# shellcheck disable=SC1091
+# SC1091: Not following: ... was not specified as input (see shellcheck -x).
+. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
 
-failcount=0
 tempfile="@abs_builddir@/console_test_tempfile_$$"
 
 # Look at tempfile and check that the count equals the expected count
 passfail() {
     count=$(wc -l $tempfile | awk '{print $1}')
     if [ "${count}" -eq "${1}" ]; then
-        printf ' pass\n'
+        test_finish 0
     else
-        printf ' FAIL\n'
-        failcount=$((failcount + $1))
+        test_finish 1
     fi
 }
 
-printf '1. Checking that console output to stdout goes to stdout:'
+test_start 'console-output.stdout'
 rm -f $tempfile
 ./logger_example -c stdout -s error 1> $tempfile 2> /dev/null
 passfail 4
 
-printf '2. Checking that console output to stdout does not go to stderr:'
+test_start 'console-output.stdout-not-stderr'
 rm -f $tempfile
 ./logger_example -c stdout -s error 1> /dev/null 2> $tempfile
 passfail 0
 
-printf '3. Checking that console output to stderr goes to stderr:'
+test_start 'console-output.stderr'
 rm -f $tempfile
 ./logger_example -c stderr -s error 1> /dev/null 2> $tempfile
 passfail 4
 
-printf '4. Checking that console output to stderr does not go to stdout:'
+test_start 'console-output.stderr-not-stdout'
 rm -f $tempfile
 ./logger_example -c stderr -s error 1> $tempfile 2> /dev/null
 passfail 0
 
-if [ $failcount -eq 0 ]; then
-    echo "PASS: $testname"
-elif [ $failcount -eq 1 ]; then
-    echo "FAIL: $testname - 1 test failed"
-else
-    echo "FAIL: $testname - $failcount tests failed"
-fi
-
 # Tidy up
 rm -f $tempfile
-
-exit $failcount
index c7d7dc35b2c0da869d5acabbfaee061bdf051b61..86fc4156237192b934ef6bea8f0ef2e4445e5a28 100644 (file)
 # used.
 set -eu
 
-# Allow non-zero exit codes to be explicitly checked in this test.
-set +e
+# Include common test library.
+# shellcheck disable=SC1091
+# SC1091: Not following: ... was not specified as input (see shellcheck -x).
+. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
 
-testname="Destination test"
-printf '%s\n' "${testname}"
-
-failcount=0
 tempfile="@abs_builddir@/destination_test_tempfile_$$"
 destfile1_tmp="@abs_builddir@/destination_test_destfile_1_tmp_$$"
 destfile2_tmp="@abs_builddir@/destination_test_destfile_2_tmp_$$"
 destfile1="@abs_builddir@/destination_test_destfile_1_$$"
 destfile2="@abs_builddir@/destination_test_destfile_2_$$"
 
-passfail() {
-    if [ "${1}" -eq 0 ]; then
-        printf ' pass\n'
-    else
-        printf ' FAIL\n'
-        failcount=$((failcount + $1))
-    fi
-}
+printf '1. One logger, multiple destinations:\n'
 
-echo "1. One logger, multiple destinations:"
 cat > $tempfile << .
 FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
 ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
@@ -49,18 +39,18 @@ sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1
 sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile2_tmp > $destfile2
 # strip the thread ids
 
-printf '   - destination 1:'
+test_start 'logger-destination.one-logger-file-1'
 cut -d' ' -f3- $destfile1 | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '   - destination 2:'
+test_start 'logger-destination.one-logger-file-2'
 cut -d' ' -f3- $destfile2 | diff $tempfile -
-passfail $?
+test_finish $?
 
 # Tidy up.
 rm -f $tempfile $destfile1_tmp $destfile2_tmp $destfile1 $destfile2
 
-printf '2. Two loggers, different destinations and severities\n'
+printf '2. Two loggers, different destinations and severities:\n'
 rm -f $destfile1 $destfile2
 ./logger_example -l example -s info -f $destfile1_tmp -l alpha -s warn -f $destfile2_tmp
 
@@ -71,6 +61,7 @@ sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1
 # All output for example and example.beta should have gone to destfile1.
 # Output for example.alpha should have done to destfile2.
 
+test_start 'logger-destination.multiples-loggers-file-1'
 cat > $tempfile << .
 FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
 ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
@@ -80,25 +71,15 @@ ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_erro
 WARN  [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
 INFO  [example.beta] LOG_READ_ERROR error reading from message file beta: info
 .
-printf '   - destination 1:'
 cut -d' ' -f3- $destfile1 | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '   - destination 2:'
+test_start 'logger-destination.multiples-loggers-file-2'
 cat > $tempfile << .
 WARN  [example.alpha] LOG_READ_ERROR error reading from message file a.txt: dummy reason
 .
 cut -d' ' -f3- $destfile2 | diff $tempfile -
-passfail $?
-if [ $failcount -eq 0 ]; then
-    echo "PASS: $testname"
-elif [ $failcount -eq 1 ]; then
-    echo "FAIL: $testname - 1 test failed"
-else
-    echo "FAIL: $testname - $failcount tests failed"
-fi
+test_finish $?
 
 # Tidy up.
 rm -f $tempfile $destfile1_tmp $destfile2_tmp $destfile1 $destfile2
-
-exit $failcount
index 37adaedfe53779f6a29ca205a9730acf2b9050aa..348008d5f1d3842e17b3c9b7dd7423a161068927 100644 (file)
 # used.
 set -eu
 
-# Allow non-zero exit codes to be explicitly checked in this test.
-set +e
+# Include common test library.
+# shellcheck disable=SC1091
+# SC1091: Not following: ... was not specified as input (see shellcheck -x).
+. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
 
-testname="initLogger test"
-printf '%s\n' "${testname}"
-
-failcount=0
 tempfile="@abs_builddir@/init_logger_test_tempfile_$$"
 destfile_tmp="@abs_builddir@/init_logger_test_destfile_tmp_$$"
 destfile="@abs_builddir@/init_logger_test_destfile_$$"
 
-passfail() {
-    if [ "${1}" -eq 0 ]; then
-        printf ' pass\n'
-    else
-        printf ' FAIL\n'
-        failcount=$((failcount + $1))
-    fi
-}
-
-printf '1. Checking that KEA_LOGGER_SEVERITY/KEA_LOGGER_DBGLEVEL work\n'
+printf '1. Checking that KEA_LOGGER_SEVERITY/KEA_LOGGER_DBGLEVEL work:\n'
 
-printf '   - severity=DEBUG, dbglevel=99: '
+test_start 'init-logger.severity=DEBUG,dbglevel=99'
 cat > $tempfile << .
 DEBUG [kea.log] LOG_BAD_DESTINATION unrecognized log destination: debug-0
 DEBUG [kea.log] LOG_BAD_DESTINATION unrecognized log destination: debug-50
@@ -48,9 +37,9 @@ FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found with
 KEA_LOGGER_DESTINATION=stdout KEA_LOGGER_SEVERITY=DEBUG KEA_LOGGER_DBGLEVEL=99 ./init_logger_test | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '   - severity=DEBUG, dbglevel=50: '
+test_start 'init-logger.severity=DEBUG,dbglevel=50'
 cat > $tempfile << .
 DEBUG [kea.log] LOG_BAD_DESTINATION unrecognized log destination: debug-0
 DEBUG [kea.log] LOG_BAD_DESTINATION unrecognized log destination: debug-50
@@ -62,9 +51,9 @@ FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found with
 KEA_LOGGER_DESTINATION=stdout KEA_LOGGER_SEVERITY=DEBUG KEA_LOGGER_DBGLEVEL=50 ./init_logger_test | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '   - severity=WARN: '
+test_start 'init-logger.severity=WARN'
 cat > $tempfile << .
 WARN  [kea.log] LOG_BAD_STREAM bad log console output stream: warn
 ERROR [kea.log] LOG_DUPLICATE_MESSAGE_ID duplicate message ID (error) in compiled code
@@ -73,11 +62,11 @@ FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found with
 KEA_LOGGER_DESTINATION=stdout KEA_LOGGER_SEVERITY=WARN ./init_logger_test | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '2. Checking that KEA_LOGGER_DESTINATION works\n'
+printf '2. Checking that KEA_LOGGER_DESTINATION works:\n'
 
-printf '   - stdout: '
+test_start 'init-logger.stdout'
 cat > $tempfile << .
 FATAL [kea.log] LOG_NO_MESSAGE_ID line fatal: message definition line found without a message ID
 .
@@ -85,33 +74,23 @@ rm -f $destfile_tmp $destfile
 KEA_LOGGER_SEVERITY=FATAL KEA_LOGGER_DESTINATION=stdout ./init_logger_test 1> $destfile_tmp
 sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
 cut -d' ' -f3- $destfile | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '   - stderr: '
+test_start 'init-logger.stderr'
 rm -f $destfile_tmp $destfile
 KEA_LOGGER_SEVERITY=FATAL KEA_LOGGER_DESTINATION=stderr ./init_logger_test 2> $destfile_tmp
 sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
 cut -d' ' -f3- $destfile | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '   - file: '
+test_start 'init-logger.file'
 rm -f $destfile_tmp $destfile
 KEA_LOGGER_SEVERITY=FATAL KEA_LOGGER_DESTINATION=$destfile_tmp ./init_logger_test
 sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' < $destfile_tmp > $destfile
 cut -d' ' -f3- $destfile | diff $tempfile -
-passfail $?
+test_finish $?
 
 # Note: can't automatically test syslog output.
 
-if [ $failcount -eq 0 ]; then
-    printf 'PASS: %s\n' "${testname}"
-elif [ $failcount -eq 1 ]; then
-    printf 'FAIL: %s - 1 test failed\n' "${testname}"
-else
-    printf 'FAIL: %s - %s tests failed\n' "${testname}" "${failcount}"
-fi
-
 # Tidy up.
 rm -f $tempfile $destfile_tmp $destfile
-
-exit $failcount
index b8f8c5bf1f57f1a038fb68c584601b9b5f940532..c1e7a53d24bae48f3a3a8febfc0fa3b135e3b40a 100644 (file)
 # used.
 set -eu
 
-# Allow non-zero exit codes to be explicitly checked in this test.
-set +e
+# Include common test library.
+# shellcheck disable=SC1091
+# SC1091: Not following: ... was not specified as input (see shellcheck -x).
+. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
 
-testname="Local message file test"
-printf '%s\n' "${testname}"
-
-failcount=0
 localmes="@abs_builddir@/localdef_mes_$$"
 tempfile="@abs_builddir@/run_time_init_test_tempfile_$$"
 
-passfail() {
-    if [ "${1}" -eq 0 ]; then
-        printf ' pass\n'
-    else
-        printf ' FAIL\n'
-        failcount=$((failcount + $1))
-    fi
-}
-
 # Create the local message file for testing
 
 cat > $localmes << .
@@ -40,7 +29,7 @@ cat > $localmes << .
 % LOG_READING_LOCAL_FILE replacement read local message file, parameter is '%1'
 .
 
-printf '1. Local message replacement:'
+test_start 'local-file.local-message-replacement'
 cat > $tempfile << .
 WARN  [example.log] LOG_NO_SUCH_MESSAGE could not replace message text for 'LOG_NOTHERE': no such message
 FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
@@ -54,9 +43,9 @@ WARN  [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
 ./logger_example -c stdout -s warn $localmes | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '2. Report error if unable to read local message file:'
+test_start 'local-file.read-error-reporting'
 cat > $tempfile << .
 ERROR [example.log] LOG_INPUT_OPEN_FAIL unable to open message file $localmes for input: No such file or directory
 FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
@@ -71,17 +60,7 @@ rm -f $localmes
 ./logger_example -c stdout -s warn $localmes | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
-
-if [ $failcount -eq 0 ]; then
-    printf 'PASS: %s\n' "$testname"
-elif [ $failcount -eq 1 ]; then
-    printf 'FAIL: %s - 1 test failed\n' "$testname"
-else
-    printf 'FAIL: %s - %s tests failed\n' "$testname" "$failcount"
-fi
+test_finish $?
 
 # Tidy up.
 rm -f $tempfile
-
-exit $failcount
index 34bb55e01d3c34611a519fab8208e4540f4b9c74..2cea0f08c9569a71276448dcb8049316db13860b 100644 (file)
 # used.
 set -eu
 
-# Allow non-zero exit codes to be explicitly checked in this test.
-set +e
+# Include common test library.
+# shellcheck disable=SC1091
+# SC1091: Not following: ... was not specified as input (see shellcheck -x).
+. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
 
-failcount=0
 tempfile="@abs_builddir@/logger_lock_test_tempfile_$$"
 destfile="@abs_builddir@/logger_lock_test_destfile_$$"
 
-passfail() {
-    if [ "${1}" -eq 0 ]; then
-        printf ' pass\n'
-    else
-        printf ' FAIL\n'
-        failcount=$((failcount + $1))
-    fi
-}
-
-printf 'Testing that logger acquires and releases locks correctly:'
+test_start 'logger_lock'
 cat > $tempfile << .
 LOGGER_LOCK_TEST: MUTEXLOCK
 LOGGER_LOCK_TEST: LOCK
@@ -40,9 +32,7 @@ rm -f $destfile
 KEA_LOGGER_SEVERITY=INFO KEA_LOGGER_DESTINATION=stdout ./logger_lock_test | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' > $destfile
 cut -d' ' -f3- $destfile | diff $tempfile -
-passfail $?
+test_finish $?
 
 # Tidy up.
 rm -f $tempfile $destfile
-
-exit $failcount
index b8a1497a6cf16b92d1ad9048df5f0ed53c1ae682..02376f8a1e9cf39bbff77bba9b76e879679438b5 100644 (file)
 # used.
 set -eu
 
-# Allow non-zero exit codes to be explicitly checked in this test.
-set +e
+# Include common test library.
+# shellcheck disable=SC1091
+# SC1091: Not following: ... was not specified as input (see shellcheck -x).
+. "@abs_top_builddir@/src/lib/testutils/dhcp_test_lib.sh"
 
-testname="Severity test"
-printf '%s\n' "${testname}"
-
-failcount=0
 tempfile="@abs_builddir@/severity_test_tempfile_$$"
 
-passfail() {
-    if [ "${1}" -eq 0 ]; then
-        printf ' pass\n'
-    else
-        printf ' FAIL\n'
-        failcount=$((failcount + $1))
-    fi
-}
-
-printf '1. Default parameters:'
+test_start 'severity.default-parameters'
 cat > $tempfile << .
 FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
 ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
@@ -46,9 +35,9 @@ INFO  [example.beta] LOG_READ_ERROR error reading from message file beta: info
 ./logger_example -c stdout | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '2. Severity filter:'
+test_start 'severity.filter'
 cat > $tempfile << .
 FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
 ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
@@ -58,9 +47,9 @@ ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_erro
 ./logger_example -c stdout -s error | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
+test_finish $?
 
-printf '3. Debug level:'
+test_start 'severity.debug-level'
 cat > $tempfile << .
 FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
 ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
@@ -79,17 +68,7 @@ DEBUG [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta/25
 ./logger_example -c stdout -s debug -d 25 | \
     sed -e 's/\[\([a-z0-9\.]\{1,\}\)\/\([0-9]\{1,\}\)\.\(0x\)\{0,1\}\([0-9A-Fa-f]\{1,\}\)\]/[\1]/' | \
     cut -d' ' -f3- | diff $tempfile -
-passfail $?
-
-if [ $failcount -eq 0 ]; then
-    printf 'PASS: %s\n' "$testname"
-elif [ $failcount -eq 1 ]; then
-    printf 'FAIL: %s - 1 test failed\n' "$testname"
-else
-    printf 'FAIL: %s - %s tests failed\n' "$testname" "$failcount"
-fi
+test_finish $?
 
 # Tidy up
 rm -f $tempfile
-
-exit $failcount