I occasionally see failures in the syslogd test suite. The problem is
that the tests are racy: they often 1) send a message using logger(1),
then 2) immediately check whether the message was logged to a log file.
If the syslogd instance under test doesn't get a chance to run before
step 2 the test fails.
This change reworks things to avoid the race while minimizing the amount
of time sleeping.
- Each test uses a single logfile, so have them use a new common variable, SYSLOGD_LOGFILE, instead of something test-specific.
- In syslogd_start(), if the configuration references SYSLOGD_LOGFILE, wait for it to be created by syslogd before returning. Record its modification time.
- Add a helper syslogd_check_log(), to check for a given log entry in the last line of SYSLOGD_LOGFILE, instead of using atf_check directly.
- In syslogd_check_log(), wait for the modification time of the logfile to change relative to syslogd_startup or a previous syslogd_check_log() call, before checking for the desired log entry.
With this change, I was able to run the tests 1000 times in a loop with
4-way parallelism without seeing any test failures. Without the change
I usually get a failure within 10 loops.