[C-MPI-commits] SF.net SVN: c-mpi:[85] tools
Status: Pre-Alpha
Brought to you by:
jmwozniak
|
From: <jmw...@us...> - 2010-05-11 21:18:09
|
Revision: 85
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=85&view=rev
Author: jmwozniak
Date: 2010-05-11 21:18:02 +0000 (Tue, 11 May 2010)
Log Message:
-----------
Better driver tests.
Modified Paths:
--------------
Makefile.in
include/driver.h
include/gossip.h
src/cmpi/driver.c
src/cmpi/module.mk.in
src/cmpi/node.c
src/cmpi-db/module.mk.in
src/gossip/gossip.c
src/mpirpc/module.mk.in
test/driver/module.mk.in
test/driver/test01.c
test/driver/test02.c
test/driver/test03.c
Added Paths:
-----------
test/driver/test-quit.zsh
tools/timebomb.zsh
Modified: Makefile.in
===================================================================
--- Makefile.in 2010-05-11 19:31:33 UTC (rev 84)
+++ Makefile.in 2010-05-11 21:18:02 UTC (rev 85)
@@ -273,8 +273,8 @@
$(Q) " DEBUGGING VARIABLES "
$(Q) " "
$(E)echo MPICC: $(MPICC)
- $(E)echo MODULES: $(MODULES)
- $(E)echo DISKSIM: $(DISKSIM)
+# $(E)echo MODULES: $(MODULES)
+# $(E)echo DISKSIM: $(DISKSIM)
$(E)echo CFLAGS: $(CFLAGS)
$(E)echo IFLAGS: $(IFLAGS)
$(E)echo LIBS: $(LIBS)
@@ -287,8 +287,8 @@
# $(E)echo USE_TABLE_KDA_2A: @USE_TABLE_KDA_2A@
# $(E)echo USE_TABLE_KDA_2B: @USE_TABLE_KDA_2B@
$(E)echo USE_TABLE_DENSE_1: @USE_TABLE_DENSE_1@
-# $(E)echo CMPI_SRC: $(CMPI_OBJS)
-# $(E)echo CMPI_OBJS: $(CMPI_OBJS)
+ $(E)echo TABLE_OBJS: $(TABLE_OBJS)
+ $(E)echo CMPI_OBJS: $(CMPI_OBJS)
# $(E)echo TEST_CMPI_SRC: $(TEST_CMPI_SRC)
# $(E)echo TEST_DISKSIM_SRC: $(TEST_DISKSIM_SRC)
# $(E)echo TEST_MPIRPC_SRC: $(TEST_MPIRPC_SRC)
@@ -317,7 +317,7 @@
include src/kda-2/module.mk
include src/dense-1/module.mk
include src/cmpi/module.mk
-#include src/cmpi-db/module.mk
+include src/cmpi-db/module.mk
#include src/cmpi-cp/module.mk
################################################################
@@ -351,7 +351,7 @@
include test/adts/module.mk
include test/mpirpc/module.mk
include test/cmpi/module.mk
-#include test/driver/module.mk.in
+include test/driver/module.mk.in
#include test/cmpi-db/module.mk.in
#include test/cmpi-io/module.mk.in
@@ -409,11 +409,11 @@
unpublish: src/mpirpc/unpublish.o $(CMPI)
$(Q) " MPICC $(@)"
- $(E)$(MPICC) $(<) $(CMPI) $(LIBS) -o $(@)
+ $(E) $(MPICC) $(<) $(CMPI) $(LIBS) -o $(@)
bin:
$(Q) " MKDIR $(@)"
- $(E)mkdir -p $(@)
+ $(E) mkdir -p $(@)
## Development tools...
@@ -534,7 +534,7 @@
# add this as a make goal to disable rebuilding dependencies
.PHONY: nodep clean
.SECONDARY: $(TEST_OBJS) $(TEST_PROGS)
-.PRECIOUS: $(TEST_OUTPUT) %.gs.dummyobj %.gs.i %.gs.s %.o
+.PRECIOUS: $(TEST_OUTPUT) %.o
nodep:; @:
# default rule for generating dependency files
Modified: include/driver.h
===================================================================
--- include/driver.h 2010-05-11 19:31:33 UTC (rev 84)
+++ include/driver.h 2010-05-11 21:18:02 UTC (rev 85)
@@ -13,7 +13,7 @@
*/
#define CMPI_DRIVER_MAX_COMMAND (100+CMPI_KEY_LENGTH)
-typedef struct cmpi_driver_
+typedef struct
{
FILE* source;
FILE* sink;
Modified: include/gossip.h
===================================================================
--- include/gossip.h 2010-05-11 19:31:33 UTC (rev 84)
+++ include/gossip.h 2010-05-11 21:18:02 UTC (rev 85)
@@ -127,6 +127,8 @@
int gossip_enable_syslog(
int priority);
+int gossip_enable_stdout(
+ void);
int gossip_enable_stderr(
void);
int gossip_enable_file(
Modified: src/cmpi/driver.c
===================================================================
--- src/cmpi/driver.c 2010-05-11 19:31:33 UTC (rev 84)
+++ src/cmpi/driver.c 2010-05-11 21:18:02 UTC (rev 85)
@@ -157,8 +157,8 @@
{
char* p = tokens->head->next->data;
int i;
- SHOW_I(i);
sscanf(p, "%i", &i);
+ SHOW_FI(i);
sleep(i);
fprintf(driver->sink, "ok\n");
fflush(driver->sink);
@@ -167,11 +167,16 @@
void
driver_quit(cmpi_driver* driver)
{
+ NOTE_F;
+
driver->quitting = true;
fprintf(driver->sink, "ok\n");
fflush(driver->sink);
+ NOTE("sent ok");
+ sleep(1);
+
cmpi_shutdown();
DONE;
}
@@ -183,8 +188,8 @@
struct list* tokens = list_parse(driver->command);
- gossip_ldebug(MASK_DRIVER, "got tokens: \n");
- gossip_do(MASK_DRIVER, list_printf("%s", tokens));
+ NOTE("got tokens: ");
+ DEBUG(list_printf("%s", tokens));
if (tokens->size == 0)
return;
Modified: src/cmpi/module.mk.in
===================================================================
--- src/cmpi/module.mk.in 2010-05-11 19:31:33 UTC (rev 84)
+++ src/cmpi/module.mk.in 2010-05-11 21:18:02 UTC (rev 85)
@@ -39,5 +39,5 @@
$(CMPI): $(CMPI_OBJS) $(TABLE_OBJS)
$(Q) " AR $@"
- $(E)$(INSTALL) -d lib
- $(E)ar rcs $(@) $(CMPI_OBJS) $(TABLE_OBJS)
+ $(E) install -d lib
+ $(E) ar rcs $(@) $(CMPI_OBJS) $(TABLE_OBJS)
Modified: src/cmpi/node.c
===================================================================
--- src/cmpi/node.c 2010-05-11 19:31:33 UTC (rev 84)
+++ src/cmpi/node.c 2010-05-11 21:18:02 UTC (rev 85)
@@ -153,8 +153,10 @@
int
main(int argc, char* argv[])
{
- gossip_set_debug_mask(1,MASK_DEBUG|MASK_MPIRPC|MASK_ADTS|
- MASK_CMPI|MASK_DRIVER);
+ gossip_debug_init();
+ gossip_set_debug_mask(true,MASK_DEBUG|MASK_MPIRPC|MASK_ADTS|
+ MASK_CMPI|MASK_DRIVER);
+ gossip_enable_stdout();
// Comment out to achieve deterministic results:
// srand((unsigned int) time(NULL));
Modified: src/cmpi-db/module.mk.in
===================================================================
--- src/cmpi-db/module.mk.in 2010-05-11 19:31:33 UTC (rev 84)
+++ src/cmpi-db/module.mk.in 2010-05-11 21:18:02 UTC (rev 85)
@@ -1,17 +1,17 @@
DIR := src/cmpi-db
-CMPI_PROGS += bin/cmpi-db
-CMPI_PROGS += bin/cmpi-db-fifo-quit
-CMPI_SRC += src/cmpi-cp/cmpi-cp.c src/cmpi-db/cmpi-db-fifo-quit.c
+PROGS += bin/cmpi-db
+PROGS += bin/cmpi-db-fifo-quit
+CMPIDB_SRC += src/cmpi-cp/cmpi-cp.c src/cmpi-db/cmpi-db-fifo-quit.c
-CMPI_DB = bin/cmpi-db
+CMPIDB = bin/cmpi-db
-$(CMPI_DB): src/cmpi/node.o src/cmpi/driver.o src/cmpi-db/cmpi-db-fifo.o $(CMPI) bin
+$(CMPI_DB): src/cmpi-db/cmpi-db-fifo.o $(CMPI) bin
$(Q) " MPICC $(@)"
$(E)$(MPICC) $(MPE) src/cmpi/node.o src/cmpi/driver.o \
- src/cmpi-db/cmpi-db-fifo.o $(CMPI) $(LIBS) -o $(@)
+ $(<) $(CMPI) $(LIBS) -o $(@)
bin/cmpi-db-fifo-quit: src/cmpi-db/cmpi-db-fifo-quit.o $(CMPI) bin
$(Q) " MPICC $(@)"
- $(E)$(MPICC) src/cmpi-db/cmpi-db-fifo-quit.o $(CMPI) -o $(@)
+ $(E)$(MPICC) $(<) $(CMPI) -o $(@)
Modified: src/gossip/gossip.c
===================================================================
--- src/gossip/gossip.c 2010-05-11 19:31:33 UTC (rev 84)
+++ src/gossip/gossip.c 2010-05-11 21:18:02 UTC (rev 85)
@@ -11,6 +11,7 @@
* Handles debugging output.
*/
+#include <assert.h>
#include <strings.h>
#include <gossip.h>
@@ -23,15 +24,16 @@
enum
{
- GOSSIP_STDERR = 1,
- GOSSIP_FILE = 2,
+ GOSSIP_STDOUT = 1,
+ GOSSIP_STDERR = 2,
+ GOSSIP_FILE = 3,
GOSSIP_SYSLOG = 4
};
-/** determines which logging facility to use. Default to stderr to begin
+/** determines which logging facility to use. Default to stdout to begin
* with.
*/
-int gossip_facility = GOSSIP_STDERR;
+int gossip_facility = GOSSIP_STDOUT;
/* file handle used for file logging */
static FILE *internal_log_file = NULL;
@@ -45,6 +47,7 @@
/*****************************************************************
* prototypes
*/
+static int gossip_disable_stdout(void);
static int gossip_disable_stderr(void);
static int gossip_disable_file(void);
@@ -94,6 +97,29 @@
return 0;
}
+/** Turns on logging to stdout.
+ *
+ * \return 0 on success, -errno on failure.
+ */
+int gossip_enable_stdout(
+ void)
+{
+ /* keep up with the existing logging settings */
+ int tmp_debug_on = gossip_debug_on;
+ uint64_t tmp_debug_mask = gossip_debug_mask;
+
+ /* turn off any running facility */
+ gossip_disable();
+
+ gossip_facility = GOSSIP_STDOUT;
+
+ /* restore the logging settings */
+ gossip_debug_on = tmp_debug_on;
+ gossip_debug_mask = tmp_debug_mask;
+
+ return 0;
+}
+
/** Turns on logging to stderr.
*
* \return 0 on success, -errno on failure.
@@ -162,6 +188,9 @@
switch (gossip_facility)
{
+ case GOSSIP_STDOUT:
+ ret = gossip_disable_stdout();
+ break;
case GOSSIP_STDERR:
ret = gossip_disable_stderr();
break;
@@ -300,6 +329,9 @@
switch (gossip_facility)
{
+ case GOSSIP_STDOUT:
+ ret = gossip_debug_fp_va(stdout, prefix, format, ap, internal_logstamp);
+ break;
case GOSSIP_STDERR:
ret = gossip_debug_fp_va(stderr, prefix, format, ap, internal_logstamp);
break;
@@ -340,6 +372,9 @@
switch (gossip_facility)
{
+ case GOSSIP_STDOUT:
+ ret = gossip_debug_fp_va(stdout, 'E', format, ap, internal_logstamp);
+ break;
case GOSSIP_STDERR:
ret = gossip_debug_fp_va(stderr, 'E', format, ap, internal_logstamp);
break;
@@ -545,6 +580,18 @@
return 0;
}
+/* gossip_disable_stdout()
+ *
+ * The shutdown function for the stdout logging facility.
+ *
+ * returns 0 on success, -errno on failure
+ */
+static int gossip_disable_stdout(
+ void)
+{
+ /* this function doesn't need to do anything... */
+ return 0;
+}
/* gossip_disable_stderr()
*
Modified: src/mpirpc/module.mk.in
===================================================================
--- src/mpirpc/module.mk.in 2010-05-11 19:31:33 UTC (rev 84)
+++ src/mpirpc/module.mk.in 2010-05-11 21:18:02 UTC (rev 85)
@@ -10,5 +10,5 @@
lib/libmpirpc.a: $(MPIRPC_OBJS)
$(Q) " AR $@"
- $(E)$(INSTALL) -d lib
- $(E)ar crs $(@) $(MPIRPC_OBJS)
+ $(E) install -d lib
+ $(E) ar crs $(@) $(MPIRPC_OBJS)
Modified: test/driver/module.mk.in
===================================================================
--- test/driver/module.mk.in 2010-05-11 19:31:33 UTC (rev 84)
+++ test/driver/module.mk.in 2010-05-11 21:18:02 UTC (rev 85)
@@ -1,20 +1,37 @@
-TEST_DRIVER_SRC += # $(shell find test/driver -name "*.c" ! -name test_helpers.c)
-TEST_SRC += $(TEST_DRIVER_SRC)
-TEST_HELPER_SRC += test/driver/test_helpers.c
+DIR := test/driver
-DRIVER = test/driver/test_driver.x
+TEST_DRIVER_SRC += $(shell find test/driver -name "*.c" ! -name test_helpers.c)
-DRIVER_IMPL = test/driver/test_driver_fifo.o
+TEST_DRIVER_OBJS = $(patsubst %.c, %.o, $(TEST_DRIVER_SRC))
+TEST_DRIVER_OUTPUT = $(patsubst %.c, %.out, $(TEST_DRIVER_SRC))
-test/driver/test%.x: test/driver/test%.o $(DRIVER)
+TEST_HELPER_SRC := test/driver/test_helpers.c
+TEST_DRIVER_OBJS += $(patsubst %.c, %.o, $(TEST_HELPER_SRC))
+
+TEST_SRC += $(TEST_DRIVER_SRC)
+TEST_OBJS += $(TEST_DRIVER_OBJS)
+TEST_PROGS += $(patsubst %.c, %.x, $(TEST_DRIVER_SRC))
+TEST_OUTPUT += $(TEST_DRIVER_OUTPUT)
+
+TEST_DRIVER = test/driver/test_driver.x
+
+TEST_DRIVER_IMPL = test/driver/test_driver_fifo.o
+
+$(TEST_DRIVER): $(TEST_DRIVER_IMPL) test/driver/test_helpers.o $(CMPI)
$(Q) " MPICC $(@) "
+ $(E) $(MPICC) $(MPE) $(<) test/driver/test_helpers.o \
+ $(CMPI) $(LIBS) -o $(@)
+
+test/driver/test%.x: test/driver/test%.o test/driver/test_helpers.o $(DRIVER)
+ $(Q) " MPICC $(@) "
$(E)$(MPICC) $(MPE) $(<) test/driver/test_helpers.o $(CMPI) $(LIBS) -o $(@)
-test/driver/test%.out: test/driver/test%.x $(DRIVER)
+test/driver/test02.x: test/driver/test02.o test/driver/test_helpers.o \
+ $(CMPI)
+ $(Q) " MPICC $(@) "
+ $(E)$(MPICC) $(MPE) $(<) test/driver/test_helpers.o $(CMPI) $(LIBS) -o $(@)
+
+test/driver/test%.out: test/driver/test%.zsh test/driver/test02.x $(TEST_DRIVER)
$(Q) " TEST $(@) "
- $(E)touch $(@)
-
-$(DRIVER): $(DRIVER_IMPL) test/driver/test_helpers.o src/cmpi/node.o $(CMPI)
- $(E)$(MPICC) $(MPE) $(<) test/driver/test_helpers.o src/cmpi/node.o \
- $(CMPI) $(LIBS) -o $(@)
+ $(E) $(<) $(@)
Added: test/driver/test-quit.zsh
===================================================================
--- test/driver/test-quit.zsh (rev 0)
+++ test/driver/test-quit.zsh 2010-05-11 21:18:02 UTC (rev 85)
@@ -0,0 +1,25 @@
+#!/bin/zsh
+
+OUTPUT=$1
+
+mpiexec -n 5 test/driver/test_driver.x -n 4 > ${OUTPUT} &
+DRIVER_PID=${!}
+
+tools/timebomb.zsh ${$} 10 ${OUTPUT} $0
+BOMB1_PID=${!}
+
+sleep 5
+
+print "Launching tool 02..."
+test/driver/test02.x
+
+wait
+
+N=$( grep -c "Normal exit" ${OUTPUT} )
+if (( N != 5 ))
+then
+ mv -v ${OUTPUT} ${OUTPUT}.failed
+ exit 1
+fi
+
+return 0
Property changes on: test/driver/test-quit.zsh
___________________________________________________________________
Added: svn:executable
+ *
Modified: test/driver/test01.c
===================================================================
--- test/driver/test01.c 2010-05-11 19:31:33 UTC (rev 84)
+++ test/driver/test01.c 2010-05-11 21:18:02 UTC (rev 85)
@@ -1,21 +1,24 @@
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <accessor.h>
int
main(int argc, char* argv[])
{
+ int error;
+
driver_access_fifo();
fprintf(to_cmpi, "sleep 3\n");
fflush(to_cmpi);
- char output[30];
- fscanf(from_cmpi, "output: %s", output);
+ char output[32];
+ error = fscanf(from_cmpi, "%s", output);
- printf("%s\n", output);
+ assert(!strcmp(output, "ok"));
return 0;
}
-
Modified: test/driver/test02.c
===================================================================
--- test/driver/test02.c 2010-05-11 19:31:33 UTC (rev 84)
+++ test/driver/test02.c 2010-05-11 21:18:02 UTC (rev 85)
@@ -2,19 +2,23 @@
#include <stdio.h>
#include <stdlib.h>
+#include <mpi_tools.h>
#include <accessor.h>
int
main(int argc, char* argv[])
{
- driver_access_fifo();
+ int error;
+ error = driver_access_fifo();
+ assert(error);
+
fprintf(to_cmpi, "quit\n");
fflush(to_cmpi);
- char output[30];
- fscanf(from_cmpi, "output: %s", output);
+ char output[32];
+ fscanf(from_cmpi, "%s", output);
- printf("%s\n", output);
+ assert(!strcmp(output, "ok"));
return 0;
}
Modified: test/driver/test03.c
===================================================================
--- test/driver/test03.c 2010-05-11 19:31:33 UTC (rev 84)
+++ test/driver/test03.c 2010-05-11 21:18:02 UTC (rev 85)
@@ -1,25 +1,26 @@
-#include <stdio.h>
+#include <assert.h>
+#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
+#include <string.h>
-#include <accessor.h>
+#include <accessor.h>
int
main(int argc, char* argv[])
{
driver_access_fifo();
-
- char data[30] = "hello does this work";
-
+
+ char* data = "hello does this work";
+
fprintf(to_cmpi, "put key1 %i\n", (int) strlen(data));
fprintf(to_cmpi, "%s", data);
- fflush(to_cmpi);
-
- char output[30];
- fscanf(from_cmpi, "output: %s", output);
+ fflush(to_cmpi);
- printf("%s\n", output);
+ char output[32];
+ fscanf(from_cmpi, "%s", output);
- return 0;
+ assert(!strcmp(output, "ok"));
+
+ return 0;
}
Added: tools/timebomb.zsh
===================================================================
--- tools/timebomb.zsh (rev 0)
+++ tools/timebomb.zsh 2010-05-11 21:18:02 UTC (rev 85)
@@ -0,0 +1,17 @@
+#!/bin/zsh
+
+TARGET=$1
+DELAY=$2
+DATA=$3
+shift 3
+LABEL=${*}
+
+sleep ${DELAY}
+
+print "timebomb killing: ${LABEL} PID: ${TARGET}"
+
+cp -v ${DATA} ${DATA}.bak
+
+sleep 3
+
+kill ${TARGET}
Property changes on: tools/timebomb.zsh
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|