summaryrefslogtreecommitdiffstats
path: root/test/enc_dec_plist_cross_platform.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-05-28 14:10:51 (GMT)
committerGitHub <noreply@github.com>2021-05-28 14:10:51 (GMT)
commit2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8 (patch)
tree40975e0846d101360a838d42e16f4687fed77f4a /test/enc_dec_plist_cross_platform.c
parente22687912dbc6fcf4fff57e86e2cd5d75c81f81e (diff)
downloadhdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.zip
hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.gz
hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.bz2
Much normalization with develop (#701)
* Brings CMake updates from develop * Brings reduction in pedantic casts from develop * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Formatted source * Bring over some VOL registration changes * VOL cleanup * H5VL_request_status_t substitutions * H5F.c cleanup * Minor API tweaks from develop * Moves H5G package init/teardown to H5Gint.c * H5G cleanup * H5M cleanup * H5SM cleanup * H5T cleanup * H5R cleanup * H5Lpublic.h cleanup * H5L cleanup * H5O cleanup * H5A, H5CS, and H5AC cleanup * Moved H5A init/teardown code to H5Aint.c * Moves H5D I/O functions to H5D.c * H5D cleanup * Misc minor cleanup * H5P close cleanup * H5Tpublic.h cleanup * Fixes err_compat test * H5PLpublic.h cleanup * Updates H5Ppublic.h * H5Fpublic.h updates * H5A.c cleanup * Brings over H5Aexists and related changes * Brings CMake shell testing changes from develop * Close callback changes * H5R and H5Tcommit normalization * err_compat test works now * H5O tweaks * Updates VOL registration code * Brings over H5VL_create_object * H5Tconv.c reformatting * H5T.c tweaks * Brings datatype and reference updates from develop * Brings VOL plugin loading changes from develop * Brings event sets from develop * Brings async functions over * Tools changes * Brings over many tools changes from develop * Brings VOL flags from develop * Fixes h5dump double/float tests * Updates h5repack tests * Brings h5diff test changes from develop * Last h5dump changes * Brings test changes from develop * Committing clang-format changes * Tidied h5_testing() * Brings chunk iteration code + misc from develop * Updates vds test * Enables external link parallel test * Brings updated property lists from develop * H5G changes from develop * H5MF cleanup * Brings vfd_swmr test back into CMake * Updates threadsafe test * Updates plist test * Brings recent changes from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/enc_dec_plist_cross_platform.c')
-rw-r--r--test/enc_dec_plist_cross_platform.c115
1 files changed, 58 insertions, 57 deletions
diff --git a/test/enc_dec_plist_cross_platform.c b/test/enc_dec_plist_cross_platform.c
index c3f1fc5..9ea5cf9 100644
--- a/test/enc_dec_plist_cross_platform.c
+++ b/test/enc_dec_plist_cross_platform.c
@@ -156,70 +156,71 @@ error:
return 1;
}
-static hid_t
-read_and_decode_plist_file(const char *filename_prefix, unsigned config, char *filename, size_t filename_len)
-{
- int fd;
- size_t size;
- const char *testfile;
- void * buf = NULL;
- hid_t plist = H5I_INVALID_HID;
-
- /* Generate filename from prefix and configuration word */
- if (HDsnprintf(filename, filename_len, "%s%s%s", filename_prefix, config & CONFIG_64 ? "64" : "32",
- config & CONFIG_LE ? "le" : "be") < 0)
- TEST_ERROR
-
- /* Read file 1 */
- testfile = H5_get_srcdir_filename(filename);
- if ((fd = HDopen(testfile, O_RDONLY)) < 0)
- TEST_ERROR
- size = (size_t)HDlseek(fd, 0, SEEK_END);
- HDlseek(fd, 0, SEEK_SET);
- buf = HDmalloc(size);
- if (HDread(fd, buf, size) < 0)
- TEST_ERROR
- HDclose(fd);
-
- /* Decode property lists */
- if ((plist = H5Pdecode(buf)) < 0)
- FAIL_STACK_ERROR
-error:
- if (buf != NULL)
- HDfree(buf);
- return plist;
-}
-
static int
test_plists(const char *filename_prefix)
{
- int i;
- unsigned config[2];
- hid_t plist[2];
- char filename[2][1024];
+ unsigned config_1, config_2;
+ int fd_1, fd_2;
+ size_t size_1 = 0, size_2 = 0;
+ void * buf_1 = NULL, *buf_2 = NULL;
+ hid_t plist_1, plist_2;
+ char filename[1024];
+ const char *testfile;
/* Iterate over all combinations of configurations */
- for (config[0] = 0; config[0] < (NCONFIG - 1); config[0]++) {
- for (config[1] = config[0] + 1; config[1] < NCONFIG; config[1]++) {
- for (i = 0; i < 2; i++) {
- plist[i] =
- read_and_decode_plist_file(filename_prefix, config[i], filename[i], sizeof(filename[i]));
- if (plist[i] == H5I_INVALID_HID)
- goto error;
- }
+ for (config_1 = 0; config_1 < (NCONFIG - 1); config_1++)
+ for (config_2 = config_1 + 1; config_2 < NCONFIG; config_2++) {
+ /* Generate filename for file 1 */
+ if (HDsnprintf(filename, sizeof(filename), "%s%s%s", filename_prefix,
+ config_1 & CONFIG_64 ? "64" : "32", config_1 & CONFIG_LE ? "le" : "be") < 0)
+ TEST_ERROR
+
+ /* Read file 1 */
+ testfile = H5_get_srcdir_filename(filename);
+ if ((fd_1 = HDopen(testfile, O_RDONLY)) < 0)
+ TEST_ERROR
+ size_1 = (size_t)HDlseek(fd_1, (HDoff_t)0, SEEK_END);
+ HDlseek(fd_1, (HDoff_t)0, SEEK_SET);
+ buf_1 = (void *)HDmalloc(size_1);
+ if (HDread(fd_1, buf_1, size_1) < 0)
+ TEST_ERROR
+ HDclose(fd_1);
+
+ /* Generate filename for file 2 */
+ if (HDsnprintf(filename, sizeof(filename), "%s%s%s", filename_prefix,
+ config_2 & CONFIG_64 ? "64" : "32", config_2 & CONFIG_LE ? "le" : "be") < 0)
+ TEST_ERROR
+
+ /* Read file 1 */
+ testfile = H5_get_srcdir_filename(filename);
+ if ((fd_2 = HDopen(testfile, O_RDONLY)) < 0)
+ TEST_ERROR
+ size_2 = (size_t)HDlseek(fd_2, (HDoff_t)0, SEEK_END);
+ HDlseek(fd_2, (HDoff_t)0, SEEK_SET);
+ buf_2 = (void *)HDmalloc(size_2);
+ if (HDread(fd_2, buf_2, size_2) < 0)
+ TEST_ERROR
+ HDclose(fd_2);
+
+ /* Decode property lists */
+ if ((plist_1 = H5Pdecode(buf_1)) < 0)
+ FAIL_STACK_ERROR
+ if ((plist_2 = H5Pdecode(buf_2)) < 0)
+ FAIL_STACK_ERROR
/* Compare decoded property lists */
- if (!H5Pequal(plist[0], plist[1]))
- FAIL_PRINTF_ERROR("PLIST encoding/decoding comparison failed, "
- "%s != %s\n",
- filename[0], filename[1])
-
- for (i = 0; i < 2; i++) {
- if ((H5Pclose(plist[i])) < 0)
- FAIL_STACK_ERROR
- }
- }
- }
+ if (!H5Pequal(plist_1, plist_2))
+ FAIL_PUTS_ERROR("PLIST encoding/decoding comparison failed\n")
+
+ /* Close */
+ if ((H5Pclose(plist_1)) < 0)
+ FAIL_STACK_ERROR
+ if ((H5Pclose(plist_2)) < 0)
+ FAIL_STACK_ERROR
+
+ HDfree(buf_1);
+ HDfree(buf_2);
+ } /* end for */
return 1;