The suspended job tests were disabled in workers/43426 (commit d6859ce)
due to races with zpty: the tests used a fixed `sleep 0.1` delay to
wait for the foreground job to start before sending Ctrl-Z, which was
unreliable (particularly on OpenSUSE).
Replace the racy `sleep` command with `(print ready; sleep 100)` and
use `zpty_line` to wait for the "ready" output. Reading "ready"
proves the foreground subshell is running and its process group is
established, so the subsequent Ctrl-Z reliably delivers SIGTSTP.
This follows the same synchronization pattern already used by the
`kill` tests at the end of the file, which use `zpty_line` to read
job notification lines before sending signals.
---
Test/W02jobs.ztst | 73 ++++++++++++++++++++++++-----------------------
1 file changed, 37 insertions(+), 36 deletions(-)
diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst
index fe12f97..df62666 100644
--- a/Test/W02jobs.ztst
+++ b/Test/W02jobs.ztst
@@ -85,29 +85,29 @@
*>zsh:*running jobs*
*>zsh:*SIGHUPed*
-#### Races presumed to be associated with zpty mean that
-#### tests involving suspending jobs are not safe.
-## zpty_start
-## zpty_input 'setopt check_jobs no_check_running_jobs'
-## zpty_input 'sleep 3'
-## sleep 0.1
-## zpty_input $'\C-z'
-## zpty_stop
-## 0:suspended job with check_jobs + no_check_running_jobs
-## *>zsh:*(stopped|suspended)*sleep*
-## *>zsh:*(stopped|suspended) jobs*
-## # no 'SIGHUPed' message for suspended jobs
-##
-## zpty_start
-## zpty_input 'setopt check_jobs check_running_jobs'
-## zpty_input 'sleep 3'
-## sleep 0.1
-## zpty_input $'\C-z'
-## zpty_stop
-## 0:suspended job with check_jobs + check_running_jobs
-## *>zsh:*(stopped|suspended)*sleep*
-## *>zsh:*(stopped|suspended) jobs*
-## # no 'SIGHUPed' message for suspended jobs
+ zpty_start
+ zpty_input 'setopt check_jobs no_check_running_jobs'
+ zpty_input '(print ready; sleep 100)'
+ zpty_line
+ zpty_input $'\C-z'
+ zpty_stop
+0:suspended job with check_jobs + no_check_running_jobs
+*>ready
+*>zsh:*(stopped|suspended)*sleep*
+*>zsh:*(stopped|suspended) jobs*
+# no 'SIGHUPed' message for suspended jobs
+
+ zpty_start
+ zpty_input 'setopt check_jobs check_running_jobs'
+ zpty_input '(print ready; sleep 100)'
+ zpty_line
+ zpty_input $'\C-z'
+ zpty_stop
+0:suspended job with check_jobs + check_running_jobs
+*>ready
+*>zsh:*(stopped|suspended)*sleep*
+*>zsh:*(stopped|suspended) jobs*
+# no 'SIGHUPed' message for suspended jobs
zpty_start
zpty_input 'sleep 5 & sleep 4 & sleep 3 &'
@@ -155,19 +155,20 @@
*>-
*>zsh:*SIGHUPed*
-## zpty_start
-## zpty_input 'sleep 5'
-## sleep 0.1
-## zpty_input $'\C-z'
-## zpty_input 'jobs -r'
-## zpty_input 'print -- -'
-## zpty_input 'jobs -s'
-## zpty_stop
-## 0:`jobs -r` and `jobs -s` with suspended job
-## *>zsh:*(stopped|suspended)*sleep*
-## *>-
-## *>\[1] + (stopped|suspended)*sleep*
-## # no 'SIGHUPed' message for suspended jobs
+ zpty_start
+ zpty_input '(print ready; sleep 100)'
+ zpty_line
+ zpty_input $'\C-z'
+ zpty_input 'jobs -r'
+ zpty_input 'print -- -'
+ zpty_input 'jobs -s'
+ zpty_stop
+0:`jobs -r` and `jobs -s` with suspended job
+*>ready
+*>zsh:*(stopped|suspended)*sleep*
+*>-
+*>\[1] + (stopped|suspended)*sleep*
+# no 'SIGHUPed' message for suspended jobs
zpty_start
zpty_input 'sleep 10 & sleep 9 & sleep 8 & sleep 7 &'
--
2.43.0