Module: xenomai-forge
Branch: master
Commit: dff6f836697788dde9425c11491f548949be013b
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=dff6f836697788dde9425c11491f548949be013b

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Sep 23 16:47:20 2012 +0200

testsuite: various fixes in xeno-test-run

---

 testsuite/xeno-test/Makefile.am     |    2 +-
 testsuite/xeno-test/Makefile.in     |    2 +-
 testsuite/xeno-test/xeno-test-run.c |   17 +++++++++++------
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/testsuite/xeno-test/Makefile.am b/testsuite/xeno-test/Makefile.am
index 8395d5e..ca1987e 100644
--- a/testsuite/xeno-test/Makefile.am
+++ b/testsuite/xeno-test/Makefile.am
@@ -5,7 +5,7 @@ test_SCRIPTS = xeno-test-run-wrapper dohell
 test_PROGRAMS = xeno-test-run
 bin_SCRIPTS = xeno-test
 
-xeno_test_run_CPPFLAGS = -DTESTDIR=\"$(testdir)\"
+xeno_test_run_CPPFLAGS = -DTESTDIR=\"$(testdir)\" -D_GNU_SOURCE
 xeno_test_run_LDADD = -lrt
 
 xeno-test: $(srcdir)/xeno-test.in Makefile
diff --git a/testsuite/xeno-test/Makefile.in b/testsuite/xeno-test/Makefile.in
index bd178ef..9315c5c 100644
--- a/testsuite/xeno-test/Makefile.in
+++ b/testsuite/xeno-test/Makefile.in
@@ -274,7 +274,7 @@ testdir = @XENO_TEST_DIR@
 pkgdir = $(pkgdatadir)
 test_SCRIPTS = xeno-test-run-wrapper dohell
 bin_SCRIPTS = xeno-test
-xeno_test_run_CPPFLAGS = -DTESTDIR=\"$(testdir)\"
+xeno_test_run_CPPFLAGS = -DTESTDIR=\"$(testdir)\" -D_GNU_SOURCE
 xeno_test_run_LDADD = -lrt
 EXTRA_DIST = $(test_SCRIPTS) xeno-test.in
 CLEANFILES = xeno-test
diff --git a/testsuite/xeno-test/xeno-test-run.c 
b/testsuite/xeno-test/xeno-test-run.c
index 2761d64..0caa2de 100644
--- a/testsuite/xeno-test/xeno-test-run.c
+++ b/testsuite/xeno-test/xeno-test-run.c
@@ -5,7 +5,8 @@
 #include <ctype.h>
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <signal.h>
 #include <sys/wait.h>
@@ -17,6 +18,8 @@
 #define CHILD_LOAD    2
 #define CHILD_ANY     -1
 
+#define TIMEOUT 30
+
 struct child {
        unsigned type: 2;
        unsigned dead: 1;
@@ -156,7 +159,7 @@ int child_initv(struct child *child, int type, char *argv[])
        }
 
        time(&child->timeout);
-       child->timeout += 300;
+       child->timeout += TIMEOUT * 60;
 
        switch(type) {
        case CHILD_CHECKED:
@@ -347,7 +350,7 @@ void handle_checked_child(struct child *child, fd_set *fds)
 
        if (FD_ISSET(child->out, fds)) {
                copy(child->out, STDOUT_FILENO);
-               child->timeout = now + 300;
+               child->timeout = now + TIMEOUT * 60;
        }
 
        if (child->dead) {
@@ -381,8 +384,8 @@ void handle_checked_child(struct child *child, fd_set *fds)
        }
 
        if (now > child->timeout) {
-               fail_fprintf(stderr, "child %d produced no output for 5 
minutes.\n",
-                          child->pid);
+               fail_fprintf(stderr, "child %d produced no output for %d 
minutes.\n",
+                            child->pid, TIMEOUT);
                exit(EXIT_FAILURE);
        }
 
@@ -404,7 +407,9 @@ void handle_script_child(struct child *child, fd_set *fds)
        if (!FD_ISSET(child->out, fds))
                return;
 
-       sz = read(child->out, buffer + pos, sizeof(buffer) - pos);
+       sz = read(child->out, buffer + pos, sizeof(buffer) - (pos + 1));
+       buffer[pos + sz] = '\0';
+
        for (l = buffer; (eol = strchr(l, '\n')); l = eol + 1) {
                char buf[16];
                *eol = '\0';


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to