summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/vfd_swmr.c120
-rw-r--r--test/vfd_swmr_bigset_writer.c6
-rw-r--r--test/vfd_swmr_common.c12
-rw-r--r--test/vfd_swmr_gfail_writer.c2
-rw-r--r--test/vfd_swmr_gperf_writer.c2
5 files changed, 102 insertions, 40 deletions
diff --git a/test/vfd_swmr.c b/test/vfd_swmr.c
index e3149f2..a5b3e25 100644
--- a/test/vfd_swmr.c
+++ b/test/vfd_swmr.c
@@ -95,6 +95,17 @@ static const char *namebases[] = {FILENAME, FILENAME2, FILENAME3, FNAME, NULL};
/* Size of "flags" field in the updater file header */
#define UD_SIZE_2 2
+#define Swap2Bytes(val) ((((val) >> 8) & 0x00FF) | (((val) << 8) & 0xFF00))
+
+#define Swap8Bytes(val) \
+ ((((val) >> 56) & 0x00000000000000FF) | (((val) >> 40) & 0x000000000000FF00) | \
+ (((val) >> 24) & 0x0000000000FF0000) | (((val) >> 8) & 0x00000000FF000000) | \
+ (((val) << 8) & 0x000000FF00000000) | (((val) << 24) & 0x0000FF0000000000) | \
+ (((val) << 40) & 0x00FF000000000000) | (((val) << 56) & 0xFF00000000000000))
+#define Swap4Bytes(val) \
+ ((((val) >> 24) & 0x000000FF) | (((val) >> 8) & 0x0000FF00) | (((val) << 8) & 0x00FF0000) | \
+ (((val) << 24) & 0xFF000000))
+
/* test routines for VFD SWMR */
static unsigned test_fapl(hid_t orig_fapl);
static unsigned test_file_fapl(hid_t orig_fapl);
@@ -131,10 +142,36 @@ static void clean_chk_ud_files(char *md_file_path, char *updater_file_path);
static herr_t verify_ud_chk(char *md_file_path, char *ud_file_path);
static herr_t md_ck_cb(char *md_file_path, uint64_t tick_num);
+void check_endian(hbool_t *little_endian);
+static int vfd_swmr_fapl_augment(hid_t fapl, bool use_latest_format, bool only_meta_pages,
+ size_t page_buf_size, H5F_vfd_swmr_config_t *config);
+
+/*-------------------------------------------------------------------------
+ *
+ * Function check_endian()
+ * Helper routine to check the endianness of a machine
+ *
+ * -------------------------------------------------------------------------
+ */
+void
+check_endian(hbool_t *little_endian)
+{
+ short int word = 0x0001;
+ char * byte = (char *)&word;
+
+ if (byte[0] == 1)
+ /* little endian */
+ *little_endian = TRUE;
+ else
+ /* big endian */
+ *little_endian = FALSE;
+
+} /* check_endian() */
+
/*-------------------------------------------------------------------------
*
* Function vfd_swmr_fapl_augment()
- * A Helper routine to set up fapl for VFD SWMR
+ * Helper routine to set up fapl for VFD SWMR
*
*-------------------------------------------------------------------------
*/
@@ -985,7 +1022,7 @@ test_writer_create_open_flush(hid_t orig_fapl)
/* config, tick_len, max_lag, presume_posix_semantics, writer,
* maintain_metadata_file, generate_updater_files, flush_raw_data, md_pages_reserved,
* md_file_path, md_file_name, updater_file_path */
- init_vfd_swmr_config(my_config, 1, 3, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, MD_FILENAME, NULL);
+ init_vfd_swmr_config(my_config, 5, 10, FALSE, TRUE, TRUE, FALSE, TRUE, 2, NULL, MD_FILENAME, NULL);
if ((fapl = H5Pcopy(orig_fapl)) < 0)
FAIL_STACK_ERROR;
@@ -4199,8 +4236,12 @@ error:
static herr_t
verify_updater_flags(char *ud_name, uint16_t expected_flags)
{
- FILE * ud_fp = NULL; /* Updater file pointer */
- uint16_t flags = 0; /* The "flags" field in the updater file */
+ FILE * ud_fp = NULL; /* Updater file pointer */
+ uint16_t flags = 0; /* The "flags" field in the updater file */
+ uint16_t swapped_flags = 0; /* The "flags" field in the updater file */
+ hbool_t little_endian = FALSE; /* Endianness of a machine */
+
+ check_endian(&little_endian);
/* Open the updater file */
if ((ud_fp = HDfopen(ud_name, "r")) == NULL)
@@ -4214,7 +4255,9 @@ verify_updater_flags(char *ud_name, uint16_t expected_flags)
if (HDfread(&flags, UD_SIZE_2, 1, ud_fp) != (size_t)1)
FAIL_STACK_ERROR;
- if (flags != expected_flags)
+ swapped_flags = little_endian ? flags : Swap2Bytes(flags);
+
+ if (swapped_flags != expected_flags)
TEST_ERROR;
if (HDfclose(ud_fp) < 0)
@@ -4310,7 +4353,7 @@ test_updater_flags(hid_t orig_fapl)
TEST_ERROR;
/* Verify the first updater file: "flags" field and file size */
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num);
/* Verify "flags" of the first updater file */
if (verify_updater_flags(namebuf, CREATE_METADATA_FILE_ONLY_FLAG) < 0)
@@ -4326,11 +4369,11 @@ test_updater_flags(hid_t orig_fapl)
/* Look for the last updater file */
for (seq_num = 0;; seq_num++) {
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num);
if (HDaccess(namebuf, F_OK) != 0)
break;
}
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num - 1);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num - 1);
/* Verify "flags" of the last updater file */
if (verify_updater_flags(namebuf, FINAL_UPDATE_FLAG) < 0)
@@ -4345,7 +4388,7 @@ test_updater_flags(hid_t orig_fapl)
/* Remove updater files */
for (i = 0; i < seq_num; i++) {
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, i);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, i);
HDremove(namebuf);
}
@@ -4466,11 +4509,11 @@ test_updater_flags_same_file_opens(hid_t orig_fapl)
/* Look for the last updater file */
for (seq_num = 0;; seq_num++) {
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num);
if (HDaccess(namebuf, F_OK) != 0)
break;
}
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num - 1);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num - 1);
/* Verify "flags" of the last updater file is 0 */
if (verify_updater_flags(namebuf, 0) < 0)
@@ -4482,11 +4525,11 @@ test_updater_flags_same_file_opens(hid_t orig_fapl)
/* Look for the last updater file */
for (seq_num = 0;; seq_num++) {
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num);
if (HDaccess(namebuf, F_OK) != 0)
break;
}
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, seq_num - 1);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, seq_num - 1);
/* Verify "flags" of the last updater file after closing file */
if (verify_updater_flags(namebuf, FINAL_UPDATE_FLAG) < 0)
@@ -4494,7 +4537,7 @@ test_updater_flags_same_file_opens(hid_t orig_fapl)
/* Clean up updater files */
for (i = 0; i < seq_num; i++) {
- HDsprintf(namebuf, "%s.%lu", UD_FILENAME, i);
+ HDsprintf(namebuf, "%s.%" PRIu64 "", UD_FILENAME, i);
HDremove(namebuf);
}
@@ -4553,7 +4596,7 @@ clean_chk_ud_files(char *md_file_path, char *updater_file_path)
/* Remove all the updater files if exist: <updater_file_path>.<i> */
for (i = 0;; i++) {
- HDsprintf(ud_name, "%s.%lu", updater_file_path, i);
+ HDsprintf(ud_name, "%s.%" PRIu64 "", updater_file_path, i);
if (HDaccess(ud_name, F_OK) != 0)
break;
HDremove(ud_name);
@@ -4586,17 +4629,27 @@ clean_chk_ud_files(char *md_file_path, char *updater_file_path)
static herr_t
verify_ud_chk(char *md_file_path, char *ud_file_path)
{
- char chk_name[FILE_NAME_LEN]; /* Checksum file name */
- char ud_name[FILE_NAME_LEN]; /* Updater file name */
- FILE * chk_fp = NULL; /* Checksum file pointer */
- FILE * ud_fp = NULL; /* Updater file pointer */
- uint64_t ud_seq_num = 0; /* Sequence number in the updater file */
- uint64_t chk_ud_seq_num = 0; /* Updater sequence number in the checksum file */
- uint64_t i; /* Local index variable */
- long size = 0; /* Size of the file */
- size_t change_list_len = 0; /* change_list_len in the updater file header */
+ char chk_name[FILE_NAME_LEN]; /* Checksum file name */
+ char ud_name[FILE_NAME_LEN]; /* Updater file name */
+ FILE * chk_fp = NULL; /* Checksum file pointer */
+ FILE * ud_fp = NULL; /* Updater file pointer */
+ uint64_t i; /* Local index variable */
+ long size = 0; /* Size of the file */
+
+ uint64_t chk_ud_seq_num = 0; /* Updater sequence number in the checksum file */
+
+ uint64_t ud_seq_num = 0; /* Sequence number in the updater file */
+ uint64_t change_list_len = 0; /* change_list_len in the updater file header */
uint32_t num_change_list_entries = 0; /* num_change_list_entries in the updater change list header */
+ uint64_t swapped_ud_seq_num = 0;
+ uint64_t swapped_change_list_len = 0;
+ uint32_t swapped_num_change_list_entries = 0;
+
+ hbool_t little_endian = FALSE;
+
+ check_endian(&little_endian);
+
/* Open the checksum file */
HDsprintf(chk_name, "%s.chk", md_file_path);
if ((chk_fp = HDfopen(chk_name, "r")) == NULL)
@@ -4604,7 +4657,7 @@ verify_ud_chk(char *md_file_path, char *ud_file_path)
for (i = 0;; i++) {
/* Generate updater file name: <ud_file_path>.<i> */
- HDsprintf(ud_name, "%s.%lu", ud_file_path, i);
+ HDsprintf(ud_name, "%s.%" PRIu64 "", ud_file_path, i);
/* Open the updater file */
if ((ud_fp = HDfopen(ud_name, "r")) == NULL)
@@ -4618,8 +4671,10 @@ verify_ud_chk(char *md_file_path, char *ud_file_path)
if (HDfread(&ud_seq_num, UD_SIZE_8, 1, ud_fp) != 1)
FAIL_STACK_ERROR;
+ swapped_ud_seq_num = little_endian ? ud_seq_num : Swap8Bytes(ud_seq_num);
+
/* Compare the sequence number with i */
- if (ud_seq_num != i)
+ if (swapped_ud_seq_num != i)
TEST_ERROR;
/* Read change_list_len from updater file's header */
@@ -4629,6 +4684,8 @@ verify_ud_chk(char *md_file_path, char *ud_file_path)
if (HDfread(&change_list_len, UD_SIZE_8, 1, ud_fp) != 1)
FAIL_STACK_ERROR;
+ swapped_change_list_len = little_endian ? change_list_len : Swap8Bytes(change_list_len);
+
if (i != 0) {
/* Read num_change_list_entries from updater file's change list */
@@ -4638,12 +4695,15 @@ verify_ud_chk(char *md_file_path, char *ud_file_path)
if (HDfread(&num_change_list_entries, UD_SIZE_4, 1, ud_fp) != 1)
FAIL_STACK_ERROR;
- if (num_change_list_entries == 0) {
- if (change_list_len != H5F_UD_CL_SIZE(0))
+ swapped_num_change_list_entries =
+ little_endian ? num_change_list_entries : Swap4Bytes(num_change_list_entries);
+
+ if (swapped_num_change_list_entries == 0) {
+ if (swapped_change_list_len != H5F_UD_CL_SIZE(0))
TEST_ERROR;
}
else {
- if (change_list_len != H5F_UD_CL_SIZE(num_change_list_entries))
+ if (swapped_change_list_len != H5F_UD_CL_SIZE(swapped_num_change_list_entries))
TEST_ERROR;
}
}
@@ -4657,7 +4717,7 @@ verify_ud_chk(char *md_file_path, char *ud_file_path)
FAIL_STACK_ERROR;
/* Compare sequence number in updater file with sequence number in checksum file */
- if (ud_seq_num != chk_ud_seq_num)
+ if (swapped_ud_seq_num != chk_ud_seq_num)
TEST_ERROR;
/* Advance checksum file to the next sequence number */
diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c
index 6ff5d03..4de9b70 100644
--- a/test/vfd_swmr_bigset_writer.c
+++ b/test/vfd_swmr_bigset_writer.c
@@ -95,7 +95,7 @@
#define DEPTH 1
#define RANK2 2
#define RANK3 3
-#define NUM_ATTEMPTS 100
+#define NUM_ATTEMPTS 500
#define SKIP_CHUNK 0
/* Calculate the time passed in seconds.
@@ -103,7 +103,9 @@
* Expects X, Y to be struct timespec from the function call HDclock_gettime.
*/
#define TIME_PASSED(X, Y) \
- ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0
+ ((double)(((uint64_t)Y.tv_sec - (uint64_t)X.tv_sec) * 1000000000LL + \
+ ((uint64_t)Y.tv_nsec - (uint64_t)X.tv_nsec))) / \
+ 1000000000.0
typedef struct _base {
hsize_t depth, row, col;
diff --git a/test/vfd_swmr_common.c b/test/vfd_swmr_common.c
index 1652ee5..0d4ae0c 100644
--- a/test/vfd_swmr_common.c
+++ b/test/vfd_swmr_common.c
@@ -46,8 +46,8 @@ below_speed_limit(struct timespec *last, const struct timespec *ival)
struct timespec now;
hbool_t result;
- HDassert(0 <= last->tv_nsec && last->tv_nsec < 1000000000L);
- HDassert(0 <= ival->tv_nsec && ival->tv_nsec < 1000000000L);
+ HDassert(0 <= last->tv_nsec && last->tv_nsec < 1000000000LL);
+ HDassert(0 <= ival->tv_nsec && ival->tv_nsec < 1000000000LL);
/* NOTE: timespec_get() is C11. This may need further tweaks. */
#ifdef H5_HAVE_WIN32_API
@@ -59,12 +59,12 @@ below_speed_limit(struct timespec *last, const struct timespec *ival)
HDexit(EXIT_FAILURE);
}
- if (now.tv_sec - last->tv_sec > ival->tv_sec)
+ if ((uint64_t)now.tv_sec - (uint64_t)last->tv_sec > (uint64_t)ival->tv_sec)
result = true;
- else if (now.tv_sec - last->tv_sec < ival->tv_sec)
+ else if ((uint64_t)now.tv_sec - (uint64_t)last->tv_sec < (uint64_t)ival->tv_sec)
result = false;
else
- result = (now.tv_nsec - last->tv_nsec >= ival->tv_nsec);
+ result = ((uint64_t)now.tv_nsec - (uint64_t)last->tv_nsec >= (uint64_t)ival->tv_nsec);
if (result)
*last = now;
@@ -245,7 +245,7 @@ timer_function(void *arg)
void
await_signal(hid_t fid)
{
- struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000 / 100};
+ struct timespec tick = {.tv_sec = 0, .tv_nsec = 1000000000LL / 100};
sigset_t sleepset;
if (HDsigfillset(&sleepset) == -1) {
diff --git a/test/vfd_swmr_gfail_writer.c b/test/vfd_swmr_gfail_writer.c
index 10370cc..8b8f00e 100644
--- a/test/vfd_swmr_gfail_writer.c
+++ b/test/vfd_swmr_gfail_writer.c
@@ -116,7 +116,7 @@
#ifndef H5_HAVE_WIN32_API
#define TIME_PASSED(X, Y) \
- ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0
+ ((double)((Y.tv_sec - X.tv_sec) * 1000000000LL + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0
typedef struct {
hid_t file, filetype, one_by_one_sid;
diff --git a/test/vfd_swmr_gperf_writer.c b/test/vfd_swmr_gperf_writer.c
index c376b51..88e8b6f 100644
--- a/test/vfd_swmr_gperf_writer.c
+++ b/test/vfd_swmr_gperf_writer.c
@@ -64,7 +64,7 @@
#define VS_ATTR_NAME_LEN 21
#define TIME_PASSED(X, Y) \
- ((double)((Y.tv_sec - X.tv_sec) * 1000000000 + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0
+ ((double)((Y.tv_sec - X.tv_sec) * 1000000000LL + (Y.tv_nsec - X.tv_nsec))) / 1000000000.0
typedef struct {
hid_t file, filetype, one_by_one_sid;