[C-mpi-commits] SF.net SVN: c-mpi:[30] test/mpirpc
Status: Pre-Alpha
Brought to you by:
jmwozniak
|
From: <jmw...@us...> - 2010-04-20 19:02:43
|
Revision: 30
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=30&view=rev
Author: jmwozniak
Date: 2010-04-20 19:02:35 +0000 (Tue, 20 Apr 2010)
Log Message:
-----------
More test improvements.
Modified Paths:
--------------
Makefile.in
clean.zsh
test/mpirpc/module.mk.in
test/mpirpc/test03.c
Added Paths:
-----------
test/mpirpc/test-ping.c
test/mpirpc/test-ping.zsh
Modified: Makefile.in
===================================================================
--- Makefile.in 2010-04-20 18:27:27 UTC (rev 29)
+++ Makefile.in 2010-04-20 19:02:35 UTC (rev 30)
@@ -426,9 +426,6 @@
tests: $(CMPI) $(TEST_PROGS)
-%.status: %.out
- $(patsubst %.out, %.zsh, $(<)) $(<)
-
# Obsolete target: delete soon.
cmpi-io-test: $(CMPI_IO) src/cmpi/cmpi-io-test.o
$(Q) " MPICC cmpi-io-test"
@@ -483,6 +480,7 @@
hex unhex hexord unpublish node driver \
$(TEST_OUTPUT) $(TEST_PROGS) $(TEST_OBJS) \
$(CMPI_PROGS) $(CMPI_CP_OBJS) splint.out
+ $(E)find . -name "*.failed" -exec rm -fv \{\} \;
# $(E)find . -name "*.avg" -exec rm -fv \{\} \;
# $(E)find . -name "*.per" -exec rm -fv \{\} \;
Modified: clean.zsh
===================================================================
--- clean.zsh 2010-04-20 18:27:27 UTC (rev 29)
+++ clean.zsh 2010-04-20 19:02:35 UTC (rev 30)
@@ -8,6 +8,7 @@
then
make clean
rm -fv ${MODULES}
+ rm -fv **/*.tmp
rm Makefile
fi
Modified: test/mpirpc/module.mk.in
===================================================================
--- test/mpirpc/module.mk.in 2010-04-20 18:27:27 UTC (rev 29)
+++ test/mpirpc/module.mk.in 2010-04-20 19:02:35 UTC (rev 30)
@@ -10,7 +10,7 @@
test/mpirpc/test%.out: test/mpirpc/test%.x
mpdlistjobs
- $(LAUNCH) -n $(NODES) $(<) -c "reps=$(REPS)" > $(@) 2>&1
+ $(patsubst %.x, %.zsh, $(<)) $(<) $(LAUNCH)
cp -uv $(@) test/mpirpc/readable.txt
$(DIR)/test%.x: $(DIR)/test%.o $(CMPI)
Added: test/mpirpc/test-ping.c
===================================================================
--- test/mpirpc/test-ping.c (rev 0)
+++ test/mpirpc/test-ping.c 2010-04-20 19:02:35 UTC (rev 30)
@@ -0,0 +1,88 @@
+
+/**
+ Simple two-processor ping pong test.
+ No arguments or return values.
+*/
+
+#include <mpirpc.h>
+
+#include "test_helpers.h"
+
+int count = 0;
+bool running = true;
+
+void
+handle_ping(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
+{
+ NOTE_F;
+ SHOW_S(args);
+ MPIRPC_Null(caller, unique);
+ if (++count < 3)
+ {
+ MPIRPC_Call(caller, "ping", NULL, NULL, MPIRPC_Free);
+ }
+ else
+ {
+ MPIRPC_Flush_returns();
+ MPIRPC_Block(caller, "quit", NULL);
+ running = false;
+ }
+}
+
+void
+handle_quit(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
+{
+ NOTE_F;
+ SHOW_S(args);
+ running = false;
+ MPIRPC_Null(caller, unique);
+}
+
+int
+main(int argc, char* argv[])
+{
+ printf("host: %s\n", file_string("/etc/hostname"));
+
+ MPI_Init(&argc, &argv);
+
+ MPIRPC_Init();
+
+ SHOW_I(debug_rank);
+
+ DMALLOC_SETUP(dmalloc_setup());
+
+ MPIRPC_Comm_add(MPI_COMM_WORLD);
+ MPIRPC_Register("ping", handle_ping);
+ MPIRPC_Register("quit", handle_quit);
+
+ MPIRPC_Node neighbor;
+ if (mpi_rank == 0)
+ {
+ MPIRPC_Node_make(MPI_COMM_WORLD, 1, &neighbor);
+ MPIRPC_Block(neighbor, "ping", NULL);
+ }
+ else
+ {
+ MPIRPC_Node_make(MPI_COMM_WORLD, 0, &neighbor);
+ }
+
+ while (running)
+ {
+ MPIRPC_Check();
+ sleep(1);
+ }
+
+ note("Normal exit.\n");
+
+ MPIRPC_Finalize();
+ MPI_Finalize();
+
+ DMALLOC_SETUP(if (mpi_rank == 0)
+ {
+ SHOW_S(dmalloc_logpath);
+ dmalloc_shutdown();
+ });
+ return 0;
+}
Added: test/mpirpc/test-ping.zsh
===================================================================
--- test/mpirpc/test-ping.zsh (rev 0)
+++ test/mpirpc/test-ping.zsh 2010-04-20 19:02:35 UTC (rev 30)
@@ -0,0 +1,33 @@
+#!/bin/zsh
+
+set -x
+
+# Be sure to make tests with D=1
+
+PROGRAM=$1
+OUT=${PROGRAM%.x}.out
+shift
+LAUNCH=${*}
+
+crash()
+{
+ print $1
+ mv ${OUT} ${OUT}.failed
+ exit 1
+}
+
+eval ${LAUNCH} -n 2 ${PROGRAM} > ${OUT} 2>&1
+CODE=$?
+[[ ${CODE} == 0 ]] || crash "exit code was: ${CODE}"
+
+# Should be 5 calls to handle_ping()...
+N=$( grep -c "handle_ping" ${OUT} )
+(( N == 5 )) || crash "N != 6"
+
+grep "handle_quit" ${OUT} || crash "No handle_quit!"
+
+# Should be 2 "Normal exit."s
+N=$( grep -c "Normal exit." ${OUT} )
+(( N == 2 )) || crash "N != 2"
+
+exit 0
Property changes on: test/mpirpc/test-ping.zsh
___________________________________________________________________
Added: svn:executable
+ *
Modified: test/mpirpc/test03.c
===================================================================
--- test/mpirpc/test03.c 2010-04-20 18:27:27 UTC (rev 29)
+++ test/mpirpc/test03.c 2010-04-20 19:02:35 UTC (rev 30)
@@ -1,7 +1,7 @@
/**
Simple two-processor argument test
- for non-0-length args and
+ for non-0-length args and
for NULL, 0-length, and non-0-length return values.
*/
@@ -15,7 +15,7 @@
sscanf(args, "%i", &a);
show_fsi(args, a);
char* result = malloc(4);
-
+
if (a == 0)
{
MPIRPC_Null(caller, unique);
@@ -26,56 +26,56 @@
}
else if (a == 2)
{
- strcpy(result, "ok\n");
+ strcpy(result, "ok\n");
MPIRPC_Return(caller, unique, result, 4);
}
-
+
if (args)
- free(args);
+ free(args);
}
int
main(int argc, char* argv[])
{
- gossip_set_debug_mask(1, MASK_MPIRPC);
-
- MPI_Init(&argc, &argv);
- MPIRPC_Init();
+ gossip_set_debug_mask(1, MASK_MPIRPC);
+
+ MPI_Init(&argc, &argv);
+ MPIRPC_Init();
whoami();
- DMALLOC_SETUP(dmalloc_setup());
-
- MPIRPC_Comm_add(MPI_COMM_WORLD);
-
+ DMALLOC_SETUP(dmalloc_setup());
+
+ MPIRPC_Comm_add(MPI_COMM_WORLD);
+
MPIRPC_Node neighbor;
if (mpi_rank == 0)
{
- char* result;
+ char* result;
MPIRPC_Node_make(MPI_COMM_WORLD, 1, &neighbor);
result = MPIRPC_Block(neighbor, "test", "0");
- show_s(result);
+ show_s(result);
result = MPIRPC_Block(neighbor, "test", "1");
- show_s(result);
+ show_s(result);
result = MPIRPC_Block(neighbor, "test", "2");
- show_s(result);
+ show_s(result);
}
else
{
- MPIRPC_Node_make(MPI_COMM_WORLD, 0, &neighbor);
- MPIRPC_Register("test", handle_test);
+ MPIRPC_Node_make(MPI_COMM_WORLD, 0, &neighbor);
+ MPIRPC_Register("test", handle_test);
while (! MPIRPC_Check());
while (! MPIRPC_Check());
- while (! MPIRPC_Check());
+ while (! MPIRPC_Check());
}
- printf("Normal exit.\n");
- MPIRPC_Finalize();
+ printf("Normal exit.\n");
+ MPIRPC_Finalize();
MPI_Finalize();
DMALLOC_SETUP(if (mpi_rank == 0)
{
- SHOW_S(dmalloc_logpath);
+ SHOW_S(dmalloc_logpath);
dmalloc_shutdown();
});
- return 0;
+ return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|