major changes in preparations for 1.6 release: will add details to CHANGES
This commit is contained in:
+18
-159
@@ -1,171 +1,30 @@
|
||||
# test level Makefile.am
|
||||
|
||||
# PATH SETTING
|
||||
HDF5ROOT = @HDF5ROOT@
|
||||
OBJEXT=o
|
||||
|
||||
# COMPILER SETTING
|
||||
CXX = @CXX@
|
||||
FC = @FC@
|
||||
MPIFC = @MPIFC@
|
||||
MPICXX = @MPICXX@
|
||||
MPICC = @MPICC@
|
||||
HDFLIB = -L@HDF5ROOT@/lib -lhdf5 -lz @SZLIB@
|
||||
LIBS = -L@H5P_LIB_LOC@ -lH5PartF -lH5Part $(HDFLIB) -lm
|
||||
|
||||
# COMPILER FLAG SETTING
|
||||
CFLAGS = @CFLAGS@
|
||||
FFLAGS = @FFLAGS@ @MPIINC@
|
||||
INCLUDES = -I@H5P_LIB_LOC@ -I@HDF5ROOT@/include @MPIINC@
|
||||
|
||||
# LIBRARIES
|
||||
SZLIB = @SZLIB@
|
||||
HDFLIB = -L$(HDF5ROOT)/lib -lhdf5 -lz $(SZLIB) @LDFLAGS@
|
||||
MPILIB = @MPILIB@
|
||||
H5LIB = -L@H5P_LIB_LOC@ -lH5Part
|
||||
noinst_PROGRAMS = @TTARGET@
|
||||
|
||||
LIBS = ${H5LIB} $(HDFLIB) $(MPILIB) -lm @STDCXX@
|
||||
TESTS_ENVIRONMENT = env LD_LIBRARY_PATH=@HDF5ROOT@/lib:$(LD_LIBRARY_PATH)
|
||||
TESTS = @TTARGET@
|
||||
|
||||
# H5Part compiled library location
|
||||
# H5PLIB = -L@prefix@/lib
|
||||
EXTRA_PROGRAMS = test testf
|
||||
|
||||
# INCLUDES
|
||||
HDFINC = -I$(HDF5ROOT)/include
|
||||
MPIINC = @MPIINC@
|
||||
H5INC = -I@H5P_LIB_LOC@
|
||||
test_SOURCES = test.c \
|
||||
testframe.c \
|
||||
write.c \
|
||||
read.c \
|
||||
testframe.h
|
||||
|
||||
INC = $(HDFINC) $(MPIINC) $(H5INC)
|
||||
|
||||
|
||||
# What to build... make install will place these files in the $(prefix)/bin directory.
|
||||
bin_PROGRAMS = @TTARGET@
|
||||
|
||||
# Some useful scripts that I wish to place in the $(prefix)/bin directory.
|
||||
bin_SCRIPTS =
|
||||
#bin_SCRIPTS = JAC_H5PartTestP_script.scr JAC_H5testFpar_script.scr JAC_RUN_ALL_script.scr
|
||||
|
||||
|
||||
# Listing of all programs that maybe built. (Has to know statically...)
|
||||
EXTRA_PROGRAMS =
|
||||
|
||||
# Extra files that I wish to include in the dist tar ball.
|
||||
EXTRA_DIST = Bench.c \
|
||||
H5ParallelTest.cc \
|
||||
H5PartTest.cc H5PartTestParallel.cc \
|
||||
H5PartAndreasTest.cc \
|
||||
H5test.cc H5testF.f \
|
||||
H5testFpar.F90 \
|
||||
H5BlockParTestScalarField.c H5BlockParTestScalarFieldF.F90 \
|
||||
H5BlockTestAttributes.c H5BlockTestAttributesF.F90 \
|
||||
H5PartBench.c H5BlockBench.c \
|
||||
$(bin_SCRIPTS)
|
||||
|
||||
# Specific building instruction (What compilers to use...)
|
||||
# ------------ Build Tests ------------
|
||||
|
||||
Bench: Bench.c
|
||||
$(CC) $(CFLAGS) $(INC) -o $@ $< $(H5PLIB) -lH5Part $(LIBS)
|
||||
|
||||
H5PartBench: H5PartBench.c
|
||||
$(CC) $(CFLAGS) $(INC) -o $@ $< $(H5PLIB) -lpH5Part $(LIBS)
|
||||
|
||||
H5BlockBench: H5BlockBench.c
|
||||
$(CC) $(CFLAGS) $(INC) -o $@ $< $(H5PLIB) -lpH5Part $(LIBS)
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartTest: H5PartTest.o
|
||||
$(CXX) -o $@ $< $(H5PLIB) -lH5Part $(LIBS)
|
||||
|
||||
H5PartTest.o: H5PartTest.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -g -c $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartTestP: H5PartTestP.o
|
||||
$(CXX) $(INC) -o $@ $< $(H5LIB) -lH5Part $(LIBS)
|
||||
|
||||
H5PartTestP.o: H5PartTest.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -c $< -o $@
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartTestParallel: H5PartTestParallel.o
|
||||
$(CXX) -o $@ $< $(H5LIB) -lH5Part $(LIBS)
|
||||
|
||||
H5PartTestParallel.o: H5PartTestParallel.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -c $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5PartAndreasTest: H5PartAndreasTest.o
|
||||
$(CXX) -o $@ $< $(H5LIB) -lpH5Part $(LIBS)
|
||||
|
||||
H5PartAndreasTest.o: H5PartAndreasTest.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -c $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5testF: H5testF.o
|
||||
$(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
|
||||
|
||||
H5testF.o: H5testF.f
|
||||
$(FC) $(FFLAGS) -c $(H5INC) $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5testFpar: H5testFpar.o
|
||||
$(MPIFC) -o $@ $< $(H5LIB) -lpH5PartF -lpH5Part $(LIBS)
|
||||
|
||||
H5testFpar.o: H5testFpar.F90
|
||||
$(MPIFC) $(FFLAGS) -c $(H5INC) $<
|
||||
|
||||
###############################################################################
|
||||
|
||||
H5test: H5test.o
|
||||
$(CXX) -o $@ $< $(H5LIB) $(LIBS)
|
||||
|
||||
H5test.o: H5test.cc
|
||||
$(CXX) $(CFLAGS) $(INC) -DREGRESSIONTEST -g -c $<
|
||||
|
||||
###############################################################################
|
||||
% : %.o
|
||||
$(CC) -o $@ $< $(H5LIB) $(LIBS)
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) $(INC) -g -c $<
|
||||
|
||||
%.o : %.F90
|
||||
${FC} $(FFLAGS) -c $(H5INC) $<
|
||||
|
||||
H5BlockTestAttributes.o: H5BlockTestAttributes.c
|
||||
|
||||
H5BlockTestAttributes: H5BlockTestAttributes.o
|
||||
|
||||
H5BlockTestAttributesF.o: H5BlockTestAttributesF.F90
|
||||
|
||||
H5BlockTestAttributesF: H5BlockTestAttributesF.o
|
||||
$(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
|
||||
|
||||
H5BlockParTestScalarField.o: H5BlockParTestScalarField.c
|
||||
|
||||
H5BlockParTestScalarField: H5BlockParTestScalarField.o
|
||||
|
||||
H5BlockParTestScalarFieldF.o: H5BlockParTestScalarFieldF.F90
|
||||
|
||||
H5BlockParTestScalarFieldF: H5BlockParTestScalarFieldF.o
|
||||
$(FC) -o $@ $< $(H5LIB) -lH5PartF -lH5Part $(LIBS)
|
||||
|
||||
H5BlockDissolveGhosts.o: H5BlockDissolveGhosts.c
|
||||
|
||||
H5BlockDissolveGhosts: H5BlockDissolveGhosts.o
|
||||
|
||||
|
||||
###############################################################################
|
||||
clean:
|
||||
${RM} -f *~ *.o ${bin_PROGRAMS}
|
||||
|
||||
distclean: clean
|
||||
${RM} -rf .deps
|
||||
${RM} -rf .libs
|
||||
${RM} -f parttest.h5
|
||||
${RM} -rf config.status config.log config.h Makefile
|
||||
testf_SOURCES = testf.F90
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $<
|
||||
|
||||
clean: clean-am
|
||||
rm -f *.h5
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef _H5PART_TEST_PARAMS_H_
|
||||
#define _H5PART_TEST_PARAMS_H_
|
||||
|
||||
#define FILENAME "test.h5"
|
||||
#define LONGSTEPNAME "thisisaverylongstepnamethatshouldexceedthelimitof64charcausingawarningtoprint"
|
||||
#define NTIMESTEPS 10
|
||||
|
||||
/* do not decrease this value below 99, or it will break assumptions
|
||||
* made in the read tests! */
|
||||
#define NPARTICLES 99
|
||||
|
||||
/* do not increase this value past 32! */
|
||||
#define MAX_MPI_TASKS 32
|
||||
|
||||
#define ATTR_NAME_SIZE 16
|
||||
#define ATTR_STR_VAL "test"
|
||||
#define ATTR_INT32_VAL -2147483648
|
||||
#define ATTR_INT64_VAL 2147483648
|
||||
#define ATTR_FLOAT_VAL 3.14159265F
|
||||
|
||||
#endif
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#include <stdlib.h>
|
||||
#include <H5Part.h>
|
||||
|
||||
#include "testframe.h"
|
||||
#include "params.h"
|
||||
|
||||
/* from write.c */
|
||||
void test_write1(void);
|
||||
void test_write2(void);
|
||||
void test_write3(void);
|
||||
void test_write4(void);
|
||||
|
||||
/* from read.c */
|
||||
void test_read1(void);
|
||||
void test_read2(void);
|
||||
void test_read3(void);
|
||||
void test_read4(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#ifdef PARALLEL_IO
|
||||
MPI_Init(&argc, &argv);
|
||||
int procs;
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &procs);
|
||||
if (procs > MAX_MPI_TASKS) {
|
||||
fprintf(stderr, "ERROR: please use <= %d MPI tasks for the test.",
|
||||
MAX_MPI_TASKS);
|
||||
MPI_Abort(MPI_COMM_WORLD, -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize testing framework */
|
||||
TestInit(argv[0], NULL, NULL);
|
||||
|
||||
/* Tests are generally arranged from least to most complexity... */
|
||||
AddTest("write1", test_write1, NULL, "Write 32-bit data", NULL);
|
||||
AddTest("read1", test_read1, NULL, "Read 32-bit data", NULL);
|
||||
AddTest("write2", test_write2, NULL, "Write 32-bit strided data", NULL);
|
||||
AddTest("read2", test_read2, NULL, "Read 32-bit strided data", NULL);
|
||||
AddTest("write3", test_write3, NULL, "Write 64-bit strided data", NULL);
|
||||
AddTest("read3", test_read3, NULL, "Read 64-bit strided data", NULL);
|
||||
AddTest("write4", test_write4, NULL, "Write 64-bit data", NULL);
|
||||
AddTest("read4", test_read4, NULL, "Read 64-bit data", NULL);
|
||||
|
||||
/* Display testing information */
|
||||
TestInfo(argv[0]);
|
||||
|
||||
/* Parse command line arguments */
|
||||
TestParseCmdLine(argc, argv);
|
||||
|
||||
H5PartSetVerbosityLevel(GetTestVerbosity());
|
||||
|
||||
/* Perform requested testing */
|
||||
PerformTests();
|
||||
|
||||
/* Display test summary, if requested */
|
||||
if (GetTestSummary())
|
||||
TestSummary();
|
||||
|
||||
/* Clean up test files, if allowed */
|
||||
//if (GetTestCleanup() && !getenv("HDF5_NOCLEANUP"))
|
||||
// TestCleanup();
|
||||
|
||||
//return GetTestNumErrs();
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
return MPI_Finalize();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -0,0 +1,651 @@
|
||||
/* Test framework borrowed from HDF5 1.8.3:
|
||||
* test/testframe.c
|
||||
*/
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* Copyright by the Board of Trustees of the University of Illinois. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
||||
* of the source code distribution tree; Copyright.html can be found at the *
|
||||
* root level of an installed copy of the electronic HDF5 document set and *
|
||||
* is linked from the top-level documents page. It can also be found at *
|
||||
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
||||
* access to either file, you may request a copy from help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
|
||||
* Tuesday, January 6, 2004
|
||||
*
|
||||
* Purpose: Provides support functions for the testing framework.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <H5Part.h>
|
||||
#include "testframe.h"
|
||||
|
||||
/*
|
||||
* Definitions for the testing structure.
|
||||
*/
|
||||
#define MAXNUMOFTESTS 64
|
||||
#define MAXTESTNAME 16
|
||||
#define MAXTESTDESC 64
|
||||
|
||||
typedef struct TestStruct {
|
||||
int NumErrors;
|
||||
char Description[MAXTESTDESC];
|
||||
int SkipFlag;
|
||||
char Name[MAXTESTNAME];
|
||||
void (*Call)(void);
|
||||
void (*Cleanup)(void);
|
||||
const void *Parameters;
|
||||
} TestStruct;
|
||||
|
||||
|
||||
/*
|
||||
* Variables used by testing framework.
|
||||
*/
|
||||
static int num_errs = 0; /* Total number of errors during testing */
|
||||
static int Verbosity = VERBO_DEF; /* Default Verbosity is Low */
|
||||
static int Summary = 0; /* Show test summary. Default is no. */
|
||||
static int CleanUp = 1; /* Do cleanup or not. Default is yes. */
|
||||
static int TestExpress = -1; /* Do TestExpress or not. -1 means not set yet. */
|
||||
static TestStruct Test[MAXNUMOFTESTS];
|
||||
static int Index = 0;
|
||||
static const void *Test_parameters = NULL;
|
||||
static const char *TestProgName = NULL;
|
||||
static void (*TestPrivateUsage)(void) = NULL;
|
||||
static int (*TestPrivateParser)(int ac, char *av[]) = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Setup a test function and add it to the list of tests.
|
||||
* It must have no parameters and returns void.
|
||||
* TheName--short test name.
|
||||
* If the name starts with '-', do not run it by default.
|
||||
* TheCall--the test routine.
|
||||
* Cleanup--the cleanup routine for the test.
|
||||
* TheDescr--Long description of the test.
|
||||
* Parameters--pointer to extra parameters. Use NULL if none used.
|
||||
* Since only the pointer is copied, the contents should not change.
|
||||
*/
|
||||
void
|
||||
AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), const char *TheDescr, const void *Parameters)
|
||||
{
|
||||
/* Sanity checking */
|
||||
if (Index >= MAXNUMOFTESTS) {
|
||||
printf("Too many tests added, increase MAXNUMOFTEST(%d).\n",
|
||||
MAXNUMOFTESTS);
|
||||
exit(-1);
|
||||
} /* end if */
|
||||
if (strlen(TheDescr) >= MAXTESTDESC) {
|
||||
printf("Test description too long, increase MAXTESTDESC(%d).\n",
|
||||
MAXTESTDESC);
|
||||
exit(-1);
|
||||
} /* end if */
|
||||
if (strlen(TheName) >= MAXTESTNAME) {
|
||||
printf("Test name too long, increase MAXTESTNAME(%d).\n",
|
||||
MAXTESTNAME);
|
||||
exit(-1);
|
||||
} /* end if */
|
||||
|
||||
/* Set up test function */
|
||||
strcpy(Test[Index].Description, TheDescr);
|
||||
if (*TheName != '-'){
|
||||
strcpy(Test[Index].Name, TheName);
|
||||
Test[Index].SkipFlag = 0;
|
||||
}
|
||||
else { /* skip test by default */
|
||||
strcpy(Test[Index].Name, TheName+1);
|
||||
Test[Index].SkipFlag = 1;
|
||||
}
|
||||
Test[Index].Call = TheCall;
|
||||
Test[Index].Cleanup = Cleanup;
|
||||
Test[Index].NumErrors = -1;
|
||||
Test[Index].Parameters = Parameters;
|
||||
|
||||
/* Increment test count */
|
||||
Index++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Initialize testing framework
|
||||
*
|
||||
* ProgName: Name of test program.
|
||||
* private_usage: Optional routine provided by test program to print the
|
||||
* private portion of usage page. Default to NULL which means none is
|
||||
* provided.
|
||||
* private_parser: Optional routine provided by test program to parse the
|
||||
* private options. Default to NULL which means none is provided.
|
||||
*
|
||||
* Modifications:
|
||||
* Albert Cheng 2004/08/17
|
||||
* Added the ProgName, private_usage and private_parser arguments.
|
||||
*/
|
||||
void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]))
|
||||
{
|
||||
#if !(defined MAC || defined SYMANTEC_C)
|
||||
/* Un-buffer the stdout and stderr */
|
||||
setbuf(stderr, NULL);
|
||||
setbuf(stdout, NULL);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Turn off automatic error reporting since we do it ourselves. Besides,
|
||||
* half the functions this test calls are private, so automatic error
|
||||
* reporting wouldn't do much good since it's triggered at the API layer.
|
||||
*/
|
||||
//H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
|
||||
|
||||
/*
|
||||
* Record the program name and private routines if provided.
|
||||
*/
|
||||
TestProgName = ProgName;
|
||||
if (NULL != private_usage)
|
||||
TestPrivateUsage = private_usage;
|
||||
if (NULL != private_parser)
|
||||
TestPrivateParser = private_parser;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print test usage.
|
||||
* First print the common test options, then the extra options if provided.
|
||||
*
|
||||
* Modification:
|
||||
* 2004/08/18 Albert Cheng. Add TestPrivateUsage feature.
|
||||
*/
|
||||
void TestUsage(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n",
|
||||
TestProgName, (TestPrivateUsage ? "<extra options>" : ""));
|
||||
printf(" [-[e]x[clude] name+] \n");
|
||||
printf(" [-o[nly] name+] \n");
|
||||
printf(" [-b[egin] name] \n");
|
||||
printf(" [-s[ummary]] \n");
|
||||
printf(" [-c[leanoff]] \n");
|
||||
printf(" [-h[elp]] \n");
|
||||
printf("\n\n");
|
||||
printf("verbose controls the amount of information displayed\n");
|
||||
printf("exclude to exclude tests by name\n");
|
||||
printf("only to name tests which should be run\n");
|
||||
printf("begin start at the name of the test givin\n");
|
||||
printf("summary prints a summary of test results at the end\n");
|
||||
printf("cleanoff does not delete *.hdf files after execution of tests\n");
|
||||
printf("help print out this information\n");
|
||||
if (TestPrivateUsage){
|
||||
printf("\nExtra options\n");
|
||||
TestPrivateUsage();
|
||||
}
|
||||
printf("\n\n");
|
||||
printf("This program currently tests the following: \n\n");
|
||||
printf("%16s %s\n", "Name", "Description");
|
||||
printf("%16s %s\n", "----", "-----------");
|
||||
|
||||
for (i = 0; i < Index; i++)
|
||||
printf("%16s %s\n", Test[i].Name, Test[i].Description);
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Print test info.
|
||||
*/
|
||||
void TestInfo(const char *ProgName)
|
||||
{
|
||||
unsigned major, minor, release;
|
||||
|
||||
H5get_libversion(&major, &minor, &release);
|
||||
|
||||
printf("\nFor help use: %s -help\n",ProgName);
|
||||
printf("Linked with hdf5 version %u.%u release %u\n", major, minor, release);
|
||||
printf("Linked with H5Part version %s\n", H5PART_VER_STRING);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Parse command line information.
|
||||
* argc, argv: the usual command line argument count and strings
|
||||
*
|
||||
* Modification:
|
||||
* 2004/08/18 Albert Cheng. Add extra_parse feature.
|
||||
*/
|
||||
void TestParseCmdLine(int argc, char *argv[])
|
||||
{
|
||||
int ret_code;
|
||||
|
||||
while (argv++, --argc > 0){
|
||||
if ((strcmp(*argv, "-verbose") == 0) ||
|
||||
(strcmp(*argv, "-v") == 0)) {
|
||||
if (argc > 0){
|
||||
--argc; ++argv;
|
||||
ParseTestVerbosity(*argv);
|
||||
}else{
|
||||
TestUsage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (((strcmp(*argv, "-exclude") == 0) ||
|
||||
(strcmp(*argv, "-x") == 0))) {
|
||||
if (argc > 0){
|
||||
--argc; ++argv;
|
||||
SetTest(*argv, SKIPTEST);
|
||||
}else{
|
||||
TestUsage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (((strcmp(*argv, "-begin") == 0) ||
|
||||
(strcmp(*argv, "-b") == 0))) {
|
||||
if (argc > 0){
|
||||
--argc; ++argv;
|
||||
SetTest(*argv, BEGINTEST);
|
||||
}else{
|
||||
TestUsage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (((strcmp(*argv, "-only") == 0) ||
|
||||
(strcmp(*argv, "-o") == 0))) {
|
||||
if (argc > 0){
|
||||
int Loop;
|
||||
--argc; ++argv;
|
||||
/* Skip all tests, then activate only one. */
|
||||
for (Loop = 0; Loop < Index; Loop++)
|
||||
Test[Loop].SkipFlag = 1;
|
||||
SetTest(*argv, ONLYTEST);
|
||||
}else{
|
||||
TestUsage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if ((strcmp(*argv, "-summary") == 0) || (strcmp(*argv, "-s") == 0))
|
||||
Summary = 1;
|
||||
else if ((strcmp(*argv, "-help") == 0) || (strcmp(*argv, "-h") == 0)) {
|
||||
TestUsage();
|
||||
exit(0);
|
||||
}
|
||||
else if ((strcmp(*argv, "-cleanoff") == 0) || (strcmp(*argv, "-c") == 0))
|
||||
SetTestNoCleanup();
|
||||
else {
|
||||
/* non-standard option. Break out. */
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Call extra parsing function if provided. */
|
||||
if (NULL != TestPrivateParser){
|
||||
ret_code=TestPrivateParser(argc+1, argv-1);
|
||||
if (ret_code != 0)
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Perform Tests.
|
||||
*/
|
||||
void PerformTests(void)
|
||||
{
|
||||
int Loop;
|
||||
|
||||
for (Loop = 0; Loop < Index; Loop++)
|
||||
if (Test[Loop].SkipFlag) {
|
||||
MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
|
||||
} else {
|
||||
MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name));
|
||||
MESSAGE(5, ("===============================================\n"));
|
||||
Test[Loop].NumErrors = num_errs;
|
||||
Test_parameters = Test[Loop].Parameters;
|
||||
//ALARM_ON;
|
||||
Test[Loop].Call();
|
||||
//ALARM_OFF;
|
||||
Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors;
|
||||
MESSAGE(5, ("===============================================\n"));
|
||||
MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors));
|
||||
}
|
||||
|
||||
Test_parameters = NULL; /* clear it. */
|
||||
MESSAGE(2, ("\n\n"));
|
||||
|
||||
if (num_errs)
|
||||
printf("!!! %d Error(s) were detected !!!\n\n", (int) num_errs);
|
||||
else
|
||||
printf("All tests were successful. \n\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Display test summary.
|
||||
*/
|
||||
void TestSummary(void)
|
||||
{
|
||||
int Loop;
|
||||
|
||||
printf("Summary of Test Results:\n");
|
||||
printf("Name of Test Errors Description of Test\n");
|
||||
printf("---------------- ------ --------------------------------------\n");
|
||||
|
||||
for (Loop = 0; Loop < Index; Loop++) {
|
||||
if (Test[Loop].NumErrors == -1)
|
||||
printf("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description);
|
||||
else
|
||||
printf("%16s %6d %s\n", Test[Loop].Name, (int)Test[Loop].NumErrors, Test[Loop].Description);
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cleanup files from testing
|
||||
*/
|
||||
void TestCleanup(void)
|
||||
{
|
||||
int Loop;
|
||||
|
||||
MESSAGE(2, ("\nCleaning Up temp files...\n\n"));
|
||||
|
||||
/* call individual cleanup routines in each source module */
|
||||
for (Loop = 0; Loop < Index; Loop++)
|
||||
if (!Test[Loop].SkipFlag && Test[Loop].Cleanup!=NULL)
|
||||
Test[Loop].Cleanup();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Retrieve the verbosity level for the testing framework
|
||||
*/
|
||||
int GetTestVerbosity(void)
|
||||
{
|
||||
return(Verbosity);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the verbosity level for the testing framework.
|
||||
* Return previous verbosity level.
|
||||
*/
|
||||
int SetTestVerbosity(int newval)
|
||||
{
|
||||
int oldval;
|
||||
|
||||
oldval = Verbosity;
|
||||
Verbosity = newval;
|
||||
return(oldval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the TestExpress mode for the testing framework
|
||||
Values:
|
||||
0: Exhaustive run
|
||||
Tests should take as long as necessary
|
||||
1: Full run. Default if HDF5TestExpress is not defined
|
||||
Tests should take no more than 30 minutes
|
||||
2: Quick run
|
||||
Tests should take no more than 10 minutes
|
||||
3: Smoke test. Default if HDF5TestExpress is set to a value other than 0-3
|
||||
Tests should take less than 1 minute
|
||||
|
||||
Design:
|
||||
If the environment variable $HDF5TestExpress is defined,
|
||||
then test programs should skip some tests so that they
|
||||
complete sooner.
|
||||
|
||||
Terms:
|
||||
A "test" is a single executable, even if it contains multiple
|
||||
sub-tests.
|
||||
The standard system for test times is a Linux machine running in
|
||||
NFS space (to catch tests that involve a great deal of disk I/O).
|
||||
|
||||
Implementation:
|
||||
I think this can be easily implemented in the test library (libh5test.a)
|
||||
so that all tests can just call it to check the status of $HDF5TestExpress.
|
||||
*/
|
||||
int GetTestExpress(void)
|
||||
{
|
||||
char * env_val;
|
||||
|
||||
/* set it here for now. Should be done in something like h5test_init(). */
|
||||
if(TestExpress==-1)
|
||||
{
|
||||
env_val = getenv("HDF5TestExpress");
|
||||
|
||||
if(env_val == NULL)
|
||||
SetTestExpress(1);
|
||||
else if(strcmp(env_val, "0") == 0)
|
||||
SetTestExpress(0);
|
||||
else if(strcmp(env_val, "1") == 0)
|
||||
SetTestExpress(1);
|
||||
else if(strcmp(env_val, "2") == 0)
|
||||
SetTestExpress(2);
|
||||
else
|
||||
SetTestExpress(3);
|
||||
}
|
||||
|
||||
return(TestExpress);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the TestExpress mode for the testing framework.
|
||||
* Return previous TestExpress mode.
|
||||
* Values: non-zero means TestExpress mode is on, 0 means off.
|
||||
*/
|
||||
int SetTestExpress(int newval)
|
||||
{
|
||||
int oldval;
|
||||
|
||||
oldval = TestExpress;
|
||||
TestExpress = newval;
|
||||
return(oldval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve Summary request value.
|
||||
* 0 means no summary, 1 means yes.
|
||||
*/
|
||||
int GetTestSummary(void)
|
||||
{
|
||||
return(Summary);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve Cleanup request value.
|
||||
* 0 means no Cleanup, 1 means yes.
|
||||
*/
|
||||
int GetTestCleanup(void)
|
||||
{
|
||||
return(CleanUp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set cleanup to no.
|
||||
* Return previous cleanup value.
|
||||
*/
|
||||
int SetTestNoCleanup(void)
|
||||
{
|
||||
int oldval;
|
||||
|
||||
oldval = CleanUp;
|
||||
CleanUp = 0;
|
||||
return(oldval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse an argument string for verbosity level and set it.
|
||||
*/
|
||||
void ParseTestVerbosity(char *argv)
|
||||
{
|
||||
if (*argv == 'l')
|
||||
SetTestVerbosity(VERBO_LO);
|
||||
else if (*argv == 'm')
|
||||
SetTestVerbosity(VERBO_MED);
|
||||
else if (*argv == 'h')
|
||||
SetTestVerbosity(VERBO_HI);
|
||||
else
|
||||
SetTestVerbosity(atoi(argv));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Retrieve the number of testing errors for the testing framework
|
||||
*/
|
||||
int GetTestNumErrs(void)
|
||||
{
|
||||
return(num_errs);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Increment the number of testing errors
|
||||
*/
|
||||
void IncTestNumErrs(void)
|
||||
{
|
||||
num_errs++;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Retrieve the current Test Parameters pointer.
|
||||
*/
|
||||
const void *GetTestParameters(void)
|
||||
{
|
||||
return(Test_parameters);
|
||||
}
|
||||
|
||||
int
|
||||
TestPrintf(const char *format, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
int ret_value;
|
||||
|
||||
#if PARALLEL_IO
|
||||
int nproc;
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &nproc);
|
||||
if ( nproc == 0 || VERBOSE_HI ) {
|
||||
char *format2 = malloc(strlen(format)+8);
|
||||
sprintf(format2, "[%d] %s", nproc, format);
|
||||
va_start(arglist, format);
|
||||
ret_value = vprintf(format2, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
#else
|
||||
va_start(arglist, format);
|
||||
ret_value = vprintf(format, arglist);
|
||||
va_end(arglist);
|
||||
#endif
|
||||
|
||||
/* Return the length of the string produced (like printf() does) */
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This routine is designed to provide equivalent functionality to 'printf'
|
||||
* and also increment the error count for the testing framework.
|
||||
*/
|
||||
int
|
||||
TestErrPrintf(const char *format, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
int ret_value;
|
||||
|
||||
/* Increment the error count */
|
||||
num_errs++;
|
||||
|
||||
#if PARALLEL_IO
|
||||
int nproc;
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &nproc);
|
||||
if ( nproc == 0 || VERBOSE_HI ) {
|
||||
char *format2 = malloc(strlen(format)+8);
|
||||
sprintf(format2, "[%d] %s", nproc, format);
|
||||
va_start(arglist, format);
|
||||
ret_value = vfprintf(stderr, format2, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
#else
|
||||
va_start(arglist, format);
|
||||
ret_value = vfprintf(stderr, format, arglist);
|
||||
va_end(arglist);
|
||||
#endif
|
||||
|
||||
/* Return the length of the string produced (like printf() does) */
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set (control) which test will be tested.
|
||||
* SKIPTEST: skip this test
|
||||
* ONLYTEST: do only this test
|
||||
* BEGINETEST: skip all tests before this test
|
||||
*
|
||||
*/
|
||||
void SetTest(const char *testname, int action)
|
||||
{
|
||||
int Loop;
|
||||
switch (action){
|
||||
case SKIPTEST:
|
||||
for (Loop = 0; Loop < Index; Loop++)
|
||||
if (strcmp(testname, Test[Loop].Name) == 0){
|
||||
Test[Loop].SkipFlag = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BEGINTEST:
|
||||
for (Loop = 0; Loop < Index; Loop++) {
|
||||
if (strcmp(testname, Test[Loop].Name) != 0)
|
||||
Test[Loop].SkipFlag = 1;
|
||||
else{
|
||||
/* Found it. Set it to run. Done. */
|
||||
Test[Loop].SkipFlag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ONLYTEST:
|
||||
for (Loop = 0; Loop < Index; Loop++) {
|
||||
if (strcmp(testname, Test[Loop].Name) != 0)
|
||||
Test[Loop].SkipFlag = 1;
|
||||
else {
|
||||
/* Found it. Set it to run. Break to skip the rest. */
|
||||
Test[Loop].SkipFlag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* skip the rest */
|
||||
while (++Loop < Index)
|
||||
Test[Loop].SkipFlag = 1;
|
||||
break;
|
||||
default:
|
||||
/* error */
|
||||
printf("*** ERROR: Unknown action (%d) for SetTest\n", action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
get_attr_name(char *name, char *tag, int id)
|
||||
{
|
||||
sprintf(name, "Attr%d%s", id, tag);
|
||||
}
|
||||
|
||||
void
|
||||
test_is_valid(H5PartFile *file)
|
||||
{
|
||||
h5part_int64_t status = H5PartFileIsValid(file);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartFileIsValid");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
/* Test framework borrowed from HDF5 1.8.3:
|
||||
* test/h5test.h
|
||||
* test/testhdf5.h
|
||||
*/
|
||||
|
||||
#ifndef _H5PART_TESTFRAME_H_
|
||||
#define _H5PART_TESTFRAME_H_
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
#define OPEN(file,mode) \
|
||||
H5PartOpenFileParallel(file,mode,MPI_COMM_WORLD)
|
||||
#define OPENALIGN(file,mode,align) \
|
||||
H5PartOpenFileParallelAlign(file,mode,MPI_COMM_WORLD,align)
|
||||
#else
|
||||
#define OPEN(file,mode) H5PartOpenFile(file,mode)
|
||||
#define OPENALIGN(file,mode,align) H5PartOpenFileAlign(file,mode,align)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Predefined test verbosity levels.
|
||||
*
|
||||
* Convention:
|
||||
*
|
||||
* The higher the verbosity value, the more information printed.
|
||||
* So, output for higher verbosity also include output of all lower
|
||||
* verbosity.
|
||||
*
|
||||
* Value Description
|
||||
* 0 None: No informational message.
|
||||
* 1 "All tests passed"
|
||||
* 2 Header of overall test
|
||||
* 3 Default: header and results of individual test
|
||||
* 4
|
||||
* 5 Low: Major category of tests.
|
||||
* 6
|
||||
* 7 Medium: Minor category of tests such as functions called.
|
||||
* 8
|
||||
* 9 High: Highest level. All information.
|
||||
*/
|
||||
#define VERBO_DEF 0 /* Default */
|
||||
#define VERBO_LO 2 /* Low */
|
||||
#define VERBO_MED 3 /* Medium */
|
||||
#define VERBO_HI 4 /* High */
|
||||
|
||||
/*
|
||||
* Verbose queries
|
||||
* Only None needs an exact match. The rest are at least as much.
|
||||
*/
|
||||
#define VERBOSE_DEF (GetTestVerbosity()>=VERBO_DEF)
|
||||
#define VERBOSE_LO (GetTestVerbosity()>=VERBO_LO)
|
||||
#define VERBOSE_MED (GetTestVerbosity()>=VERBO_MED)
|
||||
#define VERBOSE_HI (GetTestVerbosity()>=VERBO_HI)
|
||||
|
||||
#define SKIPTEST 1
|
||||
#define ONLYTEST 2
|
||||
#define BEGINTEST 3
|
||||
|
||||
/*
|
||||
* Print the current location on the standard output stream.
|
||||
*/
|
||||
#define AT() TestPrintf (" at %s:%d in %s()...\n", \
|
||||
__FILE__, __LINE__, __FUNCTION__);
|
||||
|
||||
/*
|
||||
* The name of the test is printed by saying TESTING("something") which will
|
||||
* result in the string `Testing something' being flushed to standard output.
|
||||
* If a test passes, fails, or is skipped then the PASSED(), H5_FAILED(), or
|
||||
* SKIPPED() macro should be called. After H5_FAILED() or SKIPPED() the caller
|
||||
* should print additional information to stdout indented by at least four
|
||||
* spaces. If the h5_errors() is used for automatic error handling then
|
||||
* the H5_FAILED() macro is invoked automatically when an API function fails.
|
||||
*/
|
||||
#define TESTING(WHAT) {TestPrintf("Testing %-62s",WHAT); fflush(stdout);}
|
||||
#define TESTING_2(WHAT) {TestPrintf(" Testing %-62s",WHAT); fflush(stdout);}
|
||||
#define PASSED() {TestPrintf(" PASSED");fflush(stdout);}
|
||||
#define H5_FAILED() {TestPrintf("*FAILED*");fflush(stdout);}
|
||||
#define H5_WARNING() {TestPrintf("*WARNING*");fflush(stdout);}
|
||||
#define SKIPPED() {TestPrintf(" -SKIP-");fflush(stdout);}
|
||||
#define TEST_ERROR {H5_FAILED(); AT(); goto error;}
|
||||
//#define STACK_ERROR {H5Eprint2(H5E_DEFAULT, stdout); goto error;}
|
||||
//#define FAIL_STACK_ERROR {H5_FAILED(); AT(); H5Eprint2(H5E_DEFAULT, stdout); \
|
||||
// goto error;}
|
||||
#define FAIL_PUTS_ERROR(s) {H5_FAILED(); AT(); TestPrintf(s); goto error;}
|
||||
|
||||
/* Use %ld to print the value because long should cover most cases. */
|
||||
/* Used to make certain a return value _is_not_ a value */
|
||||
#define RETURN(ret, val, where) do { \
|
||||
if (VERBOSE_HI) TestPrintf( " Call to routine %15s at line %4d " \
|
||||
"in %s returned %ld \n", \
|
||||
where, (int)__LINE__, __FILE__, \
|
||||
(long)(ret)); \
|
||||
if ((ret) != (val)) { \
|
||||
TestErrPrintf("*** UNEXPECTED RETURN from %s is %ld at line %4d " \
|
||||
"in %s\n", where, (long)(ret), (int)__LINE__, __FILE__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define VALUE(val, expected, what) do { \
|
||||
if ((val) != (expected)) { \
|
||||
TestErrPrintf( "*** INCORRECT VALUE of %s at line " \
|
||||
"%d in %s\n", what, (int)__LINE__, \
|
||||
__FILE__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define IVALUE(val, expected, what) do { \
|
||||
if (VERBOSE_HI) TestPrintf( " Value of int %15s at line %4d " \
|
||||
"in %s is %ld =? %ld\n", what, \
|
||||
(int)__LINE__, __FILE__, \
|
||||
(long)(val), (long)(expected)); \
|
||||
VALUE(val, expected, what); \
|
||||
} while(0)
|
||||
|
||||
#define FVALUE(val, expected, what) do { \
|
||||
if (VERBOSE_HI) TestPrintf( " Value of float %15s at line %4d " \
|
||||
"in %s is %g =? %g\n", what, \
|
||||
(int)__LINE__, __FILE__, \
|
||||
(val), (expected)); \
|
||||
VALUE(val, expected, what); \
|
||||
} while(0)
|
||||
|
||||
#define CVALUE(val, expected, what) do { \
|
||||
if (VERBOSE_HI) TestPrintf( " Value of char %15s at line %4d " \
|
||||
"in %s is %c =? %c\n", what, \
|
||||
(int)__LINE__, __FILE__, \
|
||||
(val), (expected)); \
|
||||
VALUE(val, expected, what); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define SVALUE(val, expected, what) do { \
|
||||
if (VERBOSE_HI) TestPrintf( " Value of string %15s at line %4d " \
|
||||
"in %s is %s =? %s\n", what, \
|
||||
(int)__LINE__, __FILE__, \
|
||||
(val), (expected)); \
|
||||
if (strcmp(val,expected) != 0) { \
|
||||
TestErrPrintf( "*** INCORRECT VALUE of %d at line " \
|
||||
"%4d in %s\n", what, (int)__LINE__, \
|
||||
__FILE__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* Used to document process through a test */
|
||||
#define MESSAGE(V,A) do { \
|
||||
if (V) TestPrintf A; \
|
||||
} while(0)
|
||||
|
||||
#define TEST(WHAT) MESSAGE(VERBOSE_DEF,(WHAT "\n"))
|
||||
|
||||
/* definitions for command strings */
|
||||
#define VERBOSITY_STR "Verbosity"
|
||||
#define SKIP_STR "Skip"
|
||||
#define TEST_STR "Test"
|
||||
#define CLEAN_STR "Cleanup"
|
||||
|
||||
void TestUsage(void);
|
||||
void AddTest(const char *TheName, void (*TheCall) (void),
|
||||
void (*Cleanup) (void), const char *TheDescr,
|
||||
const void *Parameters);
|
||||
void TestInfo(const char *ProgName);
|
||||
void TestParseCmdLine(int argc, char *argv[]);
|
||||
void PerformTests(void);
|
||||
void TestSummary(void);
|
||||
void TestCleanup(void);
|
||||
void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[]));
|
||||
int GetTestVerbosity(void);
|
||||
int SetTestVerbosity(int newval);
|
||||
int GetTestSummary(void);
|
||||
int GetTestCleanup(void);
|
||||
int SetTestNoCleanup(void);
|
||||
int GetTestExpress(void);
|
||||
int SetTestExpress(int newval);
|
||||
void ParseTestVerbosity(char *argv);
|
||||
int GetTestNumErrs(void);
|
||||
void IncTestNumErrs(void);
|
||||
const void *GetTestParameters(void);
|
||||
int TestPrintf(const char *format, ...);
|
||||
int TestErrPrintf(const char *format, ...);
|
||||
void SetTest(const char *testname, int action);
|
||||
|
||||
void
|
||||
get_attr_name(char *name, char *tag, int id);
|
||||
|
||||
void
|
||||
test_is_valid(H5PartFile *file);
|
||||
|
||||
#endif
|
||||
|
||||
+418
@@ -0,0 +1,418 @@
|
||||
#include <H5Part.h>
|
||||
|
||||
#include "testframe.h"
|
||||
#include "params.h"
|
||||
|
||||
static void
|
||||
test_write_file_attribs(H5PartFile *file, int position)
|
||||
{
|
||||
h5part_int64_t status;
|
||||
char name[ATTR_NAME_SIZE];
|
||||
|
||||
TEST("Writing file attributes");
|
||||
|
||||
get_attr_name(name, "str", position);
|
||||
status = H5PartWriteFileAttribString(file, name, ATTR_STR_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribString");
|
||||
|
||||
get_attr_name(name, "i32", position);
|
||||
status = H5PartWriteFileAttribInt32(file, name, ATTR_INT32_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribInt32");
|
||||
|
||||
get_attr_name(name, "i64", position);
|
||||
status = H5PartWriteFileAttribInt64(file, name, ATTR_INT64_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribInt64");
|
||||
|
||||
get_attr_name(name, "f32", position);
|
||||
status = H5PartWriteFileAttribFloat32(file, name, ATTR_FLOAT_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribFloat32");
|
||||
|
||||
get_attr_name(name, "f64", position);
|
||||
status = H5PartWriteFileAttribFloat64(file, name, ATTR_FLOAT_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteFileAttribFloat64");
|
||||
}
|
||||
|
||||
static void
|
||||
test_write_step_attribs(H5PartFile *file, int position)
|
||||
{
|
||||
h5part_int64_t status;
|
||||
char name[ATTR_NAME_SIZE];
|
||||
|
||||
TEST("Writing step attributes");
|
||||
|
||||
get_attr_name(name, "str", position);
|
||||
status = H5PartWriteStepAttribString(file, name, ATTR_STR_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribString");
|
||||
|
||||
get_attr_name(name, "i32", position);
|
||||
status = H5PartWriteStepAttribInt32(file, name, ATTR_INT32_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribInt32");
|
||||
|
||||
get_attr_name(name, "i64", position);
|
||||
status = H5PartWriteStepAttribInt64(file, name, ATTR_INT64_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribInt64");
|
||||
|
||||
get_attr_name(name, "f32", position);
|
||||
status = H5PartWriteStepAttribFloat32(file, name, ATTR_FLOAT_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribFloat32");
|
||||
|
||||
get_attr_name(name, "f64", position);
|
||||
status = H5PartWriteStepAttribFloat64(file, name, ATTR_FLOAT_VAL);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteStepAttribFloat64");
|
||||
}
|
||||
|
||||
static void
|
||||
test_write_data64(H5PartFile *file, int nparticles, int step)
|
||||
{
|
||||
int i,t;
|
||||
h5part_int64_t status;
|
||||
|
||||
double *x,*y,*z;
|
||||
double *px,*py,*pz;
|
||||
h5part_int64_t *id;
|
||||
|
||||
x=(double*)malloc(nparticles*sizeof(double));
|
||||
y=(double*)malloc(nparticles*sizeof(double));
|
||||
z=(double*)malloc(nparticles*sizeof(double));
|
||||
px=(double*)malloc(nparticles*sizeof(double));
|
||||
py=(double*)malloc(nparticles*sizeof(double));
|
||||
pz=(double*)malloc(nparticles*sizeof(double));
|
||||
id=(h5part_int64_t*)malloc(nparticles*sizeof(h5part_int64_t));
|
||||
|
||||
/* invalid stride will produce a warning */
|
||||
status = H5PartSetNumParticlesStrided(file, nparticles, -1);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticlesStrided");
|
||||
|
||||
#if PARALLEL_IO
|
||||
TEST("Setting throttle");
|
||||
status = H5PartSetThrottle(file, 2);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetThrottle");
|
||||
#endif
|
||||
|
||||
TEST("Writing 64-bit data");
|
||||
|
||||
for (t=step; t<step+NTIMESTEPS; t++)
|
||||
{
|
||||
for (i=0; i<nparticles; i++)
|
||||
{
|
||||
x[i] = 0.0 + (double)(i+nparticles*t);
|
||||
y[i] = 0.1 + (double)(i+nparticles*t);
|
||||
z[i] = 0.2 + (double)(i+nparticles*t);
|
||||
px[i] = 0.3 + (double)(i+nparticles*t);
|
||||
py[i] = 0.4 + (double)(i+nparticles*t);
|
||||
pz[i] = 0.5 + (double)(i+nparticles*t);
|
||||
id[i] = i + nparticles*t;
|
||||
}
|
||||
|
||||
status = H5PartSetStep(file, t);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetStep");
|
||||
|
||||
test_write_step_attribs(file, t);
|
||||
|
||||
status = H5PartSetNumParticles(file, nparticles);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticles");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "x", x);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "y", y);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "z", z);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "px", px);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "py", py);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "pz", pz);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataInt64(file, "id", id);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataInt64");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_write_strided_data64(H5PartFile *file, int nparticles, int step)
|
||||
{
|
||||
int i,t;
|
||||
h5part_int64_t status;
|
||||
|
||||
double *data;
|
||||
|
||||
data=(double*)malloc(6*nparticles*sizeof(double));
|
||||
|
||||
status = H5PartSetNumParticlesStrided(file, nparticles, 6);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticlesStrided");
|
||||
|
||||
TEST("Writing 64-bit strided data");
|
||||
|
||||
for (t=step; t<step+NTIMESTEPS; t++)
|
||||
{
|
||||
for (i=0; i<nparticles; i++)
|
||||
{
|
||||
data[6*i] = 0.0 + (double)(i+nparticles*t);
|
||||
data[6*i+1] = 0.1 + (double)(i+nparticles*t);
|
||||
data[6*i+2] = 0.2 + (double)(i+nparticles*t);
|
||||
data[6*i+3] = 0.3 + (double)(i+nparticles*t);
|
||||
data[6*i+4] = 0.4 + (double)(i+nparticles*t);
|
||||
data[6*i+5] = 0.5 + (double)(i+nparticles*t);
|
||||
}
|
||||
|
||||
status = H5PartSetStep(file, t);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetStep");
|
||||
|
||||
status = H5PartSetNumParticlesStrided(file, nparticles, 6);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticlesStrided");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "x", data+0);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "y", data+1);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "z", data+2);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "px", data+3);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "py", data+4);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
status = H5PartWriteDataFloat64(file, "pz", data+5);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat64");
|
||||
|
||||
test_write_step_attribs(file, t);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_write_data32(H5PartFile *file, int nparticles, int step)
|
||||
{
|
||||
int i,t;
|
||||
h5part_int32_t status;
|
||||
|
||||
float *x,*y,*z;
|
||||
float *px,*py,*pz;
|
||||
int *id;
|
||||
|
||||
x=(float*)malloc(nparticles*sizeof(float));
|
||||
y=(float*)malloc(nparticles*sizeof(float));
|
||||
z=(float*)malloc(nparticles*sizeof(float));
|
||||
px=(float*)malloc(nparticles*sizeof(float));
|
||||
py=(float*)malloc(nparticles*sizeof(float));
|
||||
pz=(float*)malloc(nparticles*sizeof(float));
|
||||
id=(int*)malloc(nparticles*sizeof(int));
|
||||
|
||||
status = H5PartSetNumParticles(file, nparticles);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticles");
|
||||
|
||||
#if PARALLEL_IO
|
||||
/* will generate a warning since we are in MPI-IO Collective mode */
|
||||
TEST("Setting throttle");
|
||||
status = H5PartSetThrottle(file, 2);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetThrottle");
|
||||
#endif
|
||||
|
||||
TEST("Writing 32-bit data");
|
||||
|
||||
for (t=step; t<step+NTIMESTEPS; t++)
|
||||
{
|
||||
for (i=0; i<nparticles; i++)
|
||||
{
|
||||
x[i] = 0.0F + (float)(i+nparticles*t);
|
||||
y[i] = 0.1F + (float)(i+nparticles*t);
|
||||
z[i] = 0.2F + (float)(i+nparticles*t);
|
||||
px[i] = 0.3F + (float)(i+nparticles*t);
|
||||
py[i] = 0.4F + (float)(i+nparticles*t);
|
||||
pz[i] = 0.5F + (float)(i+nparticles*t);
|
||||
id[i] = i + nparticles*t;
|
||||
}
|
||||
|
||||
status = H5PartSetStep(file, t);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetStep");
|
||||
|
||||
status = H5PartSetNumParticles(file, nparticles);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticles");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "x", x);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
test_write_step_attribs(file, t);
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "y", y);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "z", z);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "px", px);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "py", py);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "pz", pz);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataInt32(file, "id", id);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataInt32");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_write_strided_data32(H5PartFile *file, int nparticles, int step)
|
||||
{
|
||||
int i,t;
|
||||
h5part_int64_t status;
|
||||
|
||||
float *data;
|
||||
|
||||
data=(float*)malloc(6*nparticles*sizeof(float));
|
||||
|
||||
//status = H5PartSetNumParticlesStrided(file, nparticles, 6);
|
||||
//RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticlesStrided");
|
||||
|
||||
TEST("Writing 32-bit strided data");
|
||||
|
||||
for (t=step; t<step+NTIMESTEPS; t++)
|
||||
{
|
||||
for (i=0; i<nparticles; i++)
|
||||
{
|
||||
data[6*i] = 0.0F + (float)(i+nparticles*t);
|
||||
data[6*i+1] = 0.1F + (float)(i+nparticles*t);
|
||||
data[6*i+2] = 0.2F + (float)(i+nparticles*t);
|
||||
data[6*i+3] = 0.3F + (float)(i+nparticles*t);
|
||||
data[6*i+4] = 0.4F + (float)(i+nparticles*t);
|
||||
data[6*i+5] = 0.5F + (float)(i+nparticles*t);
|
||||
}
|
||||
|
||||
status = H5PartSetStep(file, t);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetStep");
|
||||
|
||||
test_write_step_attribs(file, t);
|
||||
|
||||
status = H5PartSetNumParticlesStrided(file, nparticles, 6);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartSetNumParticlesStrided");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "x", data+0);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "y", data+1);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "z", data+2);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "px", data+3);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "py", data+4);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
|
||||
status = H5PartWriteDataFloat32(file, "pz", data+5);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartWriteDataFloat32");
|
||||
}
|
||||
}
|
||||
|
||||
void test_write1(void)
|
||||
{
|
||||
H5PartFile *file1;
|
||||
|
||||
h5part_int64_t status;
|
||||
|
||||
TEST("Opening file once, write-truncate");
|
||||
file1 = OPEN(FILENAME,H5PART_WRITE);
|
||||
test_is_valid(file1);
|
||||
|
||||
test_write_data32(file1, NPARTICLES, 1);
|
||||
test_write_file_attribs(file1, 0);
|
||||
|
||||
status = H5PartCloseFile(file1);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartCloseFile");
|
||||
}
|
||||
|
||||
void test_write2(void)
|
||||
{
|
||||
H5PartFile *file1;
|
||||
H5PartFile *file2;
|
||||
|
||||
h5part_int64_t status;
|
||||
|
||||
TEST("Opening file twice, write-append + read-only");
|
||||
file1 = OPEN(FILENAME,H5PART_APPEND);
|
||||
test_is_valid(file1);
|
||||
file2 = OPEN(FILENAME,H5PART_READ);
|
||||
test_is_valid(file2);
|
||||
|
||||
test_write_strided_data32(file1, NPARTICLES, NTIMESTEPS+1);
|
||||
test_write_file_attribs(file1, 1);
|
||||
|
||||
status = H5PartCloseFile(file1);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartCloseFile");
|
||||
status = H5PartCloseFile(file2);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartCloseFile");
|
||||
}
|
||||
|
||||
void test_write3(void)
|
||||
{
|
||||
H5PartFile *file1;
|
||||
|
||||
h5part_int64_t status;
|
||||
|
||||
TEST( "Opening file once, write-truncate, lustre filesyste, "
|
||||
"MPI-POSIX VFD, 64KB alignment");
|
||||
file1 = OPENALIGN(FILENAME,
|
||||
H5PART_WRITE | H5PART_VFD_MPIPOSIX | H5PART_FS_LUSTRE,
|
||||
65536);
|
||||
test_is_valid(file1);
|
||||
|
||||
TEST("Redefining step name");
|
||||
status = H5PartDefineStepName(file1, LONGSTEPNAME, 16);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartDefineStepName");
|
||||
|
||||
test_write_strided_data64(file1, NPARTICLES, 0);
|
||||
test_write_file_attribs(file1, 0);
|
||||
|
||||
status = H5PartCloseFile(file1);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartCloseFile");
|
||||
}
|
||||
|
||||
void test_write4(void)
|
||||
{
|
||||
H5PartFile *file1;
|
||||
H5PartFile *file2;
|
||||
|
||||
h5part_int64_t status;
|
||||
|
||||
TEST( "Opening file twice, write-append + read-only, "
|
||||
"lustre filesystem, MPI-IO Independent VFD, 64K alignment");
|
||||
file1 = OPENALIGN(FILENAME,
|
||||
H5PART_APPEND | H5PART_VFD_MPIIO_IND | H5PART_FS_LUSTRE,
|
||||
65536);
|
||||
test_is_valid(file1);
|
||||
file2 = OPENALIGN(FILENAME,
|
||||
H5PART_READ | H5PART_VFD_MPIIO_IND | H5PART_FS_LUSTRE,
|
||||
65536);
|
||||
test_is_valid(file2);
|
||||
|
||||
TEST("Redefining step name");
|
||||
status = H5PartDefineStepName(file1, LONGSTEPNAME, 16);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartDefineStepName");
|
||||
|
||||
status = H5PartDefineStepName(file2, LONGSTEPNAME, 16);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartDefineStepName");
|
||||
|
||||
test_write_data64(file1, NPARTICLES, NTIMESTEPS);
|
||||
test_write_file_attribs(file1, 1);
|
||||
|
||||
status = H5PartCloseFile(file1);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartCloseFile");
|
||||
status = H5PartCloseFile(file2);
|
||||
RETURN(status, H5PART_SUCCESS, "H5PartCloseFile");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user