From 6df5a1f772ec301cd33938b1849b7089cf587a62 Mon Sep 17 00:00:00 2001 From: Kevin Bowling Date: Sun, 14 Jun 2026 02:47:51 -0700 Subject: [PATCH] tombstone-e2e: use POSIX shell for portability The test relied on GNU-style options unavailable on AIX and Solaris native tools: grep -F, sed -i, and a \t escape in a sed character class Replace them with POSIX-only helpers so the test runs without requiring GNU tools or innshellvars detection: - contains(): a while-read/case substring matcher (no grep -F) - countlines(): wc -l | tr -cd '0-9' (no sed, handles AIX wc leading whitespace) - setconf(): sed > tmp && mv (no sed -i) Fixes #345. --- tests/expire/tombstone-e2e.t | 54 ++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/tests/expire/tombstone-e2e.t b/tests/expire/tombstone-e2e.t index 870b199a6..d52993a4a 100755 --- a/tests/expire/tombstone-e2e.t +++ b/tests/expire/tombstone-e2e.t @@ -20,6 +20,32 @@ printcount() { count=$(expr $count + 1) } +# POSIX-portable helpers: AIX and Solaris native grep(1) lack -F and +# native sed(1) lacks -i, so we avoid both rather than depend on GNU +# tools being installed. + +# contains FILE STRING -- succeed if STRING occurs literally on some line. +contains() { + while read -r _line; do + case "$_line" in + *"$2"*) return 0 ;; + esac + done <"$1" + return 1 +} + +# countlines FILE -- print the number of newline-terminated lines. +countlines() { + wc -l <"$1" | tr -cd '0-9' +} + +# setconf VALUE -- rewrite the expiretombstone setting in the temp inn.conf. +setconf() { + sed "s/^expiretombstone:.*\$/expiretombstone: $1/" \ + "$TMPDIR_E2E/inn.conf" >"$TMPDIR_E2E/inn.conf.new" \ + && mv "$TMPDIR_E2E/inn.conf.new" "$TMPDIR_E2E/inn.conf" +} + # Find the right directory. sm="../../frontends/sm" dirs='../data data tests/data' @@ -82,14 +108,14 @@ fi # 2. Remove it via sm -r. This should append the token to cancels.tombstone. $sm -r "$token1" -if [ -r "$CANCELS" ] && grep -qF "$token1" "$CANCELS"; then +if [ -r "$CANCELS" ] && contains "$CANCELS" "$token1"; then printcount "ok" else printcount "not ok" "cancels.tombstone missing token1" fi # 3. The file format should be exactly one line per cancellation. -lines=$(wc -l <"$CANCELS" | sed -e 's/[ \t]//g') +lines=$(countlines "$CANCELS") if [ "$lines" = 1 ]; then printcount "ok" else @@ -99,9 +125,9 @@ fi # 4. A second cancellation appends, doesn't overwrite. token2=$($sm -s /dev/null 2>&1 -lines=$(wc -l <"$CANCELS" | sed -e 's/[ \t]//g') +lines=$(countlines "$CANCELS") if [ "$lines" = 2 ]; then printcount "ok" else @@ -164,13 +188,13 @@ fi # a fourth article and confirming a clean append. token4=$($sm -s