From 763295d1991f0f21f4ee4888a5759ad8b4ef90d1 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 29 Dec 2024 19:40:54 +0100 Subject: [PATCH] test: refactor, simplify local.sh and unicode.sh Signed-off-by: Joachim Wiberg --- test/lib.sh | 9 +++++++++ test/local.sh | 19 +++---------------- test/unicode.sh | 23 +++-------------------- 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/test/lib.sh b/test/lib.sh index c79e3e8..cbeac4b 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -146,6 +146,15 @@ logger() fi } +log_find() +{ + [ $# -gt 1 ] && altsock="$1" && shift + message="$1" + + logger "${altsock}" "$message" + grep "$message" "$LOG" +} + # Helper to poll for a file with a timeout poll() { diff --git a/test/local.sh b/test/local.sh index 5f085a7..003e82d 100755 --- a/test/local.sh +++ b/test/local.sh @@ -1,19 +1,6 @@ #!/bin/sh - -verify_plain() -{ - MSG="foobar" - logger "${MSG}" - grep ${MSG} "${LOG}" -} - -verify_alt() -{ - MSG="xyzzy" - logger "${ALTSOCK}" ${MSG} - grep ${MSG} "${LOG}" -} +. "${srcdir:-.}/lib.sh" run_step "Set up local syslog daemon" setup -m0 -run_step "Verify basic logging" verify_plain -run_step "Verify alternate socket" verify_alt +run_step "Verify basic logging" log_find "foobar" +run_step "Verify alternate socket" log_find "$ALTSOCK" "xyzzy" diff --git a/test/unicode.sh b/test/unicode.sh index bdfcdbd..2d54497 100755 --- a/test/unicode.sh +++ b/test/unicode.sh @@ -3,23 +3,6 @@ # From https://github.com/troglobit/sysklogd/issues/49 . "${srcdir:-.}/lib.sh" -MSG1="öäüÖÄÜ߀¢§" -MSG2="…‘’•" - -setup_unicode() -{ - setup -8 -m0 -} - -check_log_message() -{ - [ $# -gt 1 ] && altsock="$1" && shift - message="$1" - - logger "${altsock}" "$message" - grep "$message" "$LOG" -} - -run_step "Set up unicode capable syslogd" setup_unicode -run_step "Verify logger" check_log_message "$MSG1" -run_step "Verify logger w/ alt. socket" check_log_message "$ALTSOCK" "$MSG2" +run_step "Set up unicode capable syslogd" setup -8 -m0 +run_step "Verify logger" log_find "öäüÖÄÜ߀¢§" +run_step "Verify logger w/ alt. socket" log_find "$ALTSOCK" "…‘’•"