From e03cff475487a19e857894ec810351cc00c03381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Rochoy?= Date: Thu, 12 Dec 2024 15:11:47 +0100 Subject: [PATCH] savecore: add a test for LOG_PERROR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Rochoy --- sbin/savecore/tests/Makefile | 2 +- sbin/savecore/tests/log_test.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 sbin/savecore/tests/log_test.sh diff --git a/sbin/savecore/tests/Makefile b/sbin/savecore/tests/Makefile index b58e79f518efa9..81e6b8ce266703 100644 --- a/sbin/savecore/tests/Makefile +++ b/sbin/savecore/tests/Makefile @@ -1,3 +1,3 @@ -ATF_TESTS_SH= livedump_test +ATF_TESTS_SH= livedump_test log_test .include diff --git a/sbin/savecore/tests/log_test.sh b/sbin/savecore/tests/log_test.sh new file mode 100644 index 00000000000000..9e18025ab81f4c --- /dev/null +++ b/sbin/savecore/tests/log_test.sh @@ -0,0 +1,30 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2024 Stéphane Rochoy +# + +atf_test_case log_perror +log_perror_head() +{ + atf_set "descr" "Test LOG_PERROR behavior" +} +log_perror_body() +{ + local savecore=${DESTDIR:-''}/sbin/savecore + atf_check -s exit:1 \ + -o ignore \ + -e save:savecore.err \ + $savecore -vC /dev/missing + grep -qE 'savecore [0-9]+ - - /dev/missing: No such file or directory' savecore.err \ + || atf_fail "missing/invalid error output" +} +log_perror_cleanup() +{ + rm savecore.err +} + +atf_init_test_cases() +{ + atf_add_test_case log_perror +}