1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * All rights reserved. *
4 * *
5 * This file is part of HDF5. The full HDF5 copyright notice, including *
6 * terms governing use, modification, and redistribution, is contained in *
7 * the COPYING file, which can be found at the root of the source code *
8 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
9 * If you do not have access to either file, you may request a copy from *
10 * help@hdfgroup.org. *
11 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13 /* Programmer: Vailin Choi
14 * Feb 20, 2014
15 *
16 * This file contains tests for:
17 * H5Odisable_mdc_flushes()
18 * H5Oenable_mdc_flushes()
19 * H5Oare_mdc_flushes_disabled()
20 */
21 #include "h5test.h"
22
23 /*
24 * This file needs to access private information from the H5C package.
25 * This file also needs to access the metadata cache testing code.
26 */
27 #define H5C_FRIEND /*suppress error about including H5Cpkg */
28 #define H5C_TESTING /*suppress warning about H5C testing funcs*/
29 #include "H5Cpkg.h" /* Cache */
30
31
32 /* ============ */
33 /* Test Defines */
34 /* ============ */
35
36 #define FILENAME "test_cork.h5"
37 #define ATTR "ATTR"
38 #define DSET "DSET"
39 #define DSET_BT1 "DSET_BT1"
40 #define DSET_COMPACT "DSET_COMPACT"
41 #define DSET_CONTIG "DSET_CONTIG"
42 #define DSET_EA "DSET_EA"
43 #define DSET_BT2 "DSET_BT2"
44 #define DSET_FA "DSET_FA"
45 #define DSET_NONE "DSET_NONE"
46 #define GRP "GRP"
47 #define GRP2 "GRP2"
48 #define GRP3 "GRP3"
49 #define DT "DT"
50 #define DT2 "DT2"
51 #define DT3 "DT3"
52 #define GRP_ATTR "GRP_ATTR"
53 #define DSET_ATTR "DSET_ATTR"
54 #define DT_ATTR "DT_ATTR"
55
56 #define RANK 2
57 #define DIM0 5
58 #define DIM1 10
59 #define DIMS0 50
60 #define DIMS1 100
61
62
63 /* ===================== */
64 /* Function Declarations */
65 /* ===================== */
66
67 /* Tests */
68 static unsigned test_objs_cork(hbool_t swmr, hbool_t new_format);
69 static unsigned test_dset_cork(hbool_t swmr, hbool_t new_format);
70 static unsigned verify_old_dset_cork(void);
71 static unsigned verify_obj_dset_cork(hbool_t swmr);
72 static unsigned verify_dset_cork(hbool_t swmr, hbool_t new_format);
73 static unsigned verify_group_cork(hbool_t swmr);
74 static unsigned verify_named_cork(hbool_t swmr);
75 static unsigned verify_multiple_cork(hbool_t swmr);
76
77
78 /*-------------------------------------------------------------------------
79 * Function: verify_old_dset_cork
80 *
81 * Purpose: This function verifies corking operation for datasets
82 * created with old library format. Cache entries associated with the
83 * object tag are checked for the correct cork status.
84 *
85 * Return: 0 on Success, 1 on Failure
86 *
87 * Programmer: Vailin Choi; Feb 2014
88 *
89 *-------------------------------------------------------------------------
90 */
91 static unsigned
verify_old_dset_cork(void)92 verify_old_dset_cork(void)
93 {
94 /* Variable Declarations */
95 hid_t fid = -1; /* File ID */
96 hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */
97 hid_t dcpl = -1, dcpl2 = -1, dcpl3 = -1; /* Dataset creation property lists */
98 hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */
99 hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */
100 hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */
101 hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */
102 int buf[100][20]; /* Data buffer */
103 int i = 0, j = 0; /* Local index variable */
104 H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */
105 hsize_t dims2[2] = {8, 16}; /* Dataset dimension sizes */
106
107 /* Testing Macro */
108 TESTING("cork status for datasets with old format");
109
110 /* Create the file */
111 if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
112 TEST_ERROR
113
114 /* Create dcpl */
115 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
116 FAIL_STACK_ERROR
117
118 /* Set to use chunked dataset */
119 if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
120 FAIL_STACK_ERROR
121
122 /* Create chunked dataset with v1-btree indexing: DSET_BT1 */
123 if((sid = H5Screate_simple(2, dims, max_dims)) < 0)
124 TEST_ERROR
125 if((did = H5Dcreate2(fid, DSET_BT1, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
126 TEST_ERROR
127
128 /* Get dataset object header address: DSET_BT1 */
129 if(H5Oget_info2(did, &oinfo, H5O_INFO_BASIC) < 0)
130 TEST_ERROR
131
132 /* Cork the dataset: DSET_BT1 */
133 if(H5Odisable_mdc_flushes(did) < 0)
134 TEST_ERROR
135
136 /* Verify cork status */
137 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
138 TEST_ERROR
139
140 /* Initialize data buffer */
141 for(i = 0; i < (int)dims[0]; i++)
142 for(j = 0; j < (int)dims[1]; j++)
143 buf[i][j] = (i + 1) * (j + 1);
144
145 /* Write to the dataset: DSET_BT1 */
146 if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
147 TEST_ERROR
148
149 /* Verify the cork status for DSET_BT1 */
150 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
151 TEST_ERROR
152
153 /* Create compact dataset: DSET_COMPACT */
154 if((sid2 = H5Screate_simple(2, dims2, NULL)) < 0)
155 FAIL_STACK_ERROR
156 if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
157 FAIL_STACK_ERROR
158 if(H5Pset_layout(dcpl2, H5D_COMPACT) < 0)
159 FAIL_STACK_ERROR
160 if(H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0)
161 FAIL_STACK_ERROR
162 if((did2 = H5Dcreate2(fid, DSET_COMPACT, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0)
163 FAIL_STACK_ERROR
164
165 /* Get dataset object address */
166 if(H5Oget_info2(did2, &oinfo2, H5O_INFO_BASIC) < 0)
167 TEST_ERROR
168
169 /* Cork the dataset: DSET_COMPACT */
170 if(H5Odisable_mdc_flushes(did2) < 0)
171 TEST_ERROR
172
173 /* Verify cork status */
174 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
175 TEST_ERROR
176
177 /* Closing */
178 if(H5Dclose(did) < 0)
179 TEST_ERROR
180 if(H5Sclose(sid) < 0)
181 TEST_ERROR
182 if(H5Pclose(dcpl) < 0)
183 TEST_ERROR
184
185 if(H5Dclose(did2) < 0)
186 TEST_ERROR
187 if(H5Sclose(sid2) < 0)
188 TEST_ERROR
189 if(H5Pclose(dcpl2) < 0)
190 TEST_ERROR
191
192 if(H5Fclose(fid) < 0)
193 TEST_ERROR
194
195 /* Reopen the file */
196 if((fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
197 TEST_ERROR
198
199 /* Initialize data buffer */
200 for(i = 0; i < (int)dims[0]; i++)
201 for(j = 0; j < (int)dims[1]; j++)
202 buf[i][j] = (i + 1) * (j + 1);
203
204 /* Open and write to the dataset: DSET_BT1 */
205 if((did = H5Dopen2(fid, DSET_BT1, H5P_DEFAULT)) < 0)
206 TEST_ERROR
207
208 /* Create contiguous dataset: DSET_CONTIG */
209 if((sid3 = H5Screate_simple(2, dims2, NULL)) < 0)
210 FAIL_STACK_ERROR
211 if((dcpl3 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
212 FAIL_STACK_ERROR
213 if(H5Pset_layout(dcpl3, H5D_CONTIGUOUS) < 0)
214 FAIL_STACK_ERROR
215 if((did3 = H5Dcreate2(fid, DSET_CONTIG, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl3, H5P_DEFAULT)) < 0)
216 FAIL_STACK_ERROR
217
218 /* Get dataset object address: DSET_CONTIG */
219 if(H5Oget_info2(did3, &oinfo3, H5O_INFO_BASIC) < 0)
220 TEST_ERROR
221
222 /* Cork the dataset: DSET_CONTIG */
223 if(H5Odisable_mdc_flushes(did3) < 0)
224 TEST_ERROR
225
226 /* Verify the cork status for DSET_CONTIG */
227 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
228 TEST_ERROR
229
230 /* Verify the cork status for DSET_BT1 */
231 if(H5C__verify_cork_tag_test(fid, oinfo.addr, FALSE) < 0)
232 TEST_ERROR
233
234 /* Un-cork the dataset: DSET_CONTIG */
235 if(H5Oenable_mdc_flushes(did3) < 0)
236 TEST_ERROR
237
238 /* Verify the cork status for DSET_CONTIG */
239 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, FALSE) < 0)
240 TEST_ERROR
241
242 /* Closing */
243 if(H5Dclose(did3) < 0)
244 TEST_ERROR
245 if(H5Pclose(dcpl3) < 0)
246 TEST_ERROR
247 if(H5Dclose(did) < 0)
248 TEST_ERROR
249 if(H5Fclose(fid) < 0)
250 TEST_ERROR
251
252 PASSED();
253 return 0;
254
255 error:
256 H5E_BEGIN_TRY {
257 H5Sclose(sid);
258 H5Sclose(sid2);
259 H5Sclose(sid3);
260 H5Dclose(did);
261 H5Dclose(did2);
262 H5Dclose(did3);
263 H5Pclose(dcpl);
264 H5Pclose(dcpl2);
265 H5Pclose(dcpl3);
266 H5Fclose(fid);
267 } H5E_END_TRY;
268 return 1;
269 } /* verify_old_dset_cork */
270
271
272 /*-------------------------------------------------------------------------
273 * Function: verify_obj_dset_cork
274 *
275 * Purpose: This function verifies corking operations for dataset objects.
276 * Cache entries associated with the object tag are checked
277 * for the correct cork status.
278 *
279 * Return: 0 on Success, 1 on Failure
280 *
281 * Programmer: Vailin Choi; Feb 2014
282 *
283 *-------------------------------------------------------------------------
284 */
285 static unsigned
verify_obj_dset_cork(hbool_t swmr)286 verify_obj_dset_cork(hbool_t swmr)
287 {
288 /* Variable Declarations */
289 hid_t fid = -1; /* File ID */
290 hid_t fapl = -1; /* File access property list */
291 hid_t aid = -1; /* Attribute ID */
292 hid_t sid = -1, sid2 = -1; /* Dataspace IDs */
293 hid_t did = -1, did2 = -1; /* Dataset IDs */
294 hid_t oid = -1; /* Object ID */
295 hid_t dcpl2; /* Dataset creation property list */
296 int i = 0; /* Local index variable */
297 hsize_t dim[1] = {100}; /* Dataset dimension size */
298 hsize_t chunk_dim[1] = {7}; /* Dataset chunk dimension size */
299 H5O_info_t oinfo, oinfo2; /* Object metadata information */
300 char attrname[500]; /* Name of attribute */
301 unsigned flags; /* File access flags */
302
303 if(swmr) {
304 TESTING("cork status for dataset objects with attributes (SWMR)");
305 } else {
306 TESTING("cork status for dataset objects with attributes");
307 }
308
309 /* Create fapl */
310 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
311 TEST_ERROR
312 /* Set to use latest format */
313 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
314 TEST_ERROR
315
316 /* Create the file with/without SWMR access */
317 flags = H5F_ACC_TRUNC;
318 if(swmr)
319 flags |= H5F_ACC_SWMR_WRITE;
320 if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0)
321 TEST_ERROR
322
323 /* Create dataspace */
324 if((sid = H5Screate(H5S_SCALAR)) < 0)
325 TEST_ERROR
326
327 /* Create dataset: DSET */
328 if((did = H5Dcreate2(fid, DSET, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
329 TEST_ERROR
330
331 /* Get dataset object header address */
332 if(H5Oget_info2(did, &oinfo, H5O_INFO_BASIC) < 0)
333 TEST_ERROR
334
335 /* Verify cork status of the dataset: DSET */
336 if(H5C__verify_cork_tag_test(fid, oinfo.addr, FALSE) < 0)
337 TEST_ERROR
338
339 /* Cork the dataset: DSET */
340 if(H5Odisable_mdc_flushes(did) < 0)
341 TEST_ERROR
342
343 /* Attach and write to an attribute to the dataset: DSET */
344 if((aid = H5Acreate2(did, ATTR, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
345 TEST_ERROR
346
347 /* Verify cork status of the dataset: DSET */
348 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
349 TEST_ERROR
350
351 /* Close the attribute */
352 if(H5Aclose(aid) < 0)
353 TEST_ERROR
354
355 /* Verify cork status of the dataset: DSET */
356 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
357 TEST_ERROR
358
359 /* Create dcpl */
360 if((dcpl2 = H5Pcreate(H5P_DATASET_CREATE)) < 0)
361 TEST_ERROR
362 /* Set to early allocation for dataset space */
363 if(H5Pset_alloc_time(dcpl2, H5D_ALLOC_TIME_EARLY) < 0)
364 TEST_ERROR
365
366 /* Create chunked dataset with implicit indexing: DSET_NONE */
367 if(H5Pset_chunk(dcpl2, 1, chunk_dim) < 0)
368 FAIL_STACK_ERROR
369 if((sid2 = H5Screate_simple(1, dim, NULL)) < 0)
370 TEST_ERROR
371 if((did2 = H5Dcreate2(fid, DSET_NONE, H5T_NATIVE_INT, sid2, H5P_DEFAULT, dcpl2, H5P_DEFAULT)) < 0)
372 TEST_ERROR
373
374 /* Get dataset object header address */
375 if(H5Oget_info2(did2, &oinfo2, H5O_INFO_BASIC) < 0)
376 TEST_ERROR
377
378 /* Cork the dataset: DSET_NONE */
379 if(H5Odisable_mdc_flushes(did2) < 0)
380 TEST_ERROR
381
382 /* Attach 8 attributes to the dataset */
383 for(i = 0; i < 8; i++) {
384 HDsprintf(attrname, "attr %d", i);
385 if((aid = H5Acreate2(did2, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
386 TEST_ERROR
387 if(H5Awrite(aid, H5T_NATIVE_INT, &i) < 0)
388 TEST_ERROR
389 if(H5Aclose(aid) < 0)
390 TEST_ERROR
391 } /* end for */
392
393 /* Verify cork status of the dataset: DSET_NONE */
394 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
395 TEST_ERROR
396
397 /* Closing */
398 if(H5Oclose(did) < 0)
399 TEST_ERROR
400 if(H5Oclose(did2) < 0)
401 TEST_ERROR
402 if(H5Sclose(sid) < 0)
403 TEST_ERROR
404 if(H5Sclose(sid2) < 0)
405 TEST_ERROR
406 if(H5Pclose(dcpl2) < 0)
407 TEST_ERROR
408 if(H5Fclose(fid) < 0)
409 TEST_ERROR
410
411 /* Re-open the file */
412 flags = H5F_ACC_RDWR;
413 if(swmr)
414 flags |= H5F_ACC_SWMR_WRITE;
415 if((fid = H5Fopen(FILENAME, flags, fapl)) < 0)
416 TEST_ERROR
417
418 /* Open the dataset object: DSET_NONE */
419 if((oid = H5Oopen(fid, DSET_NONE, H5P_DEFAULT)) < 0)
420 TEST_ERROR
421
422 /* Verify cork status of the dataset: DSET */
423 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, FALSE) < 0)
424 TEST_ERROR
425
426 /* Open the attribute attached to the dataset object: DSET_NONE */
427 if((aid = H5Aopen_by_idx(oid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)4, H5P_DEFAULT, H5P_DEFAULT)) < 0)
428 TEST_ERROR
429
430 /* Cork the dataset: DSET_NONE */
431 if(H5Odisable_mdc_flushes(oid) < 0)
432 TEST_ERROR
433
434 /* Verify cork status of the dataset: DSET_NONE */
435 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
436 TEST_ERROR
437
438 /* Close the attribute */
439 if(H5Aclose(aid) < 0)
440 TEST_ERROR
441
442 /* Verify cork status of the dataset: DSET */
443 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
444 TEST_ERROR
445
446 /* Closing */
447 if(H5Oclose(oid) < 0)
448 TEST_ERROR
449 if(H5Pclose(fapl) < 0)
450 TEST_ERROR
451 if(H5Fclose(fid) < 0)
452 TEST_ERROR
453
454 PASSED();
455 return 0;
456
457 error:
458 H5E_BEGIN_TRY {
459 H5Aclose(aid);
460 H5Sclose(sid);
461 H5Sclose(sid2);
462 H5Dclose(did);
463 H5Dclose(did2);
464 H5Oclose(oid);
465 H5Pclose(dcpl2);
466 H5Pclose(fapl);
467 H5Fclose(fid);
468 } H5E_END_TRY;
469 return 1;
470 } /* verify_obj_dset_cork */
471
472
473 /*-------------------------------------------------------------------------
474 * Function: verify_dset_cork
475 *
476 * Purpose: This function verifies corking operations for chunked datasets
477 * with different indexing types.
478 * Cache entries associated with the object tag are checked
479 * for the correct cork status.
480 *
481 * Return: 0 on Success, 1 on Failure
482 *
483 * Programmer: Vailin Choi; Feb 2014
484 *
485 *-------------------------------------------------------------------------
486 */
487 static unsigned
verify_dset_cork(hbool_t swmr,hbool_t new_format)488 verify_dset_cork(hbool_t swmr, hbool_t new_format)
489 {
490 /* Variable Declarations */
491 hid_t fid = -1; /* File ID */
492 hid_t fapl = -1; /* File access property list */
493 hid_t did = -1, did2 = -1, did3 = -1; /* Dataset IDs */
494 hid_t dcpl = -1; /* Dataset creation property list */
495 hid_t sid = -1, sid2 = -1, sid3 = -1; /* Dataspace IDs */
496 hsize_t dims[2] = {100, 20}; /* Dataset dimension sizes */
497 hsize_t max_dims[2] = {100, H5S_UNLIMITED}; /* Dataset maximum dimension sizes */
498 hsize_t chunk_dims[2] = {2, 5}; /* Dataset chunked dimension sizes */
499 int buf[100][20]; int i = 0, j = 0; /* Data buffer */
500 H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */
501 unsigned flags; /* File access flags */
502
503 /* Testing Macro */
504 if(swmr) {
505 if(new_format) {
506 TESTING("cork status for chunked datasets with different indexing types (SWMR & latest)");
507 } else {
508 TESTING("cork status for chunked datasets with different indexing types (SWMR & non-latest)");
509 } /* end if */
510 } else {
511 if(new_format) {
512 TESTING("cork status for chunked datasets with different indexing types (non-SWMR & latest)");
513 } else {
514 TESTING("cork status for chunked datasets with different indexing types (non-SWMR & non-latest)");
515 } /* end if */
516 } /* end if */
517
518 /* Create fapl */
519 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
520 TEST_ERROR
521 if(new_format) {
522 /* Set to use latest format */
523 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
524 TEST_ERROR
525 } /* end if */
526
527 /* Create the file */
528 flags = H5F_ACC_TRUNC;
529 if(swmr)
530 flags |= H5F_ACC_SWMR_WRITE;
531 if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0)
532 TEST_ERROR
533
534 /* Create dcpl */
535 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
536 FAIL_STACK_ERROR
537
538 /* Set to use chunked dataset */
539 if(H5Pset_chunk(dcpl, 2, chunk_dims) < 0)
540 FAIL_STACK_ERROR
541
542 /* Create chunked dataset with extensive array indexing: DSET_EA */
543 if((sid = H5Screate_simple(2, dims, max_dims)) < 0)
544 TEST_ERROR
545 if((did = H5Dcreate2(fid, DSET_EA, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
546 TEST_ERROR
547
548 /* Get dataset object header address: DSET_EA */
549 if(H5Oget_info2(did, &oinfo, H5O_INFO_BASIC) < 0)
550 TEST_ERROR
551
552 /* Cork the dataset: DSET_EA */
553 if(H5Odisable_mdc_flushes(did) < 0)
554 TEST_ERROR
555
556 /* Verify cork status */
557 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
558 TEST_ERROR
559
560 /* Create chunked dataset with fixed array indexing: DSET_FA */
561 if((sid2 = H5Screate_simple(2, dims, NULL)) < 0)
562 TEST_ERROR
563 if((did2 = H5Dcreate2(fid, DSET_FA, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
564 TEST_ERROR
565
566 /* Get dataset object header address: DSET_FA */
567 if(H5Oget_info2(did2, &oinfo2, H5O_INFO_BASIC) < 0)
568 TEST_ERROR
569
570 /* Cork the dataset: DSET_FA */
571 if(H5Odisable_mdc_flushes(did2) < 0)
572 TEST_ERROR
573
574 /* Uncork the dataset: DSET_EA */
575 if(H5Oenable_mdc_flushes(did) < 0)
576 TEST_ERROR
577
578 /* Verify the cork status for DSET_FA */
579 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
580 TEST_ERROR
581
582 /* Verify the cork status for DSET_EA */
583 if(H5C__verify_cork_tag_test(fid, oinfo.addr, FALSE) < 0)
584 TEST_ERROR
585
586 /* Create chunked dataset with v2-Btree indexing */
587 max_dims[0] = H5S_UNLIMITED;
588 if((sid3 = H5Screate_simple(2, dims, max_dims)) < 0)
589 TEST_ERROR
590 if((did3 = H5Dcreate2(fid, DSET_BT2, H5T_NATIVE_INT, sid3, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
591 TEST_ERROR
592
593 /* Get dataset object header address: DSET_BT2 */
594 if(H5Oget_info2(did3, &oinfo3, H5O_INFO_BASIC) < 0)
595 TEST_ERROR
596
597 /* Cork the dataset: DSET_BT2 */
598 if(H5Odisable_mdc_flushes(did3) < 0)
599 TEST_ERROR
600
601 /* Verify the cork status for DSET_BT2 */
602 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
603 TEST_ERROR
604
605 /* Closing */
606 if(H5Dclose(did3) < 0)
607 TEST_ERROR
608 if(H5Sclose(sid3) < 0)
609 TEST_ERROR
610
611 if(H5Dclose(did2) < 0)
612 TEST_ERROR
613 if(H5Sclose(sid2) < 0)
614 TEST_ERROR
615
616 if(H5Dclose(did) < 0)
617 TEST_ERROR
618 if(H5Sclose(sid) < 0)
619 TEST_ERROR
620
621 if(H5Pclose(dcpl) < 0)
622 TEST_ERROR
623 if(H5Fclose(fid) < 0)
624 TEST_ERROR
625
626 /* Reopen the file */
627 flags = H5F_ACC_RDWR;
628 if(swmr)
629 flags |= H5F_ACC_SWMR_WRITE;
630 if((fid = H5Fopen(FILENAME, flags, fapl)) < 0)
631 TEST_ERROR
632
633 /* Initialize data buffer */
634 for(i = 0; i < (int)dims[0]; i++)
635 for(j = 0; j < (int)dims[1]; j++)
636 buf[i][j] = (i + 1) * (j + 1);
637
638 /* Open and write to the dataset: DSET_EA */
639 if((did = H5Dopen2(fid, DSET_EA, H5P_DEFAULT)) < 0)
640 TEST_ERROR
641 if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
642 TEST_ERROR
643
644 /* Verify the cork status for DSET_EA */
645 if(H5C__verify_cork_tag_test(fid, oinfo.addr, FALSE) < 0)
646 TEST_ERROR
647
648 /* Open and write to the dataset: DSET_FA */
649 if((did2 = H5Dopen2(fid, DSET_FA, H5P_DEFAULT)) < 0)
650 TEST_ERROR
651 if(H5Dwrite(did2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
652 TEST_ERROR
653
654 /* Cork the dataset: DSET_FA */
655 if(H5Odisable_mdc_flushes(did2) < 0)
656 TEST_ERROR
657
658 /* Verify the cork status for DSET_FA */
659 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
660 TEST_ERROR
661
662 /* Open and write to the dataset: DSET_BT2 */
663 if((did3 = H5Dopen2(fid, DSET_BT2, H5P_DEFAULT)) < 0)
664 TEST_ERROR
665 if(H5Dwrite(did3, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
666 TEST_ERROR
667
668 /* Verify the cork status for DSET_BT2 */
669 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, FALSE) < 0)
670 TEST_ERROR
671
672 /* Cork the dataset: DSET_BT2 */
673 if(H5Odisable_mdc_flushes(did3) < 0)
674 TEST_ERROR
675
676 /* Verify the cork status for DSET_BT2 */
677 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
678 TEST_ERROR
679
680 /* Closing */
681 if(H5Dclose(did) < 0)
682 TEST_ERROR
683 if(H5Dclose(did2) < 0)
684 TEST_ERROR
685 if(H5Dclose(did3) < 0)
686 TEST_ERROR
687 if(H5Pclose(fapl) < 0)
688 TEST_ERROR
689 if(H5Fclose(fid) < 0)
690 TEST_ERROR
691
692 PASSED();
693 return 0;
694
695 error:
696 H5E_BEGIN_TRY {
697 H5Sclose(sid);
698 H5Sclose(sid2);
699 H5Sclose(sid3);
700 H5Dclose(did);
701 H5Dclose(did2);
702 H5Dclose(did3);
703 H5Pclose(dcpl);
704 H5Pclose(fapl);
705 H5Fclose(fid);
706 } H5E_END_TRY;
707 return 1;
708 } /* verify_dset_cork */
709
710
711
712 /*-------------------------------------------------------------------------
713 * Function: verify_group_cork
714 *
715 * Purpose: This function verifies corking operations for groups.
716 * Cache entries associated with the object tag are checked
717 * for the correct cork status.
718 *
719 * Return: 0 on Success, 1 on Failure
720 *
721 * Programmer: Vailin Choi; Feb 2014
722 *
723 *-------------------------------------------------------------------------
724 */
725 static unsigned
verify_group_cork(hbool_t swmr)726 verify_group_cork(hbool_t swmr)
727 {
728 /* Variable Declarations */
729 hid_t fid = -1; /* File ID */
730 hid_t fapl = -1; /* File access property list */
731 hid_t gid = -1, gid2 = -1, gid3 = -1; /* Group IDs */
732 H5O_info_t oinfo, oinfo2, oinfo3; /* Object metadata information */
733 hid_t aid; /* Attribute ID */
734 hid_t sid; /* Dataspace ID */
735 char attrname[500]; /* Name of attribute */
736 unsigned flags; /* File access flags */
737 int i = 0; /* Local index variable */
738
739 /* Testing Macro */
740 if(swmr) {
741 TESTING("cork status for groups (SWMR)");
742 } else {
743 TESTING("cork status for groups");
744 }
745
746 /* Create fapl */
747 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
748 TEST_ERROR
749 /* Set to use latest format */
750 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
751 TEST_ERROR
752
753 /* Create the file */
754 flags = H5F_ACC_TRUNC;
755 if(swmr)
756 flags |= H5F_ACC_SWMR_WRITE;
757 if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0)
758 TEST_ERROR
759
760 /* Create 3 groups */
761 if((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
762 TEST_ERROR
763 if((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
764 TEST_ERROR
765 if((gid3 = H5Gcreate2(gid2, GRP3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
766 TEST_ERROR
767
768 /* Cork the second group: GRP2 */
769 if(H5Odisable_mdc_flushes(gid2) < 0)
770 TEST_ERROR
771
772 /* Get group object header addresses */
773 if(H5Oget_info2(gid, &oinfo, H5O_INFO_BASIC) < 0)
774 TEST_ERROR
775 if(H5Oget_info2(gid2, &oinfo2, H5O_INFO_BASIC) < 0)
776 TEST_ERROR
777 if(H5Oget_info2(gid3, &oinfo3, H5O_INFO_BASIC) < 0)
778 TEST_ERROR
779
780 /* Verify cork status of the groups */
781 if(H5C__verify_cork_tag_test(fid, oinfo.addr, FALSE) < 0)
782 TEST_ERROR
783 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
784 TEST_ERROR
785 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, FALSE) < 0)
786 TEST_ERROR
787
788 /* Close the second group: GRP2 */
789 if(H5Gclose(gid2) < 0)
790 TEST_ERROR
791
792 /* Re-open the second group: GRP2 */
793 if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0)
794 FAIL_STACK_ERROR
795
796 /* Verify cork status of the second group: GRP2 */
797 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, FALSE) < 0)
798 TEST_ERROR
799
800 /* Closing */
801 if(H5Gclose(gid) < 0)
802 TEST_ERROR
803 if(H5Gclose(gid2) < 0)
804 TEST_ERROR
805 if(H5Gclose(gid3) < 0)
806 TEST_ERROR
807 if(H5Fclose(fid) < 0)
808 TEST_ERROR
809
810 /* Re-open the file and the three groups */
811 flags = H5F_ACC_RDWR;
812 if(swmr)
813 flags |= H5F_ACC_SWMR_WRITE;
814 if((fid = H5Fopen(FILENAME, flags, fapl)) < 0)
815 FAIL_STACK_ERROR
816 if((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0)
817 FAIL_STACK_ERROR
818 if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0)
819 FAIL_STACK_ERROR
820 if((gid3 = H5Gopen2(gid2, GRP3, H5P_DEFAULT)) < 0)
821 FAIL_STACK_ERROR
822
823 /* Create dataspace */
824 if((sid = H5Screate(H5S_SCALAR)) < 0)
825 TEST_ERROR
826
827 /* Attach 8 attributes to the third group: GRP3 */
828 for(i = 0;i < 8; i++) {
829 HDsprintf(attrname, "attr %d", i);
830 if((aid = H5Acreate2(gid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
831 TEST_ERROR
832 if(H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0)
833 TEST_ERROR
834 /* Cork the third group while attaching attributes */
835 if(i == 3) {
836 if(H5Odisable_mdc_flushes(gid3) < 0)
837 TEST_ERROR
838 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
839 TEST_ERROR
840 }
841 if(H5Aclose(aid) < 0)
842 TEST_ERROR
843 } /* end for */
844
845 /* Verify cork status of the third group: GRP3 */
846 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
847 TEST_ERROR
848
849 /* Closing */
850 if(H5Gclose(gid) < 0)
851 TEST_ERROR
852 if(H5Gclose(gid2) < 0)
853 TEST_ERROR
854 if(H5Gclose(gid3) < 0)
855 TEST_ERROR
856 if(H5Sclose(sid) < 0)
857 TEST_ERROR
858 if(H5Pclose(fapl) < 0)
859 TEST_ERROR
860 if(H5Fclose(fid) < 0)
861 TEST_ERROR
862
863 PASSED();
864 return 0;
865
866 error:
867 H5E_BEGIN_TRY {
868 H5Gclose(gid);
869 H5Gclose(gid2);
870 H5Gclose(gid3);
871 H5Sclose(sid);
872 H5Pclose(fapl);
873 H5Fclose(fid);
874 } H5E_END_TRY;
875 return 1;
876 } /* verify_group_cork */
877
878
879 /*-------------------------------------------------------------------------
880 * Function: verify_named_cork
881 *
882 * Purpose: This function verifies corking operations for named datatypes.
883 * Cache entries associated with the object tag are checked
884 * for the correct cork status.
885 *
886 * Return: 0 on Success, 1 on Failure
887 *
888 * Programmer: Vailin Choi; Feb 2014
889 *
890 *-------------------------------------------------------------------------
891 */
892 static unsigned
verify_named_cork(hbool_t swmr)893 verify_named_cork(hbool_t swmr)
894 {
895 /* Variable Declarations */
896 hid_t fid = -1; /* File ID */
897 hid_t fapl = -1; /* File access property list */
898 hid_t tid = -1, tid2 = -1, tid3 = -1; /* Datatype IDs */
899 hid_t gid = -1, gid2 = -1; /* Group IDs */
900 H5O_info_t oinfo, oinfo2, oinfo3, oinfo4; /* Object metadata information */
901 hid_t aid = -1; /* Attribute ID */
902 hid_t sid; /* Dataspace ID */
903 hid_t did; /* Dataset ID */
904 char attrname[500]; /* Name of attribute */
905 unsigned flags; /* File access flags */
906 int i = 0; /* Local index variable */
907
908 /* Testing Macro */
909 if(swmr) {
910 TESTING("cork status for named datatypes (SWMR)");
911 } else {
912 TESTING("cork status for named datatypes");
913 }
914
915 /* Create fapl */
916 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
917 TEST_ERROR
918 /* Set to use latest format */
919 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
920 TEST_ERROR
921
922 /* Create the file */
923 flags = H5F_ACC_TRUNC;
924 if(swmr)
925 flags |= H5F_ACC_SWMR_WRITE;
926 if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0)
927 TEST_ERROR
928
929 /* Create 3 copies of datatypes */
930 if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)
931 TEST_ERROR
932 if((tid2 = H5Tcopy(H5T_NATIVE_LONG)) < 0)
933 TEST_ERROR
934 if((tid3 = H5Tcopy(H5T_NATIVE_CHAR)) < 0)
935 TEST_ERROR
936
937 /* Commit datatype /DT */
938 if(H5Tcommit2(fid, DT, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
939 TEST_ERROR
940
941 /* Create /GRP */
942 if((gid = H5Gcreate2(fid, GRP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
943 TEST_ERROR
944 /* Commit datatype /GRP/DT2 */
945 if(H5Tcommit2(gid, DT2, tid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
946 TEST_ERROR
947
948 /* Create /GRP/GRP2 */
949 if((gid2 = H5Gcreate2(gid, GRP2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
950 TEST_ERROR
951 /* Commit datatype /GRP/GRP2/DT3 */
952 if(H5Tcommit2(gid2, DT3, tid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
953 TEST_ERROR
954
955 /* Cork 2 named datatypes: /DT and /GRP/GRP2/DT3 */
956 if(H5Odisable_mdc_flushes(tid) < 0)
957 TEST_ERROR
958 if(H5Odisable_mdc_flushes(tid3) < 0)
959 TEST_ERROR
960
961 /* Get named datatype object header addresses */
962 if(H5Oget_info2(tid, &oinfo, H5O_INFO_BASIC) < 0)
963 TEST_ERROR
964 if(H5Oget_info2(tid2, &oinfo2, H5O_INFO_BASIC) < 0)
965 TEST_ERROR
966 if(H5Oget_info2(tid3, &oinfo3, H5O_INFO_BASIC) < 0)
967 TEST_ERROR
968
969 /* Verify cork status of the named datatypes */
970 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
971 TEST_ERROR
972 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, FALSE) < 0)
973 TEST_ERROR
974 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
975 TEST_ERROR
976
977 /* Close the datatypes */
978 if(H5Tclose(tid) < 0)
979 TEST_ERROR
980 if(H5Tclose(tid2) < 0)
981 TEST_ERROR
982 if(H5Tclose(tid3) < 0)
983 TEST_ERROR
984
985 /* Re-open the named datatypes */
986 if((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0)
987 FAIL_STACK_ERROR
988 if((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0)
989 FAIL_STACK_ERROR
990 if((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0)
991 FAIL_STACK_ERROR
992
993 /* Verify cork status of the named datatypes */
994 if(H5C__verify_cork_tag_test(fid, oinfo.addr, FALSE) < 0)
995 TEST_ERROR
996 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, FALSE) < 0)
997 TEST_ERROR
998 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, FALSE) < 0)
999 TEST_ERROR
1000
1001 /* Closing */
1002 if(H5Tclose(tid) < 0)
1003 TEST_ERROR
1004 if(H5Tclose(tid2) < 0)
1005 TEST_ERROR
1006 if(H5Tclose(tid3) < 0)
1007 TEST_ERROR
1008 if(H5Gclose(gid) < 0)
1009 TEST_ERROR
1010 if(H5Gclose(gid2) < 0)
1011 TEST_ERROR
1012 if(H5Fclose(fid) < 0)
1013 TEST_ERROR
1014
1015
1016 /* Re-open the file and the three groups */
1017 flags = H5F_ACC_RDWR;
1018 if(swmr)
1019 flags |= H5F_ACC_SWMR_WRITE;
1020 if((fid = H5Fopen(FILENAME, flags, fapl)) < 0)
1021 FAIL_STACK_ERROR
1022 if((gid = H5Gopen2(fid, GRP, H5P_DEFAULT)) < 0)
1023 FAIL_STACK_ERROR
1024 if((gid2 = H5Gopen2(gid, GRP2, H5P_DEFAULT)) < 0)
1025 FAIL_STACK_ERROR
1026
1027 /* Re-open the named datatypes */
1028 if((tid = H5Topen2(fid, DT, H5P_DEFAULT)) < 0)
1029 FAIL_STACK_ERROR
1030 if((tid2 = H5Topen2(gid, DT2, H5P_DEFAULT)) < 0)
1031 FAIL_STACK_ERROR
1032 if((tid3 = H5Topen2(gid2, DT3, H5P_DEFAULT)) < 0)
1033 FAIL_STACK_ERROR
1034
1035 /* Cork the datatype: DT2 */
1036 if(H5Odisable_mdc_flushes(tid2) < 0)
1037 TEST_ERROR
1038
1039 /* Create dataspace */
1040 if((sid = H5Screate(H5S_SCALAR)) < 0)
1041 TEST_ERROR
1042
1043 /* Attach 8 attributes to datatype: DT3 */
1044 for(i = 0;i < 8; i++) {
1045 HDsprintf(attrname, "attr %d", i);
1046 if((aid = H5Acreate2(tid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1047 TEST_ERROR
1048 if(H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0)
1049 TEST_ERROR
1050 /* Cork the datatype while attaching attributes */
1051 if(i == 3) {
1052 if(H5Odisable_mdc_flushes(tid3) < 0)
1053 TEST_ERROR
1054 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
1055 TEST_ERROR
1056 }
1057 if(H5Aclose(aid) < 0)
1058 TEST_ERROR
1059 } /* end for */
1060
1061 /* Create a dataset with named datatype: DT */
1062 if((did = H5Dcreate2(fid, DSET, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1063 FAIL_STACK_ERROR
1064
1065 /* Get dataset object header address */
1066 if(H5Oget_info2(did, &oinfo4, H5O_INFO_BASIC) < 0)
1067 TEST_ERROR
1068
1069 /* Cork the dataset: DSET */
1070 if(H5Odisable_mdc_flushes(did) < 0)
1071 TEST_ERROR
1072
1073 /* Verify cork status of the datatype: DT */
1074 if(H5C__verify_cork_tag_test(fid, oinfo.addr, FALSE) < 0)
1075 TEST_ERROR
1076 /* Verify cork status of the datatype: DT2 */
1077 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
1078 TEST_ERROR
1079 /* Verify cork status of the datatype: DT3 */
1080 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, TRUE) < 0)
1081 TEST_ERROR
1082
1083 /* Un-cork the datatype: DT3 */
1084 if(H5Oenable_mdc_flushes(tid3) < 0)
1085 TEST_ERROR
1086 /* Verify cork status of the datatype: DT3 */
1087 if(H5C__verify_cork_tag_test(fid, oinfo3.addr, FALSE) < 0)
1088 TEST_ERROR
1089
1090 /* Cork the datatype: DT */
1091 if(H5Odisable_mdc_flushes(tid) < 0)
1092 TEST_ERROR
1093
1094 /* Verify cork status of the datatype: DT */
1095 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
1096 TEST_ERROR
1097 /* Verify cork status of the datatype: DT2 */
1098 if(H5C__verify_cork_tag_test(fid, oinfo2.addr, TRUE) < 0)
1099 TEST_ERROR
1100
1101 /* Verify cork status of the dataset: DSET */
1102 if(H5C__verify_cork_tag_test(fid, oinfo4.addr, TRUE) < 0)
1103 TEST_ERROR
1104
1105 /* Close the dataset */
1106 if(H5Dclose(did) < 0)
1107 TEST_ERROR
1108
1109 /* Verify cork status of the datatype: DT */
1110 if(H5C__verify_cork_tag_test(fid, oinfo.addr, TRUE) < 0)
1111 TEST_ERROR
1112
1113 /* Verify cork status of the dataset: DSET */
1114 if(H5C__verify_cork_tag_test(fid, oinfo4.addr, FALSE) < 0)
1115 TEST_ERROR
1116
1117 /* Closing */
1118 if(H5Tclose(tid) < 0)
1119 TEST_ERROR
1120 if(H5Tclose(tid2) < 0)
1121 TEST_ERROR
1122 if(H5Tclose(tid3) < 0)
1123 TEST_ERROR
1124 if(H5Gclose(gid) < 0)
1125 TEST_ERROR
1126 if(H5Gclose(gid2) < 0)
1127 TEST_ERROR
1128 if(H5Sclose(sid) < 0)
1129 TEST_ERROR
1130 if(H5Fclose(fid) < 0)
1131 TEST_ERROR
1132 if(H5Pclose(fapl) < 0)
1133 TEST_ERROR
1134
1135 PASSED();
1136 return 0;
1137
1138 error:
1139 H5E_BEGIN_TRY {
1140 H5Tclose(tid);
1141 H5Tclose(tid2);
1142 H5Tclose(tid3);
1143 H5Gclose(gid);
1144 H5Gclose(gid2);
1145 H5Dclose(did);
1146 H5Pclose(fapl);
1147 H5Fclose(fid);
1148 } H5E_END_TRY;
1149 return 1;
1150 } /* verify_named_cork */
1151
1152
1153 /*-------------------------------------------------------------------------
1154 * Function: verify_multiple_cork
1155 *
1156 * Purpose: This function verifies corking operations when there are
1157 * multiple opens of files, objects, attributes.
1158 * (based on test_attr_bug5() in tattr.c)
1159 * Cache entries associated with the object tag are checked
1160 * for the correct cork status.
1161 *
1162 * Return: 0 on Success, 1 on Failure
1163 *
1164 * Programmer: Vailin Choi; Feb 2014
1165 *
1166 *-------------------------------------------------------------------------
1167 */
1168 static unsigned
verify_multiple_cork(hbool_t swmr)1169 verify_multiple_cork(hbool_t swmr)
1170 {
1171 /* Variable Declarations */
1172 hid_t fid1 = -1, fid2 = -1; /* File ID */
1173 hid_t fapl = -1; /* File access property list */
1174 hid_t tid1 = -1, tid2 = -1; /* Datatype IDs */
1175 hid_t gid1 = -1, gid2 = -1; /* Group IDs */
1176 hid_t did1 = -1, did2 = -1; /* Dataset ID */
1177 hid_t aidg1 = -1, aidg2 = -1; /* Attribute ID */
1178 hid_t aidd1 = -1, aidd2 = -1; /* Attribute ID */
1179 hid_t aidt1 = -1, aidt2 = -1; /* Attribute ID */
1180 hid_t sid = -1; /* Dataspace ID */
1181 H5O_info_t oinfo1, oinfo2, oinfo3; /* Object metadata information */
1182 hsize_t dim[1] = {5}; /* Dimension sizes */
1183 unsigned flags; /* File access flags */
1184 hbool_t corked; /* Cork status */
1185 herr_t ret; /* Return value */
1186
1187 /* Testing Macro */
1188 if(swmr) {
1189 TESTING("cork status for multiple opens (SWMR)");
1190 } else {
1191 TESTING("cork status for multiple opens");
1192 }
1193
1194 /* Create fapl */
1195 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
1196 TEST_ERROR
1197 /* Set to use latest format */
1198 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
1199 TEST_ERROR
1200
1201 /* Create the file */
1202 flags = H5F_ACC_TRUNC;
1203 if(swmr)
1204 flags |= H5F_ACC_SWMR_WRITE;
1205 if((fid1 = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0)
1206 TEST_ERROR
1207
1208 /* Open root group */
1209 if((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0)
1210 TEST_ERROR
1211
1212 /* Create and commit datatype */
1213 if((tid1 = H5Tcopy(H5T_STD_I32LE)) < 0)
1214 TEST_ERROR
1215 if(H5Tcommit2(fid1, DT, tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
1216 TEST_ERROR
1217
1218 /* Create dataset */
1219 if((sid = H5Screate_simple(1, dim, NULL)) < 0)
1220 TEST_ERROR
1221 if((did1 = H5Dcreate2(fid1, DSET, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1222 TEST_ERROR
1223
1224 /* Create attribute on root group */
1225 if((aidg1 = H5Acreate2(gid1, GRP_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1226 TEST_ERROR
1227
1228 /* Create attribute on dataset */
1229 if((aidd1 = H5Acreate2(did1, DSET_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1230 TEST_ERROR
1231
1232 /* Create attribute on datatype */
1233 if((aidt1 = H5Acreate2(tid1, DT_ATTR, tid1, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1234 TEST_ERROR
1235
1236 /* Closing */
1237 if(H5Aclose(aidt1) < 0)
1238 TEST_ERROR
1239 if(H5Aclose(aidd1) < 0)
1240 TEST_ERROR
1241 if(H5Aclose(aidg1) < 0)
1242 TEST_ERROR
1243 if(H5Dclose(did1) < 0)
1244 TEST_ERROR
1245 if(H5Tclose(tid1) < 0)
1246 TEST_ERROR
1247 if(H5Gclose(gid1) < 0)
1248 TEST_ERROR
1249 if(H5Fclose(fid1) < 0)
1250 TEST_ERROR
1251 if(H5Sclose(sid) < 0)
1252 TEST_ERROR
1253
1254 /* Open the file twice: fid1, fid2 */
1255 flags = H5F_ACC_RDWR;
1256 if(swmr)
1257 flags |= H5F_ACC_SWMR_WRITE;
1258 if((fid1 = H5Fopen(FILENAME, flags, fapl)) < 0)
1259 TEST_ERROR
1260 if((fid2 = H5Fopen(FILENAME, flags, fapl)) < 0)
1261 TEST_ERROR
1262
1263 /* Open the root group twice: gid1, gid2 */
1264 if((gid1 = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0)
1265 TEST_ERROR
1266 if((gid2 = H5Gopen2(fid2, "/", H5P_DEFAULT)) < 0)
1267 TEST_ERROR
1268
1269 /* Open the root group attribute twice: aidg1, aidg2 */
1270 if((aidg1 = H5Aopen(gid1, GRP_ATTR, H5P_DEFAULT)) < 0)
1271 TEST_ERROR
1272 if((aidg2 = H5Aopen(gid2, GRP_ATTR, H5P_DEFAULT)) < 0)
1273 TEST_ERROR
1274
1275 /* Cork the group: gid2 */
1276 if(H5Odisable_mdc_flushes(gid2) < 0)
1277 TEST_ERROR
1278
1279 /* Verify cork status of the group: gid2 */
1280 if(H5Oget_info2(gid2, &oinfo1, H5O_INFO_BASIC) < 0)
1281 TEST_ERROR
1282 if(H5C__verify_cork_tag_test(fid2, oinfo1.addr, TRUE) < 0)
1283 TEST_ERROR
1284
1285 /* Check cork status of the group: gid1 */
1286 if(H5Oare_mdc_flushes_disabled(gid1, &corked) < 0)
1287 TEST_ERROR
1288 if(!corked)
1289 TEST_ERROR
1290
1291 /* Open the dataset twice: did1, did2 */
1292 if((did1 = H5Dopen2(fid1, DSET, H5P_DEFAULT)) < 0)
1293 TEST_ERROR
1294 if((did2 = H5Dopen2(fid2, DSET, H5P_DEFAULT)) < 0)
1295 TEST_ERROR
1296
1297 /* Open the dataset attribute twice: aidd1, aidd2 */
1298 if((aidd1 = H5Aopen(did1, DSET_ATTR, H5P_DEFAULT)) < 0)
1299 TEST_ERROR
1300 if((aidd2 = H5Aopen(did2, DSET_ATTR, H5P_DEFAULT)) < 0)
1301 TEST_ERROR
1302
1303 /* Cork the dataset: did1 */
1304 if(H5Odisable_mdc_flushes(did1) < 0)
1305 TEST_ERROR
1306
1307 /* Verify cork status of the dataset: did1 */
1308 if(H5Oget_info2(did1, &oinfo2, H5O_INFO_BASIC) < 0)
1309 TEST_ERROR
1310 if(H5C__verify_cork_tag_test(fid1, oinfo2.addr, TRUE) < 0)
1311 TEST_ERROR
1312
1313 /* Check cork status of the dataset: did2 */
1314 if(H5Oare_mdc_flushes_disabled(did2, &corked) < 0)
1315 TEST_ERROR
1316 if(!corked)
1317 TEST_ERROR
1318
1319 /* Open the datatype twice: tid1, tid2 */
1320 if((tid1 = H5Topen2(fid1, DT, H5P_DEFAULT)) < 0)
1321 TEST_ERROR
1322 if((tid2 = H5Topen2(fid2, DT, H5P_DEFAULT)) < 0)
1323 TEST_ERROR
1324
1325 /* Open the datatype attribute twice: aidt1, aidt2 */
1326 if((aidt1 = H5Aopen(tid1, DT_ATTR, H5P_DEFAULT)) < 0)
1327 TEST_ERROR
1328 if((aidt2 = H5Aopen(tid2, DT_ATTR, H5P_DEFAULT)) < 0)
1329 TEST_ERROR
1330
1331 /* Cork the datatype: tid2 */
1332 if(H5Odisable_mdc_flushes(tid2) < 0)
1333 TEST_ERROR
1334
1335 /* Verify cork status of the datatype: tid2 */
1336 if(H5Oget_info2(tid2, &oinfo3, H5O_INFO_BASIC) < 0)
1337 TEST_ERROR
1338 if(H5C__verify_cork_tag_test(fid2, oinfo3.addr, TRUE) < 0)
1339 TEST_ERROR
1340
1341 /* Check cork status of the datatype: tid1 */
1342 if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0)
1343 TEST_ERROR
1344 if(!corked)
1345 TEST_ERROR
1346
1347 /* Uncork the group: gid1 */
1348 if(H5Oenable_mdc_flushes(gid1) < 0)
1349 TEST_ERROR
1350
1351 /* Verify cork status of the group: gid1 */
1352 if(H5Oget_info2(gid1, &oinfo1, H5O_INFO_BASIC) < 0)
1353 TEST_ERROR
1354 if(H5C__verify_cork_tag_test(fid1, oinfo1.addr, FALSE) < 0)
1355 TEST_ERROR
1356
1357 /* Check cork status of the group: gid2 */
1358 if(H5Oare_mdc_flushes_disabled(gid2, &corked) < 0)
1359 TEST_ERROR
1360 if(corked)
1361 TEST_ERROR
1362
1363 /* Close the group: gid2 */
1364 if(H5Gclose(gid2) < 0)
1365 TEST_ERROR
1366
1367 /* Check cork status of the group: gid1 */
1368 if(H5Oare_mdc_flushes_disabled(gid1, &corked) < 0)
1369 TEST_ERROR
1370 if(corked)
1371 TEST_ERROR
1372
1373 /* Verify cork status of the group: gid1 */
1374 if(H5C__verify_cork_tag_test(fid1, oinfo1.addr, FALSE) < 0)
1375 TEST_ERROR
1376
1377 /* Close the group: gid1 */
1378 if(H5Gclose(gid1) < 0)
1379 TEST_ERROR
1380
1381 /* Uncork the dataset: gid2 */
1382 if(H5Oenable_mdc_flushes(did2) < 0)
1383 TEST_ERROR
1384
1385 /* Verify cork status of the dataset: did2 */
1386 if(H5Oget_info2(did2, &oinfo2, H5O_INFO_BASIC) < 0)
1387 TEST_ERROR
1388 if(H5C__verify_cork_tag_test(fid2, oinfo2.addr, FALSE) < 0)
1389 TEST_ERROR
1390
1391 /* Check cork status of the dataset: did1 */
1392 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
1393 TEST_ERROR
1394 if(corked)
1395 TEST_ERROR
1396
1397 /* Close the dataset: did2 */
1398 if(H5Dclose(did2) < 0)
1399 TEST_ERROR
1400
1401 /* Check cork status of the dataset: did1 */
1402 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
1403 TEST_ERROR
1404 if(corked)
1405 TEST_ERROR
1406
1407 /* Verify cork status of the dataset: did1 */
1408 if(H5C__verify_cork_tag_test(fid1, oinfo2.addr, FALSE) < 0)
1409 TEST_ERROR
1410
1411 /* Close the dataset: did1 */
1412 if(H5Dclose(did1) < 0)
1413 TEST_ERROR
1414
1415 /* Check cork status of the datatype: tid1 */
1416 if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0)
1417 TEST_ERROR
1418 if(!corked)
1419 TEST_ERROR
1420
1421 /* Close datatype: tid1 */
1422 if(H5Tclose(tid1) < 0)
1423 TEST_ERROR
1424
1425 /* Check cork status of the datatype: tid2 */
1426 if(H5Oare_mdc_flushes_disabled(tid2, &corked) < 0)
1427 TEST_ERROR
1428 if(!corked)
1429 TEST_ERROR
1430
1431 /* Close datatype: tid2 */
1432 if(H5Tclose(tid2) < 0)
1433 TEST_ERROR
1434
1435 /* Should fail to cork the attribute: aidg2; not an object */
1436 H5E_BEGIN_TRY {
1437 ret = H5Odisable_mdc_flushes(aidg2);
1438 } H5E_END_TRY;
1439 if(ret >= 0)
1440 TEST_ERROR
1441
1442 /* Should fail to uncork the attribute: aidd1; not an object */
1443 H5E_BEGIN_TRY {
1444 ret = H5Odisable_mdc_flushes(aidd1);
1445 } H5E_END_TRY;
1446 if(ret >= 0)
1447 TEST_ERROR
1448
1449 /* Should fail to check cork status of the attribute: aidt2; not an object */
1450 H5E_BEGIN_TRY {
1451 ret = H5Oare_mdc_flushes_disabled(aidt2, &corked);
1452 } H5E_END_TRY;
1453 if(ret >= 0)
1454 TEST_ERROR
1455
1456 /* Close all attributes */
1457 if(H5Aclose(aidg1) < 0)
1458 TEST_ERROR
1459 if(H5Aclose(aidg2) < 0)
1460 TEST_ERROR
1461 if(H5Aclose(aidd1) < 0)
1462 TEST_ERROR
1463 if(H5Aclose(aidd2) < 0)
1464 TEST_ERROR
1465 if(H5Aclose(aidt1) < 0)
1466 TEST_ERROR
1467 if(H5Aclose(aidt2) < 0)
1468 TEST_ERROR
1469
1470 /* Should fail to cork the file: fid1; not an object */
1471 H5E_BEGIN_TRY {
1472 ret = H5Oare_mdc_flushes_disabled(fid1, &corked);
1473 ret = H5Odisable_mdc_flushes(fid1);
1474 } H5E_END_TRY;
1475 if(ret >= 0)
1476 TEST_ERROR
1477
1478 /* Should fail to uncork the file: fid2; not an object */
1479 H5E_BEGIN_TRY {
1480 ret = H5Oenable_mdc_flushes(fid2);
1481 } H5E_END_TRY;
1482 if(ret >= 0)
1483 TEST_ERROR
1484
1485 /* Closing */
1486 if(H5Pclose(fapl) < 0)
1487 TEST_ERROR
1488 if(H5Fclose(fid1) < 0)
1489 TEST_ERROR
1490 if(H5Fclose(fid2) < 0)
1491 TEST_ERROR
1492
1493 PASSED();
1494 return 0;
1495
1496 error:
1497 H5E_BEGIN_TRY {
1498 H5Tclose(tid1);
1499 H5Tclose(tid2);
1500 H5Gclose(gid1);
1501 H5Gclose(gid2);
1502 H5Dclose(did1);
1503 H5Dclose(did2);
1504 H5Aclose(aidg1);
1505 H5Aclose(aidg2);
1506 H5Aclose(aidd1);
1507 H5Aclose(aidt1);
1508 H5Aclose(aidt2);
1509 H5Aclose(aidd2);
1510 H5Pclose(fapl);
1511 H5Fclose(fid1);
1512 H5Fclose(fid1);
1513 } H5E_END_TRY;
1514 return 1;
1515 } /* verify_multiple_cork */
1516
1517 /*-------------------------------------------------------------------------
1518 * Function: test_objs_cork
1519 *
1520 * Purpose: This function verifies H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled public
1521 * routines are working as specified.
1522 *
1523 * Return: 0 on Success, 1 on Failure
1524 *
1525 * Programmer: Vailin Choi; Feb 2014
1526 *
1527 *-------------------------------------------------------------------------
1528 */
1529 static unsigned
test_objs_cork(hbool_t swmr,hbool_t new_format)1530 test_objs_cork(hbool_t swmr, hbool_t new_format)
1531 {
1532 hid_t fid = H5I_INVALID_HID; /* HDF5 File ID */
1533 hid_t fapl = H5I_INVALID_HID; /* File access property list */
1534 hid_t gid = H5I_INVALID_HID;
1535 hid_t did = H5I_INVALID_HID;
1536 hid_t tid = H5I_INVALID_HID; /* Object IDs */
1537 hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
1538 hid_t aid = H5I_INVALID_HID; /* Attribute ID */
1539 hsize_t dims[RANK]; /* Dataset dimension sizes */
1540 hbool_t corked; /* Cork status of an object */
1541 unsigned flags; /* File access flags */
1542 herr_t ret; /* Return value */
1543
1544 /* Testing Macro */
1545 if(new_format) {
1546 if(swmr) {
1547 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (new library format) (SWMR)");
1548 } /* end if */
1549 else {
1550 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (new library format)");
1551 } /* end else */
1552 } else {
1553 if(swmr) {
1554 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (old library format) (SWMR)");
1555 } /* end if */
1556 else {
1557 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled (old library format)");
1558 } /* end else */
1559 } /* end else */
1560
1561 /* Create fapl */
1562 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
1563 TEST_ERROR
1564
1565 /* Set to use latest format */
1566 if(new_format) {
1567 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
1568 TEST_ERROR
1569 } /* end if */
1570
1571 /* Create the file with/without SWMR access */
1572 flags = H5F_ACC_TRUNC;
1573 if(swmr)
1574 flags |= H5F_ACC_SWMR_WRITE;
1575 if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0)
1576 TEST_ERROR
1577
1578 /* Create group */
1579 if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1580 TEST_ERROR
1581
1582 /* Check cork status of the group: not corked */
1583 if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0)
1584 TEST_ERROR
1585 if(corked)
1586 TEST_ERROR
1587
1588 /* Cork the group: an object */
1589 if(H5Odisable_mdc_flushes(gid) < 0)
1590 TEST_ERROR
1591
1592 /* Check cork status of the group: corked */
1593 if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0)
1594 TEST_ERROR
1595 if(!corked)
1596 TEST_ERROR
1597
1598 /* Close the group */
1599 if(H5Gclose(gid) < 0)
1600 TEST_ERROR
1601
1602 /* Create a transient copy of a native type */
1603 if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)
1604 TEST_ERROR
1605
1606 /* Should fail to cork the datatype: not an object */
1607 H5E_BEGIN_TRY {
1608 ret = H5Odisable_mdc_flushes(tid);
1609 } H5E_END_TRY;
1610 if(ret >= 0)
1611 TEST_ERROR
1612
1613 /* Create a named datatype */
1614 if(H5Tcommit2(fid, "group/datatype", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
1615 TEST_ERROR
1616
1617 /* Check cork status of the named datatype: not corked */
1618 if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0)
1619 TEST_ERROR
1620 if(corked)
1621 TEST_ERROR
1622
1623 /* Cork the named datatype: an object */
1624 if(H5Odisable_mdc_flushes(tid) < 0)
1625 TEST_ERROR
1626
1627 /* Check cork status of the named datatype: corked */
1628 if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0)
1629 TEST_ERROR
1630 if(!corked)
1631 TEST_ERROR
1632
1633 /* Close the named datatype */
1634 if(H5Tclose(tid) < 0)
1635 TEST_ERROR
1636
1637 /* Create dataspace */
1638 dims[0] = DIM0;
1639 dims[1] = DIM1;
1640 if((sid = H5Screate_simple(RANK, dims, NULL)) < 0)
1641 TEST_ERROR
1642
1643 /* Should fail to uncork the dataspace: not an object */
1644 H5E_BEGIN_TRY {
1645 ret = H5Oenable_mdc_flushes(sid);
1646 } H5E_END_TRY;
1647 if(ret >= 0)
1648 TEST_ERROR
1649
1650 /* Create dataset. */
1651 if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1652 TEST_ERROR
1653
1654 /* Create attribute on the dataset */
1655 if((aid = H5Acreate2(did, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1656 TEST_ERROR
1657
1658 /* Should fail to check cork status of the attribute: not an object */
1659 H5E_BEGIN_TRY {
1660 ret = H5Oare_mdc_flushes_disabled(aid, &corked);
1661 } H5E_END_TRY;
1662 if(ret >= 0)
1663 TEST_ERROR
1664
1665 /* Check cork status of the dataset: not corked */
1666 if(H5Oare_mdc_flushes_disabled(did, &corked) < 0)
1667 TEST_ERROR
1668 if(corked)
1669 TEST_ERROR
1670
1671 /* Cork the dataset: an object */
1672 if(H5Odisable_mdc_flushes(did) < 0)
1673 TEST_ERROR
1674
1675 /* Check cork status of the dataset: corked */
1676 if(H5Oare_mdc_flushes_disabled(did, &corked) < 0)
1677 TEST_ERROR
1678 if(!corked)
1679 TEST_ERROR
1680
1681 /* Close the dataset and dataspace */
1682 if(H5Dclose(did) < 0)
1683 TEST_ERROR
1684
1685 /* Open the group */
1686 if((gid = H5Oopen(fid, "group", H5P_DEFAULT)) < 0)
1687 TEST_ERROR
1688
1689 /* Check cork status of the group */
1690 if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0)
1691 TEST_ERROR
1692 if(corked)
1693 TEST_ERROR
1694
1695 /* Cork the group */
1696 if(H5Odisable_mdc_flushes(gid) < 0)
1697 TEST_ERROR
1698
1699 /* Should fail to cork the group again */
1700 H5E_BEGIN_TRY {
1701 ret = H5Odisable_mdc_flushes(gid);
1702 } H5E_END_TRY;
1703 if(ret >= 0)
1704 TEST_ERROR
1705
1706 /* Check cork status of the group */
1707 if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0)
1708 TEST_ERROR
1709 if(!corked)
1710 TEST_ERROR
1711
1712 /* Open the named datatype */
1713 if((tid = H5Oopen(fid, "group/datatype", H5P_DEFAULT)) < 0)
1714 TEST_ERROR
1715
1716 /* Check cork status of the named datatype */
1717 if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0)
1718 TEST_ERROR
1719 if(corked)
1720 TEST_ERROR
1721
1722 /* Should fail to un-cork the named datatype that is not corked yet */
1723 H5E_BEGIN_TRY {
1724 ret = H5Oenable_mdc_flushes(tid);
1725 } H5E_END_TRY;
1726 if(ret >= 0)
1727 TEST_ERROR
1728
1729 /* Cork the named datatype */
1730 if(H5Odisable_mdc_flushes(tid) < 0)
1731 TEST_ERROR
1732
1733 /* Check cork status of the named datatype */
1734 if(H5Oare_mdc_flushes_disabled(tid, &corked) < 0)
1735 TEST_ERROR
1736 if(!corked)
1737 TEST_ERROR
1738
1739 /* Open the dataset */
1740 if((did = H5Oopen(fid, "/dataset", H5P_DEFAULT)) < 0)
1741 TEST_ERROR
1742
1743 /* Check cork status of the dataset */
1744 if(H5Oare_mdc_flushes_disabled(did, &corked) < 0)
1745 TEST_ERROR
1746 if(corked)
1747 TEST_ERROR
1748
1749 /* Cork the dataset */
1750 if(H5Odisable_mdc_flushes(did) < 0)
1751 TEST_ERROR
1752
1753 /* Check cork status of dataset */
1754 if(H5Oare_mdc_flushes_disabled(did, &corked) < 0)
1755 TEST_ERROR
1756 if(!corked)
1757 TEST_ERROR
1758
1759 /* Un-cork the dataset */
1760 if(H5Oenable_mdc_flushes(did) < 0)
1761 TEST_ERROR
1762
1763 /* Check cork status of the dataset */
1764 if(H5Oare_mdc_flushes_disabled(did, &corked) < 0)
1765 TEST_ERROR
1766 if(corked)
1767 TEST_ERROR
1768
1769 /* Closing */
1770 if(H5Tclose(tid) < 0)
1771 TEST_ERROR
1772 if(H5Gclose(gid) < 0)
1773 TEST_ERROR
1774 if(H5Dclose(did) < 0)
1775 TEST_ERROR
1776 if(H5Sclose(sid) < 0)
1777 TEST_ERROR
1778 if(H5Aclose(aid) < 0)
1779 TEST_ERROR
1780 if(H5Pclose(fapl) < 0)
1781 TEST_ERROR
1782 if(H5Fclose(fid) < 0)
1783 TEST_ERROR
1784
1785 PASSED();
1786 return 0;
1787
1788 error:
1789 H5E_BEGIN_TRY {
1790 H5Sclose(sid);
1791 H5Aclose(aid);
1792 H5Dclose(did);
1793 H5Gclose(gid);
1794 H5Tclose(tid);
1795 H5Pclose(fapl);
1796 H5Fclose(fid);
1797 } H5E_END_TRY;
1798 return 1;
1799 } /* test_objs_cork() */
1800
1801
1802 /*-------------------------------------------------------------------------
1803 * Function: test_dset_cork
1804 *
1805 * Purpose: This function verifies H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled are
1806 * working as specified when manipulating datasets.
1807 *
1808 * Return: 0 on Success, 1 on Failure
1809 *
1810 * Programmer: Vailin Choi; Feb 2014
1811 *
1812 *-------------------------------------------------------------------------
1813 */
1814 static unsigned
test_dset_cork(hbool_t swmr,hbool_t new_format)1815 test_dset_cork(hbool_t swmr, hbool_t new_format)
1816 {
1817 hid_t fid; /* File ID */
1818 hid_t fapl; /* File access property list */
1819 hid_t gid; /* Groupd ID */
1820 hid_t did1, did2; /* Dataset IDs */
1821 hid_t tid1, tid2; /* Datatype IDs */
1822 hid_t sid; /* Dataspace ID */
1823 hid_t dcpl; /* Dataset creation property list */
1824 hsize_t dims[RANK]; /* Dataset dimensions */
1825 hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dataset dimensions */
1826 hsize_t cdims[RANK] = {2,2}; /* Chunk dimensions */
1827 int fillval = 0; /* Fill value */
1828 int i, j, k = 0; /* Local index variables */
1829 int data[DIMS0][DIMS1]; /* Data buffer */
1830 int rbuf[DIMS0][DIMS1]; /* Data buffer */
1831 hbool_t corked; /* Cork status of an object */
1832 unsigned flags; /* File access flags */
1833
1834 /* Testing Macro */
1835 if(new_format) {
1836 if(swmr) {
1837 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (new library format) (SWMR)");
1838 } /* end if */
1839 else {
1840 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (new library format)");
1841 } /* end else */
1842 } else {
1843 if(swmr) {
1844 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (old library format) (SWMR)");
1845 } /* end if */
1846 else {
1847 TESTING("H5Odisable_mdc_flushes/H5Oenable_mdc_flushes/H5Oare_mdc_flushes_disabled on datasets (old library format)");
1848 } /* end else */
1849 } /* end if */
1850
1851 /* Create fapl */
1852 if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
1853 TEST_ERROR
1854
1855 /* Set to use latest format */
1856 if(new_format) {
1857 if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
1858 TEST_ERROR
1859 } /* end if */
1860
1861 /* Create the file with/without SWMR access */
1862 flags = H5F_ACC_TRUNC;
1863 if(swmr)
1864 flags |= H5F_ACC_SWMR_WRITE;
1865 if((fid = H5Fcreate(FILENAME, flags, H5P_DEFAULT, fapl)) < 0)
1866 TEST_ERROR
1867
1868 /* Create a group */
1869 if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
1870 TEST_ERROR
1871
1872 /* Commit the datatype with the group */
1873 if((tid1 = H5Tcopy(H5T_NATIVE_INT)) < 0)
1874 TEST_ERROR
1875 if(H5Tcommit2(gid, "datatype", tid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
1876 TEST_ERROR
1877
1878 /* Cork the named datatype */
1879 if(H5Odisable_mdc_flushes(tid1) < 0)
1880 TEST_ERROR
1881
1882 /* Set up dataset creation property list */
1883 if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
1884 TEST_ERROR
1885
1886 /* Enable chunking */
1887 if(H5Pset_chunk(dcpl, RANK, cdims) < 0)
1888 TEST_ERROR
1889
1890 /* Set up a fill value */
1891 if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fillval) < 0)
1892 TEST_ERROR
1893
1894 /* Create dataspace */
1895 dims[0] = DIMS0;
1896 dims[1] = DIMS1;
1897 if((sid = H5Screate_simple(RANK, dims, maxdims)) < 0)
1898 TEST_ERROR
1899
1900 /* Create the dataset inside the group with the named datatype */
1901 if((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
1902 TEST_ERROR
1903
1904 /* Check cork status of the named datatype */
1905 if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0)
1906 TEST_ERROR
1907 if(!corked)
1908 TEST_ERROR
1909
1910 /* Cork the dataset */
1911 if(H5Odisable_mdc_flushes(did1) < 0)
1912 TEST_ERROR
1913
1914 /* Check cork status of the dataset */
1915 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
1916 TEST_ERROR
1917 if(!corked)
1918 TEST_ERROR
1919
1920 /* Check cork status of the group */
1921 if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0)
1922 TEST_ERROR
1923 if(corked)
1924 TEST_ERROR
1925
1926 /* Initialize the buffer */
1927 for(i = 0; i < DIMS0;i++)
1928 for(j = 0;j < DIMS1;j++)
1929 data[i][j] = k++;
1930
1931 /* Write to the dataset */
1932 if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0)
1933 TEST_ERROR
1934
1935 /* Flush the dataset */
1936 if(H5Oflush(did1) < 0)
1937 TEST_ERROR
1938
1939 /* Check cork status of the dataset */
1940 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
1941 TEST_ERROR
1942 if(!corked)
1943 TEST_ERROR
1944
1945 /* Check cork status of the named datatype */
1946 if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0)
1947 TEST_ERROR
1948 if(!corked)
1949 TEST_ERROR
1950
1951 /* Close the dataset */
1952 if(H5Dclose(did1) < 0)
1953 TEST_ERROR
1954
1955 /* Open the dataset again */
1956 if((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0)
1957 TEST_ERROR
1958
1959 /* Check cork status of dataset */
1960 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
1961 TEST_ERROR
1962 if(corked)
1963 TEST_ERROR
1964
1965 /* Read from the dataset */
1966 if(H5Dread(did1, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
1967 TEST_ERROR
1968
1969 /* Cork the dataset */
1970 if(H5Odisable_mdc_flushes(did1) < 0)
1971 TEST_ERROR
1972
1973 /* Delete the dataset */
1974 if(H5Ldelete(gid, "dataset", H5P_DEFAULT) < 0)
1975 TEST_ERROR
1976
1977 /* Check cork status of the dataset */
1978 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
1979 TEST_ERROR
1980 if(!corked)
1981 TEST_ERROR
1982
1983 /* Close the dataset */
1984 if(H5Oclose(did1) < 0)
1985 TEST_ERROR
1986
1987 /* Create the dataset again */
1988 if((did1 = H5Dcreate2(gid, "dataset", tid1, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
1989 TEST_ERROR
1990
1991 /* Cork the dataset */
1992 if(H5Odisable_mdc_flushes(did1) < 0)
1993 TEST_ERROR
1994
1995 /* Write to the dataset */
1996 if(H5Dwrite(did1, tid1, sid, sid, H5P_DEFAULT, data) < 0)
1997 TEST_ERROR
1998
1999 /* Refresh the dataset */
2000 if(H5Drefresh(did1) < 0)
2001 TEST_ERROR
2002
2003 /* Check cork status of the dataset */
2004 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
2005 TEST_ERROR
2006 if(!corked)
2007 TEST_ERROR
2008
2009 /* Close the dataset */
2010 if(H5Dclose(did1) < 0)
2011 TEST_ERROR
2012
2013 /* First open of the dataset */
2014 if((did1 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0)
2015 TEST_ERROR
2016
2017 /* Second open of the dataset */
2018 if((did2 = H5Dopen2(gid, "dataset", H5P_DEFAULT)) < 0)
2019 TEST_ERROR
2020
2021 /* Cork the first opened dataset */
2022 if(H5Odisable_mdc_flushes(did1) < 0)
2023 TEST_ERROR
2024
2025 /* Check cork status of the first opened dataset */
2026 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
2027 TEST_ERROR
2028 if(!corked)
2029 TEST_ERROR
2030
2031 /* Check cork status of the second opened dataset */
2032 if(H5Oare_mdc_flushes_disabled(did2, &corked) < 0)
2033 TEST_ERROR
2034 if(!corked)
2035 TEST_ERROR
2036
2037 /* Close the second opened dataset */
2038 if(H5Dclose(did2) < 0)
2039 TEST_ERROR
2040
2041 /* Check cork status of the first opened dataset */
2042 if(H5Oare_mdc_flushes_disabled(did1, &corked) < 0)
2043 TEST_ERROR
2044 if(!corked)
2045 TEST_ERROR
2046
2047 /* Close the first opened dastaset */
2048 if(H5Dclose(did1) < 0)
2049 TEST_ERROR
2050
2051 /* Check cork status of the named datatype */
2052 if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0)
2053 TEST_ERROR
2054 if(!corked)
2055 TEST_ERROR
2056
2057 /* Second open of the named datatype */
2058 if((tid2 = H5Topen2(gid, "datatype", H5P_DEFAULT)) < 0)
2059 TEST_ERROR
2060
2061 /* Check cork status of the second opened named datatype */
2062 if(H5Oare_mdc_flushes_disabled(tid2, &corked) < 0)
2063 TEST_ERROR
2064 if(!corked)
2065 TEST_ERROR
2066
2067 /* Uncork the second opened named datatype */
2068 if(H5Oenable_mdc_flushes(tid2) < 0)
2069 TEST_ERROR
2070
2071 /* Check cork status of the second opened named datatype */
2072 if(H5Oare_mdc_flushes_disabled(tid2, &corked) < 0)
2073 TEST_ERROR
2074 if(corked)
2075 TEST_ERROR
2076
2077 /* Check cork status of the first opened named datatype */
2078 if(H5Oare_mdc_flushes_disabled(tid1, &corked) < 0)
2079 TEST_ERROR
2080 if(corked)
2081 TEST_ERROR
2082
2083 /* Close the first opened datatype */
2084 if(H5Tclose(tid1) < 0)
2085 TEST_ERROR
2086
2087 /* Close the second opened datatype */
2088 if(H5Tclose(tid2) < 0)
2089 TEST_ERROR
2090
2091 /* Check cork status of the group */
2092 if(H5Oare_mdc_flushes_disabled(gid, &corked) < 0)
2093 TEST_ERROR
2094 if(corked)
2095 TEST_ERROR
2096
2097 /* Closing */
2098 if(H5Gclose(gid) < 0)
2099 TEST_ERROR
2100 if(H5Sclose(sid) < 0)
2101 TEST_ERROR
2102 if(H5Pclose(fapl) < 0)
2103 TEST_ERROR
2104 if(H5Fclose(fid) < 0)
2105 TEST_ERROR
2106 if(H5Pclose(dcpl) < 0)
2107 TEST_ERROR
2108
2109 PASSED();
2110 return 0;
2111
2112 error:
2113 H5E_BEGIN_TRY {
2114 H5Sclose(sid);
2115 H5Dclose(did1);
2116 H5Dclose(did2);
2117 H5Tclose(tid1);
2118 H5Tclose(tid2);
2119 H5Pclose(dcpl);
2120 H5Gclose(gid);
2121 H5Pclose(fapl);
2122 H5Fclose(fid);
2123 } H5E_END_TRY;
2124 return 1;
2125
2126 } /* test_dset_cork() */
2127
2128
2129
2130 /*-------------------------------------------------------------------------
2131 * Function: main
2132 *
2133 * Purpose: Run tests to verify the library's corking operations.
2134 *
2135 * Return: Success:
2136 *
2137 * Failure:
2138 *
2139 * Programmer: Vailin Choi; Feb 2014
2140 *
2141 *-------------------------------------------------------------------------
2142 */
2143 int
main(void)2144 main(void)
2145 {
2146 unsigned swmr; /* Loop over SWMR/non-SWMR */
2147 unsigned nerrs = 0; /* Error Encountered */
2148
2149 /* Test for dataset created with old library format */
2150 nerrs += verify_old_dset_cork();
2151
2152 for(swmr = 0; swmr <= 1; swmr++) {
2153 /* Tests with new/old library format */
2154 /* This is the test moved from th5o.c: test_h5o_cork() */
2155 nerrs += test_objs_cork(swmr, TRUE);
2156 nerrs += test_objs_cork(swmr, FALSE);
2157 /* This is the test moved from th5o.c: test_h5o_cork_dataset() */
2158 nerrs += test_dset_cork(swmr, TRUE);
2159 nerrs += test_dset_cork(swmr, FALSE);
2160
2161 /* Tests with/without SWMR access */
2162 nerrs += verify_obj_dset_cork(swmr);
2163 nerrs += verify_dset_cork(swmr, TRUE);
2164 nerrs += verify_dset_cork(swmr, FALSE);
2165 nerrs += verify_group_cork(swmr);
2166 nerrs += verify_named_cork(swmr);
2167 nerrs += verify_multiple_cork(swmr);
2168 } /* end for */
2169
2170 /* Delete test files */
2171 HDremove(FILENAME);
2172
2173 /* Return Errors */
2174 return(nerrs > 0);
2175 } /* main */
2176
2177