From a536649abb4335719dd503337778c64cfbdd0d5b Mon Sep 17 00:00:00 2001 From: "Julian M. Kunkel" Date: Wed, 20 May 2020 17:46:35 +0100 Subject: [PATCH] Clarified some issues in the test framework and added example test. #219 --- configure.ac | 1 + src/Makefile.am | 10 +--------- src/ior-internal.h | 3 +++ src/ior.c | 6 ++---- src/test/Makefile.am | 8 ++++++++ src/test/example.c | 31 +++++++++++++++++++++++++++++++ 6 files changed, 46 insertions(+), 13 deletions(-) create mode 100755 src/test/Makefile.am create mode 100644 src/test/example.c diff --git a/configure.ac b/configure.ac index 0cb99c4..cd71b39 100755 --- a/configure.ac +++ b/configure.ac @@ -348,6 +348,7 @@ AM_CONDITIONAL([USE_CAPS], [test x$enable_caps = xyes]) AC_CONFIG_FILES([Makefile src/Makefile + src/test/Makefile contrib/Makefile doc/Makefile]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 1c37a6e..3786560 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = . +SUBDIRS = . test bin_PROGRAMS = ior mdtest if USE_CAPS @@ -123,11 +123,3 @@ MDTEST_CPPFLAGS = $(mdtest_CPPFLAGS) libaiori_a_SOURCES += $(extraSOURCES) libaiori_a_CPPFLAGS = $(extraCPPFLAGS) - - -TESTS = testlib -bin_PROGRAMS += testlib - -testlib_SOURCES = ./test/lib.c -testlib_LDFLAGS = $(extraLDFLAGS) -testlib_LDADD = libaiori.a $(extraLDADD) diff --git a/src/ior-internal.h b/src/ior-internal.h index 7daf8de..9cc8406 100644 --- a/src/ior-internal.h +++ b/src/ior-internal.h @@ -26,6 +26,9 @@ void PrintTestEnds(); void PrintTableHeader(); /* End of ior-output */ +IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, int pretendRank); +IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank, int access); + struct results { double min; double max; diff --git a/src/ior.c b/src/ior.c index c831a84..2237cc3 100755 --- a/src/ior.c +++ b/src/ior.c @@ -1731,8 +1731,7 @@ static void ValidateTests(IOR_param_t * test) * @param pretendRank int pretended Rank for shifting the offsest corectly * @return IOR_offset_t */ -static IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, - int pretendRank) +IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, int pretendRank) { IOR_offset_t i, j, k = 0; IOR_offset_t offsets; @@ -1781,8 +1780,7 @@ static IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, * @return IOR_offset_t * @return */ -static IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank, - int access) +IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank, int access) { int seed; IOR_offset_t i, value, tmp; diff --git a/src/test/Makefile.am b/src/test/Makefile.am new file mode 100755 index 0000000..1f2b141 --- /dev/null +++ b/src/test/Makefile.am @@ -0,0 +1,8 @@ +LDFLAGS = $(extraLDFLAGS) +LDADD = ../libaiori.a $(extraLDADD) + +# Add test here +TESTS = testlib testexample +check_PROGRAMS = $(TESTS) +testexample_SOURCES = example.c +testlib_SOURCES = lib.c diff --git a/src/test/example.c b/src/test/example.c new file mode 100644 index 0000000..5bb4b2b --- /dev/null +++ b/src/test/example.c @@ -0,0 +1,31 @@ +#include + +#include +#include + +// build a single test via, e.g., mpicc example.c -I ../src/ ../src/libaiori.a -lm + +int main(){ + IOR_param_t test; + init_IOR_Param_t(& test); + test.blockSize = 10; + test.transferSize = 10; + test.segmentCount = 5; + test.numTasks = 2; + + // having an individual file + test.filePerProc = 1; + + IOR_offset_t * offsets; + offsets = GetOffsetArraySequential(& test, 0); + assert(offsets[0] == 0); + assert(offsets[1] == 10); + assert(offsets[2] == 20); + assert(offsets[3] == 30); + assert(offsets[4] == 40); + // for(int i = 0; i < test.segmentCount; i++){ + // printf("%lld\n", (long long int) offsets[i]); + // } + printf("OK\n"); + return 0; +}