diff options
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 5 | ||||
-rw-r--r-- | c++/src/H5AbstractDs.h | 4 | ||||
-rw-r--r-- | c++/src/H5Attribute.cpp | 25 | ||||
-rw-r--r-- | c++/src/H5Attribute.h | 4 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 26 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 5 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 60 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 4 | ||||
-rw-r--r-- | c++/test/th5s.cpp | 9 | ||||
-rw-r--r-- | c++/test/tlinks.cpp | 3 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 1 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 7 | ||||
-rw-r--r-- | c++/test/tvlstr.cpp | 5 |
13 files changed, 91 insertions, 67 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 9cf1ee8..e6cacf9 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -25,11 +25,6 @@ #include "H5CommonFG.h" #include "H5Alltypes.h" -#include <iostream> // remove when done - - using std::cerr; - using std::endl; - #ifndef H5_NO_NAMESPACE namespace H5 { #endif diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 1d04d6c..c5ffa36 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -65,7 +65,7 @@ class H5_DLLCPP AbstractDs { // dataset - pure virtual. virtual hsize_t getStorageSize() const = 0; - // Returns this class name + // Returns this class name - pure virtual. virtual H5std_string fromClass() const = 0; // Copy constructor @@ -82,7 +82,7 @@ class H5_DLLCPP AbstractDs { AbstractDs( const hid_t ds_id ); private: - // This member function is implemented by DataSet and Attribute. + // This member function is implemented by DataSet and Attribute - pure virtual. virtual hid_t p_get_type() const = 0; }; #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 226ae5c..6c14269 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -385,6 +385,31 @@ hsize_t Attribute::getStorageSize() const } //-------------------------------------------------------------------------- +// Function: Attribute::flush +///\brief Flushes all buffers associated with a file specified by +/// this attribute, to disk. +///\param scope - IN: Specifies the scope of the flushing action, +/// which can be either of these values: +/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file +/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file +///\exception H5::AttributeIException +///\par Description +/// This attribute is used to identify the file to be flushed. +// Programmer Binh-Minh Ribler - 2013 +// Modification +// Mar 2013 - BMR +// Duplicated from H5Location +//-------------------------------------------------------------------------- +void Attribute::flush(H5F_scope_t scope) const +{ + herr_t ret_value = H5Fflush(getId(), scope); + if( ret_value < 0 ) + { + throw AttributeIException("Attribute::flush", "H5Fflush failed"); + } +} + +//-------------------------------------------------------------------------- // Function: Attribute::getId // Purpose: Get the id of this attribute // Description: diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index f392f1a..cafc264 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -51,6 +51,10 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent { void write(const DataType& mem_type, const void *buf ) const; void write(const DataType& mem_type, const H5std_string& strg ) const; + // Flushes all buffers associated with the file specified by this + // attribute to disk. + void flush( H5F_scope_t scope ) const; + ///\brief Returns this class name virtual H5std_string fromClass () const { return("Attribute"); } diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index da0241f..6e85428 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -61,7 +61,7 @@ H5File::H5File() : IdComponent(), id(0) {} /// modifying default file meta-data. Default to /// FileCreatPropList::DEFAULT ///\param access_plist - IN: File access property list. Default to -/// FileCreatPropList::DEFAULT +/// FileAccPropList::DEFAULT ///\par Description /// Valid values of \a flags include: /// \li \c H5F_ACC_TRUNC - Truncate file, if it already exists, @@ -77,11 +77,18 @@ H5File::H5File() : IdComponent(), id(0) {} /// please refer to the \b Special \b case section in the C layer /// Reference Manual at: /// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-Create +// Notes With a PGI compiler (~2012-2013), the exception thrown by p_get_file +// could not be caught in the applications. Added try block here +// to catch then re-throw it. -BMR 2013/03/21 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent(0) { - p_get_file(name, flags, create_plist, access_plist); + try { + p_get_file(name, flags, create_plist, access_plist); + } catch (FileIException open_file) { + throw open_file; + } } //-------------------------------------------------------------------------- @@ -94,12 +101,19 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c /// modifying default file meta-data. Default to /// FileCreatPropList::DEFAULT ///\param access_plist - IN: File access property list. Default to -/// FileCreatPropList::DEFAULT +/// FileAccPropList::DEFAULT +// Notes With a PGI compiler (~2012-2013), the exception thrown by p_get_file +// could not be caught in the applications. Added try block here +// to catch then re-throw it. -BMR 2013/03/21 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent(0) { - p_get_file(name.c_str(), flags, create_plist, access_plist); + try { + p_get_file(name.c_str(), flags, create_plist, access_plist); + } catch (FileIException open_file) { + throw open_file; + } } //-------------------------------------------------------------------------- @@ -166,7 +180,7 @@ void H5File::flush(H5F_scope_t scope) const } //-------------------------------------------------------------------------- -// Function: H5File::isHdf5 +// Function: H5File::isHdf5 (static) ///\brief Determines whether a file in HDF5 format. ///\param name - IN: Name of the file ///\return true if the file is in HDF5 format, and false, otherwise @@ -189,7 +203,7 @@ bool H5File::isHdf5(const char* name) } //-------------------------------------------------------------------------- -// Function: H5File::isHdf5 +// Function: H5File::isHdf5 (static) ///\brief This is an overloaded member function, provided for convenience. /// It takes an \c H5std_string for \a name. ///\param name - IN: Name of the file - \c H5std_string diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index bb13f2f..744118f 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -288,11 +288,6 @@ test_datasize() { SUBTEST("DataSet::getInMemDataSize()"); - - int points[100][200]; - int check[100][200]; - int i, j, n; - try { // Open FILE1. diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index df01752..6e49162 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -111,22 +111,15 @@ static void test_file_create() // try to create the same file with H5F_ACC_TRUNC. This should fail // because file1 is the same file and is currently open. -/* These three are failing with new/PGI compiler, HDFFV-8067 - The line "H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E" - Results in this message: - "terminate called without an active exception - Command terminated by signal 6" - Commenting it out until it's fixed LK 20120626. -#ifndef H5_HAVE_FILE_VERSIONS try { H5File file2 (FILE1, H5F_ACC_TRUNC); // should throw E + // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); } catch( FileIException E ) // catch truncating existing file {} // do nothing, FAIL expected -#endif // Close file1 delete file1; file1 = NULL; @@ -141,10 +134,10 @@ static void test_file_create() } catch( FileIException E ) // catching creating existing file {} // do nothing, FAIL expected + // Test create with H5F_ACC_TRUNC. This will truncate the existing file. file1 = new H5File (FILE1, H5F_ACC_TRUNC); -#ifndef H5_HAVE_FILE_VERSIONS // Try to truncate first file again. This should fail because file1 // is the same file and is currently open. try { @@ -155,19 +148,17 @@ static void test_file_create() } catch( FileIException E ) // catching truncating opened file {} // do nothing, FAIL expected -#endif + // Try with H5F_ACC_EXCL. This should fail too because the file already // exists. try { -// H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E + H5File file3 (FILE1, H5F_ACC_EXCL); // should throw E // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "H5F_ACC_EXCL attempt on an existing file."); } catch( FileIException E ) // catching H5F_ACC_EXCL on existing file {} // do nothing, FAIL expected -*/ - std::cerr << "SKIPPED for HDFFV-8067" << std::endl; // Get the file-creation template FileCreatPropList tmpl1 = file1->getCreatePlist(); @@ -333,6 +324,7 @@ static void test_file_open() tmpl1.getSymk( iparm1, iparm2); verify_val(iparm1, F2_SYM_INTERN_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); verify_val(iparm2, F2_SYM_LEAF_K, "FileCreatPropList::getSymk", __LINE__, __FILE__); + PASSED(); } // end of try block @@ -381,8 +373,16 @@ static void test_file_size() hsize_t file_size = file4.getFileSize(); // Check if file size is reasonable. It's supposed to be 2KB now. - if(file_size<1*KB || file_size>4*KB) - issue_fail_msg("test_file_size()", __LINE__, __FILE__); + if (file_size < 1*KB || file_size > 4*KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFileSize() returned unreasonable value"); + + // Get the amount of free space in the file + hssize_t free_space = file4.getFreeSpace(); + + // Check if it's reasonable. It's 0 now. + if (free_space < 0 || free_space > 4*KB) + issue_fail_msg("test_file_size()", __LINE__, __FILE__, "getFreeSpace returned unreasonable value"); + PASSED(); } // end of try block @@ -415,7 +415,8 @@ const int NX = 4; const int NY = 5; const H5std_string GROUPNAME ("group"); const H5std_string DSETNAME ("dataset"); -const H5std_string ATTRNAME ("attribute"); +const H5std_string DATTRNAME ("dataset attribute"); +const H5std_string FATTRNAME ("file attribute"); const H5std_string DTYPENAME ("compound"); // Compound datatype @@ -426,7 +427,7 @@ typedef struct s1_t { static void test_file_name() { - // Output message about test being performed + // Output message about test being performed. SUBTEST("File Name"); H5std_string file_name; @@ -438,42 +439,42 @@ static void test_file_name() file_name = file4.getFileName(); verify_val(file_name, FILE4, "H5File::getFileName", __LINE__, __FILE__); - // Create a group in the root group + // Create a group in the root group. Group group(file4.createGroup(GROUPNAME, 0)); - // Get and verify file name + // Get and verify file name via a group. file_name = group.getFileName(); verify_val(file_name, FILE4, "Group::getFileName", __LINE__, __FILE__); - // Create the data space + // Create the data space. hsize_t dims[RANK] = {NX, NY}; DataSpace space(RANK, dims); - // Create a new dataset + // Create a new dataset. DataSet dataset(file4.createDataSet (DSETNAME, PredType::NATIVE_INT, space)); - // Get and verify file name + // Get and verify file name via a dataset. file_name = dataset.getFileName(); verify_val(file_name, FILE4, "DataSet::getFileName", __LINE__, __FILE__); - // Create an attribute for the dataset - Attribute attr(dataset.createAttribute(ATTRNAME, PredType::NATIVE_INT, space)); + // Create an attribute for the dataset. + Attribute attr(dataset.createAttribute(DATTRNAME, PredType::NATIVE_INT, space)); - // Get and verify file name + // Get and verify file name via an attribute. file_name = attr.getFileName(); verify_val(file_name, FILE4, "Attribute::getFileName", __LINE__, __FILE__); - // Create a compound datatype + // Create a compound datatype. CompType comp_type (sizeof(s1_t)); - // Insert fields + // Insert fields. comp_type.insertMember("a", HOFFSET(s1_t, a), PredType::NATIVE_INT); comp_type.insertMember("b", HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); - // Save it on file + // Save it on file. comp_type.commit(file4, DTYPENAME); - // Get and verify file name + // Get and verify file name via a committed datatype. comp_type.getFileName(); verify_val(file_name, FILE4, "CompType::getFileName", __LINE__, __FILE__); PASSED(); @@ -507,7 +508,6 @@ void test_file() { // Output message about test being performed MESSAGE(5, ("Testing File I/O operations\n")); - //MESSAGE("Testing File I/O operations\n"); test_file_create(); // Test file creation (also creation templates) test_file_open(); // Test file opening diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index 0dbdf00..9e60655 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -47,12 +47,14 @@ #define FILTER_CHUNK_DIM2 25 // will do this function later or use it as guideline - BMR - 2007/01/26 +#if 0 static herr_t test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, int corrupted, hsize_t *dset_size) { cerr << "do nothing right now" << endl; return(0); } +#endif /* Temporary filter IDs used for testing */ #define H5Z_FILTER_BOGUS 305 @@ -254,13 +256,11 @@ extern "C" void test_filters() { // Output message about test being performed - //MESSAGE("Testing Various Filters\n"); MESSAGE(5, ("Testing Various Filters\n")); hid_t fapl_id; fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template - int nerrors=0; // keep track of number of failures occurr try { // Use the file access template id to create a file access prop. list diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index e6ed440..7947a9b 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -188,13 +188,7 @@ static void test_h5s_basic() * If this test fails and the H5S_MAX_RANK variable has changed, follow * the instructions in space_overflow.c for regenating the th5s.h5 file. */ - char testfile[512]=""; - char *srcdir = getenv("srcdir"); - if (srcdir && ((strlen(srcdir) + strlen(TESTFILE.c_str()) + 1) < sizeof(testfile))){ - strcpy(testfile, srcdir); - strcat(testfile, "/"); - } - strcat(testfile, TESTFILE.c_str()); + const char *testfile = H5_get_srcdir_filename(TESTFILE.c_str()); // Create file H5File fid1(testfile, H5F_ACC_RDONLY); @@ -575,7 +569,6 @@ extern "C" void test_h5s() { // Output message about test being performed - //MESSAGE("Testing Dataspaces\n"); MESSAGE(5, ("Testing Dataspaces\n")); test_h5s_basic(); // Test basic H5S code diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index e4e691a..fca5918 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -226,6 +226,7 @@ typedef struct { hbool_t *visited; /* Pointer to array of "visited link" flags */ } link_iter_info_t; +#if 0 /* Link visit structs */ typedef struct { const char *path; /* Path to link */ @@ -374,6 +375,7 @@ typedef struct { unsigned idx; /* Index in object visit structure */ const obj_visit_t *info; /* Pointer to the object visit structure to use */ } ovisit_ud_t; +#endif static const char *FILENAME[] = { "link0", @@ -529,7 +531,6 @@ void test_links() fapl_id = h5_fileaccess(); // Output message about test being performed - //MESSAGE("Testing Various Links\n"); MESSAGE(5, ("Testing Various Links\n")); try { diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index 7f63d33..dcb32dc 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -244,7 +244,6 @@ static void test_reference_obj(void) verify_val(name_size, DSET1_LEN, "Group::getObjnameByIdx(index,(std::string)buf,buf_len)", __LINE__, __FILE__); // Test getObjnameByIdx(hsize_t idx, char* name, size_t size) - char name_C[DSET1_LEN+1]; group.getObjnameByIdx(0, name, name_size+1); verify_val(name, DSET1_NAME, "Group::getObjnameByIdx(index,(char*)buf,buf_len)", __LINE__, __FILE__); verify_val(name_size, DSET1_LEN, "Group::getObjnameByIdx(index,(char*)buf,buf_len)", __LINE__, __FILE__); diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index d97a1ec..6950523 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -52,6 +52,7 @@ * normally require alignment. When set, all native datatypes must be aligned * on a byte boundary equal to the data size. */ +#if 0 #define TEST_ALIGNMENT /* Alignment test stuff */ @@ -61,6 +62,7 @@ #endif #define SET_ALIGNMENT(TYPE,VAL) \ H5T_NATIVE_##TYPE##_ALIGN_g=MAX(H5T_NATIVE_##TYPE##_ALIGN_g, VAL) +#endif const char *FILENAME[] = { "dtypes1.h5", @@ -143,9 +145,6 @@ static void test_classes() */ static void test_copy() { - hid_t a_copy; - herr_t status; - SUBTEST("DataType::copy() and DataType::operator="); try { // Test copying from a predefined datatype using DataType::operator= @@ -212,7 +211,6 @@ static void test_query() long c; double d; } s_type_t; - char filename[1024]; short enum_val; // Output message about test being performed @@ -387,7 +385,6 @@ static void test_transient () const H5std_string filename2("dtypes2.h5"); static void test_named () { - herr_t status; static hsize_t ds_size[2] = {10, 20}; hsize_t i; unsigned attr_data[10][20]; diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 73e54e0..89f24f2 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -129,7 +129,7 @@ void test_vlstr_free_custom(void *_mem, void *info) *------------------------------------------------------------------------- */ // String for testing datasets -static char stastring_ds_write[1]={'A'}; +// static char stastring_ds_write[1]={'A'}; // Info for a string dataset const H5std_string DSET1_NAME("String_ds"); @@ -687,6 +687,7 @@ static void test_vlstring_attribute() } } // test_vlstring_attribute() +#if 0 /*------------------------------------------------------------------------- * Function: test_read_vl_string_attribute * @@ -746,6 +747,7 @@ static void test_read_vl_string_attribute() issue_fail_msg("test_read_vl_string_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_read_vl_string_attribute +#endif // 2013: need to verify before adding to test /*------------------------------------------------------------------------- * Function: test_vlstring_array_attribute @@ -957,7 +959,6 @@ extern "C" void test_vlstrings() { // Output message about test being performed - //MESSAGE("Testing Variable-Length Strings"); MESSAGE(5, ("Testing Variable-Length Strings")); // These tests use the same file |