tests: opensmtpd: Gracefully handle test failure.

Previously the 'wait' loop would run for ~1024 seconds, at which point
we'd reach the file descriptor limit due to the leak in 'queue-empty?'.

* gnu/tests/mail.scm (run-opensmtpd-test)[test]("mail arrived"): In
'queue-empty?', close PIPE to avoid file descriptor leak.  In 'wait'
loop, arrange to run at most 20 times.
This commit is contained in:
Ludovic Courtès 2020-03-16 12:18:59 +01:00
parent 0f13dd2b7f
commit c215d9ec1c
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5

View File

@ -140,16 +140,21 @@ match from any for local action inbound
(ice-9 rdelim))
(define (queue-empty?)
(eof-object?
(read-line
(open-input-pipe
(string-append #$(file-append opensmtpd "/sbin/smtpctl")
" show queue")))))
(let* ((pipe (open-pipe* OPEN_READ
#$(file-append opensmtpd
"/sbin/smtpctl")
"show" "queue"))
(line (read-line pipe)))
(close-pipe pipe)
(eof-object? line)))
(let wait ()
(if (queue-empty?)
(file-exists? "/var/mail/root")
(begin (sleep 1) (wait)))))
(let wait ((n 20))
(cond ((queue-empty?)
(file-exists? "/var/mail/root"))
((zero? n)
(error "root mailbox didn't show up"))
(else
(sleep 1) (wait (- n 1))))))
marionette))
(test-end)