diff options
author | Jacob Smith <jake.smith@hdfgroup.org> | 2020-03-13 22:13:17 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-05-20 14:34:20 (GMT) |
commit | b11015c4ccec9384e516ca13a0a56b209b71a578 (patch) | |
tree | d140c28354788589a09ae8d6cdec116bdc5b9646 /test/h5test.c | |
parent | 333388c744626b23791298be9f9165fa5bc9d037 (diff) | |
download | hdf5-b11015c4ccec9384e516ca13a0a56b209b71a578.zip hdf5-b11015c4ccec9384e516ca13a0a56b209b71a578.tar.gz hdf5-b11015c4ccec9384e516ca13a0a56b209b71a578.tar.bz2 |
Add Splitter VFD to library.
* "Simultaneous and equivalent" Read-Write and Write-Only channels for
file I/O.
* Only supports drivers with the H5FD_FEAT_DEFAULT_VFD_COMPATIBLE flag for
now, preventing issues with multi-file drivers.
Add Mirror VFD to library.
* Write-only operations over a network.
* Uses TCP/IP sockets.
* Server and auxiliary server-shutdown programs provided in a new directory,
`utils/mirror_vfd`.
* Automated testing via loopback ("remote" of localhost).
Diffstat (limited to 'test/h5test.c')
-rw-r--r-- | test/h5test.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/test/h5test.c b/test/h5test.c index ab57370..2b00ee8 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -2054,6 +2054,80 @@ h5_get_version_string(H5F_libver_t libver) } /* end of h5_get_version_string */ /*------------------------------------------------------------------------- + * Function: h5_compare_file_bytes() + * + * Purpose: Helper function to compare two files byte-for-byte. + * + * Return: Success: 0, if files are identical + * Failure: -1, if files differ + * + * Programmer: Binh-Minh Ribler + * October, 2018 + *------------------------------------------------------------------------- + */ +int +h5_compare_file_bytes(char *f1name, char *f2name) +{ + FILE *f1ptr = NULL; /* two file pointers */ + FILE *f2ptr = NULL; + hsize_t f1size = 0; /* size of the files */ + hsize_t f2size = 0; + char f1char = 0; /* one char from each file */ + char f2char = 0; + hsize_t ii = 0; + int ret_value = 0; /* for error handling */ + + /* Open files for reading */ + f1ptr = fopen(f1name, "r"); + if (f1ptr == NULL) { + HDfprintf(stderr, "Unable to fopen() %s\n", f1name); + ret_value = -1; + goto done; + } + f2ptr = fopen(f2name, "r"); + if (f2ptr == NULL) { + HDfprintf(stderr, "Unable to fopen() %s\n", f2name); + ret_value = -1; + goto done; + } + + /* Get the file sizes and verify that they equal */ + fseek(f1ptr , 0 , SEEK_END); + f1size = ftell(f1ptr); + + fseek(f2ptr , 0 , SEEK_END); + f2size = ftell(f2ptr); + + if (f1size != f2size) { + HDfprintf(stderr, "Files differ in size, %llu vs. %llu\n", f1size, f2size); + ret_value = -1; + goto done; + } + + /* Compare each byte and fail if a difference is found */ + rewind(f1ptr); + rewind(f2ptr); + for (ii = 0; ii < f1size; ii++) { + fread(&f1char, 1, 1, f1ptr); + fread(&f2char, 1, 1, f2ptr); + if (f1char != f2char) { + HDfprintf(stderr, "Mismatch @ 0x%llX: 0x%X != 0x%X\n", ii, f1char, f2char); + ret_value = -1; + goto done; + } + } + +done: + if (f1ptr) { + fclose(f1ptr); + } + if (f2ptr) { + fclose(f2ptr); + } + return(ret_value); +} /* end h5_compare_file_bytes() */ + +/*------------------------------------------------------------------------- * Function: H5_get_srcdir_filename * * Purpose: Append the test file name to the srcdir path and return the whole string @@ -2105,3 +2179,4 @@ const char *H5_get_srcdir(void) else return(NULL); } /* end H5_get_srcdir() */ + |