[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] gnu: dmd: Sleep longer in tests, for slower machines
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH] gnu: dmd: Sleep longer in tests, for slower machines |
Date: |
Tue, 18 Feb 2014 17:49:07 +0100 |
User-agent: |
Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux) |
Mark H Weaver <address@hidden> skribis:
> Andreas Enge <address@hidden> writes:
>> It looks like the patch broke dmd on i686 and x86_64:
>> http://hydra.gnu.org/eval/52352
>
> Wow, those tests must be very fragile. All I did was increase all of
> the sleep times by a factor of about 3. I didn't look closely at the
> logic.
I think this is fixed by dmd commit 3c45967 (below), which I just pushed.
Thanks,
Ludo’.
commit 3c459670690f90f85905d241d230a7541a41fe15
Author: Ludovic Courtès <address@hidden>
Date: Tue Feb 18 15:10:28 2014 +0100
dmd: Add '--pid' option.
* modules/dmd.scm (main): Add '--pid' option and honor it.
* tests/basic.sh: Run dmd with '--pid'. Wait for the PID file to be
available, for synchronization.
* tests/respawn.sh: Likewise.
* dmd.texi (Invoking dmd): Document '--pid'.
Modified dmd.texi
diff --git a/dmd.texi b/dmd.texi
index a970894..f7306db 100644
--- a/dmd.texi
+++ b/dmd.texi
@@ -369,6 +369,10 @@ Log output into @var{file}, or if @var{file} is not given,
@code{/var/log/dmd.log} when running as superuser, @var{~/.dmd.log}
otherwise.
address@hidden address@hidden
+When dmd is ready to accept connections, write its PID to @var{file} or
+to the standard output if @var{file} is omitted.
+
@item -p address@hidden
@itemx address@hidden
@c FIXME-CRITICAL
Modified modules/dmd.scm
diff --git a/modules/dmd.scm b/modules/dmd.scm
index df41eb3..bfa579f 100644
--- a/modules/dmd.scm
+++ b/modules/dmd.scm
@@ -1,5 +1,5 @@
;; dmd.scm -- Daemon managing Daemons (or Daemons-managing Daemon?)
-;; Copyright (C) 2013 Ludovic Courts <address@hidden>
+;; Copyright (C) 2013, 2014 Ludovic Courts <address@hidden>
;; Copyright (C) 2002, 2003 Wolfgang Jhrling <address@hidden>
;;
;; This file is part of GNU dmd.
@@ -23,6 +23,7 @@
#:use-module (ice-9 readline) ;; Readline (for interactive use).
#:use-module (oop goops) ;; Defining classes and methods.
#:use-module (srfi srfi-1) ;; List library.
+ #:use-module (srfi srfi-26)
#:use-module (dmd config)
#:use-module (dmd support)
#:use-module (dmd service)
@@ -54,6 +55,7 @@
(let ((config-file default-config-file)
(socket-file default-socket-file)
+ (pid-file #f)
(insecure #f)
(logfile default-logfile))
;; Process command line arguments.
@@ -99,6 +101,12 @@
#:action (lambda (file)
(set! logfile file)))
(make <option>
+ #:long "pid"
+ #:takes-arg? #t #:optional-arg? #t #:arg-name "FILE"
+ #:description "when ready write PID to FILE or stdout"
+ #:action (lambda (file)
+ (set! pid-file (or file #t))))
+ (make <option>
#:long "config" #:short #\c
#:takes-arg? #t #:optional-arg? #f #:arg-name "FILE"
#:description "read configuration from FILE"
@@ -173,6 +181,16 @@
;; EINTR, which happens anytime we receive a signal, such as
;; SIGCHLD. Thus, wrap the 'accept' call.
(accept (EINTR-safe accept)))
+
+ ;; Possibly write out our PID, which means we're ready to accept
+ ;; connections. XXX: What if we daemonized already?
+ (match pid-file
+ ((? string? file)
+ (call-with-output-file pid-file
+ (cute display (getpid) <>)))
+ (#t (display (getpid)))
+ (_ #t))
+
(let next-command ()
(match (accept sock)
((command-source . client-address)
Modified tests/basic.sh
diff --git a/tests/basic.sh b/tests/basic.sh
index 0311f20..e9ad970 100644
--- a/tests/basic.sh
+++ b/tests/basic.sh
@@ -1,5 +1,5 @@
# GNU dmd --- Test basic communication capabilities.
-# Copyright © 2013 Ludovic Courtès <address@hidden>
+# Copyright © 2013, 2014 Ludovic Courtès <address@hidden>
#
# This file is part of GNU dmd.
#
@@ -23,11 +23,12 @@ socket="t-socket-$$"
conf="t-conf-$$"
log="t-log-$$"
stamp="t-stamp-$$"
+pid="t-pid-$$"
deco="deco -s $socket"
-dmd_pid=""
-trap "rm -f $socket $conf $stamp $log; test -z $dmd_pid || kill $dmd_pid" EXIT
+trap "rm -f $socket $conf $stamp $log $pid;
+ test -f $pid && kill \`cat $pid\` || true" EXIT
cat > "$conf"<<EOF
(use-modules (srfi srfi-26))
@@ -43,10 +44,14 @@ cat > "$conf"<<EOF
#:respawn? #f))
EOF
-dmd -I -s "$socket" -c "$conf" -l "$log" &
-dmd_pid=$!
+rm -f "$pid"
+dmd -I -s "$socket" -c "$conf" -l "$log" --pid="$pid" &
+
+# Wait till it's ready.
+while ! test -f "$pid" ; do : ; done
+
+dmd_pid="`cat $pid`"
-sleep 1 # XXX: wait till it's up
kill -0 $dmd_pid
test -S "$socket"
$deco status dmd | grep -E '(Start.*dmd|Stop.*test)'
Modified tests/respawn.sh
diff --git a/tests/respawn.sh b/tests/respawn.sh
index 96fad66..161eead 100644
--- a/tests/respawn.sh
+++ b/tests/respawn.sh
@@ -1,5 +1,5 @@
# GNU dmd --- Test respawnable services.
-# Copyright © 2013 Ludovic Courtès <address@hidden>
+# Copyright © 2013, 2014 Ludovic Courtès <address@hidden>
#
# This file is part of GNU dmd.
#
@@ -25,11 +25,12 @@ log="t-log-$$"
stamp="t-stamp-$$"
service1_pid="t-service1-pid-$$"
service2_pid="t-service2-pid-$$"
+pid="t-pid-$$"
deco="deco -s $socket"
-dmd_pid=""
-trap "rm -f $socket $conf $stamp $log; test -z $dmd_pid || kill $dmd_pid ;
+trap "rm -f $socket $conf $stamp $log $pid $service1_pid $service2_pid ;
+ test -f $pid && kill \`cat $pid\` || true ;
test -f $service1_pid && kill \`cat $service1_pid\` || true ;
test -f $service2_pid && kill \`cat $service2_pid\` || true ;
rm -f $service1_pid $service2_pid" EXIT
@@ -79,10 +80,14 @@ cat > "$conf"<<EOF
(start 'test2)
EOF
-dmd -I -s "$socket" -c "$conf" -l "$log" &
-dmd_pid=$!
+rm -f "$pid"
+dmd -I -s "$socket" -c "$conf" -l "$log" --pid="$pid" &
+
+# Wait till it's ready.
+wait_for_file "$pid"
+
+dmd_pid="`cat $pid`"
-sleep 1 # XXX: wait till it's up
kill -0 $dmd_pid
test -S "$socket"
$deco status test1 | grep started