Skip to content

Commit

Permalink
test: refactor, simplify local.sh and unicode.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
  • Loading branch information
troglobit committed Dec 29, 2024
1 parent 649b3b4 commit 763295d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 36 deletions.
9 changes: 9 additions & 0 deletions test/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
19 changes: 3 additions & 16 deletions test/local.sh
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 3 additions & 20 deletions test/unicode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" "…‘’•"

0 comments on commit 763295d

Please sign in to comment.