all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] gnu: dmd: Sleep longer in tests, for slower machines
Date: Tue, 18 Feb 2014 17:49:07 +0100	[thread overview]
Message-ID: <87fvng9xj0.fsf@gnu.org> (raw)
In-Reply-To: <8761odq49b.fsf@netris.org> (Mark H. Weaver's message of "Mon, 17 Feb 2014 08:04:48 -0500")

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

Mark H Weaver <mhw@netris.org> skribis:

> Andreas Enge <andreas@enge.fr> 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’.


[-- Attachment #2: Type: text/x-patch, Size: 5686 bytes --]

commit 3c459670690f90f85905d241d230a7541a41fe15
Author: Ludovic Courtès <ludo@gnu.org>
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.
 
+@item --pid[=@var{file}]
+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 [@var{file}]
 @itemx --persistency[=@var{file}]
 @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 <ludo@gnu.org>
+;; Copyright (C) 2013, 2014 Ludovic Courts <ludo@gnu.org>
 ;; Copyright (C) 2002, 2003 Wolfgang Jhrling <wolfgang@pro-linux.de>
 ;;
 ;; 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 <ludo@gnu.org>
+# Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 #
 # 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 <ludo@gnu.org>
+# Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 #
 # 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

      reply	other threads:[~2014-02-18 16:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-16  7:33 [PATCH] gnu: dmd: Sleep longer in tests, for slower machines Mark H Weaver
2014-02-16 21:16 ` Ludovic Courtès
2014-02-17  9:01   ` Andreas Enge
2014-02-17 13:04     ` Mark H Weaver
2014-02-18 16:49       ` Ludovic Courtès [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fvng9xj0.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.