diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2010-09-27 19:02:48 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2010-09-27 19:02:48 (GMT) |
commit | 1c61b6fe13f6fd9c84c0407f02865568e0a7f638 (patch) | |
tree | e294883e7a2d7de4ec264d9ea68392c3587ecea3 /test | |
parent | 82c6eab1814e1e06ef9472f6f4bbc8522064e0bc (diff) | |
download | hdf5-1c61b6fe13f6fd9c84c0407f02865568e0a7f638.zip hdf5-1c61b6fe13f6fd9c84c0407f02865568e0a7f638.tar.gz hdf5-1c61b6fe13f6fd9c84c0407f02865568e0a7f638.tar.bz2 |
[svn-r19481] I'm backing out my fix for bug 1707 because there're some unresolved issues - r19441 and 19467.
Bug 1707 is that H5Eset_auto causes a seg fault when an application uses -DH5_USE_16_API with
the 1.8 library to compile.
I created a branch off the trunk called set_auto to continue working on the problem.
Tested on jam - backing out, simple.
Diffstat (limited to 'test')
-rw-r--r-- | test/dtransform.c | 18 | ||||
-rw-r--r-- | test/enum.c | 6 | ||||
-rw-r--r-- | test/err_compat.c | 175 | ||||
-rw-r--r-- | test/error_test.c | 7 | ||||
-rw-r--r-- | test/flush2.c | 35 | ||||
-rw-r--r-- | test/h5test.c | 6 | ||||
-rw-r--r-- | test/testerror.sh.in | 2 | ||||
-rw-r--r-- | test/testfiles/err_compat_1 | 14 | ||||
-rw-r--r-- | test/testframe.c | 6 | ||||
-rw-r--r-- | test/ttsafe_error.c | 20 |
10 files changed, 49 insertions, 240 deletions
diff --git a/test/dtransform.c b/test/dtransform.c index 15c5934..5d5cefe 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -641,7 +641,7 @@ static int test_set(void) { hid_t dxpl_id = -1; - H5E_auto_t func; + H5E_auto2_t func; const char *str = "(9/5.0)*x + 32"; char *ptrgetTest = NULL; @@ -654,15 +654,9 @@ test_set(void) TEST_ERROR /* Test get before set */ -#ifdef H5_USE_16_API_DEFAULT - H5Eget_auto(&func, NULL); + H5Eget_auto2(H5E_DEFAULT, &func, NULL); - H5Eset_auto(NULL, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eget_auto(H5E_DEFAULT, &func, NULL); - - H5Eset_auto(H5E_DEFAULT, NULL, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); if(H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0) PASSED() @@ -699,11 +693,7 @@ test_set(void) TESTING("H5Pset_data_transform (set with invalid transform 8)") INVALID_SET_TEST("(9/5)*x + x^2"); -#ifdef H5_USE_16_API_DEFAULT - H5Eset_auto(func, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eset_auto(H5E_DEFAULT, func, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eset_auto2(H5E_DEFAULT, func, NULL); if(H5Pclose(dxpl_id) < 0) TEST_ERROR diff --git a/test/enum.c b/test/enum.c index 0033c44..c627af1 100644 --- a/test/enum.c +++ b/test/enum.c @@ -383,11 +383,7 @@ test_value_dsnt_exist(void) TESTING("for non-existing name and value"); /* Turn off error reporting since we expect failure in this test */ -#ifdef H5_USE_16_API_DEFAULT - if (H5Eset_auto(NULL, NULL) < 0) goto error; -#else /* H5_USE_16_API_DEFAULT */ - if (H5Eset_auto(H5E_DEFAULT, NULL, NULL) < 0) goto error; -#endif /* H5_USE_16_API_DEFAULT */ + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) goto error; if ((datatype_id = H5Tenum_create(H5T_NATIVE_INT))< 0) goto error; diff --git a/test/err_compat.c b/test/err_compat.c index 4c0df06..be86a2d 100644 --- a/test/err_compat.c +++ b/test/err_compat.c @@ -44,144 +44,9 @@ int ipoints2[DIM0][DIM1], icheck2[DIM0][DIM1]; herr_t custom_print_cb(int n, H5E_error1_t *err_desc, void* client_data); -#ifdef H5_USE_16_API_DEFAULT /*------------------------------------------------------------------------- - * Function: test_error1 - * - * Purpose: Test the backward compatibility of H5Eset/get_auto. - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * 17 September 2010 - * - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -test_error1(void) -{ - hid_t dataset, space; - hsize_t dims[2]; - H5E_auto1_t old_func1; - H5E_auto2_t old_func2; - void *old_data; - herr_t ret; - - TESTING("error API H5Eset/get_auto"); - fprintf(stderr, "\n"); - - /* Create the data space */ - dims[0] = DIM0; - dims[1] = DIM1; - if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; - - /* Test whether the printing function is mismatched. The library should indicate - * H5Eprint1 as the default. */ - if (H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data)<0) - TEST_ERROR; - if (old_data != NULL) - TEST_ERROR; - if (!old_func2) - TEST_ERROR; - - /* This function changes the default printing function to be H5Eprint2. */ - if(H5Eset_auto2(H5E_DEFAULT, old_func2, old_data)<0) - TEST_ERROR; - - /* Dataset creation should fail because the file doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - if(dataset >= 0) - TEST_ERROR; - - /* This call should fail because the test mixes H5Eget_auto1 with H5Eset_auto2. - * Once the H5Eset_auto2 is called, a call to H5Eget_auto1 will fail. */ - if((ret = H5Eget_auto1(&old_func1, &old_data)) >= 0) - TEST_ERROR; - - return 0; - - error: - return -1; -} - -#else /*H5_USE_16_API_DEFAULT*/ - -/*------------------------------------------------------------------------- - * Function: test_error2 - * - * Purpose: Test the backward compatibility of H5Eset/get_auto. - * - * Return: Success: 0 - * - * Failure: -1 - * - * Programmer: Raymond Lu - * 17 September 2010 - * - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static herr_t -test_error2(void) -{ - hid_t dataset, space; - hsize_t dims[2]; - H5E_auto1_t old_func1; - H5E_auto2_t old_func2; - void *old_data; - herr_t ret; - - TESTING("error API H5Eset/get_auto"); - fprintf(stderr, "\n"); - - /* Create the data space */ - dims[0] = DIM0; - dims[1] = DIM1; - if ((space = H5Screate_simple(2, dims, NULL))<0) TEST_ERROR; - - /* Test whether the printing function is mismatched. The library should indicate - * H5Eprint2 as the default. */ - if (H5Eget_auto1(&old_func1, &old_data)<0) - TEST_ERROR; - if (old_data != NULL) - TEST_ERROR; - if (!old_func1) - TEST_ERROR; - - /* This function changes the default printing function to be H5Eprint1. */ - if(H5Eset_auto1(old_func1, old_data)<0) - TEST_ERROR; - - /* Dataset creation should fail because the file doesn't exist. */ - dataset = H5Dcreate2(FAKE_ID, DSET_NAME, H5T_STD_I32BE, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - if(dataset >= 0) - TEST_ERROR; - - /* This call should fail because it mixed H5Eget_auto2 with H5Eset_auto1. - * Once the H5Eset_auto1 is called, a call to H5Eget_auto2 will fail. */ - if((ret = H5Eget_auto2(H5E_DEFAULT, &old_func2, &old_data)) >= 0) - TEST_ERROR; - - return 0; - - error: - return -1; -} -#endif /*H5_USE_16_API_DEFAULT*/ - - -/*------------------------------------------------------------------------- - * Function: test_error3 + * Function: test_error * * Purpose: Test error API functions * @@ -198,7 +63,7 @@ test_error2(void) *------------------------------------------------------------------------- */ static herr_t -test_error3(hid_t file) +test_error(hid_t file) { hid_t dataset, space; hsize_t dims[2]; @@ -227,21 +92,35 @@ test_error3(hid_t file) goto error; } - /* Disable the library's default printing function */ -#ifdef H5_USE_16_API_DEFAULT - if(H5Eset_auto(NULL, NULL)<0) -#else - if(H5Eset_auto(H5E_DEFAULT, NULL, NULL)<0) -#endif + /* Test enabling and disabling default printing */ + if (H5Eget_auto1(&old_func, &old_data)<0) + TEST_ERROR; + if (old_data != NULL) + TEST_ERROR; + if (!old_func) + TEST_ERROR; +#ifdef H5_USE_16_API + if (old_func != (H5E_auto1_t)H5Eprint1) + TEST_ERROR; +#else /* H5_USE_16_API */ + if (old_func != (H5E_auto1_t)H5Eprint2) + TEST_ERROR; +#endif /* H5_USE_16_API */ + + if(H5Eset_auto1(NULL, NULL)<0) TEST_ERROR; - /* Make H5Dwrite fail, verify default printing is disabled */ + /* Make H5Dwrite fail, verify default print is disabled */ if (H5Dwrite(FAKE_ID, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2)<0) { H5Epush1(__FILE__, FUNC_test_error, __LINE__, H5E_ERROR, H5E_WRITEERROR, "H5Dwrite shouldn't succeed"); goto error; } + if(H5Eset_auto1(old_func, old_data)<0) + TEST_ERROR; + + /* In case program comes to this point, close dataset */ if(H5Dclose(dataset)<0) TEST_ERROR; TEST_ERROR; @@ -379,13 +258,7 @@ main(void) H5Eclear1(); /* Test error API */ -#ifdef H5_USE_16_API_DEFAULT - if(test_error1() < 0) TEST_ERROR ; -#else /*H5_USE_16_API_DEFAULT*/ - if(test_error2() < 0) TEST_ERROR ; -#endif /*H5_USE_16_API_DEFAULT*/ - - if(test_error3(file) < 0) { + if(test_error(file) < 0) { H5Epush1(__FILE__, FUNC_main, __LINE__, H5E_ERROR, H5E_BADMESG, "Error test failed"); H5Eprint1(stderr); diff --git a/test/error_test.c b/test/error_test.c index 6a37b80..52dcc0c 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -21,7 +21,7 @@ */ #include "h5test.h" -#ifdef H5_USE_16_API_DEFAULT +#ifdef H5_USE_16_API int main(void) { printf("Test skipped because backward compatbility with v1.6 is configured in\n"); @@ -127,8 +127,13 @@ test_error(hid_t file) TEST_ERROR; if(old_data != NULL) TEST_ERROR; +#ifdef H5_USE_16_API + if (old_func != (H5E_auto_t)H5Eprint) + TEST_ERROR; +#else /* H5_USE_16_API */ if (old_func != (H5E_auto2_t)H5Eprint2) TEST_ERROR; +#endif /* H5_USE_16_API */ if(H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) TEST_ERROR; diff --git a/test/flush2.c b/test/flush2.c index c674426..5675856 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -158,7 +158,7 @@ int main(void) { hid_t fapl; - H5E_auto_t func; + H5E_auto2_t func; char name[1024]; h5_reset(); @@ -178,14 +178,8 @@ main(void) /* Check the case where the file was not flushed. This should give an error * so we turn off the error stack temporarily */ TESTING("H5Fflush (part2 without flush)"); - -#ifdef H5_USE_16_API_DEFAULT - H5Eget_auto(&func,NULL); - H5Eset_auto(NULL, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eget_auto(H5E_DEFAULT,&func,NULL); - H5Eset_auto(H5E_DEFAULT, NULL, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eget_auto2(H5E_DEFAULT,&func,NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); h5_fixname(FILENAME[1], fapl, name, sizeof name); if(check_file(name, fapl, FALSE)) @@ -202,23 +196,13 @@ main(void) goto error; #endif } -#ifdef H5_USE_16_API_DEFAULT - H5Eset_auto(func, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eset_auto(H5E_DEFAULT, func, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eset_auto2(H5E_DEFAULT, func, NULL); /* Check the case where the file was flushed, but more data was added afterward. This should give an error * so we turn off the error stack temporarily */ TESTING("H5Fflush (part2 with flush and later addition)"); - -#ifdef H5_USE_16_API_DEFAULT - H5Eget_auto(&func,NULL); - H5Eset_auto(NULL, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eget_auto(H5E_DEFAULT,&func,NULL); - H5Eset_auto(H5E_DEFAULT, NULL, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eget_auto2(H5E_DEFAULT,&func,NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); h5_fixname(FILENAME[2], fapl, name, sizeof name); if(check_file(name, fapl, TRUE)) @@ -236,12 +220,7 @@ main(void) #endif } -#ifdef H5_USE_16_API_DEFAULT - H5Eset_auto(func, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eset_auto(H5E_DEFAULT, func, NULL); -#endif /* H5_USE_16_API_DEFAULT */ - + H5Eset_auto2(H5E_DEFAULT, func, NULL); h5_cleanup(FILENAME, fapl); diff --git a/test/h5test.c b/test/h5test.c index d02fea9..229efec 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -212,11 +212,7 @@ h5_reset(void) HDfflush(stdout); HDfflush(stderr); H5close(); -#ifdef H5_USE_16_API_DEFAULT - H5Eset_auto(h5_errors, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eset_auto(H5E_DEFAULT, h5_errors, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eset_auto2(H5E_DEFAULT, h5_errors, NULL); /* * I commented this chunk of code out because it's not clear what diagnostics diff --git a/test/testerror.sh.in b/test/testerror.sh.in index 440be4f..7f9657a 100644 --- a/test/testerror.sh.in +++ b/test/testerror.sh.in @@ -71,8 +71,6 @@ TEST() { -e 's/line [0-9]*/line (number)/' \ -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ - -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ - -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ $actual_err > $actual_ext cat $actual_ext >> $actual diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index f3d11a3..032e7bc 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -1,7 +1,7 @@ ############################# Expected output for err_compat ############################# -Testing error API H5Eset/get_auto Testing error API based on data I/O All error API tests passed. +Testing error API based on data I/O All error API tests passed. This program tests the Error API compatible with HDF5 version (number). There're supposed to be some error messages ********* Print error stack in HDF5 default way ********* HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): @@ -15,18 +15,6 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dcreate2(): not a location ID - major: Invalid arguments to routine - minor: Inappropriate type - #001: (file name) line (number) in H5G_loc(): invalid object ID - major: Invalid arguments to routine - minor: Bad value -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Eget_auto(1 or 2)(): wrong API function, H5Eset_auto(1 or 2) has been called - major: Error API - minor: Can't get value - -HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in main(): Error test failed major: Error API minor: Unrecognized message diff --git a/test/testframe.c b/test/testframe.c index f933d8b..082a27f 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -135,11 +135,7 @@ void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_p * 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. */ -#ifdef H5_USE_16_API_DEFAULT - H5Eset_auto(NULL, NULL); -#else /* H5_USE_16_API_DEFAULT */ - H5Eset_auto(H5E_DEFAULT, NULL, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* * Record the program name and private routines if provided. diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index edc5c07..f55afdc 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -158,24 +158,16 @@ void *tts_error_thread(void UNUSED *arg) { hid_t dataspace, datatype, dataset; hsize_t dimsf[1]; /* dataset dimensions */ - H5E_auto_t old_error_cb; + H5E_auto2_t old_error_cb; void *old_error_client_data; int value; int ret; -#ifdef H5_USE_16_API_DEFAULT /* preserve previous error stack handler */ - H5Eget_auto(&old_error_cb, &old_error_client_data); + H5Eget_auto2(H5E_DEFAULT, &old_error_cb, &old_error_client_data); /* set each thread's error stack handler */ - H5Eset_auto(error_callback, NULL); -#else /* H5_USE_16_API_DEFAULT */ - /* preserve previous error stack handler */ - H5Eget_auto(H5E_DEFAULT, &old_error_cb, &old_error_client_data); - - /* set each thread's error stack handler */ - H5Eset_auto(H5E_DEFAULT, error_callback, NULL); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eset_auto2(H5E_DEFAULT, error_callback, NULL); /* define dataspace for dataset */ dimsf[0] = 1; @@ -201,11 +193,7 @@ void *tts_error_thread(void UNUSED *arg) assert(ret >= 0); /* turn our error stack handler off */ -#ifdef H5_USE_16_API_DEFAULT - H5Eset_auto(old_error_cb, old_error_client_data); -#else /* H5_USE_16_API_DEFAULT */ - H5Eset_auto(H5E_DEFAULT, old_error_cb, old_error_client_data); -#endif /* H5_USE_16_API_DEFAULT */ + H5Eset_auto2(H5E_DEFAULT, old_error_cb, old_error_client_data); return NULL; } |