Skip to content

Conversation

@jessp01
Copy link

@jessp01 jessp01 commented Apr 30, 2025

tests/p_sendmail/20_sendmail_mta.sh

Allow more than 1 second for relevant entries to appear in
/var/log/maillog
With this change, the test will give up after a minute but will check for
the expected pattern in the log every second

This script runs with /bin/sh but really, it will fail in all below
places with multiple POSIX compat shells and was clearly designed to run
with BASH:

if [ $MTA_ACCEPT == 0 ] # W: In POSIX sh, == in place of = is undefined.
if [[ $mail =~ $regex ]] # W: In POSIX sh, [[ ]] is undefined.
if ([ $MTA_ACCEPT == 0  ] && [ $DELIVERED == 0 ]) # W: In POSIX sh, == in place of = is undefined.
egrep -q "${BASH_REMATCH[1]}\:.*stat\=Sent" /var/log/maillog # W: In POSIX sh, BASH_REMATCH is undefined.
echo -e # W: In POSIX sh, echo flags are undefined.

Wherever possible, I replaced == with = (which will work with BASH
and any POSIX compat shell) but since there are other BASH specific
features that are being used, changed to #!/bin/bash

tests/p_squid/squid_test.sh

SKIP_QA_HARNESS is set in runtests.sh (line 17) but if you run this
single test directly, it will fail with:

tests/p_squid/squid_test.sh: line 9: [: : integer expression expected

Fixed by setting SKIP_QA_HARNESS to 1 if it is unset.

jessp01 added 2 commits April 30, 2025 10:42
`/var/log/maillog`
With this change, the test will give up after a minute but will check for
the expected pattern in the log every second

This script runs with `/bin/sh` but really, it will fail in all below
places with multiple POSIX compat shells and was clearly designed to run
with BASH:
```
if [ $MTA_ACCEPT == 0 ] # W: In POSIX sh, == in place of = is undefined.
if [[ $mail =~ $regex ]] # W: In POSIX sh, [[ ]] is undefined.
if ([ $MTA_ACCEPT == 0  ] && [ $DELIVERED == 0 ]) # W: In POSIX sh, == in place of = is undefined.
egrep -q "${BASH_REMATCH[1]}\:.*stat\=Sent" /var/log/maillog # W: In POSIX sh, BASH_REMATCH is undefined.
echo -e # W: In POSIX sh, echo flags are undefined.
```

Wherever possible, I replaced `==` with `=` (which will work with BASH
and any POSIX compat shell) but since there are other BASH specific
features that are being used, changed to `#!/bin/bash`
single test directly, it will fail with:
> tests/p_squid/squid_test.sh: line 9: [: : integer expression expected

Fixed by setting `SKIP_QA_HARNESS` to 1 if it is unset.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant