diff options
-rw-r--r-- | echld/Makefile.am | 12 | ||||
-rw-r--r-- | echld/Makefile.common | 4 | ||||
-rw-r--r-- | echld/echld_test.c (renamed from echld/echld-test.c) | 73 |
3 files changed, 76 insertions, 13 deletions
diff --git a/echld/Makefile.am b/echld/Makefile.am index e40ee5718d..6dfb03d0b8 100644 --- a/echld/Makefile.am +++ b/echld/Makefile.am @@ -36,6 +36,7 @@ if HAVE_WARNINGS_AS_ERRORS AM_CFLAGS += -Werror endif + lib_LTLIBRARIES = libechld.la # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html libechld_la_LDFLAGS = -version-info 0:0:0 @LDFLAGS_SHAREDLIB@ @@ -66,6 +67,17 @@ CLEANFILES = \ MAINTAINERCLEANFILES = \ Makefile.in +bin_PROGRAMS = + @echld_test_bin@ + +EXTRA_PROGRAMS = echld_test + +echld_test_LDADD = \ + echld/libechld.la \ + @GLIB_LIBS@ + +echld_test_CFLAGS = $(AM_CLEAN_CFLAGS) + # ABI compliance checker can be obtained from # http://ispras.linux-foundation.org/index.php/ABI_compliance_checker # Checked using version 1.21.12 diff --git a/echld/Makefile.common b/echld/Makefile.common index f8004280e3..aefe6a9a46 100644 --- a/echld/Makefile.common +++ b/echld/Makefile.common @@ -40,3 +40,7 @@ LIBECHLD_INCLUDES = \ echld-int.h \ echld-util.h \ echld.h + +# echld_test specifics +echld_test_SOURCES = \ + echld_test.c diff --git a/echld/echld-test.c b/echld/echld_test.c index b65d83b5f9..525c95a001 100644 --- a/echld/echld-test.c +++ b/echld/echld_test.c @@ -24,30 +24,77 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "config.h" + +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif + +#include <sys/time.h> +#include <sys/uio.h> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + #include "echld.h" +#include "echld-util.h" + #include <signal.h> #include <stdio.h> +#include <stdlib.h> -void reaper(int sig) { +int pings = 0; +int errors = 0; -}; +void ping_cb(long usec, void* data _U_) { + if (usec > 0) { + fprintf(stderr, "ping=%d usec=%d\n", pings ,(int)usec ); + pings++; + } else { + errors++; + } +} int main(int argc, char** argv) { - int pid; + struct timeval tv; + int tot_cycles = 0; + int npings; - echld_initialize(ECHLD_ENCODING_JSON); + tv.tv_sec = 0; + tv.tv_usec = 250000; - switch((pid = fork())) { - case -1: - return 222; - case 0: - exit(echld_loop()); + switch(argc) { case 1: - echld_ping(0,) - signal(reaper) - waitpid(); + npings = 10; + break; + case 2: + npings = (int)atoi(argv[1]); + break; + default: + fprintf(stderr, "usage: %s [num pings, default=10]\n",argv[0]); + return 1; } -}; + + echld_initialize(ECHLD_ENCODING_JSON); + + + do { + if (tot_cycles < npings) echld_ping(0,ping_cb,NULL); + tot_cycles++; + } while( pings < 10 && tot_cycles < 25 && echld_wait(&tv)); + + fprintf(stderr, "Done: pings=%d errors=%d tot_cycles=%d\n", pings, errors ,tot_cycles ); + + echld_terminate(); + return 0; +} + + |