summaryrefslogtreecommitdiffstats
path: root/test/ttsafe_dcreate.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2018-05-23 19:27:05 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2018-05-23 19:27:05 (GMT)
commitbe2fc7dcd1720590e9970edc6c74a48329fccbc2 (patch)
tree2d9be408e9d982356095eb64cac1d5edaafd3d63 /test/ttsafe_dcreate.c
parentb178d80be0946e3d332ecf575b2f145837cc9454 (diff)
parent2b0fb7e3f1f7da5b23d430702493ed4fb7f87166 (diff)
downloadhdf5-be2fc7dcd1720590e9970edc6c74a48329fccbc2.zip
hdf5-be2fc7dcd1720590e9970edc6c74a48329fccbc2.tar.gz
hdf5-be2fc7dcd1720590e9970edc6c74a48329fccbc2.tar.bz2
Merging in latest from upstream (HDFFV/hdf5:refs/heads/develop)
* commit '2b0fb7e3f1f7da5b23d430702493ed4fb7f87166': (21 commits) HDFFV-9739 only executes H5E tests in production Remove link flag from compile command fix typo Add release note Correct attribute location HDFFV-9739 fix copy testfiles command HDFFV-9739 remove obsolete test files HDFFV-9739 dup test file for concurrent tests HDFFV-9739 Fix autotools script HDFFV-9739 Change autotools test scripts Fix typo HDFFV-9739 Update test reference Update current windows test machines HDFFV-9739 Grab err number before API call HDFFV-9739 Add release note Adjust test names for concurrent tests Fix soversion HDFFV-9739 Fix copy name HDFFV-9739 factor out tests into separate JUnit Updated the threadsafety test to use error macros instead of asserts. ...
Diffstat (limited to 'test/ttsafe_dcreate.c')
-rw-r--r--test/ttsafe_dcreate.c77
1 files changed, 35 insertions, 42 deletions
diff --git a/test/ttsafe_dcreate.c b/test/ttsafe_dcreate.c
index 65051c7..36b5f1f 100644
--- a/test/ttsafe_dcreate.c
+++ b/test/ttsafe_dcreate.c
@@ -23,20 +23,9 @@
* Temporary files generated:
* ttsafe_dcreate.h5
*
- * HDF5 APIs exercised in thread:
- * H5Screate_simple, H5Tcopy, H5Tset_order, H5Dcreate2, H5Dwrite, H5Dclose,
- * H5Tclose, H5Sclose.
- *
* Created: Apr 28 2000
* Programmer: Chee Wai LEE
*
- * Modification History
- * --------------------
- *
- * 19 May 2000, Bill Wendling
- * Changed so that it creates its own HDF5 file and removes it at cleanup
- * time.
- *
********************************************************************/
#include "ttsafe.h"
@@ -83,16 +72,18 @@ thread_info thread_out[NUM_THREAD];
* Thread safe test - multiple dataset creation
**********************************************************************
*/
-void tts_dcreate(void)
+void
+tts_dcreate(void)
{
/* thread definitions */
H5TS_thread_t threads[NUM_THREAD];
/* HDF5 data definitions */
- hid_t file, dataset;
+ hid_t file = H5I_INVALID_HID;
+ hid_t dataset = H5I_INVALID_HID;
int datavalue, i;
H5TS_attr_t attribute;
- int ret;
+ herr_t status;
/* set pthread attribute to perform global scheduling */
H5TS_attr_init(&attribute);
@@ -107,7 +98,7 @@ void tts_dcreate(void)
* creation plist and default file access plist
*/
file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- assert(file >= 0);
+ CHECK(file, H5I_INVALID_HID, "H5Fcreate");
/* simultaneously create a large number of datasets within the file */
for(i = 0; i < NUM_THREAD; i++) {
@@ -115,11 +106,10 @@ void tts_dcreate(void)
thread_out[i].file = file;
thread_out[i].dsetname = dsetname[i];
threads[i] = H5TS_create_thread(tts_dcreate_creator, NULL, &thread_out[i]);
- } /* end for */
+ }
- for(i = 0;i < NUM_THREAD; i++) {
+ for(i = 0;i < NUM_THREAD; i++)
H5TS_wait_for_thread(threads[i]);
- } /* end for */
/* compare data to see if it is written correctly */
@@ -129,36 +119,38 @@ void tts_dcreate(void)
H5Fclose(file);
return;
} else {
- ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue);
- assert(ret >= 0);
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &datavalue);
+ CHECK(status, FAIL, "H5Dread");
if(datavalue != i) {
TestErrPrintf("Wrong value read %d for dataset name %s - test failed\n",
datavalue, dsetname[i]);
- ret = H5Dclose(dataset);
- assert(ret >= 0);
- ret = H5Fclose(file);
- assert(ret >= 0);
+ status = H5Dclose(dataset);
+ CHECK(status, FAIL, "H5Dclose");
+ status = H5Fclose(file);
+ CHECK(status, FAIL, "H5Fclose");
return;
}
- ret = H5Dclose(dataset);
- assert(ret >= 0);
+ status= H5Dclose(dataset);
+ CHECK(status, FAIL, "H5Dclose");
}
}
/* close remaining resources */
- ret = H5Fclose(file);
- assert(ret >= 0);
+ status = H5Fclose(file);
+ CHECK(status, FAIL, "H5Fclose");
/* Destroy the thread attribute */
H5TS_attr_destroy(&attribute);
-}
+} /* end tts_dcreate() */
-void *tts_dcreate_creator(void *_thread_data)
+void *
+tts_dcreate_creator(void *_thread_data)
{
- hid_t dataspace, dataset;
- herr_t ret;
+ hid_t dataspace = H5I_INVALID_HID;
+ hid_t dataset = H5I_INVALID_HID;
+ herr_t status;
hsize_t dimsf[1]; /* dataset dimensions */
struct thread_info thread_data;
@@ -167,28 +159,29 @@ void *tts_dcreate_creator(void *_thread_data)
/* define dataspace for dataset */
dimsf[0] = 1;
dataspace = H5Screate_simple(1, dimsf, NULL);
- assert(dataspace >= 0);
+ CHECK(dataspace, H5I_INVALID_HID, "H5Screate_simple");
/* create a new dataset within the file */
dataset = H5Dcreate2(thread_data.file, thread_data.dsetname,
H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- assert(dataset >= 0);
+ CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2");
/* initialize data for dataset and write value to dataset */
- ret = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
H5P_DEFAULT, &thread_data.id);
- assert(ret >= 0);
+ CHECK(status, FAIL, "H5Dwrite");
/* close dataset and dataspace resources */
- ret = H5Dclose(dataset);
- assert(ret >= 0);
- ret = H5Sclose(dataspace);
- assert(ret >= 0);
+ status = H5Dclose(dataset);
+ CHECK(status, FAIL, "H5Dclose");
+ status = H5Sclose(dataspace);
+ CHECK(status, FAIL, "H5Sclose");
return NULL;
-}
+} /* end tts_dcreate_creator() */
-void cleanup_dcreate(void)
+void
+cleanup_dcreate(void)
{
HDunlink(FILENAME);
}