summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2011-02-08 15:55:31 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2011-02-08 15:55:31 (GMT)
commitf3ee1cc38d0604116afbffe72cd98dabfe1014a7 (patch)
treeb7b11d751b526c91b0e0695d34c66991b80d74b3 /c++/test
parente1cd1485b8bb78b4a99ca4246c522bbaf3c0ed76 (diff)
parenta6d5fa2c7db165fa2cecee86bdbd201339349968 (diff)
downloadhdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.zip
hdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.tar.gz
hdf5-f3ee1cc38d0604116afbffe72cd98dabfe1014a7.tar.bz2
[svn-r20063] Merge changes from trunk from revision 19519 to 20062 into open_file_pool branch. No testing needed as the branch is currently identical to the trunk.
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/CMakeLists.txt39
-rw-r--r--c++/test/Makefile.in3
-rw-r--r--c++/test/tcompound.cpp34
-rw-r--r--c++/test/tfilter.cpp87
-rw-r--r--c++/test/tlinks.cpp1
-rw-r--r--c++/test/trefer.cpp3
-rw-r--r--c++/test/ttypes.cpp8
-rw-r--r--c++/test/tvlstr.cpp28
8 files changed, 142 insertions, 61 deletions
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt
index e29963e..197ed84 100644
--- a/c++/test/CMakeLists.txt
+++ b/c++/test/CMakeLists.txt
@@ -36,8 +36,7 @@ INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES (${HDF5_TEST_SRC_DIR} )
ADD_EXECUTABLE (cpp_testhdf5 ${CPP_TEST_SRCS} )
-H5_NAMING (cpp_testhdf5)
-TARGET_WIN_PROPERTIES (cpp_testhdf5)
+H5_NAMING (cpp_testhdf5 ${LIB_TYPE})
TARGET_LINK_LIBRARIES (cpp_testhdf5
${HDF5_CPP_LIB_TARGET}
${HDF5_LIB_TARGET}
@@ -45,3 +44,39 @@ TARGET_LINK_LIBRARIES (cpp_testhdf5
)
ADD_TEST (NAME cpp_testhdf5 COMMAND $<TARGET_FILE:cpp_testhdf5>)
+
+IF (HDF5_TEST_VFD)
+
+ SET (VFD_LIST
+ sec2
+ stdio
+ core
+ split
+ multi
+ family
+ )
+
+ IF (DIRECT_VFD)
+ SET (VFD_LIST ${VFD_LIST} direct)
+ ENDIF (DIRECT_VFD)
+
+ MACRO (ADD_VFD_TEST vfdname resultcode)
+ ADD_TEST (
+ NAME VFD-${vfdname}-cpp_testhdf5
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_PROGRAM=$<TARGET_FILE:cpp_testhdf5>"
+ -D "TEST_ARGS:STRING="
+ -D "TEST_VFD:STRING=${vfdname}"
+ -D "TEST_EXPECT=${resultcode}"
+ -D "TEST_OUTPUT=cpp_testhdf5"
+ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
+ -P "${HDF5_RESOURCES_DIR}/vfdTest.cmake"
+ )
+ ENDMACRO (ADD_VFD_TEST)
+
+ # Run test with different Virtual File Driver
+ FOREACH (vfd ${VFD_LIST})
+ ADD_VFD_TEST (${vfd} 0)
+ ENDFOREACH (vfd ${VFD_LIST})
+
+ENDIF (HDF5_TEST_VFD)
diff --git a/c++/test/Makefile.in b/c++/test/Makefile.in
index 5a3f52c..68418d9 100644
--- a/c++/test/Makefile.in
+++ b/c++/test/Makefile.in
@@ -142,6 +142,7 @@ DEFS = @DEFS@
DEPDIR = @DEPDIR@
DEPRECATED_SYMBOLS = @DEPRECATED_SYMBOLS@
DIRECT_VFD = @DIRECT_VFD@
+DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
DYNAMIC_DIRS = @DYNAMIC_DIRS@
@@ -203,6 +204,7 @@ LTLIBOBJS = @LTLIBOBJS@
LT_STATIC_EXEC = @LT_STATIC_EXEC@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MPE = @MPE@
MPI_GET_SIZE = @MPI_GET_SIZE@
@@ -259,6 +261,7 @@ abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp
index fb8bd17..fbb1219 100644
--- a/c++/test/tcompound.cpp
+++ b/c++/test/tcompound.cpp
@@ -115,7 +115,8 @@ static void test_compound_2()
const int nelmts = NTESTELEM;
const hsize_t four = 4;
int i;
- unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
+ unsigned char *buf = NULL, *orig = NULL, *bkg = NULL;
+ ArrayType *array_dt = NULL;
// Output message about test being performed
SUBTEST("Compound Element Reordering");
@@ -138,7 +139,7 @@ static void test_compound_2()
memcpy(buf, orig, nelmts*sizeof(src_typ_t));
// Build hdf5 datatypes
- ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
+ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
// Create an empty compound datatype
CompType st(sizeof(src_typ_t));
@@ -148,6 +149,7 @@ static void test_compound_2()
st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT);
st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT);
array_dt->close();
+ delete array_dt;
array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
@@ -202,6 +204,9 @@ static void test_compound_2()
cerr << "test_compound_2 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
+
+ if(array_dt)
+ delete array_dt;
} // test_compound_2()
@@ -235,7 +240,8 @@ static void test_compound_3()
int i;
const int nelmts = NTESTELEM;
const hsize_t four = 4;
- unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
+ unsigned char *buf = NULL, *orig = NULL, *bkg = NULL;
+ ArrayType* array_dt = NULL;
// Output message about test being performed
SUBTEST("Compound Datatype Subset Conversions");
@@ -258,7 +264,7 @@ static void test_compound_3()
memcpy(buf, orig, nelmts*sizeof(src_typ_t));
/* Build hdf5 datatypes */
- ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
+ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
// Create an empty compound datatype
CompType st(sizeof(src_typ_t));
@@ -268,6 +274,7 @@ static void test_compound_3()
st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT);
st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT);
array_dt->close();
+ delete array_dt;
array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
@@ -319,6 +326,9 @@ static void test_compound_3()
cerr << "test_compound_3 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
+
+ if(array_dt)
+ delete array_dt;
} // test_compound_3()
@@ -357,7 +367,8 @@ static void test_compound_4()
int i;
const int nelmts = NTESTELEM;
const hsize_t four = 4;
- unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;
+ unsigned char *buf = NULL, *orig = NULL, *bkg = NULL;
+ ArrayType* array_dt = NULL;
// Output message about test being performed
SUBTEST("Compound Element Shrinking & Reordering");
@@ -380,7 +391,7 @@ static void test_compound_4()
memcpy(buf, orig, nelmts*sizeof(src_typ_t));
/* Build hdf5 datatypes */
- ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
+ array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
// Create an empty compound datatype
CompType st(sizeof(src_typ_t));
@@ -390,6 +401,7 @@ static void test_compound_4()
st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT);
st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT);
array_dt->close();
+ delete array_dt;
array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
@@ -446,6 +458,9 @@ static void test_compound_4()
cerr << "test_compound_4 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
+
+ if(array_dt)
+ delete array_dt;
} // test_compound_4()
@@ -486,16 +501,18 @@ static void test_compound_5()
dst_typ_t *dst;
void *buf = calloc(2, sizeof(dst_typ_t));
void *bkg = calloc(2, sizeof(dst_typ_t));
+ ArrayType* array_dt = NULL;
// Output message about test being performed
SUBTEST("Optimized Struct Converter");
try {
/* Build datatypes */
- ArrayType* array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims);
+ array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims);
CompType short_array(4*sizeof(short));
short_array.insertMember("_", 0, *array_dt);
array_dt->close();
+ delete array_dt;
CompType int_array(4*sizeof(int));
array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims);
@@ -545,6 +562,9 @@ static void test_compound_5()
cerr << "test_compound_5 in catch" << endl;
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
+
+ if(array_dt)
+ delete array_dt;
} // test_compound_5()
diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp
index e59707a..0dbdf00 100644
--- a/c++/test/tfilter.cpp
+++ b/c++/test/tfilter.cpp
@@ -174,58 +174,61 @@ void test_szip_filter(H5File& file1)
SUBTEST("szip filter (with encoder)");
if ( h5_szip_can_encode() == 1) {
- char* tconv_buf = new char [1000];
- try {
- const hsize_t size[2] = {DSET_DIM1, DSET_DIM2};
-
- // Create the data space
- DataSpace space1(2, size, NULL);
+ char* tconv_buf = new char [1000];
- // Create a small conversion buffer to test strip mining (?)
- DSetMemXferPropList xfer;
- xfer.setBuffer (1000, tconv_buf, NULL);
+ try {
+ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2};
- // Prepare dataset create property list
- DSetCreatPropList dsplist;
- dsplist.setChunk(2, chunk_size);
+ // Create the data space
+ DataSpace space1(2, size, NULL);
- // Set up for szip compression
- dsplist.setSzip(szip_options_mask, szip_pixels_per_block);
+ // Create a small conversion buffer to test strip mining (?)
+ DSetMemXferPropList xfer;
+ xfer.setBuffer (1000, tconv_buf, NULL);
- // Create a dataset with szip compression
- DataSpace space2 (2, size, NULL);
- DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist));
+ // Prepare dataset create property list
+ DSetCreatPropList dsplist;
+ dsplist.setChunk(2, chunk_size);
- hsize_t i, j, n;
- for (i=n=0; i<size[0]; i++)
- {
- for (j=0; j<size[1]; j++)
- {
- points[i][j] = (int)n++;
- }
- }
+ // Set up for szip compression
+ dsplist.setSzip(szip_options_mask, szip_pixels_per_block);
- // Write to the dataset then read back the values
- dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
- dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ // Create a dataset with szip compression
+ DataSpace space2 (2, size, NULL);
+ DataSet dataset(file1.createDataSet (DSET_SZIP_NAME, PredType::NATIVE_INT, space2, dsplist));
- // Check that the values read are the same as the values written
- for (i = 0; i < size[0]; i++)
- for (j = 0; j < size[1]; j++)
+ hsize_t i, j, n;
+ for (i=n=0; i<size[0]; i++)
{
- int status = check_values (i, j, points[i][j], check[i][j]);
- if (status == -1)
- throw Exception("test_szip_filter", "Failed in testing szip method");
+ for (j=0; j<size[1]; j++)
+ {
+ points[i][j] = (int)n++;
+ }
}
- dsplist.close();
- PASSED();
- } // end of try
- // catch all other exceptions
- catch (Exception E)
- {
- issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg());
- }
+ // Write to the dataset then read back the values
+ dataset.write ((void*)points, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+ dataset.read ((void*)check, PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer);
+
+ // Check that the values read are the same as the values written
+ for (i = 0; i < size[0]; i++)
+ for (j = 0; j < size[1]; j++)
+ {
+ int status = check_values (i, j, points[i][j], check[i][j]);
+ if (status == -1)
+ throw Exception("test_szip_filter", "Failed in testing szip method");
+ }
+ dsplist.close();
+ PASSED();
+ } // end of try
+
+ // catch all other exceptions
+ catch (Exception E)
+ {
+ issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg());
+ }
+
+ delete tconv_buf;
} // if szip presents
else {
SKIPPED();
diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp
index 53a1c8c..e4e691a 100644
--- a/c++/test/tlinks.cpp
+++ b/c++/test/tlinks.cpp
@@ -403,7 +403,6 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
{
hsize_t size[1] = {1};
char filename[NAME_BUF_SIZE];
- char* tconv_buf = new char [1000];
// Use the file access template id to create a file access prop. list.
FileAccPropList fapl(fapl_id);
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp
index aeb202a..7f63d33 100644
--- a/c++/test/trefer.cpp
+++ b/c++/test/trefer.cpp
@@ -326,6 +326,9 @@ static void test_reference_obj(void)
catch (Exception E) {
issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCDetailMsg());
}
+
+ if(file1)
+ delete file1;
} // test_reference_obj()
/****************************************************************
diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp
index ef00c08..b1baa29 100644
--- a/c++/test/ttypes.cpp
+++ b/c++/test/ttypes.cpp
@@ -387,6 +387,7 @@ static void test_named ()
static hsize_t ds_size[2] = {10, 20};
hsize_t i;
unsigned attr_data[10][20];
+ DataType *ds_type = NULL;
SUBTEST("Named datatypes");
try {
@@ -462,12 +463,13 @@ now.
// Create a dataset that uses the named type, then get the dataset's
// datatype and make sure it's a named type.
DataSet dset = file.createDataSet("dset1", another_type, space);
- DataType *ds_type = new DataType(dset.getDataType());
+ ds_type = new DataType(dset.getDataType());
iscommitted = ds_type->committed();
if (!iscommitted)
throw InvalidActionException("IntType::committed()", "1 Dataset type should be named type!");
dset.close();
ds_type->close();
+ delete ds_type;
// Reopen the dataset and its type, then make sure the type is
// a named type.
@@ -483,6 +485,7 @@ now.
dset = file.createDataSet("dset2", *ds_type, space);
ds_type->close();
dset.close();
+ delete ds_type;
// Reopen the second dataset and make sure the type is shared
dset = file.openDataSet("dset2");
@@ -509,6 +512,9 @@ now.
catch (Exception E) {
issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg());
}
+
+ if(ds_type)
+ delete ds_type;
} // test_named
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index 91036f9..73e54e0 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -129,7 +129,6 @@ void test_vlstr_free_custom(void *_mem, void *info)
*-------------------------------------------------------------------------
*/
// String for testing datasets
-static char *dynstring_ds_write=NULL;
static char stastring_ds_write[1]={'A'};
// Info for a string dataset
@@ -138,6 +137,9 @@ const H5std_string DSET1_DATA("String Dataset");
static void test_vlstring_dataset()
{
+ char *dynstring_ds_write = NULL;
+ char *string_ds_check = NULL;
+
// Output message about test being performed
SUBTEST("VL String on Datasets");
@@ -161,12 +163,12 @@ static void test_vlstring_dataset()
dset1.write(DSET1_DATA, vlst);
// Read and verify the dataset string as a string of chars.
- char *string_ds_check;
dset1.read(&string_ds_check, vlst);
if(HDstrcmp(string_ds_check, DSET1_DATA.c_str())!=0)
TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n",__LINE__, DSET1_DATA.c_str(), string_ds_check);
HDfree(string_ds_check); // note: no need for std::string test
+ string_ds_check = NULL;
// Read and verify the dataset string as an std::string.
H5std_string read_str;
@@ -191,6 +193,7 @@ static void test_vlstring_dataset()
if(HDstrcmp(string_ds_check,dynstring_ds_write)!=0)
TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",dynstring_ds_write,string_ds_check);
HDfree(string_ds_check);
+ string_ds_check = NULL;
dset1.close();
// Open dataset DSET1_NAME again.
@@ -207,6 +210,11 @@ static void test_vlstring_dataset()
catch (Exception E) {
issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg());
}
+
+ if(dynstring_ds_write)
+ HDfree(dynstring_ds_write);
+ if(string_ds_check)
+ HDfree(string_ds_check);
} // test_vlstring_dataset()
/*-------------------------------------------------------------------------
@@ -231,10 +239,10 @@ static void test_vlstring_array_dataset()
// Output message about test being performed
SUBTEST("VL String Array on Datasets");
- H5File* file1;
+ H5File* file1 = NULL;
try {
// Create file.
- file1 = new H5File (FILENAME, H5F_ACC_RDWR);
+ file1 = new H5File(FILENAME, H5F_ACC_RDWR);
// Create dataspace for datasets.
hsize_t dims1[] = {SPACE1_DIM1};
@@ -278,8 +286,7 @@ static void test_vlstring_array_dataset()
HDmemset(wdata2, 'A', 65533);
dataset2.write(&wdata2, vlst);
- char *rdata2 = (char*)HDcalloc(65534, sizeof(char));
- HDmemset(rdata2, 0, 65533);
+ char *rdata2;
dataset2.read(&rdata2, vlst);
if (HDstrcmp(wdata2, rdata2)!=0)
TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n",__LINE__, wdata2, rdata2);
@@ -302,8 +309,10 @@ static void test_vlstring_array_dataset()
catch (Exception E)
{
issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg());
- delete file1;
}
+
+ if(file1)
+ delete file1;
} // end test_vlstring_array_dataset()
/*-------------------------------------------------------------------------
@@ -482,6 +491,7 @@ static void test_vlstring_type()
// Close datatype and file.
vlst.close();
file1->close();
+ delete file1;
// Open file.
file1 = new H5File(FILENAME, H5F_ACC_RDWR);
@@ -506,8 +516,10 @@ static void test_vlstring_type()
catch (Exception E)
{
issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg());
- delete file1;
}
+
+ if(file1)
+ delete file1;
} // end test_vlstring_type()
/*-------------------------------------------------------------------------