[C-mpi-commits] SF.net SVN: c-mpi:[28] test/mpirpc
Status: Pre-Alpha
Brought to you by:
jmwozniak
|
From: <jmw...@us...> - 2010-04-20 18:26:28
|
Revision: 28
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=28&view=rev
Author: jmwozniak
Date: 2010-04-20 18:26:19 +0000 (Tue, 20 Apr 2010)
Log Message:
-----------
Improving MPIRPC tests...
Modified Paths:
--------------
Makefile.in
include/mpi_tools.h
src/mpi_tools/mpi_tools.c
test/mpirpc/module.mk.in
test/mpirpc/test01.c
test/mpirpc/test02.c
test/mpirpc/test_helpers.h
Added Paths:
-----------
test/mpirpc/test02.zsh
Modified: Makefile.in
===================================================================
--- Makefile.in 2010-04-20 17:42:29 UTC (rev 27)
+++ Makefile.in 2010-04-20 18:26:19 UTC (rev 28)
@@ -426,6 +426,9 @@
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"
Modified: include/mpi_tools.h
===================================================================
--- include/mpi_tools.h 2010-04-20 17:42:29 UTC (rev 27)
+++ include/mpi_tools.h 2010-04-20 18:26:19 UTC (rev 28)
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <mpi.h>
@@ -42,8 +43,9 @@
char* iheap(int i);
char* xheap(int i);
-/** Execute code line or block in rank order.
- */
+/**
+ Execute code line or block in rank order.
+*/
#define sequential(code) \
{ \
int sequential_i; \
@@ -331,6 +333,8 @@
#define DUMPSTACK DEBUG(dump_stack());
+char* file_string(char* file);
+
//// Memory usage debugging:
#ifdef DMALLOC
#include <dmalloc.h>
@@ -340,6 +344,22 @@
#endif
/**
+ Set up DMALLOC
+*/
+
+#ifdef DMALLOC
+void
+dmalloc_setup(void)
+{
+ dmalloc_logpath = malloc(100);
+ assert(dmalloc_logpath != NULL);
+ sprintf(dmalloc_logpath, "./dmalloc_%i.out", debug_rank);
+ printf("dmalloc_logpath: %s \n", dmalloc_logpath);
+ fflush(NULL);
+}
+#endif
+
+/**
Return a number in [0,n-1].
*/
int roll(int n);
Modified: src/mpi_tools/mpi_tools.c
===================================================================
--- src/mpi_tools/mpi_tools.c 2010-04-20 17:42:29 UTC (rev 27)
+++ src/mpi_tools/mpi_tools.c 2010-04-20 18:26:19 UTC (rev 28)
@@ -409,6 +409,27 @@
return d;
}
+/**
+ Read in a whole small file as a string.
+*/
+char*
+file_string(char* file)
+{
+ intmax_t size;
+ struct stat stats;
+
+ stat(file, &stats);
+ size = (intmax_t) stats.st_size;
+ char* result = malloc(size+1);
+
+ FILE* f = fopen(file, "r");
+ int r = fread(result, 1, size, f);
+ assert(r == size);
+ result[size] = '\0';
+ fclose(f);
+ return result;
+}
+
#ifdef ENABLE_DEBUG
#ifdef HAVE_EXEC_INFO_H
/**
Modified: test/mpirpc/module.mk.in
===================================================================
--- test/mpirpc/module.mk.in 2010-04-20 17:42:29 UTC (rev 27)
+++ test/mpirpc/module.mk.in 2010-04-20 18:26:19 UTC (rev 28)
@@ -1,14 +1,18 @@
DIR := test/mpirpc
+# Tests require NODES and REPS variables
+# Usage: make D=1 NODES=2 REPS=1 test/mpirpc/test01.out
+
TEST_MPIRPC_SRC += $(shell find $(DIR) -name "*.c" )
TEST_SRC += $(TEST_MPIRPC_SRC)
+TEST_STATUS += $(DIR)/test02.status
test/mpirpc/test%.out: test/mpirpc/test%.x
+ mpdlistjobs
$(LAUNCH) -n $(NODES) $(<) -c "reps=$(REPS)" > $(@) 2>&1
cp -uv $(@) test/mpirpc/readable.txt
$(DIR)/test%.x: $(DIR)/test%.o $(CMPI)
$(Q) " MPICC $(@) "
$(E)$(MPICC) $(MPE) $(<) $(CMPI) $(LIBS) -o $(@)
-
Modified: test/mpirpc/test01.c
===================================================================
--- test/mpirpc/test01.c 2010-04-20 17:42:29 UTC (rev 27)
+++ test/mpirpc/test01.c 2010-04-20 18:26:19 UTC (rev 28)
@@ -4,8 +4,6 @@
No arguments or return values.
*/
-#include <sys/stat.h>
-
#include <mpirpc.h>
#include "test_helpers.h"
@@ -13,22 +11,6 @@
int count = 0;
bool running = true;
-char*
-file_string(char* file)
-{
- intmax_t size;
- struct stat stats;
-
- stat(file, &stats);
- size = (intmax_t) stats.st_size;
- char* result = malloc(size+1);
-
- FILE* f = fopen(file, "r");
- fread(result, 1, size, f);
- fclose(f);
- return result;
-}
-
void
handle_ping(MPIRPC_Node caller, int unique, char* args,
char* blob, int blob_length)
Modified: test/mpirpc/test02.c
===================================================================
--- test/mpirpc/test02.c 2010-04-20 17:42:29 UTC (rev 27)
+++ test/mpirpc/test02.c 2010-04-20 18:26:19 UTC (rev 28)
@@ -2,7 +2,7 @@
/**
Simple two-processor argument test
for NULL, 0-length, and non-0-length args.
- NULL return values.
+ NULL return values.
*/
#include <mpirpc.h>
@@ -13,48 +13,48 @@
{
show_fs(args);
if (args)
- free(args);
- MPIRPC_Null(caller, unique);
+ free(args);
+ MPIRPC_Null(caller, unique);
}
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)
{
MPIRPC_Node_make(MPI_COMM_WORLD, 1, &neighbor);
MPIRPC_Block(neighbor, "test", NULL);
MPIRPC_Block(neighbor, "test", "");
- MPIRPC_Block(neighbor, "test", "alpha");
+ MPIRPC_Block(neighbor, "test", "alpha");
}
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;
}
Added: test/mpirpc/test02.zsh
===================================================================
--- test/mpirpc/test02.zsh (rev 0)
+++ test/mpirpc/test02.zsh 2010-04-20 18:26:19 UTC (rev 28)
@@ -0,0 +1,29 @@
+#!/bin/zsh
+
+set -x
+
+# Be sure to make tests with D=1
+
+OUT=$1
+STATUS=${OUT%.out}.status
+
+crash()
+{
+ print $1
+ exit 1
+}
+
+# Should only be 3 calls to handle_test()...
+N=$( grep -c "handle_test(args=" ${OUT} )
+(( N == 3 )) || crash "N != 3"
+
+TOKENS=("handle_test(args=(null))"
+ "handle_test(args=)"
+ "handle_test(args=alpha)" )
+
+for T in ${TOKENS}
+do
+ grep ${T} ${OUT} || crash "Not found: ${T}"
+done
+
+print success > ${STATUS}
Property changes on: test/mpirpc/test02.zsh
___________________________________________________________________
Added: svn:executable
+ *
Modified: test/mpirpc/test_helpers.h
===================================================================
--- test/mpirpc/test_helpers.h 2010-04-20 17:42:29 UTC (rev 27)
+++ test/mpirpc/test_helpers.h 2010-04-20 18:26:19 UTC (rev 28)
@@ -1,14 +0,0 @@
-
-
-#ifdef DMALLOC
-void
-dmalloc_setup(void)
-{
- dmalloc_logpath = malloc(100);
- assert(dmalloc_logpath != NULL);
- sprintf(dmalloc_logpath, "./dmalloc_%i.out", debug_rank);
- printf("dmalloc_logpath: %s \n", dmalloc_logpath);
- fflush(NULL);
-}
-#endif
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|