1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* Programmer:  John Mainzer
15  *              7/13/15
16  *
17  *              This file contains tests specific to the cache image
18  *              feature implemented in H5C.c
19  */
20 #include "cache_common.h"
21 #include "genall5.h"
22 
23 /* global variable declarations: */
24 
25 
26 const char *FILENAMES[] = {
27         "cache_image_test",
28         NULL
29 };
30 
31 /* local utility function declarations */
32 static void create_datasets(hid_t file_id, int min_dset, int max_dset);
33 static void delete_datasets(hid_t file_id, int min_dset, int max_dset);
34 static void open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected,
35     hbool_t read_only, hbool_t set_mdci_fapl, hbool_t config_fsm,
36     hbool_t set_eoc, const char *hdf_file_name, unsigned cache_image_flags,
37     hid_t *file_id_ptr, H5F_t **file_ptr_ptr, H5C_t **cache_ptr_ptr);
38 static void attempt_swmr_open_hdf5_file(hbool_t create_file,
39     hbool_t set_mdci_fapl, const char *hdf_file_name);
40 static void verify_datasets(hid_t file_id, int min_dset, int max_dset);
41 
42 /* local test function declarations */
43 static unsigned check_cache_image_ctl_flow_1(void);
44 static unsigned check_cache_image_ctl_flow_2(void);
45 static unsigned check_cache_image_ctl_flow_3(void);
46 static unsigned check_cache_image_ctl_flow_4(void);
47 static unsigned check_cache_image_ctl_flow_5(void);
48 static unsigned check_cache_image_ctl_flow_6(void);
49 
50 static unsigned cache_image_smoke_check_1(void);
51 static unsigned cache_image_smoke_check_2(void);
52 static unsigned cache_image_smoke_check_3(void);
53 static unsigned cache_image_smoke_check_4(void);
54 static unsigned cache_image_smoke_check_5(void);
55 static unsigned cache_image_smoke_check_6(void);
56 
57 static unsigned cache_image_api_error_check_1(void);
58 static unsigned cache_image_api_error_check_2(void);
59 static unsigned cache_image_api_error_check_3(void);
60 static unsigned cache_image_api_error_check_4(void);
61 
62 static unsigned get_free_sections_test(void);
63 static unsigned evict_on_close_test(void);
64 
65 /****************************************************************************/
66 /***************************** Utility Functions ****************************/
67 /****************************************************************************/
68 
69 /*-------------------------------------------------------------------------
70  * Function:    create_datasets()
71  *
72  * Purpose:     If pass is TRUE on entry, create the specified datasets
73  *        in the indicated file.
74  *
75  *        Datasets and their contents must be well known, as we
76  *        will verify that they contain the expected data later.
77  *
78  *              On failure, set pass to FALSE, and set failure_mssg
79  *              to point to an appropriate failure message.
80  *
81  *              Do nothing if pass is FALSE on entry.
82  *
83  * Return:      void
84  *
85  * Programmer:  John Mainzer
86  *              7/15/15
87  *
88  *-------------------------------------------------------------------------
89  */
90 
91 #define CHUNK_SIZE              10
92 #define DSET_SIZE               (40 * CHUNK_SIZE)
93 #define MAX_NUM_DSETS           256
94 
95 static void
create_datasets(hid_t file_id,int min_dset,int max_dset)96 create_datasets(hid_t file_id, int min_dset, int max_dset)
97 {
98     const char * fcn_name = "create_datasets()";
99     char dset_name[64];
100     hbool_t show_progress = FALSE;
101     hbool_t valid_chunk;
102     hbool_t verbose = FALSE;
103     int cp = 0;
104     int i, j, k, l, m;
105     int data_chunk[CHUNK_SIZE][CHUNK_SIZE];
106     herr_t status;
107     hid_t dataspace_id = -1;
108     hid_t filespace_ids[MAX_NUM_DSETS];
109     hid_t memspace_id = -1;
110     hid_t dataset_ids[MAX_NUM_DSETS];
111     hid_t properties = -1;
112     hsize_t dims[2];
113     hsize_t a_size[2];
114     hsize_t offset[2];
115     hsize_t chunk_size[2];
116 
117     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
118 
119     HDassert(0 <= min_dset);
120     HDassert(min_dset <= max_dset);
121     HDassert(max_dset < MAX_NUM_DSETS);
122 
123     /* create the datasets */
124 
125     if ( pass ) {
126 
127         i = min_dset;
128 
129         while ( ( pass ) && ( i <= max_dset ) )
130         {
131             /* create a dataspace for the chunked dataset */
132             dims[0] = DSET_SIZE;
133             dims[1] = DSET_SIZE;
134             dataspace_id = H5Screate_simple(2, dims, NULL);
135 
136             if ( dataspace_id < 0 ) {
137 
138                 pass = FALSE;
139                 failure_mssg = "H5Screate_simple() failed.";
140             }
141 
142             /* set the dataset creation plist to specify that the raw data is
143              * to be partioned into 10X10 element chunks.
144              */
145 
146             if ( pass ) {
147 
148                 chunk_size[0] = CHUNK_SIZE;
149                 chunk_size[1] = CHUNK_SIZE;
150                 properties = H5Pcreate(H5P_DATASET_CREATE);
151 
152                 if ( properties < 0 ) {
153 
154                     pass = FALSE;
155                     failure_mssg = "H5Pcreate() failed.";
156                 }
157             }
158 
159             if ( pass ) {
160 
161                 if ( H5Pset_chunk(properties, 2, chunk_size) < 0 ) {
162 
163                     pass = FALSE;
164                     failure_mssg = "H5Pset_chunk() failed.";
165                 }
166             }
167 
168             /* create the dataset */
169             if ( pass ) {
170 
171                 HDsprintf(dset_name, "/dset%03d", i);
172                 dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE,
173                                             dataspace_id, H5P_DEFAULT,
174                                             properties, H5P_DEFAULT);
175 
176                 if ( dataset_ids[i] < 0 ) {
177 
178                     pass = FALSE;
179                     failure_mssg = "H5Dcreate() failed.";
180                 }
181             }
182 
183             /* get the file space ID */
184             if ( pass ) {
185 
186                 filespace_ids[i] = H5Dget_space(dataset_ids[i]);
187 
188                 if ( filespace_ids[i] < 0 ) {
189 
190                     pass = FALSE;
191                     failure_mssg = "H5Dget_space() failed.";
192                 }
193             }
194 
195             i++;
196         }
197     }
198 
199     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
200 
201     /* create the mem space to be used to read and write chunks */
202     if ( pass ) {
203 
204         dims[0] = CHUNK_SIZE;
205         dims[1] = CHUNK_SIZE;
206         memspace_id = H5Screate_simple(2, dims, NULL);
207 
208         if ( memspace_id < 0 ) {
209 
210             pass = FALSE;
211             failure_mssg = "H5Screate_simple() failed.";
212         }
213     }
214 
215     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
216 
217     /* select in memory hyperslab */
218     if ( pass ) {
219 
220         offset[0] = 0;  /*offset of hyperslab in memory*/
221         offset[1] = 0;
222         a_size[0] = CHUNK_SIZE;  /*size of hyperslab*/
223         a_size[1] = CHUNK_SIZE;
224         status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL,
225                                      a_size, NULL);
226 
227         if ( status < 0 ) {
228 
229             pass = FALSE;
230             failure_mssg = "H5Sselect_hyperslab() failed.";
231         }
232     }
233 
234     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
235 
236     /* initialize all datasets on a round robin basis */
237     i = 0;
238     while ( ( pass ) && ( i < DSET_SIZE ) )
239     {
240         j = 0;
241         while ( ( pass ) && ( j < DSET_SIZE ) )
242         {
243             m = min_dset;
244             while ( ( pass ) && ( m <= max_dset ) )
245             {
246                 /* initialize the slab */
247                 for ( k = 0; k < CHUNK_SIZE; k++ )
248                 {
249                     for ( l = 0; l < CHUNK_SIZE; l++ )
250                     {
251                         data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) +
252                                            (DSET_SIZE * (i + k)) + j + l;
253                     }
254                 }
255 
256                 /* select on disk hyperslab */
257                 offset[0] = (hsize_t)i; /*offset of hyperslab in file*/
258                 offset[1] = (hsize_t)j;
259                 a_size[0] = CHUNK_SIZE;   /*size of hyperslab*/
260                 a_size[1] = CHUNK_SIZE;
261                 status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET,
262                                              offset, NULL, a_size, NULL);
263 
264                 if ( status < 0 ) {
265 
266                     pass = FALSE;
267                     failure_mssg = "disk H5Sselect_hyperslab() failed.";
268                 }
269 
270                 /* write the chunk to file */
271                 status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id,
272                                   filespace_ids[m], H5P_DEFAULT, data_chunk);
273 
274                 if ( status < 0 ) {
275 
276                     pass = FALSE;
277                     failure_mssg = "H5Dwrite() failed.";
278                 }
279                 m++;
280             }
281             j += CHUNK_SIZE;
282         }
283 
284         i += CHUNK_SIZE;
285     }
286 
287     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
288 
289     /* read data from datasets and validate it */
290     i = 0;
291     while ( ( pass ) && ( i < DSET_SIZE ) )
292     {
293         j = 0;
294         while ( ( pass ) && ( j < DSET_SIZE ) )
295         {
296             m = min_dset;
297             while ( ( pass ) && ( m <= max_dset ) )
298             {
299 
300                 /* select on disk hyperslab */
301                 offset[0] = (hsize_t)i; /* offset of hyperslab in file */
302                 offset[1] = (hsize_t)j;
303                 a_size[0] = CHUNK_SIZE; /* size of hyperslab */
304                 a_size[1] = CHUNK_SIZE;
305                 status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET,
306                                              offset, NULL, a_size, NULL);
307 
308                 if ( status < 0 ) {
309 
310                    pass = FALSE;
311                    failure_mssg = "disk hyperslab create failed.";
312                 }
313 
314                 /* read the chunk from file */
315                 if ( pass ) {
316 
317                     status = H5Dread(dataset_ids[m], H5T_NATIVE_INT,
318                                      memspace_id, filespace_ids[m],
319                                      H5P_DEFAULT, data_chunk);
320 
321                     if ( status < 0 ) {
322 
323                        pass = FALSE;
324                        failure_mssg = "disk hyperslab create failed.";
325                     }
326                 }
327 
328                 /* validate the slab */
329                 if ( pass ) {
330 
331                     valid_chunk = TRUE;
332                     for ( k = 0; k < CHUNK_SIZE; k++ )
333                     {
334                         for ( l = 0; l < CHUNK_SIZE; l++ )
335                         {
336                             if ( data_chunk[k][l]
337                                  !=
338                                  ((DSET_SIZE * DSET_SIZE * m) +
339                                   (DSET_SIZE * (i + k)) + j + l) ) {
340 
341                                 valid_chunk = FALSE;
342 
343                 if ( verbose ) {
344 
345                                     HDfprintf(stdout,
346                                     "data_chunk[%0d][%0d] = %0d, expect %0d.\n",
347                                     k, l, data_chunk[k][l],
348                                     ((DSET_SIZE * DSET_SIZE * m) +
349                                      (DSET_SIZE * (i + k)) + j + l));
350                                     HDfprintf(stdout,
351                                     "m = %d, i = %d, j = %d, k = %d, l = %d\n",
352                                     m, i, j, k, l);
353                 }
354                             }
355                         }
356                     }
357 
358                     if ( ! valid_chunk ) {
359 
360                         pass = FALSE;
361                         failure_mssg = "slab validation failed.";
362 
363             if ( verbose ) {
364 
365                 HDfprintf(stdout,
366                                   "Chunk (%0d, %0d) in /dset%03d is invalid.\n",
367                                   i, j, m);
368             }
369                     }
370                 }
371                 m++;
372             }
373             j += CHUNK_SIZE;
374         }
375         i += CHUNK_SIZE;
376     }
377 
378     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
379 
380     /* close the file spaces */
381     i = min_dset;
382     while ( ( pass ) && ( i <= max_dset ) )
383     {
384         if ( H5Sclose(filespace_ids[i]) < 0 ) {
385 
386             pass = FALSE;
387             failure_mssg = "H5Sclose() failed.";
388         }
389         i++;
390     }
391 
392 
393     /* close the datasets */
394     i = min_dset;
395     while ( ( pass ) && ( i <= max_dset ) )
396     {
397         if ( H5Dclose(dataset_ids[i]) < 0 ) {
398 
399             pass = FALSE;
400             failure_mssg = "H5Dclose() failed.";
401         }
402         i++;
403     }
404 
405     /* close the mem space */
406     if ( pass ) {
407 
408         if ( H5Sclose(memspace_id) < 0 ) {
409 
410             pass = FALSE;
411             failure_mssg = "H5Sclose(memspace_id) failed.";
412         }
413     }
414 
415     return;
416 
417 } /* create_datasets() */
418 
419 
420 /*-------------------------------------------------------------------------
421  * Function:    delete_datasets()
422  *
423  * Purpose:     If pass is TRUE on entry, verify and then delete the
424  *        dataset(s) indicated by min_dset and max_dset in the
425  *        indicated file.
426  *
427  *        Datasets and their contents must be well know, as we
428  *        will verify that they contain the expected data later.
429  *
430  *              On failure, set pass to FALSE, and set failure_mssg
431  *              to point to an appropriate failure message.
432  *
433  *              Do nothing if pass is FALSE on entry.
434  *
435  * Return:      void
436  *
437  * Programmer:  John Mainzer
438  *              10/31/16
439  *
440  *-------------------------------------------------------------------------
441  */
442 
443 static void
delete_datasets(hid_t file_id,int min_dset,int max_dset)444 delete_datasets(hid_t file_id, int min_dset, int max_dset)
445 {
446     const char * fcn_name = "delete_datasets()";
447     char dset_name[64];
448     hbool_t show_progress = FALSE;
449     int cp = 0;
450     int i;
451 
452     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
453 
454     HDassert(0 <= min_dset);
455     HDassert(min_dset <= max_dset);
456     HDassert(max_dset < MAX_NUM_DSETS);
457 
458     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
459 
460     /* first, verify the contents of the target dataset(s) */
461     verify_datasets(file_id, min_dset, max_dset);
462 
463     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
464 
465     /* now delete the target datasets */
466     if ( pass ) {
467 
468         i = min_dset;
469 
470         while ( ( pass ) && ( i <= max_dset ) )
471         {
472             HDsprintf(dset_name, "/dset%03d", i);
473 
474         if ( H5Ldelete(file_id, dset_name, H5P_DEFAULT) < 0) {
475 
476                 pass = FALSE;
477                 failure_mssg = "H5Ldelete() failed.";
478         }
479 
480             i++;
481         }
482     }
483 
484     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
485 
486     return;
487 
488 } /* delete_datasets() */
489 
490 
491 /*-------------------------------------------------------------------------
492  * Function:    open_hdf5_file()
493  *
494  * Purpose:     If pass is true on entry, create or open the specified HDF5
495  *        and test to see if it has a metadata cache image superblock
496  *        extension message.
497  *
498  *        Set pass to FALSE and issue a suitable failure
499  *        message if either the file contains a metadata cache image
500  *        superblock extension and mdci_sbem_expected is TRUE, or
501  *        vise versa.
502  *
503  *        If mdci_sbem_expected is TRUE, also verify that the metadata
504  *        cache has been advised of this.
505  *
506  *        If read_only is TRUE, open the file read only.  Otherwise
507  *        open the file read/write.
508  *
509  *        If set_mdci_fapl is TRUE, set the metadata cache image
510  *        FAPL entry when opening the file, and verify that the
511  *        metadata cache is notified.
512  *
513  *        If config_fsm is TRUE, setup the persistent free space
514  *        manager.  Note that this flag may only be set if
515  *        create_file is also TRUE.
516  *
517  *              Return pointers to the cache data structure and file data
518  *              structures.
519  *
520  *              On failure, set pass to FALSE, and set failure_mssg
521  *              to point to an appropriate failure message.
522  *
523  *              Do nothing if pass is FALSE on entry.
524  *
525  * Return:      void
526  *
527  * Programmer:  John Mainzer
528  *              7/14/15
529  *
530  *-------------------------------------------------------------------------
531  */
532 
533 static void
open_hdf5_file(hbool_t create_file,hbool_t mdci_sbem_expected,hbool_t read_only,hbool_t set_mdci_fapl,hbool_t config_fsm,hbool_t set_eoc,const char * hdf_file_name,unsigned cache_image_flags,hid_t * file_id_ptr,H5F_t ** file_ptr_ptr,H5C_t ** cache_ptr_ptr)534 open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected,
535     hbool_t read_only, hbool_t set_mdci_fapl, hbool_t config_fsm,
536     hbool_t set_eoc, const char *hdf_file_name, unsigned cache_image_flags,
537     hid_t *file_id_ptr, H5F_t ** file_ptr_ptr, H5C_t ** cache_ptr_ptr)
538 {
539     const char * fcn_name = "open_hdf5_file()";
540     hbool_t show_progress = FALSE;
541     hbool_t verbose = FALSE;
542     int cp = 0;
543     hid_t fapl_id = -1;
544     hid_t fcpl_id = -1;
545     hid_t file_id = -1;
546     herr_t result;
547     H5F_t * file_ptr = NULL;
548     H5C_t * cache_ptr = NULL;
549     H5C_cache_image_ctl_t image_ctl;
550     H5AC_cache_image_config_t cache_image_config = {
551         H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION,
552         TRUE,
553         FALSE,
554         H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE};
555 
556     if ( pass )
557     {
558     /* opening the file both read only and with a cache image
559          * requested is a contradiction.  We resolve it by ignoring
560          * the cache image request silently.
561          */
562         if ( ( create_file && mdci_sbem_expected ) ||
563              ( create_file && read_only ) ||
564              ( config_fsm && !create_file ) ||
565              ( hdf_file_name == NULL ) ||
566              ( ( set_mdci_fapl ) && ( cache_image_flags == 0 ) ) ||
567              ( ( set_mdci_fapl ) &&
568                ( (cache_image_flags & ~H5C_CI__ALL_FLAGS) != 0 ) ) ||
569              ( file_id_ptr == NULL ) ||
570              ( file_ptr_ptr == NULL ) ||
571              ( cache_ptr_ptr == NULL ) ) {
572 
573             failure_mssg =
574                "Bad param(s) on entry to open_hdf5_file().\n";
575             pass = FALSE;
576         } else  if ( verbose ) {
577 
578             HDfprintf(stdout, "%s: HDF file name = \"%s\".\n",
579                       fcn_name, hdf_file_name);
580         }
581     }
582 
583     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
584 
585     /* create a file access propertly list. */
586     if ( pass ) {
587 
588         fapl_id = H5Pcreate(H5P_FILE_ACCESS);
589 
590         if ( fapl_id < 0 ) {
591 
592             pass = FALSE;
593             failure_mssg = "H5Pcreate() failed.\n";
594         }
595     }
596 
597     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
598 
599     /* call H5Pset_libver_bounds() on the fapl_id */
600     if ( pass ) {
601 
602         if ( H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST,
603                                   H5F_LIBVER_LATEST) < 0 ) {
604 
605             pass = FALSE;
606             failure_mssg = "H5Pset_libver_bounds() failed.\n";
607         }
608     }
609 
610     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
611 
612     /* get metadata cache image config -- verify that it is the default */
613     if ( pass ) {
614 
615         result = H5Pget_mdc_image_config(fapl_id, &cache_image_config);
616 
617         if ( result < 0 ) {
618 
619             pass = FALSE;
620             failure_mssg = "H5Pget_mdc_image_config() failed.\n";
621         }
622 
623         if ( ( cache_image_config.version !=
624                H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) ||
625              ( cache_image_config.generate_image != FALSE ) ||
626              ( cache_image_config.save_resize_status != FALSE ) ||
627              ( cache_image_config.entry_ageout !=
628                H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) ) {
629 
630             pass = FALSE;
631             failure_mssg = "Unexpected default cache image config.\n";
632         }
633     }
634 
635     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
636 
637     /* set metadata cache image fapl entry if indicated */
638     if ( ( pass ) && ( set_mdci_fapl ) ) {
639 
640         /* set cache image config fields to taste */
641         cache_image_config.generate_image = TRUE;
642         cache_image_config.save_resize_status = FALSE;
643         cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE;
644 
645         result = H5Pset_mdc_image_config(fapl_id, &cache_image_config);
646 
647         if ( result < 0 ) {
648 
649             pass = FALSE;
650             failure_mssg = "H5Pset_mdc_image_config() failed.\n";
651         }
652     }
653 
654     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
655 
656     /* setup the persistent free space manager if indicated */
657     if ( ( pass ) && ( config_fsm ) ) {
658 
659     fcpl_id = H5Pcreate(H5P_FILE_CREATE);
660 
661     if ( fcpl_id <= 0 ) {
662 
663         pass = FALSE;
664         failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.";
665     }
666     }
667 
668     if ( ( pass ) && ( config_fsm ) ) {
669         if(H5Pset_file_space_strategy(fcpl_id, H5F_FSPACE_STRATEGY_PAGE,
670                                       TRUE, (hsize_t)1) < 0) {
671             pass = FALSE;
672             failure_mssg = "H5Pset_file_space_strategy() failed.";
673         }
674     }
675 
676     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
677 
678     /* set evict on close if indicated */
679     if ( ( pass ) && ( set_eoc ) ) {
680 
681         if ( H5Pset_evict_on_close(fapl_id, TRUE) < 0 ) {
682 
683             pass = FALSE;
684             failure_mssg = "H5Pset_evict_on_close() failed.";
685         }
686     }
687 
688     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
689 
690     /* open the file */
691     if ( pass ) {
692 
693         if ( create_file ) {
694 
695         if ( fcpl_id != -1 )
696 
697                 file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC,
698                                     fcpl_id, fapl_id);
699         else
700 
701         file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC,
702                                     H5P_DEFAULT, fapl_id);
703 
704         } else {
705 
706             if ( read_only )
707 
708                 file_id = H5Fopen(hdf_file_name, H5F_ACC_RDONLY, fapl_id);
709 
710             else
711 
712                 file_id = H5Fopen(hdf_file_name, H5F_ACC_RDWR, fapl_id);
713         }
714 
715         /* tidy up */
716         H5Pclose(fapl_id);
717 
718         if ( file_id < 0 ) {
719 
720             pass = FALSE;
721             failure_mssg = "H5Fcreate() or H5Fopen() failed.\n";
722 
723         } else {
724 
725             file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE);
726 
727             if ( file_ptr == NULL ) {
728 
729                 pass = FALSE;
730                 failure_mssg = "Can't get file_ptr.";
731 
732                 if ( verbose ) {
733                     HDfprintf(stdout, "%s: Can't get file_ptr.\n", fcn_name);
734                 }
735             }
736         }
737     }
738 
739     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
740 
741     /* get a pointer to the files internal data structure and then
742      * to the cache structure
743      */
744     if ( pass ) {
745 
746         if ( file_ptr->shared->cache == NULL ) {
747 
748             pass = FALSE;
749             failure_mssg = "can't get cache pointer(1).\n";
750 
751         } else {
752 
753             cache_ptr = file_ptr->shared->cache;
754         }
755     }
756 
757     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
758 
759     /* verify expected metadata cache status */
760 
761     /* get the cache image control structure from the cache, and verify
762      * that it contains the expected values.
763      *
764      * Then set the flags in this structure to the specified value.
765      */
766     if ( pass ) {
767 
768         if ( H5C_get_cache_image_config(cache_ptr, &image_ctl) < 0 ) {
769 
770             pass = FALSE;
771             failure_mssg = "error returned by H5C_get_cache_image_config().";
772         }
773     }
774 
775     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
776 
777     if ( pass ) {
778 
779         if ( set_mdci_fapl ) {
780 
781         if ( read_only ) {
782 
783                 if ( ( image_ctl.version !=
784                        H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) ||
785                      ( image_ctl.generate_image != FALSE ) ||
786                      ( image_ctl.save_resize_status != FALSE ) ||
787                      ( image_ctl.entry_ageout !=
788                        H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) ||
789                      ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) {
790 
791                     pass = FALSE;
792                     failure_mssg = "Unexpected image_ctl values(1).\n";
793                 }
794         } else {
795 
796                 if ( ( image_ctl.version !=
797                        H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) ||
798                      ( image_ctl.generate_image != TRUE ) ||
799                      ( image_ctl.save_resize_status != FALSE ) ||
800                      ( image_ctl.entry_ageout !=
801                        H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) ||
802                      ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) {
803 
804                     pass = FALSE;
805                     failure_mssg = "Unexpected image_ctl values(2).\n";
806                 }
807             }
808         } else {
809 
810             if ( ( image_ctl.version !=
811                    H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION ) ||
812                  ( image_ctl.generate_image != FALSE ) ||
813                  ( image_ctl.save_resize_status != FALSE ) ||
814                  ( image_ctl.entry_ageout !=
815                    H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE ) ||
816                  ( image_ctl.flags != H5C_CI__ALL_FLAGS ) ) {
817 
818                 pass = FALSE;
819                 failure_mssg = "Unexpected image_ctl values(3).\n";
820             }
821         }
822     }
823 
824     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
825 
826     if ( ( pass ) && ( set_mdci_fapl ) ) {
827 
828         image_ctl.flags = cache_image_flags;
829 
830         if ( H5C_set_cache_image_config(file_ptr, cache_ptr, &image_ctl) < 0 ) {
831 
832             pass = FALSE;
833             failure_mssg = "error returned by H5C_set_cache_image_config().";
834         }
835     }
836 
837     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
838 
839     if ( pass ) {
840 
841         if ( cache_ptr->close_warning_received == TRUE ) {
842 
843             pass = FALSE;
844             failure_mssg = "Unexpected value of close_warning_received.\n";
845         }
846 
847         if ( mdci_sbem_expected ) {
848 
849             if ( read_only ) {
850 
851                 if ( ( cache_ptr->load_image != TRUE ) ||
852                      ( cache_ptr->delete_image != FALSE ) ) {
853 
854                     pass = FALSE;
855                     failure_mssg = "mdci sb extension message not present?\n";
856                 }
857             } else {
858 
859                 if ( ( cache_ptr->load_image != TRUE ) ||
860                      ( cache_ptr->delete_image != TRUE ) ) {
861 
862                     pass = FALSE;
863                     failure_mssg = "mdci sb extension message not present?\n";
864                 }
865         }
866         } else {
867 
868         if ( ( cache_ptr->load_image == TRUE ) ||
869                  ( cache_ptr->delete_image == TRUE ) ) {
870 
871                 pass = FALSE;
872                 failure_mssg = "mdci sb extension message present?\n";
873         }
874         }
875     }
876 
877     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
878 
879     if ( pass ) {
880 
881         *file_id_ptr = file_id;
882         *file_ptr_ptr = file_ptr;
883         *cache_ptr_ptr = cache_ptr;
884     }
885 
886     if ( show_progress )
887         HDfprintf(stdout, "%s: cp = %d -- exiting.\n", fcn_name, cp++);
888 
889     return;
890 
891 } /* open_hdf5_file() */
892 
893 
894 /*-------------------------------------------------------------------------
895  * Function:    attempt_swmr_open_hdf5_file()
896  *
897  * Purpose:     If pass is true on entry, attempt to create or open the
898  *        specified HDF5 file with SWMR, and also with cache image
899  *              creation if requested.
900  *
901  *              In all cases, the attempted open or create should fail.
902  *
903  *              Do nothing if pass is FALSE on entry.
904  *
905  * Return:      void
906  *
907  * Programmer:  John Mainzer
908  *              7/14/15
909  *
910  *-------------------------------------------------------------------------
911  */
912 
913 static void
attempt_swmr_open_hdf5_file(const hbool_t create_file,const hbool_t set_mdci_fapl,const char * hdf_file_name)914 attempt_swmr_open_hdf5_file(const hbool_t create_file,
915                         const hbool_t set_mdci_fapl,
916                         const char * hdf_file_name)
917 {
918     const char * fcn_name = "attempt_swmr_open_hdf5_file()";
919     hbool_t show_progress = FALSE;
920     int cp = 0;
921     hid_t fapl_id = -1;
922     hid_t file_id = -1;
923     herr_t result;
924     H5AC_cache_image_config_t cache_image_config = {
925         H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION,
926         TRUE,
927         FALSE,
928         H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE};
929 
930     /* create a file access propertly list. */
931     if ( pass ) {
932 
933         fapl_id = H5Pcreate(H5P_FILE_ACCESS);
934 
935         if ( fapl_id < 0 ) {
936 
937             pass = FALSE;
938             failure_mssg = "H5Pcreate() failed.\n";
939         }
940     }
941 
942     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
943 
944     /* call H5Pset_libver_bounds() on the fapl_id */
945     if ( pass ) {
946 
947         if ( H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)
948                 < 0 ) {
949 
950             pass = FALSE;
951             failure_mssg = "H5Pset_libver_bounds() failed.\n";
952         }
953     }
954 
955     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
956 
957     /* set metadata cache image fapl entry if indicated */
958     if ( ( pass ) && ( set_mdci_fapl ) ) {
959 
960         /* set cache image config fields to taste */
961         cache_image_config.generate_image = TRUE;
962         cache_image_config.save_resize_status = FALSE;
963         cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE;
964 
965         result = H5Pset_mdc_image_config(fapl_id, &cache_image_config);
966 
967         if ( result < 0 ) {
968 
969             pass = FALSE;
970             failure_mssg = "H5Pset_mdc_image_config() failed.\n";
971         }
972     }
973 
974     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
975 
976     /* open the file */
977     if ( pass ) {
978 
979         if ( create_file ) {
980 
981             H5E_BEGIN_TRY {
982                 file_id = H5Fcreate(hdf_file_name, H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE,
983                         H5P_DEFAULT, fapl_id);
984             } H5E_END_TRY;
985         } else {
986 
987             H5E_BEGIN_TRY {
988                 file_id = H5Fopen(hdf_file_name, H5F_ACC_RDWR | H5F_ACC_SWMR_WRITE, fapl_id);
989             } H5E_END_TRY;
990         }
991 
992         if ( file_id >= 0 ) {
993 
994             pass = FALSE;
995             failure_mssg = "SWMR H5Fcreate() or H5Fopen() succeeded.\n";
996 
997         }
998     }
999 
1000     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
1001 
1002     return;
1003 
1004 } /* attempt_swmr_open_hdf5_file() */
1005 
1006 
1007 /*-------------------------------------------------------------------------
1008  * Function:    verify_datasets()
1009  *
1010  * Purpose:     If pass is TRUE on entry, verify that the datasets in the
1011  *        file exist and contain the expected data.
1012  *
1013  *        Note that these datasets were created by
1014  *        create_datasets() above.  Thus any changes in that
1015  *        function must be reflected in this function, and
1016  *        vise-versa.
1017  *
1018  *              On failure, set pass to FALSE, and set failure_mssg
1019  *              to point to an appropriate failure message.
1020  *
1021  *              Do nothing if pass is FALSE on entry.
1022  *
1023  * Return:      void
1024  *
1025  * Programmer:  John Mainzer
1026  *              7/15/15
1027  *
1028  *-------------------------------------------------------------------------
1029  */
1030 
1031 static void
verify_datasets(hid_t file_id,int min_dset,int max_dset)1032 verify_datasets(hid_t file_id, int min_dset, int max_dset)
1033 {
1034     const char * fcn_name = "verify_datasets()";
1035     char dset_name[64];
1036     hbool_t show_progress = FALSE;
1037     hbool_t valid_chunk;
1038     hbool_t verbose = FALSE;
1039     int cp = 0;
1040     int i, j, k, l, m;
1041     int data_chunk[CHUNK_SIZE][CHUNK_SIZE];
1042     herr_t status;
1043     hid_t filespace_ids[MAX_NUM_DSETS];
1044     hid_t memspace_id = -1;
1045     hid_t dataset_ids[MAX_NUM_DSETS];
1046     hsize_t dims[2];
1047     hsize_t a_size[2];
1048     hsize_t offset[2];
1049 
1050     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
1051 
1052     HDassert(0 <= min_dset);
1053     HDassert(min_dset <= max_dset);
1054     HDassert(max_dset < MAX_NUM_DSETS);
1055 
1056     /* open the datasets */
1057 
1058     if ( pass ) {
1059 
1060         i = min_dset;
1061 
1062         while ( ( pass ) && ( i <= max_dset ) )
1063         {
1064             /* open the dataset */
1065             if ( pass ) {
1066 
1067                 HDsprintf(dset_name, "/dset%03d", i);
1068                 dataset_ids[i] = H5Dopen2(file_id, dset_name, H5P_DEFAULT);
1069 
1070                 if ( dataset_ids[i] < 0 ) {
1071 
1072                     pass = FALSE;
1073                     failure_mssg = "H5Dopen2() failed.";
1074                 }
1075             }
1076 
1077             /* get the file space ID */
1078             if ( pass ) {
1079 
1080                 filespace_ids[i] = H5Dget_space(dataset_ids[i]);
1081 
1082                 if ( filespace_ids[i] < 0 ) {
1083 
1084                     pass = FALSE;
1085                     failure_mssg = "H5Dget_space() failed.";
1086                 }
1087             }
1088 
1089             i++;
1090         }
1091     }
1092 
1093     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
1094 
1095     /* create the mem space to be used to read and write chunks */
1096     if ( pass ) {
1097 
1098         dims[0] = CHUNK_SIZE;
1099         dims[1] = CHUNK_SIZE;
1100         memspace_id = H5Screate_simple(2, dims, NULL);
1101 
1102         if ( memspace_id < 0 ) {
1103 
1104             pass = FALSE;
1105             failure_mssg = "H5Screate_simple() failed.";
1106         }
1107     }
1108 
1109     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
1110 
1111     /* select in memory hyperslab */
1112     if ( pass ) {
1113 
1114         offset[0] = 0;  /*offset of hyperslab in memory*/
1115         offset[1] = 0;
1116         a_size[0] = CHUNK_SIZE;  /*size of hyperslab*/
1117         a_size[1] = CHUNK_SIZE;
1118         status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL,
1119                                      a_size, NULL);
1120 
1121         if ( status < 0 ) {
1122 
1123             pass = FALSE;
1124             failure_mssg = "H5Sselect_hyperslab() failed.";
1125         }
1126     }
1127 
1128     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
1129 
1130 
1131     /* read data from datasets and validate it */
1132     i = 0;
1133     while ( ( pass ) && ( i < DSET_SIZE ) )
1134     {
1135         j = 0;
1136         while ( ( pass ) && ( j < DSET_SIZE ) )
1137         {
1138             m = min_dset;
1139             while ( ( pass ) && ( m <= max_dset ) )
1140             {
1141 
1142                 /* select on disk hyperslab */
1143                 offset[0] = (hsize_t)i; /* offset of hyperslab in file */
1144                 offset[1] = (hsize_t)j;
1145                 a_size[0] = CHUNK_SIZE; /* size of hyperslab */
1146                 a_size[1] = CHUNK_SIZE;
1147                 status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET,
1148                                              offset, NULL, a_size, NULL);
1149 
1150                 if ( status < 0 ) {
1151 
1152                    pass = FALSE;
1153                    failure_mssg = "disk hyperslab create failed.";
1154                 }
1155 
1156                 /* read the chunk from file */
1157                 if ( pass ) {
1158 
1159                     status = H5Dread(dataset_ids[m], H5T_NATIVE_INT,
1160                                      memspace_id, filespace_ids[m],
1161                                      H5P_DEFAULT, data_chunk);
1162 
1163                     if ( status < 0 ) {
1164 
1165                        pass = FALSE;
1166                        failure_mssg = "disk hyperslab create failed.";
1167                     }
1168                 }
1169 
1170                 /* validate the slab */
1171                 if ( pass ) {
1172 
1173                     valid_chunk = TRUE;
1174                     for ( k = 0; k < CHUNK_SIZE; k++ )
1175                     {
1176                         for ( l = 0; l < CHUNK_SIZE; l++ )
1177                         {
1178                             if ( data_chunk[k][l]
1179                                  !=
1180                                  ((DSET_SIZE * DSET_SIZE * m) +
1181                                   (DSET_SIZE * (i + k)) + j + l) ) {
1182 
1183                                 valid_chunk = FALSE;
1184 
1185                 if ( verbose ) {
1186 
1187                                     HDfprintf(stdout,
1188                                     "data_chunk[%0d][%0d] = %0d, expect %0d.\n",
1189                                     k, l, data_chunk[k][l],
1190                                     ((DSET_SIZE * DSET_SIZE * m) +
1191                                      (DSET_SIZE * (i + k)) + j + l));
1192                                     HDfprintf(stdout,
1193                                      "m = %d, i = %d, j = %d, k = %d, l = %d\n",
1194                                      m, i, j, k, l);
1195                 }
1196                             }
1197                         }
1198                     }
1199 
1200                     if ( ! valid_chunk ) {
1201 
1202                         pass = FALSE;
1203                         failure_mssg = "slab validation failed.";
1204 
1205             if ( verbose ) {
1206 
1207                 HDfprintf(stdout,
1208                                   "Chunk (%0d, %0d) in /dset%03d is invalid.\n",
1209                                   i, j, m);
1210             }
1211                     }
1212                 }
1213                 m++;
1214             }
1215             j += CHUNK_SIZE;
1216         }
1217         i += CHUNK_SIZE;
1218     }
1219 
1220     if ( show_progress ) HDfprintf(stdout, "%s: cp = %d.\n", fcn_name, cp++);
1221 
1222     /* close the file spaces */
1223     i = min_dset;
1224     while ( ( pass ) && ( i <= max_dset ) )
1225     {
1226         if ( H5Sclose(filespace_ids[i]) < 0 ) {
1227 
1228             pass = FALSE;
1229             failure_mssg = "H5Sclose() failed.";
1230         }
1231         i++;
1232     }
1233 
1234 
1235     /* close the datasets */
1236     i = min_dset;
1237     while ( ( pass ) && ( i <= max_dset ) )
1238     {
1239         if ( H5Dclose(dataset_ids[i]) < 0 ) {
1240 
1241             pass = FALSE;
1242             failure_mssg = "H5Dclose() failed.";
1243         }
1244         i++;
1245     }
1246 
1247     /* close the mem space */
1248     if ( pass ) {
1249 
1250         if ( H5Sclose(memspace_id) < 0 ) {
1251 
1252             pass = FALSE;
1253             failure_mssg = "H5Sclose(memspace_id) failed.";
1254         }
1255     }
1256 
1257     return;
1258 
1259 } /* verify_datasets() */
1260 
1261 
1262 /****************************************************************************/
1263 /******************************* Test Functions *****************************/
1264 /****************************************************************************/
1265 
1266 /*-------------------------------------------------------------------------
1267  * Function:    check_cache_image_ctl_flow_1()
1268  *
1269  * Purpose:     This test is one of a sequence of control flow tests intended
1270  *        to verify that control flow for the cache image feature works
1271  *        as expected.
1272  *
1273  *        This test is an initial smoke check, so the sequence of
1274  *        operations is relatively simple.  In particular, we are
1275  *        testing:
1276  *
1277  *            i) Creation of file with cache image FAPL entry set
1278  *               and insertion of metadata cache image superblock
1279  *               message on file close.
1280  *
1281  *               ii) Open of file with metadata cache image superblock
1282  *               message, transmission of message to metadata cache,
1283  *               and deletion of superblock message prior to close.
1284  *
1285  *        Note that in all cases we are performing operations on the
1286  *        file.  While this is the typical case, we must repeat this
1287  *        test without operations on the file.
1288  *
1289  *        1) Create a HDF5 file with the cache image FAPL entry.
1290  *
1291  *           Verify that the cache is informed of the cache image
1292  *           FAPL entry.
1293  *
1294  *           Set flags forcing creation of metadata cache image
1295  *           super block extension message only.
1296  *
1297  *        2) Create some datasets in the file.
1298  *
1299  *        3) Close the file.
1300  *
1301  *        4) Open the file.
1302  *
1303  *           Verify that the metadata cache is instructed
1304  *           to load the metadata cache image, and that the
1305  *           supplied address and length are HADDR_UNDEF and
1306  *           zero respectively.  Note that these values indicate
1307  *           that the metadata image block doesn't exist.
1308  *
1309  *        5) Open a dataset.
1310  *
1311  *           Verify that the metadata cache image superblock
1312  *           extension message has been deleted.
1313  *
1314  *        6) Close the file.
1315  *
1316  *        7) Open the file.
1317  *
1318  *           Verify that the file doesn't contain a metadata cache
1319  *           image superblock extension message.
1320  *
1321  *        8) Close the file.
1322  *
1323  *        9) Delete the file.
1324  *
1325  * Return:      void
1326  *
1327  * Programmer:  John Mainzer
1328  *              7/15/15
1329  *
1330  *-------------------------------------------------------------------------
1331  */
1332 
1333 static unsigned
check_cache_image_ctl_flow_1(void)1334 check_cache_image_ctl_flow_1(void)
1335 {
1336     const char * fcn_name = "check_cache_image_ctl_flow_1()";
1337     char filename[512];
1338     hbool_t show_progress = FALSE;
1339     hid_t file_id = -1;
1340     H5F_t *file_ptr = NULL;
1341     H5C_t *cache_ptr = NULL;
1342     int cp = 0;
1343 
1344     TESTING("metadata cache image control flow test 1");
1345 
1346     pass = TRUE;
1347 
1348     if ( show_progress )
1349         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1350 
1351 
1352     /* setup the file name */
1353     if ( pass ) {
1354 
1355         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
1356             == NULL ) {
1357 
1358             pass = FALSE;
1359             failure_mssg = "h5_fixname() failed.\n";
1360         }
1361     }
1362 
1363     if ( show_progress )
1364         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1365 
1366 
1367     /* 1) Create a HDF5 file with the cache image FAPL entry.
1368      *
1369      *      Verify that the cache is informed of the cache image FAPL entry.
1370      *
1371      *    Set flags forcing creation of metadata cache image super block
1372      *      extension message only.
1373      */
1374 
1375     if ( pass ) {
1376 
1377         open_hdf5_file(/* create_file        */ TRUE,
1378                        /* mdci_sbem_expected */ FALSE,
1379                        /* read_only          */ FALSE,
1380                        /* set_mdci_fapl      */ TRUE,
1381             /* config_fsm         */ FALSE,
1382             /* set_eoc            */ FALSE,
1383                        /* hdf_file_name      */ filename,
1384                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
1385                        /* file_id_ptr        */ &file_id,
1386                        /* file_ptr_ptr       */ &file_ptr,
1387                        /* cache_ptr_ptr      */ &cache_ptr);
1388     }
1389 
1390     if ( show_progress )
1391         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1392 
1393 
1394     /* 2) Create some datasets in the file. */
1395 
1396     if ( pass ) {
1397 
1398         create_datasets(file_id, 0, 5);
1399     }
1400 
1401     if ( show_progress )
1402         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1403 
1404 
1405     /* 3) Close the file. */
1406 
1407     if ( pass ) {
1408 
1409         if ( H5Fclose(file_id) < 0  ) {
1410 
1411             pass = FALSE;
1412             failure_mssg = "H5Fclose() failed.\n";
1413 
1414         }
1415     }
1416 
1417     if ( show_progress )
1418         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1419 
1420 
1421     /* 4) Open the file.
1422      *
1423      *    Verify that the metadata cache is instructed to load the
1424      *    metadata cache image, and that the supplied address and length
1425      *    are HADDR_UNDEF and zero respectively.  Note that these values
1426      *    indicate that the metadata image block doesn't exist.
1427      */
1428 
1429     if ( pass ) {
1430 
1431         open_hdf5_file(/* create_file        */ FALSE,
1432                 /* mdci_sbem_expected */ TRUE,
1433                        /* read_only          */ FALSE,
1434                        /* set_mdci_fapl      */ FALSE,
1435             /* config_fsm         */ FALSE,
1436             /* set_eoc            */ FALSE,
1437                        /* hdf_file_name      */ filename,
1438                        /* cache_image_flags  */ 0,
1439                        /* file_id_ptr        */ &file_id,
1440                        /* file_ptr_ptr       */ &file_ptr,
1441                        /* cache_ptr_ptr      */ &cache_ptr);
1442     }
1443 
1444     if ( show_progress )
1445         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1446 
1447 
1448     /* 5) Open and close a dataset.
1449      *
1450      *    Verify that the metadata cache image superblock
1451      *    extension message has been deleted.
1452      */
1453 
1454     if ( pass ) {
1455 
1456        verify_datasets(file_id, 0, 5);
1457     }
1458 
1459     if ( pass ) {
1460 
1461         /* think on how to verify that the superblock extension has been
1462          * deleted, and if it is necessary to verify this directly.
1463          */
1464     }
1465 
1466     if ( show_progress )
1467         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1468 
1469 
1470     /* 6) Close the file. */
1471 
1472     if ( pass ) {
1473 
1474         if ( H5Fclose(file_id) < 0  ) {
1475 
1476             pass = FALSE;
1477             failure_mssg = "H5Fclose() failed.\n";
1478         }
1479     }
1480 
1481     if ( show_progress )
1482         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1483 
1484 
1485     /* 7) Open the file.
1486      *
1487      *    Verify that the file doesn't contain a metadata cache image
1488      *    superblock extension message.
1489      */
1490 
1491     if ( pass ) {
1492 
1493         open_hdf5_file(/* create_file        */ FALSE,
1494             /* mdci_sbem_expected */ FALSE,
1495                        /* read_only          */ FALSE,
1496                        /* set_mdci_fapl      */ FALSE,
1497             /* config_fsm         */ FALSE,
1498             /* set_eoc            */ FALSE,
1499                        /* hdf_file_name      */ filename,
1500                        /* cache_image_flags  */ 0,
1501                        /* file_id_ptr        */ &file_id,
1502                        /* file_ptr_ptr       */ &file_ptr,
1503                        /* cache_ptr_ptr      */ &cache_ptr);
1504     }
1505 
1506     if ( show_progress )
1507         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1508 
1509 
1510     /* 8) Close the file. */
1511 
1512     if ( pass ) {
1513 
1514         if ( H5Fclose(file_id) < 0  ) {
1515 
1516             pass = FALSE;
1517             failure_mssg = "H5Fclose() failed.\n";
1518         }
1519     }
1520 
1521     if ( show_progress )
1522         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1523 
1524 
1525     /* 9) Delete the file */
1526 
1527     if ( pass ) {
1528 
1529         if ( HDremove(filename) < 0 ) {
1530 
1531             pass = FALSE;
1532             failure_mssg = "HDremove() failed.\n";
1533         }
1534     }
1535 
1536     if ( pass ) { PASSED(); } else { H5_FAILED(); }
1537 
1538     if ( ! pass )
1539         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
1540                   FUNC, failure_mssg);
1541 
1542     return !pass;
1543 
1544 } /* check_cache_image_ctl_flow_1() */
1545 
1546 
1547 /*-------------------------------------------------------------------------
1548  * Function:    check_cache_image_ctl_flow_2()
1549  *
1550  * Purpose:     This test is one of a sequence of control flow tests intended
1551  *        to verify that control flow for the cache image feature works
1552  *        as expected.
1553  *
1554  *        This test is an initial smoke check, so the sequence of
1555  *        operations is relatively simple.  In particular, we are
1556  *        testing:
1557  *
1558  *            i) Creation of file with cache image FAPL entry set
1559  *               and insertion of metadata cache image superblock
1560  *               message on file close.
1561  *
1562  *               ii) Open of file with metadata cache image superblock
1563  *               message, transmission of message to metadata cache,
1564  *               and deletion of superblock message prior to close.
1565  *
1566  *        Note that unlike the previous test, no operations are performed
1567  *        on the file.  As a result of this, the metadata cache image
1568  *        message is not processed until the metadata cache receives
1569  *        the file close warning.  (Under normal circumstances, it is
1570  *        processed as part of the first protect operation after the
1571  *        superblock is loaded.)
1572  *
1573  *        In this particular test, we preform the following operations:
1574  *
1575  *        1) Create a HDF5 file with the cache image FAPL entry.
1576  *
1577  *           Verify that the cache is informed of the cache image
1578  *           FAPL entry.
1579  *
1580  *           Set flags forcing creation of metadata cache image
1581  *           super block extension message only.
1582  *
1583  *        2) Close the file.
1584  *
1585  *        3) Open the file.
1586  *
1587  *           Verify that the metadata cache is instructed
1588  *           to load the metadata cache image, and that the
1589  *           supplied address and length are HADDR_UNDEF and
1590  *           zero respectively.  Note that these values indicate
1591  *           that the metadata image block doesn't exist.
1592  *
1593  *        6) Close the file.
1594  *
1595  *        7) Open the file.
1596  *
1597  *           Verify that the file doesn't contain a metadata cache
1598  *           image superblock extension message.
1599  *
1600  *        8) Close the file.
1601  *
1602  *        9) Delete the file.
1603  *
1604  * Return:      void
1605  *
1606  * Programmer:  John Mainzer
1607  *              7/15/15
1608  *
1609  *-------------------------------------------------------------------------
1610  */
1611 
1612 static unsigned
check_cache_image_ctl_flow_2(void)1613 check_cache_image_ctl_flow_2(void)
1614 {
1615     const char * fcn_name = "check_cache_image_ctl_flow_2()";
1616     char filename[512];
1617     hbool_t show_progress = FALSE;
1618     hid_t file_id = -1;
1619     H5F_t *file_ptr = NULL;
1620     H5C_t *cache_ptr = NULL;
1621     int cp = 0;
1622 
1623     TESTING("metadata cache image control flow test 2");
1624 
1625     pass = TRUE;
1626 
1627     if ( show_progress )
1628         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1629 
1630     /* setup the file name */
1631     if ( pass ) {
1632 
1633         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
1634             == NULL ) {
1635 
1636             pass = FALSE;
1637             failure_mssg = "h5_fixname() failed.\n";
1638         }
1639     }
1640 
1641     if ( show_progress )
1642         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1643 
1644 
1645     /* 1) Create a HDF5 file with the cache image FAPL entry.
1646      *
1647      *      Verify that the cache is informed of the cache image FAPL entry.
1648      *
1649      *    Set flags forcing creation of metadata cache image super block
1650      *      extension message only.
1651      */
1652 
1653     if ( pass ) {
1654 
1655         open_hdf5_file(/* create_file        */ TRUE,
1656                        /* mdci_sbem_expected */ FALSE,
1657                        /* read_only          */ FALSE,
1658                        /* set_mdci_fapl      */ TRUE,
1659             /* config_fsm         */ FALSE,
1660             /* set_eoc            */ FALSE,
1661                        /* hdf_file_name      */ filename,
1662                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
1663                        /* file_id_ptr        */ &file_id,
1664                        /* file_ptr_ptr       */ &file_ptr,
1665                        /* cache_ptr_ptr      */ &cache_ptr);
1666     }
1667 
1668     if ( show_progress )
1669         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1670 
1671 
1672     /* 2) Close the file. */
1673 
1674     if ( pass ) {
1675 
1676         if ( H5Fclose(file_id) < 0  ) {
1677 
1678             pass = FALSE;
1679             failure_mssg = "H5Fclose() failed.\n";
1680 
1681         }
1682     }
1683 
1684     if ( show_progress )
1685         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1686 
1687 
1688     /* 3) Open the file.
1689      *
1690      *    Verify that the metadata cache is instructed to load the
1691      *    metadata cache image, and that the supplied address and length
1692      *    are HADDR_UNDEF and zero respectively.  Note that these values
1693      *    indicate that the metadata image block doesn't exist.
1694      */
1695 
1696     if ( pass ) {
1697 
1698         open_hdf5_file(/* create_file        */ FALSE,
1699             /* mdci_sbem_expected */ TRUE,
1700                        /* read_only          */ FALSE,
1701                        /* set_mdci_fapl      */ FALSE,
1702             /* config_fsm         */ FALSE,
1703             /* set_eoc            */ FALSE,
1704                        /* hdf_file_name      */ filename,
1705                        /* cache_image_flags  */ 0,
1706                        /* file_id_ptr        */ &file_id,
1707                        /* file_ptr_ptr       */ &file_ptr,
1708                        /* cache_ptr_ptr      */ &cache_ptr);
1709     }
1710 
1711     if ( show_progress )
1712         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1713 
1714 
1715     /* 4) Close the file. */
1716 
1717     if ( pass ) {
1718 
1719         if ( H5Fclose(file_id) < 0  ) {
1720 
1721             pass = FALSE;
1722             failure_mssg = "H5Fclose() failed.\n";
1723         }
1724     }
1725 
1726     if ( show_progress )
1727         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1728 
1729 
1730     /* 5) Open the file.
1731      *
1732      *    Verify that the file doesn't contain a metadata cache image
1733      *    superblock extension message.
1734      */
1735 
1736     if ( pass ) {
1737 
1738         open_hdf5_file(/* create_file        */ FALSE,
1739             /* mdci_sbem_expected */ FALSE,
1740                        /* read_only          */ FALSE,
1741                        /* set_mdci_fapl      */ FALSE,
1742             /* config_fsm         */ FALSE,
1743             /* set_eoc            */ FALSE,
1744                        /* hdf_file_name      */ filename,
1745                        /* cache_image_flags  */ 0,
1746                        /* file_id_ptr        */ &file_id,
1747                        /* file_ptr_ptr       */ &file_ptr,
1748                        /* cache_ptr_ptr      */ &cache_ptr);
1749     }
1750 
1751     if ( show_progress )
1752         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1753 
1754 
1755     /* 6) Close the file. */
1756 
1757     if ( pass ) {
1758 
1759         if ( H5Fclose(file_id) < 0  ) {
1760 
1761             pass = FALSE;
1762             failure_mssg = "H5Fclose() failed.\n";
1763         }
1764     }
1765 
1766     if ( show_progress )
1767         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1768 
1769 
1770     /* 7) Delete the file */
1771 
1772     if ( pass ) {
1773 
1774         if ( HDremove(filename) < 0 ) {
1775 
1776             pass = FALSE;
1777             failure_mssg = "HDremove() failed.\n";
1778         }
1779     }
1780 
1781     if ( pass ) { PASSED(); } else { H5_FAILED(); }
1782 
1783     if ( ! pass )
1784         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
1785                   FUNC, failure_mssg);
1786 
1787     return !pass;
1788 
1789 } /* check_cache_image_ctl_flow_2() */
1790 
1791 
1792 /*-------------------------------------------------------------------------
1793  * Function:    check_cache_image_ctl_flow_3()
1794  *
1795  * Purpose:     This test is one of a sequence of control flow tests intended
1796  *        to verify that control flow for the cache image feature works
1797  *        as expected.
1798  *
1799  *        The objectives of this test are to:
1800  *
1801  *            i) Test operation of the metadata cache image FAPL
1802  *               entry set on open of an existing file.  This
1803  *               should result in the insertion of a metadata
1804  *               cache image superblock message on file close.
1805  *
1806  *               ii) Test operation of the metadata cache image super
1807  *               block extension message when it appears in a file
1808  *               that is opened READ ONLY.
1809  *
1810  *        Note that in all cases we are performing operations on the
1811  *        file between file open and close.  While this is the
1812  *        typical case, we must repeat this test without operations
1813  *        on the file.
1814  *
1815  *        1) Create a HDF5 file WITHOUT the cache image FAPL entry.
1816  *
1817  *           Verify that the cache is NOT informed of the cache image
1818  *           FAPL entry.
1819  *
1820  *        2) Close the file.
1821  *
1822  *        3) Open the file WITH the cache image FAPL entry.
1823  *
1824  *           Verify that the cache is informed of the cache image
1825  *           FAPL entry.
1826  *
1827  *           Set flags forcing creation of metadata cache image
1828  *           super block extension message only.
1829  *
1830  *        4) Create some datasets.
1831  *
1832  *        5) Close the file.
1833  *
1834  *        6) Open the file READ ONLY.
1835  *
1836  *           Verify that the metadata cache is instructed
1837  *           to load the metadata cache image, and that the
1838  *           supplied address and length are HADDR_UNDEF and
1839  *           zero respectively.  Note that these values indicate
1840  *           that the metadata image block doesn't exist.
1841  *
1842  *        7) Verify the contents of the datasets.
1843  *
1844  *        8) Close the file.
1845  *
1846  *        9) Open the file READ/WRITE.
1847  *
1848  *           Verify that the metadata cache is instructed
1849  *           to load the metadata cache image, and that the
1850  *           supplied address and length are HADDR_UNDEF and
1851  *           zero respectively.  Note that these values indicate
1852  *           that the metadata image block doesn't exist.
1853  *
1854  *           10) Verify the contents of the datasets.
1855  *
1856  *           11) Close the file.
1857  *
1858  *           12) Open the file
1859  *
1860  *           Verify that the file doesn't contain a metadata cache
1861  *           image superblock extension message.
1862  *
1863  *           13) Close the file.
1864  *
1865  *           14) Delete the file.
1866  *
1867  * Return:      void
1868  *
1869  * Programmer:  John Mainzer
1870  *              7/16/15
1871  *
1872  *-------------------------------------------------------------------------
1873  */
1874 
1875 static unsigned
check_cache_image_ctl_flow_3(void)1876 check_cache_image_ctl_flow_3(void)
1877 {
1878     const char * fcn_name = "check_cache_image_ctl_flow_3()";
1879     char filename[512];
1880     hbool_t show_progress = FALSE;
1881     hid_t file_id = -1;
1882     H5F_t *file_ptr = NULL;
1883     H5C_t *cache_ptr = NULL;
1884     int cp = 0;
1885 
1886     TESTING("metadata cache image control flow test 3");
1887 
1888     pass = TRUE;
1889 
1890     if ( show_progress ) /* 0 */
1891         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1892 
1893     /* setup the file name */
1894     if ( pass ) {
1895 
1896         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
1897             == NULL ) {
1898 
1899             pass = FALSE;
1900             failure_mssg = "h5_fixname() failed.\n";
1901         }
1902     }
1903 
1904     if ( show_progress ) /* 1 */
1905         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1906 
1907     /* 1) Create a HDF5 file WITHOUT the cache image FAPL entry.
1908      *
1909      *    Verify that the cache is NOT informed of the cache image
1910      *    FAPL entry.
1911      */
1912 
1913     if ( pass ) {
1914 
1915         open_hdf5_file(/* create_file        */ TRUE,
1916                        /* mdci_sbem_expected */ FALSE,
1917                        /* read_only          */ FALSE,
1918                        /* set_mdci_fapl      */ FALSE,
1919             /* config_fsm         */ FALSE,
1920             /* set_eoc            */ FALSE,
1921                        /* hdf_file_name      */ filename,
1922                        /* cache_image_flags  */ 0,
1923                        /* file_id_ptr        */ &file_id,
1924                        /* file_ptr_ptr       */ &file_ptr,
1925                        /* cache_ptr_ptr      */ &cache_ptr);
1926     }
1927 
1928     if ( show_progress ) /* 2 */
1929         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1930 
1931 
1932     /* 2) Close the file. */
1933 
1934     if ( pass ) {
1935 
1936         if ( H5Fclose(file_id) < 0  ) {
1937 
1938             pass = FALSE;
1939             failure_mssg = "H5Fclose() failed.\n";
1940         }
1941     }
1942 
1943     if ( show_progress ) /* 3 */
1944         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1945 
1946 
1947     /* 3) Open the file WITH the cache image FAPL entry.
1948      *
1949      *    Verify that the cache is informed of the cache image FAPL entry.
1950      *
1951      *    Set flags forcing creation of metadata cache image super block
1952      *    extension message only.
1953      */
1954 
1955     if ( pass ) {
1956 
1957         open_hdf5_file(/* create_file        */ FALSE,
1958                        /* mdci_sbem_expected */ FALSE,
1959                        /* read_only          */ FALSE,
1960                        /* set_mdci_fapl      */ TRUE,
1961             /* config_fsm         */ FALSE,
1962             /* set_eoc            */ FALSE,
1963                        /* hdf_file_name      */ filename,
1964                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
1965                        /* file_id_ptr        */ &file_id,
1966                        /* file_ptr_ptr       */ &file_ptr,
1967                        /* cache_ptr_ptr      */ &cache_ptr);
1968     }
1969 
1970     if ( show_progress ) /* 4 */
1971         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1972 
1973 
1974     /* 4) Create some datasets. */
1975 
1976     if ( pass ) {
1977 
1978         create_datasets(file_id, 0, 5);
1979     }
1980 
1981     if ( show_progress ) /* 5 */
1982         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1983 
1984 
1985     /* 5) Close the file. */
1986 
1987     if ( pass ) {
1988 
1989         if ( H5Fclose(file_id) < 0  ) {
1990 
1991             pass = FALSE;
1992             failure_mssg = "H5Fclose() failed.\n";
1993         }
1994     }
1995 
1996     if ( show_progress ) /* 6 */
1997         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
1998 
1999 
2000     /* 6) Open the file READ ONLY.
2001      *
2002      *    Verify that the metadata cache is instructed
2003      *    to load the metadata cache image, and that the
2004      *    supplied address and length are HADDR_UNDEF and
2005      *    zero respectively.  Note that these values indicate
2006      *    that the metadata image block doesn't exist.
2007      */
2008 
2009     if ( pass ) {
2010 
2011         open_hdf5_file(/* create_file        */ FALSE,
2012             /* mdci_sbem_expected */ TRUE,
2013                        /* read_only          */ TRUE,
2014                        /* set_mdci_fapl      */ FALSE,
2015             /* config_fsm         */ FALSE,
2016             /* set_eoc            */ FALSE,
2017                        /* hdf_file_name      */ filename,
2018                        /* cache_image_flags  */ 0,
2019                        /* file_id_ptr        */ &file_id,
2020                        /* file_ptr_ptr       */ &file_ptr,
2021                        /* cache_ptr_ptr      */ &cache_ptr);
2022     }
2023 
2024     if ( show_progress ) /* 7 */
2025         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2026 
2027 
2028     /* 7) Verify the contents of the datasets. */
2029 
2030     if ( pass ) {
2031 
2032        verify_datasets(file_id, 0, 5);
2033     }
2034 
2035     if ( show_progress ) /* 8 */
2036         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2037 
2038 
2039     /* 8) Close the file. */
2040 
2041     if ( pass ) {
2042 
2043         if ( H5Fclose(file_id) < 0  ) {
2044 
2045             pass = FALSE;
2046             failure_mssg = "H5Fclose() failed.\n";
2047         }
2048     }
2049 
2050     if ( show_progress ) /* 9 */
2051         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2052 
2053 
2054     /* 9) Open the file READ/WRITE.
2055      *
2056      *    Verify that the metadata cache is instructed
2057      *    to load the metadata cache image, and that the
2058      *    supplied address and length are HADDR_UNDEF and
2059      *    zero respectively.  Note that these values indicate
2060      *    that the metadata image block doesn't exist.
2061      */
2062 
2063     if ( pass ) {
2064 
2065         open_hdf5_file(/* create_file        */ FALSE,
2066             /* mdci_sbem_expected */ TRUE,
2067                        /* read_only          */ FALSE,
2068                        /* set_mdci_fapl      */ FALSE,
2069             /* config_fsm         */ FALSE,
2070             /* set_eoc            */ FALSE,
2071                        /* hdf_file_name      */ filename,
2072                        /* cache_image_flags  */ 0,
2073                        /* file_id_ptr        */ &file_id,
2074                        /* file_ptr_ptr       */ &file_ptr,
2075                        /* cache_ptr_ptr      */ &cache_ptr);
2076     }
2077 
2078     if ( show_progress ) /* 10 */
2079         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2080 
2081 
2082     /* 10) Verify the contents of the datasets. */
2083 
2084     if ( pass ) {
2085 
2086        verify_datasets(file_id, 0, 5);
2087     }
2088 
2089     if ( show_progress ) /* 11 */
2090         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2091 
2092 
2093     /* 11) Close the file. */
2094 
2095     if ( pass ) {
2096 
2097         if ( H5Fclose(file_id) < 0  ) {
2098 
2099             pass = FALSE;
2100             failure_mssg = "H5Fclose() failed.\n";
2101         }
2102     }
2103 
2104     if ( show_progress ) /* 12 */
2105         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2106 
2107 
2108     /* 12) Open the file
2109      *
2110      *       Verify that the file doesn't contain a metadata cache
2111      *       image superblock extension message.
2112      */
2113 
2114     if ( pass ) {
2115 
2116         open_hdf5_file(/* create_file        */ FALSE,
2117             /* mdci_sbem_expected */ FALSE,
2118                        /* read_only          */ FALSE,
2119                        /* set_mdci_fapl      */ FALSE,
2120             /* config_fsm         */ FALSE,
2121             /* set_eoc            */ FALSE,
2122                        /* hdf_file_name      */ filename,
2123                        /* cache_image_flags  */ 0,
2124                        /* file_id_ptr        */ &file_id,
2125                        /* file_ptr_ptr       */ &file_ptr,
2126                        /* cache_ptr_ptr      */ &cache_ptr);
2127     }
2128 
2129     if ( show_progress ) /* 13 */
2130         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2131 
2132 
2133     /* 13) Close the file. */
2134 
2135     if ( pass ) {
2136 
2137         if ( H5Fclose(file_id) < 0  ) {
2138 
2139             pass = FALSE;
2140             failure_mssg = "H5Fclose() failed.\n";
2141         }
2142     }
2143 
2144     if ( show_progress ) /* 14 */
2145         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2146 
2147 
2148     /* 14) Delete the file. */
2149 
2150     if ( pass ) {
2151 
2152         if ( HDremove(filename) < 0 ) {
2153 
2154             pass = FALSE;
2155             failure_mssg = "HDremove() failed.\n";
2156         }
2157     }
2158 
2159 
2160     if ( pass ) { PASSED(); } else { H5_FAILED(); }
2161 
2162     if ( ! pass )
2163         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
2164                   FUNC, failure_mssg);
2165 
2166     return !pass;
2167 
2168 } /* check_cache_image_ctl_flow_3() */
2169 
2170 
2171 /*-------------------------------------------------------------------------
2172  * Function:    check_cache_image_ctl_flow_4()
2173  *
2174  * Purpose:     This test is one of a sequence of control flow tests intended
2175  *        to verify that control flow for the cache image feature works
2176  *        as expected.
2177  *
2178  *        The objectives of this test are to:
2179  *
2180  *            i) Test operation of the metadata cache image FAPL
2181  *               entry set on open of an existing file.  This
2182  *               should result in the insertion of a metadata
2183  *               cache image superblock message on file close.
2184  *
2185  *               ii) Test operation of the metadata cache image super
2186  *               block extension message when it appears in a file
2187  *               that is opened READ ONLY.
2188  *
2189  *        In this test we avoid all file access beyond file open
2190  *        and close.
2191  *
2192  *        1) Create a HDF5 file WITHOUT the cache image FAPL entry.
2193  *
2194  *           Verify that the cache is NOT informed of the cache image
2195  *           FAPL entry.
2196  *
2197  *        2) Close the file.
2198  *
2199  *        3) Open the file WITH the cache image FAPL entry.
2200  *
2201  *           Verify that the cache is informed of the cache image
2202  *           FAPL entry.
2203  *
2204  *           Set flags forcing creation of metadata cache image
2205  *           super block extension message only.
2206  *
2207  *        4) Close the file.
2208  *
2209  *        5) Open the file READ ONLY.
2210  *
2211  *           Verify that the metadata cache is instructed
2212  *           to load the metadata cache image, and that the
2213  *           supplied address and length are HADDR_UNDEF and
2214  *           zero respectively.  Note that these values indicate
2215  *           that the metadata image block doesn't exist.
2216  *
2217  *        6) Close the file.
2218  *
2219  *        7) Open the file READ/WRITE.
2220  *
2221  *           Verify that the metadata cache is instructed
2222  *           to load the metadata cache image, and that the
2223  *           supplied address and length are HADDR_UNDEF and
2224  *           zero respectively.  Note that these values indicate
2225  *           that the metadata image block doesn't exist.
2226  *
2227  *            8) Close the file.
2228  *
2229  *            9) Open the file
2230  *
2231  *           Verify that the file doesn't contain a metadata cache
2232  *           image superblock extension message.
2233  *
2234  *           10) Close the file.
2235  *
2236  *           11) Delete the file.
2237  *
2238  * Return:      void
2239  *
2240  * Programmer:  John Mainzer
2241  *              7/16/15
2242  *
2243  *-------------------------------------------------------------------------
2244  */
2245 
2246 static unsigned
check_cache_image_ctl_flow_4(void)2247 check_cache_image_ctl_flow_4(void)
2248 {
2249     const char * fcn_name = "check_cache_image_ctl_flow_4()";
2250     char filename[512];
2251     hbool_t show_progress = FALSE;
2252     hid_t file_id = -1;
2253     H5F_t *file_ptr = NULL;
2254     H5C_t *cache_ptr = NULL;
2255     int cp = 0;
2256 
2257     TESTING("metadata cache image control flow test 4");
2258 
2259     pass = TRUE;
2260 
2261     if ( show_progress ) /* 0 */
2262         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2263 
2264     /* setup the file name */
2265     if ( pass ) {
2266 
2267         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
2268             == NULL ) {
2269 
2270             pass = FALSE;
2271             failure_mssg = "h5_fixname() failed.\n";
2272         }
2273     }
2274 
2275     if ( show_progress ) /* 1 */
2276         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2277 
2278     /* 1) Create a HDF5 file WITHOUT the cache image FAPL entry.
2279      *
2280      *    Verify that the cache is NOT informed of the cache image
2281      *    FAPL entry.
2282      */
2283 
2284     if ( pass ) {
2285 
2286         open_hdf5_file(/* create_file        */ TRUE,
2287                        /* mdci_sbem_expected */ FALSE,
2288                        /* read_only          */ FALSE,
2289                        /* set_mdci_fapl      */ FALSE,
2290             /* config_fsm         */ FALSE,
2291             /* set_eoc            */ FALSE,
2292                        /* hdf_file_name      */ filename,
2293                        /* cache_image_flags  */ 0,
2294                        /* file_id_ptr        */ &file_id,
2295                        /* file_ptr_ptr       */ &file_ptr,
2296                        /* cache_ptr_ptr      */ &cache_ptr);
2297     }
2298 
2299     if ( show_progress ) /* 2 */
2300         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2301 
2302 
2303     /* 2) Close the file. */
2304 
2305     if ( pass ) {
2306 
2307         if ( H5Fclose(file_id) < 0  ) {
2308 
2309             pass = FALSE;
2310             failure_mssg = "H5Fclose() failed.\n";
2311         }
2312     }
2313 
2314     if ( show_progress ) /* 3 */
2315         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2316 
2317 
2318     /* 3) Open the file WITH the cache image FAPL entry.
2319      *
2320      *    Verify that the cache is informed of the cache image FAPL entry.
2321      *
2322      *    Set flags forcing creation of metadata cache image super block
2323      *    extension message only.
2324      */
2325 
2326     if ( pass ) {
2327 
2328         open_hdf5_file(/* create_file        */ FALSE,
2329                        /* mdci_sbem_expected */ FALSE,
2330                        /* read_only          */ FALSE,
2331                        /* set_mdci_fapl      */ TRUE,
2332             /* config_fsm         */ FALSE,
2333             /* set_eoc            */ FALSE,
2334                        /* hdf_file_name      */ filename,
2335                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
2336                        /* file_id_ptr        */ &file_id,
2337                        /* file_ptr_ptr       */ &file_ptr,
2338                        /* cache_ptr_ptr      */ &cache_ptr);
2339     }
2340 
2341     if ( show_progress ) /* 4 */
2342         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2343 
2344 
2345     /* 4) Close the file. */
2346 
2347     if ( pass ) {
2348 
2349         if ( H5Fclose(file_id) < 0  ) {
2350 
2351             pass = FALSE;
2352             failure_mssg = "H5Fclose() failed.\n";
2353         }
2354     }
2355 
2356     if ( show_progress ) /* 5 */
2357         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2358 
2359 
2360     /* 5) Open the file READ ONLY.
2361      *
2362      *    Verify that the metadata cache is instructed
2363      *    to load the metadata cache image, and that the
2364      *    supplied address and length are HADDR_UNDEF and
2365      *    zero respectively.  Note that these values indicate
2366      *    that the metadata image block doesn't exist.
2367      */
2368 
2369     if ( pass ) {
2370 
2371         open_hdf5_file(/* create_file        */ FALSE,
2372             /* mdci_sbem_expected */ TRUE,
2373                        /* read_only          */ TRUE,
2374                        /* set_mdci_fapl      */ FALSE,
2375             /* config_fsm         */ FALSE,
2376             /* set_eoc            */ FALSE,
2377                        /* hdf_file_name      */ filename,
2378                        /* cache_image_flags  */ 0,
2379                        /* file_id_ptr        */ &file_id,
2380                        /* file_ptr_ptr       */ &file_ptr,
2381                        /* cache_ptr_ptr      */ &cache_ptr);
2382     }
2383 
2384     if ( show_progress ) /* 6 */
2385         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2386 
2387 
2388     /* 6) Close the file. */
2389 
2390     if ( pass ) {
2391 
2392         if ( H5Fclose(file_id) < 0  ) {
2393 
2394             pass = FALSE;
2395             failure_mssg = "H5Fclose() failed.\n";
2396         }
2397     }
2398 
2399     if ( show_progress ) /* 7 */
2400         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2401 
2402 
2403     /* 7) Open the file READ/WRITE.
2404      *
2405      *    Verify that the metadata cache is instructed
2406      *    to load the metadata cache image, and that the
2407      *    supplied address and length are HADDR_UNDEF and
2408      *    zero respectively.  Note that these values indicate
2409      *    that the metadata image block doesn't exist.
2410      */
2411 
2412     if ( pass ) {
2413 
2414         open_hdf5_file(/* create_file        */ FALSE,
2415             /* mdci_sbem_expected */ TRUE,
2416                        /* read_only          */ FALSE,
2417                        /* set_mdci_fapl      */ FALSE,
2418             /* config_fsm         */ FALSE,
2419             /* set_eoc            */ FALSE,
2420                        /* hdf_file_name      */ filename,
2421                        /* cache_image_flags  */ 0,
2422                        /* file_id_ptr        */ &file_id,
2423                        /* file_ptr_ptr       */ &file_ptr,
2424                        /* cache_ptr_ptr      */ &cache_ptr);
2425     }
2426 
2427     if ( show_progress ) /* 8 */
2428         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2429 
2430 
2431     /* 8) Close the file. */
2432 
2433     if ( pass ) {
2434 
2435         if ( H5Fclose(file_id) < 0  ) {
2436 
2437             pass = FALSE;
2438             failure_mssg = "H5Fclose() failed.\n";
2439         }
2440     }
2441 
2442     if ( show_progress ) /* 9 */
2443         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2444 
2445 
2446     /* 9) Open the file
2447      *
2448      *       Verify that the file doesn't contain a metadata cache
2449      *       image superblock extension message.
2450      */
2451 
2452     if ( pass ) {
2453 
2454         open_hdf5_file(/* create_file        */ FALSE,
2455             /* mdci_sbem_expected */ FALSE,
2456                        /* read_only          */ FALSE,
2457                        /* set_mdci_fapl      */ FALSE,
2458             /* config_fsm         */ FALSE,
2459             /* set_eoc            */ FALSE,
2460                        /* hdf_file_name      */ filename,
2461                        /* cache_image_flags  */ 0,
2462                        /* file_id_ptr        */ &file_id,
2463                        /* file_ptr_ptr       */ &file_ptr,
2464                        /* cache_ptr_ptr      */ &cache_ptr);
2465     }
2466 
2467     if ( show_progress ) /* 10 */
2468         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2469 
2470 
2471     /* 10) Close the file. */
2472 
2473     if ( pass ) {
2474 
2475         if ( H5Fclose(file_id) < 0  ) {
2476 
2477             pass = FALSE;
2478             failure_mssg = "H5Fclose() failed.\n";
2479         }
2480     }
2481 
2482     if ( show_progress ) /* 11 */
2483         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2484 
2485 
2486     /* 11) Delete the file. */
2487 
2488     if ( pass ) {
2489 
2490         if ( HDremove(filename) < 0 ) {
2491 
2492             pass = FALSE;
2493             failure_mssg = "HDremove() failed.\n";
2494         }
2495     }
2496 
2497 
2498     if ( pass ) { PASSED(); } else { H5_FAILED(); }
2499 
2500     if ( ! pass )
2501         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
2502                   FUNC, failure_mssg);
2503 
2504     return !pass;
2505 
2506 } /* check_cache_image_ctl_flow_4() */
2507 
2508 
2509 /*-------------------------------------------------------------------------
2510  * Function:    check_cache_image_ctl_flow_5()
2511  *
2512  * Purpose:     This test is one of a sequence of control flow tests intended
2513  *        to verify that control flow for the cache image feature works
2514  *        as expected.
2515  *
2516  *        The objective of this test is verify correct control flow
2517  *        when a file with a metadata cache image superblock extension
2518  *        message is opened with the metadata cache image FAPL entry.
2519  *
2520  *        Note that in all cases we are performing operations on the
2521  *        file between file open and close.  While this is the
2522  *        typical case, we must repeat this test without operations
2523  *        on the file.
2524  *
2525  *        1) Create a HDF5 file with the cache image FAPL entry.
2526  *
2527  *           Verify that the cache is informed of the cache image
2528  *           FAPL entry.
2529  *
2530  *           Set flags forcing creation of metadata cache image
2531  *           super block extension message only.
2532  *
2533  *        2) Create some datasets.
2534  *
2535  *        3) Close the file.
2536  *
2537  *        4) Open the file WITH the cache image FAPL entry.
2538  *
2539  *           Verify that the metadata cache is instructed
2540  *           to load the metadata cache image, and that the
2541  *           supplied address and length are HADDR_UNDEF and
2542  *           zero respectively.  Note that these values indicate
2543  *           that the metadata image block doesn't exist.
2544  *
2545  *           Verify that the cache is informed of the cache image
2546  *           FAPL entry.
2547  *
2548  *           Set flags forcing creation of metadata cache image
2549  *           super block extension message only.
2550  *
2551  *        5) Verify the contents of the datasets.
2552  *
2553  *        6) Close the file.
2554  *
2555  *        7) Open the file.
2556  *
2557  *           Verify that the metadata cache is instructed
2558  *           to load the metadata cache image, and that the
2559  *           supplied address and length are HADDR_UNDEF and
2560  *           zero respectively.  Note that these values indicate
2561  *           that the metadata image block doesn't exist.
2562  *
2563  *            8) Verify the contents of the datasets.
2564  *
2565  *            9) Close the file.
2566  *
2567  *           10) Delete the file.
2568  *
2569  * Return:      void
2570  *
2571  * Programmer:  John Mainzer
2572  *              7/17/15
2573  *
2574  *-------------------------------------------------------------------------
2575  */
2576 
2577 static unsigned
check_cache_image_ctl_flow_5(void)2578 check_cache_image_ctl_flow_5(void)
2579 {
2580     const char * fcn_name = "check_cache_image_ctl_flow_5()";
2581     char filename[512];
2582     hbool_t show_progress = FALSE;
2583     hid_t file_id = -1;
2584     H5F_t *file_ptr = NULL;
2585     H5C_t *cache_ptr = NULL;
2586     int cp = 0;
2587 
2588     TESTING("metadata cache image control flow test 5");
2589 
2590     pass = TRUE;
2591 
2592     if ( show_progress ) /* 0 */
2593         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2594 
2595     /* setup the file name */
2596     if ( pass ) {
2597 
2598         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
2599             == NULL ) {
2600 
2601             pass = FALSE;
2602             failure_mssg = "h5_fixname() failed.\n";
2603         }
2604     }
2605 
2606     if ( show_progress ) /* 1 */
2607         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2608 
2609 
2610     /* 1) Create a HDF5 file with the cache image FAPL entry.
2611      *
2612      *    Verify that the cache is informed of the cache image FAPL entry.
2613      *
2614      *    Set flags forcing creation of metadata cache image
2615      *    super block extension message only.
2616      */
2617 
2618     if ( pass ) {
2619 
2620         open_hdf5_file(/* create_file        */ TRUE,
2621                        /* mdci_sbem_expected */ FALSE,
2622                        /* read_only          */ FALSE,
2623                        /* set_mdci_fapl      */ TRUE,
2624             /* config_fsm         */ FALSE,
2625             /* set_eoc            */ FALSE,
2626                        /* hdf_file_name      */ filename,
2627                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
2628                        /* file_id_ptr        */ &file_id,
2629                        /* file_ptr_ptr       */ &file_ptr,
2630                        /* cache_ptr_ptr      */ &cache_ptr);
2631     }
2632 
2633     if ( show_progress ) /* 2 */
2634         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2635 
2636 
2637     /* 2) Create some datasets. */
2638 
2639     if ( pass ) {
2640 
2641         create_datasets(file_id, 0, 5);
2642     }
2643 
2644     if ( show_progress ) /* 3 */
2645         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2646 
2647 
2648     /* 3) Close the file. */
2649 
2650     if ( pass ) {
2651 
2652         if ( H5Fclose(file_id) < 0  ) {
2653 
2654             pass = FALSE;
2655             failure_mssg = "H5Fclose() failed.\n";
2656         }
2657     }
2658 
2659     if ( show_progress ) /* 4 */
2660         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2661 
2662 
2663     /* 4) Open the file WITH the cache image FAPL entry.
2664      *
2665      *    Verify that the metadata cache is instructed
2666      *    to load the metadata cache image, and that the
2667      *    supplied address and length are HADDR_UNDEF and
2668      *    zero respectively.  Note that these values indicate
2669      *    that the metadata image block doesn't exist.
2670      *
2671      *    Verify that the cache is informed of the cache image
2672      *    FAPL entry.
2673      *
2674      *    Set flags forcing creation of metadata cache image
2675      *    super block extension message only.
2676      */
2677 
2678     if ( pass ) {
2679 
2680         open_hdf5_file(/* create_file        */ FALSE,
2681             /* mdci_sbem_expected */ TRUE,
2682                        /* read_only          */ FALSE,
2683                        /* set_mdci_fapl      */ TRUE,
2684             /* config_fsm         */ FALSE,
2685             /* set_eoc            */ FALSE,
2686                        /* hdf_file_name      */ filename,
2687                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
2688                        /* file_id_ptr        */ &file_id,
2689                        /* file_ptr_ptr       */ &file_ptr,
2690                        /* cache_ptr_ptr      */ &cache_ptr);
2691     }
2692 
2693     if ( show_progress ) /* 5 */
2694         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2695 
2696     /* 5) Verify the contents of the datasets. */
2697 
2698     if ( pass ) {
2699 
2700        verify_datasets(file_id, 0, 5);
2701     }
2702 
2703     if ( show_progress ) /* 6 */
2704         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2705 
2706 
2707     /* 6) Close the file. */
2708 
2709     if ( pass ) {
2710 
2711         if ( H5Fclose(file_id) < 0  ) {
2712 
2713             pass = FALSE;
2714             failure_mssg = "H5Fclose() failed.\n";
2715         }
2716     }
2717 
2718     if ( show_progress ) /* 7 */
2719         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2720 
2721 
2722     /* 7) Open the file.
2723      *
2724      *    Verify that the metadata cache is instructed
2725      *    to load the metadata cache image, and that the
2726      *    supplied address and length are HADDR_UNDEF and
2727      *    zero respectively.  Note that these values indicate
2728      *    that the metadata image block doesn't exist.
2729      */
2730 
2731     if ( pass ) {
2732 
2733         open_hdf5_file(/* create_file        */ FALSE,
2734             /* mdci_sbem_expected */ TRUE,
2735                        /* read_only          */ FALSE,
2736                        /* set_mdci_fapl      */ FALSE,
2737             /* config_fsm         */ FALSE,
2738             /* set_eoc            */ FALSE,
2739                        /* hdf_file_name      */ filename,
2740                        /* cache_image_flags  */ 0,
2741                        /* file_id_ptr        */ &file_id,
2742                        /* file_ptr_ptr       */ &file_ptr,
2743                        /* cache_ptr_ptr      */ &cache_ptr);
2744     }
2745 
2746     if ( show_progress ) /* 8 */
2747         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2748 
2749     /* 8) Verify the contents of the datasets. */
2750 
2751     if ( pass ) {
2752 
2753        verify_datasets(file_id, 0, 5);
2754     }
2755 
2756     if ( show_progress ) /* 9 */
2757         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2758 
2759 
2760     /* 9) Close the file. */
2761 
2762     if ( pass ) {
2763 
2764         if ( H5Fclose(file_id) < 0  ) {
2765 
2766             pass = FALSE;
2767             failure_mssg = "H5Fclose() failed.\n";
2768         }
2769     }
2770 
2771     if ( show_progress ) /* 10 */
2772         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2773 
2774 
2775     /* 10) Delete the file. */
2776 
2777     if ( pass ) {
2778 
2779         if ( HDremove(filename) < 0 ) {
2780 
2781             pass = FALSE;
2782             failure_mssg = "HDremove() failed.\n";
2783         }
2784     }
2785 
2786 
2787     if ( pass ) { PASSED(); } else { H5_FAILED(); }
2788 
2789     if ( ! pass )
2790         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
2791                   FUNC, failure_mssg);
2792 
2793     return !pass;
2794 
2795 } /* check_cache_image_ctl_flow_5() */
2796 
2797 
2798 /*-------------------------------------------------------------------------
2799  * Function:    check_cache_image_ctl_flow_6()
2800  *
2801  * Purpose:     This test is one of a sequence of control flow tests intended
2802  *        to verify that control flow for the cache image feature works
2803  *        as expected.
2804  *
2805  *        The objective of this test is verify correct control flow
2806  *        when a file with a metadata cache image superblock extension
2807  *        message is opened with the metadata cache image FAPL entry.
2808  *
2809  *        In this test we avoid all file activity other than open
2810  *        and close.
2811  *
2812  *        1) Create a HDF5 file with the cache image FAPL entry.
2813  *
2814  *           Verify that the cache is informed of the cache image
2815  *           FAPL entry.
2816  *
2817  *           Set flags forcing creation of metadata cache image
2818  *           super block extension message only.
2819  *
2820  *        2) Close the file.
2821  *
2822  *        3) Open the file WITH the cache image FAPL entry.
2823  *
2824  *           Verify that the metadata cache is instructed
2825  *           to load the metadata cache image, and that the
2826  *           supplied address and length are HADDR_UNDEF and
2827  *           zero respectively.  Note that these values indicate
2828  *           that the metadata image block doesn't exist.
2829  *
2830  *           Verify that the cache is informed of the cache image
2831  *           FAPL entry.
2832  *
2833  *           Set flags forcing creation of metadata cache image
2834  *           super block extension message only.
2835  *
2836  *        4) Close the file.
2837  *
2838  *        5) Open the file.
2839  *
2840  *           Verify that the metadata cache is instructed
2841  *           to load the metadata cache image, and that the
2842  *           supplied address and length are HADDR_UNDEF and
2843  *           zero respectively.  Note that these values indicate
2844  *           that the metadata image block doesn't exist.
2845  *
2846  *            6) Close the file.
2847  *
2848  *            7) Delete the file.
2849  *
2850  * Return:      void
2851  *
2852  * Programmer:  John Mainzer
2853  *              7/17/15
2854  *
2855  *-------------------------------------------------------------------------
2856  */
2857 
2858 static unsigned
check_cache_image_ctl_flow_6(void)2859 check_cache_image_ctl_flow_6(void)
2860 {
2861     const char * fcn_name = "check_cache_image_ctl_flow_6()";
2862     char filename[512];
2863     hbool_t show_progress = FALSE;
2864     hid_t file_id = -1;
2865     H5F_t *file_ptr = NULL;
2866     H5C_t *cache_ptr = NULL;
2867     int cp = 0;
2868 
2869     TESTING("metadata cache image control flow test 6");
2870 
2871     pass = TRUE;
2872 
2873     if ( show_progress ) /* 0 */
2874         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2875 
2876     /* setup the file name */
2877     if ( pass ) {
2878 
2879         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
2880             == NULL ) {
2881 
2882             pass = FALSE;
2883             failure_mssg = "h5_fixname() failed.\n";
2884         }
2885     }
2886 
2887     if ( show_progress ) /* 1 */
2888         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2889 
2890 
2891     /* 1) Create a HDF5 file with the cache image FAPL entry.
2892      *
2893      *    Verify that the cache is informed of the cache image FAPL entry.
2894      *
2895      *    Set flags forcing creation of metadata cache image
2896      *    super block extension message only.
2897      */
2898 
2899     if ( pass ) {
2900 
2901         open_hdf5_file(/* create_file        */ TRUE,
2902                        /* mdci_sbem_expected */ FALSE,
2903                        /* read_only          */ FALSE,
2904                        /* set_mdci_fapl      */ TRUE,
2905             /* config_fsm         */ FALSE,
2906             /* set_eoc            */ FALSE,
2907                        /* hdf_file_name      */ filename,
2908                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
2909                        /* file_id_ptr        */ &file_id,
2910                        /* file_ptr_ptr       */ &file_ptr,
2911                        /* cache_ptr_ptr      */ &cache_ptr);
2912     }
2913 
2914     if ( show_progress ) /* 2 */
2915         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2916 
2917 
2918     /* 2) Close the file. */
2919 
2920     if ( pass ) {
2921 
2922         if ( H5Fclose(file_id) < 0  ) {
2923 
2924             pass = FALSE;
2925             failure_mssg = "H5Fclose() failed.\n";
2926         }
2927     }
2928 
2929     if ( show_progress ) /* 3 */
2930         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2931 
2932 
2933     /* 4) Open the file WITH the cache image FAPL entry.
2934      *
2935      *    Verify that the metadata cache is instructed
2936      *    to load the metadata cache image, and that the
2937      *    supplied address and length are HADDR_UNDEF and
2938      *    zero respectively.  Note that these values indicate
2939      *    that the metadata image block doesn't exist.
2940      *
2941      *    Verify that the cache is informed of the cache image
2942      *    FAPL entry.
2943      *
2944      *    Set flags forcing creation of metadata cache image
2945      *    super block extension message only.
2946      */
2947 
2948     if ( pass ) {
2949 
2950         open_hdf5_file(/* create_file        */ FALSE,
2951             /* mdci_sbem_expected */ TRUE,
2952                        /* read_only          */ FALSE,
2953                        /* set_mdci_fapl      */ TRUE,
2954             /* config_fsm         */ FALSE,
2955             /* set_eoc            */ FALSE,
2956                        /* hdf_file_name      */ filename,
2957                        /* cache_image_flags  */ H5C_CI__GEN_MDCI_SBE_MESG,
2958                        /* file_id_ptr        */ &file_id,
2959                        /* file_ptr_ptr       */ &file_ptr,
2960                        /* cache_ptr_ptr      */ &cache_ptr);
2961     }
2962 
2963     if ( show_progress ) /* 4 */
2964         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2965 
2966 
2967     /* 5) Close the file. */
2968 
2969     if ( pass ) {
2970 
2971         if ( H5Fclose(file_id) < 0  ) {
2972 
2973             pass = FALSE;
2974             failure_mssg = "H5Fclose() failed.\n";
2975         }
2976     }
2977 
2978     if ( show_progress ) /* 5 */
2979         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
2980 
2981 
2982     /* 5) Open the file.
2983      *
2984      *    Verify that the metadata cache is instructed
2985      *    to load the metadata cache image, and that the
2986      *    supplied address and length are HADDR_UNDEF and
2987      *    zero respectively.  Note that these values indicate
2988      *    that the metadata image block doesn't exist.
2989      */
2990 
2991     if ( pass ) {
2992 
2993         open_hdf5_file(/* create_file        */ FALSE,
2994             /* mdci_sbem_expected */ TRUE,
2995                        /* read_only          */ FALSE,
2996                        /* set_mdci_fapl      */ FALSE,
2997             /* config_fsm         */ FALSE,
2998             /* set_eoc            */ FALSE,
2999                        /* hdf_file_name      */ filename,
3000                        /* cache_image_flags  */ 0,
3001                        /* file_id_ptr        */ &file_id,
3002                        /* file_ptr_ptr       */ &file_ptr,
3003                        /* cache_ptr_ptr      */ &cache_ptr);
3004     }
3005 
3006     if ( show_progress ) /* 6 */
3007         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3008 
3009 
3010     /* 6) Close the file. */
3011 
3012     if ( pass ) {
3013 
3014         if ( H5Fclose(file_id) < 0  ) {
3015 
3016             pass = FALSE;
3017             failure_mssg = "H5Fclose() failed.\n";
3018         }
3019     }
3020 
3021     if ( show_progress ) /* 7 */
3022         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3023 
3024 
3025     /* 7) Delete the file. */
3026 
3027     if ( pass ) {
3028 
3029         if ( HDremove(filename) < 0 ) {
3030 
3031             pass = FALSE;
3032             failure_mssg = "HDremove() failed.\n";
3033         }
3034     }
3035 
3036 
3037     if ( pass ) { PASSED(); } else { H5_FAILED(); }
3038 
3039     if ( ! pass )
3040         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
3041                   FUNC, failure_mssg);
3042 
3043     return !pass;
3044 
3045 } /* check_cache_image_ctl_flow_6() */
3046 
3047 
3048 /*-------------------------------------------------------------------------
3049  * Function:    cache_image_smoke_check_1()
3050  *
3051  * Purpose:     This test is one of a sequence of tests intended
3052  *        to exercise the cache image feature verifying that it
3053  *        works more or less correctly in common cases.
3054  *
3055  *        This test is an initial smoke check, so the sequence of
3056  *        operations is relatively simple.  In particular, we are
3057  *        testing:
3058  *
3059  *            i) Creation of file with metadata cache image
3060  *               superblock extension message and cache image
3061  *               block.
3062  *
3063  *               ii) Open of file with metadata cache image superblock
3064  *               extension message and cache image block.
3065  *               Deserialization and removal of both, insertion
3066  *               of prefetched cache entries, and deserialization
3067  *               of prefetched cache entries as they are protected.
3068  *
3069  *              iii) Subsequent write of file without metadata cache
3070  *               image.
3071  *
3072  *               iv) Open and close of file with metadata cache image
3073  *               image requested, but with no operations on the
3074  *               file.
3075  *
3076  *        To do this:
3077  *
3078  *        1) Create a HDF5 file with the cache image FAPL entry.
3079  *
3080  *           Verify that the cache is informed of the cache image
3081  *           FAPL entry.
3082  *
3083  *           Set all cache image flags, forcing full functionality.
3084  *
3085  *        2) Create some datasets in the file.
3086  *
3087  *        3) Close the file.
3088  *
3089  *        4) Open the file.
3090  *
3091  *           Verify that the metadata cache is instructed
3092  *           to load the metadata cache image.
3093  *
3094  *        5) Open a dataset.
3095  *
3096  *           Verify that it contains the expected data
3097  *
3098  *        6) Close the file.
3099  *
3100  *        7) Open the file.
3101  *
3102  *           Verify that the file doesn't contain a metadata cache
3103  *           image superblock extension message.
3104  *
3105  *        8) Open a dataset.
3106  *
3107  *           Verify that it contains the expected data.
3108  *
3109  *        9) Close the file.
3110  *
3111  *            10) Open the file with the cache image FAPL entry.
3112  *
3113  *           Verify that the cache is informed of the cache image
3114  *           FAPL entry.
3115  *
3116  *           Set all cache image flags, forcing full functionality.
3117  *
3118  *           11) Close the file.  Since there has been no access to
3119  *           any entries that would be included in the cache image,
3120  *           there should be no cache image.
3121  *
3122  *           12) Open the file.
3123  *
3124  *           Verify that the file doesn't contain a metadata cache
3125  *           image superblock extension message.
3126  *
3127  *           13) Open a dataset.
3128  *
3129  *           Verify that it contains the expected data.
3130  *
3131  *           14) Close the file.
3132  *
3133  *           15) Delete the file.
3134  *
3135  * Return:      void
3136  *
3137  * Programmer:  John Mainzer
3138  *              8/17/15
3139  *
3140  *-------------------------------------------------------------------------
3141  */
3142 
3143 static unsigned
cache_image_smoke_check_1(void)3144 cache_image_smoke_check_1(void)
3145 {
3146     const char * fcn_name = "cache_image_smoke_check_1()";
3147     char filename[512];
3148     hbool_t show_progress = FALSE;
3149     hid_t file_id = -1;
3150     H5F_t *file_ptr = NULL;
3151     H5C_t *cache_ptr = NULL;
3152     int cp = 0;
3153 
3154     TESTING("metadata cache image smoke check 1");
3155 
3156     pass = TRUE;
3157 
3158     if ( show_progress )
3159         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3160 
3161 
3162     /* setup the file name */
3163     if ( pass ) {
3164 
3165         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
3166             == NULL ) {
3167 
3168             pass = FALSE;
3169             failure_mssg = "h5_fixname() failed.\n";
3170         }
3171     }
3172 
3173     if ( show_progress )
3174         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3175 
3176 
3177     /* 1) Create a HDF5 file with the cache image FAPL entry.
3178      *
3179      *      Verify that the cache is informed of the cache image FAPL entry.
3180      *
3181      *    Set flags forcing full function of the cache image feature.
3182      */
3183 
3184     if ( pass ) {
3185 
3186         open_hdf5_file(/* create_file        */ TRUE,
3187                        /* mdci_sbem_expected */ FALSE,
3188                        /* read_only          */ FALSE,
3189                        /* set_mdci_fapl      */ TRUE,
3190             /* config_fsm         */ FALSE,
3191             /* set_eoc            */ FALSE,
3192                        /* hdf_file_name      */ filename,
3193                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
3194                        /* file_id_ptr        */ &file_id,
3195                        /* file_ptr_ptr       */ &file_ptr,
3196                        /* cache_ptr_ptr      */ &cache_ptr);
3197     }
3198 
3199     if ( show_progress )
3200         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3201 
3202 
3203     /* 2) Create some datasets in the file. */
3204 
3205     if ( pass ) {
3206 
3207         create_datasets(file_id, 0, 5);
3208     }
3209 
3210 #if H5C_COLLECT_CACHE_STATS
3211     if ( pass ) {
3212 
3213         if ( cache_ptr->images_loaded != 0 ) {
3214 
3215             pass = FALSE;
3216             failure_mssg = "metadata cache image block loaded(1).";
3217         }
3218     }
3219 #endif /* H5C_COLLECT_CACHE_STATS */
3220 
3221 
3222 
3223     if ( show_progress )
3224         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3225 
3226 
3227     /* 3) Close the file. */
3228 
3229     if ( pass ) {
3230 
3231         if ( H5Fclose(file_id) < 0  ) {
3232 
3233             pass = FALSE;
3234             failure_mssg = "H5Fclose() failed.\n";
3235 
3236         }
3237     }
3238 
3239     if ( show_progress )
3240         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3241 
3242 
3243     /* 4) Open the file.
3244      *
3245      *    Verify that the metadata cache is instructed to load the
3246      *    metadata cache image, and that the supplied address and length
3247      *    are HADDR_UNDEF and zero respectively.  Note that these values
3248      *    indicate that the metadata image block doesn't exist.
3249      */
3250 
3251     if ( pass ) {
3252 
3253         open_hdf5_file(/* create_file        */ FALSE,
3254                 /* mdci_sbem_expected */ TRUE,
3255                        /* read_only          */ FALSE,
3256                        /* set_mdci_fapl      */ FALSE,
3257             /* config_fsm         */ FALSE,
3258             /* set_eoc            */ FALSE,
3259                        /* hdf_file_name      */ filename,
3260                        /* cache_image_flags  */ 0,
3261                        /* file_id_ptr        */ &file_id,
3262                        /* file_ptr_ptr       */ &file_ptr,
3263                        /* cache_ptr_ptr      */ &cache_ptr);
3264     }
3265 
3266     if ( show_progress )
3267         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3268 
3269 
3270     /* 5) Open and close a dataset.
3271      *
3272      *    Verify that the metadata cache image superblock
3273      *    extension message has been deleted.
3274      */
3275 
3276     if ( pass ) {
3277 
3278        verify_datasets(file_id, 0, 5);
3279     }
3280 
3281 #if H5C_COLLECT_CACHE_STATS
3282     if ( pass ) {
3283 
3284         if ( cache_ptr->images_loaded != 1 ) {
3285 
3286             pass = FALSE;
3287             failure_mssg = "metadata cache image block not loaded(1).";
3288         }
3289     }
3290 #endif /* H5C_COLLECT_CACHE_STATS */
3291 
3292     if ( show_progress )
3293         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3294 
3295 
3296     /* 6) Close the file. */
3297 
3298     if ( pass ) {
3299 
3300         if ( H5Fclose(file_id) < 0  ) {
3301 
3302             pass = FALSE;
3303             failure_mssg = "H5Fclose() failed.\n";
3304         }
3305     }
3306 
3307     if ( show_progress )
3308         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3309 
3310 
3311     /* 7) Open the file.
3312      *
3313      *    Verify that the file doesn't contain a metadata cache image
3314      *    superblock extension message.
3315      */
3316 
3317     if ( pass ) {
3318 
3319         open_hdf5_file(/* create_file        */ FALSE,
3320             /* mdci_sbem_expected */ FALSE,
3321                        /* read_only          */ FALSE,
3322                        /* set_mdci_fapl      */ FALSE,
3323             /* config_fsm         */ FALSE,
3324             /* set_eoc            */ FALSE,
3325                        /* hdf_file_name      */ filename,
3326                        /* cache_image_flags  */ 0,
3327                        /* file_id_ptr        */ &file_id,
3328                        /* file_ptr_ptr       */ &file_ptr,
3329                        /* cache_ptr_ptr      */ &cache_ptr);
3330     }
3331 
3332     if ( show_progress )
3333         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3334 
3335 
3336     /* 8) Open and close a dataset.
3337      *
3338      *    Verify that the metadata cache image superblock
3339      *    extension message has been deleted.
3340      */
3341 
3342     if ( pass ) {
3343 
3344        verify_datasets(file_id, 0, 5);
3345     }
3346 
3347 #if H5C_COLLECT_CACHE_STATS
3348     if ( pass ) {
3349 
3350         if ( cache_ptr->images_loaded != 0 ) {
3351 
3352             pass = FALSE;
3353             failure_mssg = "metadata cache image block loaded(2).";
3354         }
3355     }
3356 #endif /* H5C_COLLECT_CACHE_STATS */
3357 
3358 
3359     if ( show_progress )
3360         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3361 
3362 
3363     /* 9) Close the file. */
3364 
3365     if ( pass ) {
3366 
3367         if ( H5Fclose(file_id) < 0  ) {
3368 
3369             pass = FALSE;
3370             failure_mssg = "H5Fclose() failed.\n";
3371         }
3372     }
3373 
3374     if ( show_progress )
3375         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3376 
3377 
3378     /* 10) Open the file with the cache image FAPL entry.
3379      *
3380      *       Verify that the cache is informed of the cache image
3381      *       FAPL entry.
3382      */
3383 
3384     if ( pass ) {
3385 
3386         open_hdf5_file(/* create_file        */ FALSE,
3387                 /* mdci_sbem_expected */ FALSE,
3388                        /* read_only          */ FALSE,
3389                        /* set_mdci_fapl      */ TRUE,
3390             /* config_fsm         */ FALSE,
3391             /* set_eoc            */ FALSE,
3392                        /* hdf_file_name      */ filename,
3393                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
3394                        /* file_id_ptr        */ &file_id,
3395                        /* file_ptr_ptr       */ &file_ptr,
3396                        /* cache_ptr_ptr      */ &cache_ptr);
3397     }
3398 
3399     if ( show_progress )
3400         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3401 
3402 
3403     /* 11) Close the file.  Since there has been no access to
3404      *       any entries that would be included in the cache image,
3405      *       there should be no cache image.
3406      */
3407 
3408     if ( pass ) {
3409 
3410         if ( H5Fclose(file_id) < 0  ) {
3411 
3412             pass = FALSE;
3413             failure_mssg = "H5Fclose() failed.\n";
3414         }
3415     }
3416 
3417     if ( show_progress )
3418         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3419 
3420 
3421     /* 12) Open the file.
3422      *
3423      *       Verify that the file doesn't contain a metadata cache
3424      *       image superblock extension message.
3425      */
3426 
3427     if ( pass ) {
3428 
3429         open_hdf5_file(/* create_file        */ FALSE,
3430                 /* mdci_sbem_expected */ FALSE,
3431                        /* read_only          */ FALSE,
3432                        /* set_mdci_fapl      */ FALSE,
3433             /* config_fsm         */ FALSE,
3434             /* set_eoc            */ FALSE,
3435                        /* hdf_file_name      */ filename,
3436                        /* cache_image_flags  */ 0,
3437                        /* file_id_ptr        */ &file_id,
3438                        /* file_ptr_ptr       */ &file_ptr,
3439                        /* cache_ptr_ptr      */ &cache_ptr);
3440     }
3441 
3442     if ( show_progress )
3443         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3444 
3445 
3446     /* 13) Open a dataset.
3447      *
3448      *       Verify that it contains the expected data.
3449      */
3450 
3451     if ( pass ) {
3452 
3453        verify_datasets(file_id, 0, 5);
3454     }
3455 
3456 #if H5C_COLLECT_CACHE_STATS
3457     if ( pass ) {
3458 
3459         if ( cache_ptr->images_loaded != 0 ) {
3460 
3461             pass = FALSE;
3462             failure_mssg = "metadata cache image block loaded(3).";
3463         }
3464     }
3465 #endif /* H5C_COLLECT_CACHE_STATS */
3466 
3467 
3468     if ( show_progress )
3469         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3470 
3471 
3472     /* 14) Close the file. */
3473 
3474     if ( pass ) {
3475 
3476         if ( H5Fclose(file_id) < 0  ) {
3477 
3478             pass = FALSE;
3479             failure_mssg = "H5Fclose() failed.\n";
3480         }
3481     }
3482 
3483     if ( show_progress )
3484         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3485 
3486 
3487     /* 15) Delete the file */
3488 
3489     if ( pass ) {
3490 
3491         if ( HDremove(filename) < 0 ) {
3492 
3493             pass = FALSE;
3494             failure_mssg = "HDremove() failed.\n";
3495         }
3496     }
3497 
3498     if ( pass ) { PASSED(); } else { H5_FAILED(); }
3499 
3500     if ( ! pass )
3501         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
3502                   FUNC, failure_mssg);
3503 
3504     return !pass;
3505 
3506 } /* cache_image_smoke_check_1() */
3507 
3508 
3509 /*-------------------------------------------------------------------------
3510  * Function:    cache_image_smoke_check_2()
3511  *
3512  * Purpose:     This test is one of a sequence of tests intended
3513  *        to exercise the cache image feature verifying that it
3514  *        works more or less correctly in common cases.
3515  *
3516  *        This test is an initial smoke check, so the sequence of
3517  *        operations is relatively simple.  In particular, we are
3518  *        testing:
3519  *
3520  *            i) Creation of file with metadata cache image
3521  *               superblock extension message and cache image
3522  *               block.
3523  *
3524  *               ii) Open of file with metadata cache image superblock
3525  *               extension message and cache image block.  Write
3526  *               of prefetched entries to file on file close.
3527  *
3528  *        To do this:
3529  *
3530  *        1) Create a HDF5 file with the cache image FAPL entry.
3531  *
3532  *           Verify that the cache is informed of the cache image
3533  *           FAPL entry.
3534  *
3535  *           Set all cache image flags, forcing full functionality.
3536  *
3537  *        2) Create some datasets in the file.
3538  *
3539  *        3) Close the file.
3540  *
3541  *        4) Open the file.
3542  *
3543  *        5) Close the file.
3544  *
3545  *        6) Open the file.
3546  *
3547  *           Verify that the file doesn't contain a metadata cache
3548  *           image superblock extension message.
3549  *
3550  *        7) Open a dataset.
3551  *
3552  *           Verify that it contains the expected data.
3553  *
3554  *        8) Close the file.
3555  *
3556  *            9) Delete the file.
3557  *
3558  * Return:      void
3559  *
3560  * Programmer:  John Mainzer
3561  *              8/18/15
3562  *
3563  *-------------------------------------------------------------------------
3564  */
3565 
3566 static unsigned
cache_image_smoke_check_2(void)3567 cache_image_smoke_check_2(void)
3568 {
3569     const char * fcn_name = "cache_image_smoke_check_2()";
3570     char filename[512];
3571     hbool_t show_progress = FALSE;
3572     hid_t file_id = -1;
3573     H5F_t *file_ptr = NULL;
3574     H5C_t *cache_ptr = NULL;
3575     int cp = 0;
3576 
3577     TESTING("metadata cache image smoke check 2");
3578 
3579     pass = TRUE;
3580 
3581     if ( show_progress )
3582         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3583 
3584 
3585     /* setup the file name */
3586     if ( pass ) {
3587 
3588         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
3589             == NULL ) {
3590 
3591             pass = FALSE;
3592             failure_mssg = "h5_fixname() failed.\n";
3593         }
3594     }
3595 
3596     if ( show_progress )
3597         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3598 
3599 
3600     /* 1) Create a HDF5 file with the cache image FAPL entry.
3601      *
3602      *      Verify that the cache is informed of the cache image FAPL entry.
3603      *
3604      *    Set flags forcing full function of the cache image feature.
3605      */
3606 
3607     if ( pass ) {
3608 
3609         open_hdf5_file(/* create_file        */ TRUE,
3610                        /* mdci_sbem_expected */ FALSE,
3611                        /* read_only          */ FALSE,
3612                        /* set_mdci_fapl      */ TRUE,
3613             /* config_fsm         */ TRUE,
3614             /* set_eoc            */ FALSE,
3615                        /* hdf_file_name      */ filename,
3616                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
3617                        /* file_id_ptr        */ &file_id,
3618                        /* file_ptr_ptr       */ &file_ptr,
3619                        /* cache_ptr_ptr      */ &cache_ptr);
3620     }
3621 
3622     if ( show_progress )
3623         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3624 
3625 
3626     /* 2) Create some datasets in the file. */
3627 
3628     if ( pass ) {
3629 
3630         create_datasets(file_id, 0, 5);
3631     }
3632 
3633 #if H5C_COLLECT_CACHE_STATS
3634     if ( pass ) {
3635 
3636         if ( cache_ptr->images_loaded != 0 ) {
3637 
3638             pass = FALSE;
3639             failure_mssg = "metadata cache image block loaded(1).";
3640         }
3641     }
3642 #endif /* H5C_COLLECT_CACHE_STATS */
3643 
3644 
3645     if ( show_progress )
3646         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3647 
3648 
3649     /* 3) Close the file. */
3650 
3651     if ( pass ) {
3652 
3653         if ( H5Fclose(file_id) < 0  ) {
3654 
3655             pass = FALSE;
3656             failure_mssg = "H5Fclose() failed.\n";
3657 
3658         }
3659     }
3660 
3661     if ( show_progress )
3662         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3663 
3664     /* 4) Open the file.
3665      *
3666      *    Verify that the metadata cache is instructed to load the
3667      *    metadata cache image.
3668      */
3669 
3670     if ( pass ) {
3671 
3672         open_hdf5_file(/* create_file        */ FALSE,
3673                 /* mdci_sbem_expected */ TRUE,
3674                        /* read_only          */ FALSE,
3675                        /* set_mdci_fapl      */ FALSE,
3676             /* config_fsm         */ FALSE,
3677             /* set_eoc            */ FALSE,
3678                        /* hdf_file_name      */ filename,
3679                        /* cache_image_flags  */ 0,
3680                        /* file_id_ptr        */ &file_id,
3681                        /* file_ptr_ptr       */ &file_ptr,
3682                        /* cache_ptr_ptr      */ &cache_ptr);
3683     }
3684 
3685     /* can't verify that metadata cache image has been loaded directly,
3686      * as in this cache, the load will not happen until close, and thus
3687      * the images_created stat will not be readily available as it is
3688      * incremented just before the cache is shut down.
3689      */
3690 
3691     if ( show_progress )
3692         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3693 
3694 
3695     /* 5) Close the file. */
3696 
3697     if ( pass ) {
3698 
3699         if ( H5Fclose(file_id) < 0  ) {
3700 
3701             pass = FALSE;
3702             failure_mssg = "H5Fclose() failed.\n";
3703         }
3704     }
3705 
3706     if ( show_progress )
3707         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3708 
3709 
3710     /* 6) Open the file.
3711      *
3712      *    Verify that the file doesn't contain a metadata cache image
3713      *    superblock extension message.
3714      */
3715 
3716     if ( pass ) {
3717 
3718         open_hdf5_file(/* create_file        */ FALSE,
3719             /* mdci_sbem_expected */ FALSE,
3720                        /* read_only          */ FALSE,
3721                        /* set_mdci_fapl      */ FALSE,
3722             /* config_fsm         */ FALSE,
3723             /* set_eoc            */ FALSE,
3724                        /* hdf_file_name      */ filename,
3725                        /* cache_image_flags  */ 0,
3726                        /* file_id_ptr        */ &file_id,
3727                        /* file_ptr_ptr       */ &file_ptr,
3728                        /* cache_ptr_ptr      */ &cache_ptr);
3729     }
3730 
3731     if ( show_progress )
3732         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3733 
3734 
3735     /* 7) Open and close a dataset.
3736      *
3737      *    Verify that the metadata cache image superblock
3738      *    extension message has been deleted.
3739      */
3740 
3741     if ( pass ) {
3742 
3743        verify_datasets(file_id, 0, 5);
3744     }
3745 
3746     if ( show_progress )
3747         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3748 
3749 
3750     /* 8) Close the file. */
3751 
3752     if ( pass ) {
3753 
3754         if ( H5Fclose(file_id) < 0  ) {
3755 
3756             pass = FALSE;
3757             failure_mssg = "H5Fclose() failed.\n";
3758         }
3759     }
3760 
3761     if ( show_progress )
3762         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3763 
3764 
3765     /* 9) Delete the file */
3766 
3767     if ( pass ) {
3768 
3769         if ( HDremove(filename) < 0 ) {
3770 
3771             pass = FALSE;
3772             failure_mssg = "HDremove() failed.\n";
3773         }
3774     }
3775 
3776     if ( pass ) { PASSED(); } else { H5_FAILED(); }
3777 
3778     if ( ! pass )
3779         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
3780                   FUNC, failure_mssg);
3781 
3782     return !pass;
3783 
3784 } /* cache_image_smoke_check_2() */
3785 
3786 
3787 /*-------------------------------------------------------------------------
3788  * Function:    cache_image_smoke_check_3()
3789  *
3790  * Purpose:     This test is one of a sequence of tests intended
3791  *        to exercise the cache image feature verifying that it
3792  *        works more or less correctly in common cases.
3793  *
3794  *        This test is an initial smoke check, so the sequence of
3795  *        operations is relatively simple.  In particular, we are
3796  *        testing:
3797  *
3798  *            i) Creation of file with metadata cache image
3799  *               superblock extension message and cache image
3800  *               block.
3801  *
3802  *               ii) Read only open and close of file with metadata
3803  *               cache image superblock extension message and
3804  *               cache image block.
3805  *
3806  *              iii) Subsequent R/W open and close of file with metadata
3807  *                         cache image superblock extension message and
3808  *                         cache image block.
3809  *
3810  *        To do this:
3811  *
3812  *        1) Create a HDF5 file with the cache image FAPL entry.
3813  *
3814  *           Verify that the cache is informed of the cache image
3815  *           FAPL entry.
3816  *
3817  *           Set all cache image flags, forcing full functionality.
3818  *
3819  *        2) Create some datasets in the file.
3820  *
3821  *        3) Close the file.
3822  *
3823  *        4) Open the file read only.
3824  *
3825  *           Verify that the file contains a metadata cache
3826  *           image superblock extension message.
3827  *
3828  *        5 Open a dataset.
3829  *
3830  *          Verify that it contains the expected data.
3831  *
3832  *        6) Close the file.
3833  *
3834  *        7) Open the file.
3835  *
3836  *           Verify that the file contains a metadata cache
3837  *           image superblock extension message.
3838  *
3839  *        8 Open a dataset.
3840  *
3841  *          Verify that it contains the expected data.
3842  *
3843  *        9) Close the file.
3844  *
3845  *           10) Open the file.
3846  *
3847  *           Verify that the file doesn't contain a metadata cache
3848  *           image superblock extension message.
3849  *
3850  *           11) Open a dataset.
3851  *
3852  *           Verify that it contains the expected data.
3853  *
3854  *           12) Close the file.
3855  *
3856  *           13) Delete the file.
3857  *
3858  * Return:      void
3859  *
3860  * Programmer:  John Mainzer
3861  *              8/18/15
3862  *
3863  *-------------------------------------------------------------------------
3864  */
3865 
3866 static unsigned
cache_image_smoke_check_3(void)3867 cache_image_smoke_check_3(void)
3868 {
3869     const char * fcn_name = "cache_image_smoke_check_3()";
3870     char filename[512];
3871     hbool_t show_progress = FALSE;
3872     hid_t file_id = -1;
3873     H5F_t *file_ptr = NULL;
3874     H5C_t *cache_ptr = NULL;
3875     int cp = 0;
3876 
3877     TESTING("metadata cache image smoke check 3");
3878 
3879     pass = TRUE;
3880 
3881     if ( show_progress )
3882         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3883 
3884 
3885     /* setup the file name */
3886     if ( pass ) {
3887 
3888         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
3889             == NULL ) {
3890 
3891             pass = FALSE;
3892             failure_mssg = "h5_fixname() failed.\n";
3893         }
3894     }
3895 
3896     if ( show_progress )
3897         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3898 
3899 
3900     /* 1) Create a HDF5 file with the cache image FAPL entry.
3901      *
3902      *      Verify that the cache is informed of the cache image FAPL entry.
3903      *
3904      *    Set flags forcing full function of the cache image feature.
3905      */
3906 
3907     if ( pass ) {
3908 
3909         open_hdf5_file(/* create_file        */ TRUE,
3910                        /* mdci_sbem_expected */ FALSE,
3911                        /* read_only          */ FALSE,
3912                        /* set_mdci_fapl      */ TRUE,
3913             /* config_fsm         */ TRUE,
3914             /* set_eoc            */ FALSE,
3915                        /* hdf_file_name      */ filename,
3916                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
3917                        /* file_id_ptr        */ &file_id,
3918                        /* file_ptr_ptr       */ &file_ptr,
3919                        /* cache_ptr_ptr      */ &cache_ptr);
3920     }
3921 
3922     if ( show_progress )
3923         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3924 
3925 
3926     /* 2) Create some datasets in the file. */
3927 
3928     if ( pass ) {
3929 
3930         create_datasets(file_id, 0, 5);
3931     }
3932 
3933 #if H5C_COLLECT_CACHE_STATS
3934     if ( pass ) {
3935 
3936         if ( cache_ptr->images_loaded != 0 ) {
3937 
3938             pass = FALSE;
3939             failure_mssg = "metadata cache image block loaded(1).";
3940         }
3941     }
3942 #endif /* H5C_COLLECT_CACHE_STATS */
3943 
3944     if ( show_progress )
3945         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3946 
3947 
3948     /* 3) Close the file. */
3949 
3950     if ( pass ) {
3951 
3952         if ( H5Fclose(file_id) < 0  ) {
3953 
3954             pass = FALSE;
3955             failure_mssg = "H5Fclose() failed.\n";
3956 
3957         }
3958     }
3959 
3960     if ( show_progress )
3961         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3962 
3963 
3964     /* 4) Open the file read only.
3965      *
3966      *    Verify that the metadata cache is instructed to load the
3967      *    metadata cache image.
3968      */
3969 
3970     if ( pass ) {
3971 
3972         open_hdf5_file(/* create_file        */ FALSE,
3973                 /* mdci_sbem_expected */ TRUE,
3974                        /* read_only          */ TRUE,
3975                        /* set_mdci_fapl      */ FALSE,
3976             /* config_fsm         */ FALSE,
3977             /* set_eoc            */ FALSE,
3978                        /* hdf_file_name      */ filename,
3979                        /* cache_image_flags  */ 0,
3980                        /* file_id_ptr        */ &file_id,
3981                        /* file_ptr_ptr       */ &file_ptr,
3982                        /* cache_ptr_ptr      */ &cache_ptr);
3983     }
3984 
3985     if ( show_progress )
3986         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
3987 
3988 
3989     /* 5) Open and close a dataset.
3990      *
3991      *    Verify that the metadata cache image superblock
3992      *    extension message has been deleted.
3993      */
3994 
3995     if ( pass ) {
3996 
3997        verify_datasets(file_id, 0, 5);
3998     }
3999 
4000 #if H5C_COLLECT_CACHE_STATS
4001     if ( pass ) {
4002 
4003         if ( cache_ptr->images_loaded == 0 ) {
4004 
4005             pass = FALSE;
4006             failure_mssg = "metadata cache image block not loaded(1).";
4007         }
4008     }
4009 #endif /* H5C_COLLECT_CACHE_STATS */
4010 
4011     if ( show_progress )
4012         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4013 
4014 
4015     /* 6) Close the file. */
4016 
4017     if ( pass ) {
4018 
4019         if ( H5Fclose(file_id) < 0  ) {
4020 
4021             pass = FALSE;
4022             failure_mssg = "H5Fclose() failed.\n";
4023         }
4024     }
4025 
4026     if ( show_progress )
4027         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4028 
4029 
4030     /* 7) Open the file.
4031      *
4032      *    Verify that the file contains a metadata cache image
4033      *    superblock extension message.
4034      */
4035 
4036     if ( pass ) {
4037 
4038         open_hdf5_file(/* create_file        */ FALSE,
4039             /* mdci_sbem_expected */ TRUE,
4040                        /* read_only          */ FALSE,
4041                        /* set_mdci_fapl      */ FALSE,
4042             /* config_fsm         */ FALSE,
4043             /* set_eoc            */ FALSE,
4044                        /* hdf_file_name      */ filename,
4045                        /* cache_image_flags  */ 0,
4046                        /* file_id_ptr        */ &file_id,
4047                        /* file_ptr_ptr       */ &file_ptr,
4048                        /* cache_ptr_ptr      */ &cache_ptr);
4049     }
4050 
4051     if ( show_progress )
4052         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4053 
4054 
4055     /* 8) Open and close a dataset.
4056      *
4057      *    Verify that the metadata cache image superblock
4058      *    extension message has been deleted.
4059      */
4060 
4061     if ( pass ) {
4062 
4063        verify_datasets(file_id, 0, 5);
4064     }
4065 
4066 #if H5C_COLLECT_CACHE_STATS
4067     if ( pass ) {
4068 
4069         if ( cache_ptr->images_loaded == 0 ) {
4070 
4071             pass = FALSE;
4072             failure_mssg = "metadata cache image block not loaded(2).";
4073         }
4074     }
4075 #endif /* H5C_COLLECT_CACHE_STATS */
4076 
4077 
4078     if ( show_progress )
4079         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4080 
4081 
4082     /* 9) Close the file. */
4083 
4084     if ( pass ) {
4085 
4086         if ( H5Fclose(file_id) < 0  ) {
4087 
4088             pass = FALSE;
4089             failure_mssg = "H5Fclose() failed.\n";
4090         }
4091     }
4092 
4093 
4094     /* 10) Open the file.
4095      *
4096      *    Verify that the file doesn't contain a metadata cache image
4097      *    superblock extension message.
4098      */
4099 
4100     if ( pass ) {
4101 
4102         open_hdf5_file(/* create_file        */ FALSE,
4103             /* mdci_sbem_expected */ FALSE,
4104                        /* read_only          */ FALSE,
4105                        /* set_mdci_fapl      */ FALSE,
4106             /* config_fsm         */ FALSE,
4107             /* set_eoc            */ FALSE,
4108                        /* hdf_file_name      */ filename,
4109                        /* cache_image_flags  */ 0,
4110                        /* file_id_ptr        */ &file_id,
4111                        /* file_ptr_ptr       */ &file_ptr,
4112                        /* cache_ptr_ptr      */ &cache_ptr);
4113     }
4114 
4115     if ( show_progress )
4116         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4117 
4118 
4119     /* 11) Open and close a dataset.
4120      *
4121      *    Verify that the metadata cache image superblock
4122      *    extension message has been deleted.
4123      */
4124 
4125     if ( pass ) {
4126 
4127        verify_datasets(file_id, 0, 5);
4128     }
4129 
4130 #if H5C_COLLECT_CACHE_STATS
4131     if ( pass ) {
4132 
4133         if ( cache_ptr->images_loaded != 0 ) {
4134 
4135             pass = FALSE;
4136             failure_mssg = "metadata cache image block loaded(2).";
4137         }
4138     }
4139 #endif /* H5C_COLLECT_CACHE_STATS */
4140 
4141 
4142     if ( show_progress )
4143         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4144 
4145 
4146     /* 12) Close the file. */
4147 
4148     if ( pass ) {
4149 
4150         if ( H5Fclose(file_id) < 0  ) {
4151 
4152             pass = FALSE;
4153             failure_mssg = "H5Fclose() failed.\n";
4154         }
4155     }
4156 
4157     if ( show_progress )
4158         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4159 
4160 
4161     /* 13) Delete the file */
4162 
4163     if ( pass ) {
4164 
4165         if ( HDremove(filename) < 0 ) {
4166 
4167             pass = FALSE;
4168             failure_mssg = "HDremove() failed.\n";
4169         }
4170     }
4171 
4172     if ( pass ) { PASSED(); } else { H5_FAILED(); }
4173 
4174     if ( ! pass )
4175         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
4176                   FUNC, failure_mssg);
4177 
4178     return !pass;
4179 
4180 } /* cache_image_smoke_check_3() */
4181 
4182 
4183 /*-------------------------------------------------------------------------
4184  * Function:    cache_image_smoke_check_4()
4185  *
4186  * Purpose:     This test attempts to mimic the typical "poor man's
4187  *        parallel use case in which the file is passed between
4188  *        processes, each of which open the file, write some data,
4189  *        close the file, and then pass control on to the next
4190  *        process.
4191  *
4192  *        In this case, we only write one dataset per process.
4193  *
4194  *        Cycle of operation
4195  *
4196  *        1) Create a HDF5 file with the cache image FAPL entry.
4197  *
4198  *           Verify that the cache is informed of the cache image
4199  *           FAPL entry.
4200  *
4201  *           Set all cache image flags, forcing full functionality.
4202  *
4203  *        2) Create and write a dataset in the file.
4204  *
4205  *        3) Close the file.
4206  *
4207  *        4) Open the file with the cache image FAPL entry.
4208  *
4209  *           Verify that the file contains a metadata cache
4210  *           image superblock extension message.
4211  *
4212  *        5 Create and write a new dataset
4213  *
4214  *        6) Close the file.
4215  *
4216  *           If sufficient datasets have been created, continue to
4217  *                 7).  Otherwise goto 4)
4218  *
4219  *        7) Open the file.
4220  *
4221  *           Verify that the file contains a metadata cache
4222  *           image superblock extension message.
4223  *
4224  *            8) Open all datasets that have been created, and
4225  *           verify that they contain the expected data.
4226  *
4227  *            9) Close the file.
4228  *
4229  *           10) Open the file.
4230  *
4231  *           Verify that the file doesn't contain a metadata cache
4232  *           image superblock extension message.
4233  *
4234  *           11) Open all datasets that have been created, and
4235  *                 verify that they contain the expected data.
4236  *
4237  *           Verify that it contains the expected data.
4238  *
4239  *           12) Close the file.
4240  *
4241  *           13) Delete the file.
4242  *
4243  * Return:      void
4244  *
4245  * Programmer:  John Mainzer
4246  *              8/18/15
4247  *
4248  *-------------------------------------------------------------------------
4249  */
4250 
4251 static unsigned
cache_image_smoke_check_4(void)4252 cache_image_smoke_check_4(void)
4253 {
4254     const char * fcn_name = "cache_image_smoke_check_4()";
4255     char filename[512];
4256     hbool_t show_progress = FALSE;
4257     hid_t file_id = -1;
4258     H5F_t *file_ptr = NULL;
4259     H5C_t *cache_ptr = NULL;
4260     int cp = 0;
4261     int min_dset = 0;
4262     int max_dset = 0;
4263 
4264     TESTING("metadata cache image smoke check 4");
4265 
4266     pass = TRUE;
4267 
4268     if ( show_progress )
4269         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4270 
4271 
4272     /* setup the file name */
4273     if ( pass ) {
4274 
4275         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
4276             == NULL ) {
4277 
4278             pass = FALSE;
4279             failure_mssg = "h5_fixname() failed.\n";
4280         }
4281     }
4282 
4283     if ( show_progress )
4284         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4285 
4286 
4287     /* 1) Create a HDF5 file with the cache image FAPL entry.
4288      *
4289      *      Verify that the cache is informed of the cache image FAPL entry.
4290      *
4291      *    Set flags forcing full function of the cache image feature.
4292      */
4293 
4294     if ( pass ) {
4295 
4296         open_hdf5_file(/* create_file        */ TRUE,
4297                        /* mdci_sbem_expected */ FALSE,
4298                        /* read_only          */ FALSE,
4299                        /* set_mdci_fapl      */ TRUE,
4300             /* config_fsm         */ TRUE,
4301             /* set_eoc            */ FALSE,
4302                        /* hdf_file_name      */ filename,
4303                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
4304                        /* file_id_ptr        */ &file_id,
4305                        /* file_ptr_ptr       */ &file_ptr,
4306                        /* cache_ptr_ptr      */ &cache_ptr);
4307     }
4308 
4309     if ( show_progress )
4310         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4311 
4312 
4313     /* 2) Create a dataset in the file. */
4314 
4315     if ( pass ) {
4316 
4317         create_datasets(file_id, min_dset++, max_dset++);
4318     }
4319 
4320 #if H5C_COLLECT_CACHE_STATS
4321     if ( pass ) {
4322 
4323         if ( cache_ptr->images_loaded != 0 ) {
4324 
4325             pass = FALSE;
4326             failure_mssg = "metadata cache image block loaded(1).";
4327         }
4328     }
4329 #endif /* H5C_COLLECT_CACHE_STATS */
4330 
4331     if ( show_progress )
4332         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4333 
4334 
4335     /* 3) Close the file. */
4336 
4337     if ( pass ) {
4338 
4339         if ( H5Fclose(file_id) < 0  ) {
4340 
4341             pass = FALSE;
4342             failure_mssg = "H5Fclose() failed.\n";
4343 
4344         }
4345     }
4346 
4347     if ( show_progress )
4348         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4349 
4350     while ( ( pass ) && ( max_dset < MAX_NUM_DSETS ) )
4351     {
4352 
4353         /* 4) Open the file.
4354          *
4355          *    Verify that the metadata cache is instructed to load the
4356          *    metadata cache image.
4357          */
4358 
4359         if ( pass ) {
4360 
4361             open_hdf5_file(/* create_file        */ FALSE,
4362                     /* mdci_sbem_expected */ TRUE,
4363                            /* read_only          */ FALSE,
4364                            /* set_mdci_fapl      */ TRUE,
4365                 /* config_fsm         */ FALSE,
4366                 /* set_eoc            */ FALSE,
4367                            /* hdf_file_name      */ filename,
4368                            /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
4369                            /* file_id_ptr        */ &file_id,
4370                            /* file_ptr_ptr       */ &file_ptr,
4371                            /* cache_ptr_ptr      */ &cache_ptr);
4372         }
4373 
4374         if ( show_progress )
4375             HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n",
4376                       fcn_name, cp, max_dset, pass);
4377 
4378 
4379         /* 5) Create a dataset in the file. */
4380 
4381         if ( pass ) {
4382 
4383             create_datasets(file_id, min_dset++, max_dset++);
4384         }
4385 
4386 #if H5C_COLLECT_CACHE_STATS
4387         if ( pass ) {
4388 
4389             if ( cache_ptr->images_loaded == 0 ) {
4390 
4391                 pass = FALSE;
4392                 failure_mssg = "metadata cache image block not loaded(1).";
4393             }
4394         }
4395 #endif /* H5C_COLLECT_CACHE_STATS */
4396 
4397         if ( show_progress )
4398             HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n",
4399                       fcn_name, cp + 1, max_dset, pass);
4400 
4401 
4402         /* 6) Close the file. */
4403 
4404         if ( pass ) {
4405 
4406             if ( H5Fclose(file_id) < 0  ) {
4407 
4408                 pass = FALSE;
4409                 failure_mssg = "H5Fclose() failed.\n";
4410 
4411             }
4412         }
4413 
4414         if ( show_progress )
4415             HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n",
4416                       fcn_name, cp + 2, max_dset, pass);
4417     } /* end while */
4418     cp += 3;
4419 
4420 
4421     /* 7) Open the file.
4422      *
4423      *    Verify that the file contains a metadata cache image
4424      *    superblock extension message.
4425      */
4426 
4427     if ( pass ) {
4428 
4429         open_hdf5_file(/* create_file        */ FALSE,
4430             /* mdci_sbem_expected */ TRUE,
4431                        /* read_only          */ FALSE,
4432                        /* set_mdci_fapl      */ FALSE,
4433             /* config_fsm         */ FALSE,
4434             /* set_eoc            */ FALSE,
4435                        /* hdf_file_name      */ filename,
4436                        /* cache_image_flags  */ 0,
4437                        /* file_id_ptr        */ &file_id,
4438                        /* file_ptr_ptr       */ &file_ptr,
4439                        /* cache_ptr_ptr      */ &cache_ptr);
4440     }
4441 
4442     if ( show_progress )
4443         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4444 
4445 
4446     /* 8) Open and close all datasets.
4447      *
4448      *    Verify that the metadata cache image superblock
4449      *    extension message has been deleted.
4450      */
4451 
4452     if ( pass ) {
4453 
4454        verify_datasets(file_id, 0, max_dset - 1);
4455     }
4456 
4457 #if H5C_COLLECT_CACHE_STATS
4458     if ( pass ) {
4459 
4460         if ( cache_ptr->images_loaded == 0 ) {
4461 
4462             pass = FALSE;
4463             failure_mssg = "metadata cache image block not loaded(2).";
4464         }
4465     }
4466 #endif /* H5C_COLLECT_CACHE_STATS */
4467 
4468 
4469     if ( show_progress )
4470         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4471 
4472 
4473     /* 9) Close the file. */
4474 
4475     if ( pass ) {
4476 
4477         if ( H5Fclose(file_id) < 0  ) {
4478 
4479             pass = FALSE;
4480             failure_mssg = "H5Fclose() failed.\n";
4481         }
4482     }
4483 
4484 
4485     /* 10) Open the file.
4486      *
4487      *    Verify that the file doesn't contain a metadata cache image
4488      *    superblock extension message.
4489      */
4490 
4491     if ( pass ) {
4492 
4493         open_hdf5_file(/* create_file        */ FALSE,
4494             /* mdci_sbem_expected */ FALSE,
4495                        /* read_only          */ FALSE,
4496                        /* set_mdci_fapl      */ FALSE,
4497             /* config_fsm         */ FALSE,
4498             /* set_eoc            */ FALSE,
4499                        /* hdf_file_name      */ filename,
4500                        /* cache_image_flags  */ 0,
4501                        /* file_id_ptr        */ &file_id,
4502                        /* file_ptr_ptr       */ &file_ptr,
4503                        /* cache_ptr_ptr      */ &cache_ptr);
4504     }
4505 
4506     if ( show_progress )
4507         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4508 
4509 
4510     /* 11) Open and close all datasets.
4511      *
4512      *    Verify that the metadata cache image superblock
4513      *    extension message has been deleted.
4514      */
4515 
4516     if ( pass ) {
4517 
4518        verify_datasets(file_id, 0, max_dset - 1);
4519     }
4520 
4521 #if H5C_COLLECT_CACHE_STATS
4522     if ( pass ) {
4523 
4524         if ( cache_ptr->images_loaded != 0 ) {
4525 
4526             pass = FALSE;
4527             failure_mssg = "metadata cache image block loaded(2).";
4528         }
4529     }
4530 #endif /* H5C_COLLECT_CACHE_STATS */
4531 
4532 
4533     if ( show_progress )
4534         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4535 
4536 
4537     /* 12) Close the file. */
4538 
4539     if ( pass ) {
4540 
4541         if ( H5Fclose(file_id) < 0  ) {
4542 
4543             pass = FALSE;
4544             failure_mssg = "H5Fclose() failed.\n";
4545         }
4546     }
4547 
4548     if ( show_progress )
4549         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4550 
4551     /* 13) Delete the file */
4552 
4553     if ( pass ) {
4554 
4555         if ( HDremove(filename) < 0 ) {
4556 
4557             pass = FALSE;
4558             failure_mssg = "HDremove() failed.\n";
4559         }
4560     }
4561 
4562     if ( pass ) { PASSED(); } else { H5_FAILED(); }
4563 
4564     if ( ! pass )
4565         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
4566                   FUNC, failure_mssg);
4567 
4568     return !pass;
4569 } /* cache_image_smoke_check_4() */
4570 
4571 
4572 /*-------------------------------------------------------------------------
4573  * Function:    cache_image_smoke_check_5()
4574  *
4575  * Purpose:     This test attempts to mimic the typical "poor man's
4576  *        parallel use case in which the file is passed between
4577  *        processes, each of which open the file, write some data,
4578  *        close the file, and then pass control on to the next
4579  *        process.
4580  *
4581  *        In this case, we create one group for each process, and
4582  *        populate it with a "zoo" of HDF5 objects selected to
4583  *        (ideally) exercise all HDF5 on disk data structures.
4584  *
4585  *        Cycle of operation
4586  *
4587  *        1) Create a HDF5 file with the cache image FAPL entry.
4588  *
4589  *           Verify that the cache is informed of the cache image
4590  *           FAPL entry.
4591  *
4592  *           Set all cache image flags, forcing full functionality.
4593  *
4594  *        2) Create a process specific group.
4595  *
4596  *        3) Construct a "zoo" in the above group, and validate it.
4597  *
4598  *        4) Close the file.
4599  *
4600  *        5) Open the file with the cache image FAPL entry.
4601  *
4602  *           Verify that the file contains a metadata cache
4603  *           image superblock extension message.
4604  *
4605  *        6) Validate the "zoo" created in the previous file open.
4606  *
4607  *        7) Create a process specific group for this file open
4608  *
4609  *        8) Construct a "zoo" in the above group, and validate it.
4610  *
4611  *        9) Close the file.
4612  *
4613  *           If sufficient zoos have been created, continue to
4614  *                 10).  Otherwise goto 5)
4615  *
4616  *           10) Open the file R/O.
4617  *
4618  *           Verify that the file contains a metadata cache
4619  *           image superblock extension message.
4620  *
4621  *           11) Validate all the zoos.
4622  *
4623  *           12) Close the file.
4624  *
4625  *           13) Open the file.
4626  *
4627  *           Verify that the file contains a metadata cache
4628  *           image superblock extension message.
4629  *
4630  *           14) Validate all the zoos.
4631  *
4632  *           15) Close the file.
4633  *
4634  *           16) Open the file.
4635  *
4636  *           Verify that the file doesn't contain a metadata cache
4637  *           image superblock extension message.
4638  *
4639  *           17) Validate all the zoos.
4640  *
4641  *           18) Close the file.
4642  *
4643  *           19) Delete the file.
4644  *
4645  * Return:      void
4646  *
4647  * Programmer:  John Mainzer
4648  *              9/15/15
4649  *
4650  *-------------------------------------------------------------------------
4651  */
4652 
4653 #define MAX_NUM_GROUPS 128
4654 
4655 static unsigned
cache_image_smoke_check_5(void)4656 cache_image_smoke_check_5(void)
4657 {
4658     const char * fcn_name = "cache_image_smoke_check_5()";
4659     char filename[512];
4660     char process_group_name[512];
4661     hbool_t show_progress = FALSE;
4662     hid_t file_id = -1;
4663     hid_t proc_gid = -1;
4664     H5F_t *file_ptr = NULL;
4665     H5C_t *cache_ptr = NULL;
4666     int cp = 0;
4667     int i;
4668     int min_group = 0;
4669     int max_group = 0;
4670 
4671     TESTING("metadata cache image smoke check 5");
4672 
4673     pass = TRUE;
4674 
4675     if ( show_progress )
4676         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4677 
4678 
4679     /* setup the file name */
4680     if ( pass ) {
4681 
4682         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
4683             == NULL ) {
4684 
4685             pass = FALSE;
4686             failure_mssg = "h5_fixname() failed.\n";
4687         }
4688     }
4689 
4690     if ( show_progress )
4691         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4692 
4693 
4694     /* 1) Create a HDF5 file with the cache image FAPL entry.
4695      *
4696      *      Verify that the cache is informed of the cache image FAPL entry.
4697      *
4698      *    Set flags forcing full function of the cache image feature.
4699      */
4700 
4701     if ( pass ) {
4702 
4703         open_hdf5_file(/* create_file        */ TRUE,
4704                        /* mdci_sbem_expected */ FALSE,
4705                        /* read_only          */ FALSE,
4706                        /* set_mdci_fapl      */ TRUE,
4707             /* config_fsm         */ TRUE,
4708             /* set_eoc            */ FALSE,
4709                        /* hdf_file_name      */ filename,
4710                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
4711                        /* file_id_ptr        */ &file_id,
4712                        /* file_ptr_ptr       */ &file_ptr,
4713                        /* cache_ptr_ptr      */ &cache_ptr);
4714     }
4715 
4716     if ( show_progress )
4717         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4718 
4719 
4720     /* 2) Create a process specific group. */
4721     if ( pass ) {
4722 
4723         HDsprintf(process_group_name, "/process_%d", min_group);
4724 
4725         proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT,
4726                               H5P_DEFAULT, H5P_DEFAULT);
4727 
4728         if ( proc_gid < 0 ) {
4729 
4730         pass = FALSE;
4731         failure_mssg = "H5Gcreate2() failed (1).\n";
4732         }
4733     }
4734 
4735     if ( show_progress )
4736         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4737 
4738 
4739     /* 3) Construct a "zoo" in the above group, and validate it. */
4740     if ( pass )
4741         create_zoo(file_id, process_group_name, min_group);
4742 
4743 #if H5C_COLLECT_CACHE_STATS
4744     if ( pass ) {
4745 
4746         if ( cache_ptr->images_loaded != 0 ) {
4747 
4748             pass = FALSE;
4749             failure_mssg = "metadata cache image block loaded(1).";
4750         }
4751     }
4752 #endif /* H5C_COLLECT_CACHE_STATS */
4753 
4754     if ( show_progress )
4755         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4756 
4757 
4758     /* 4) Close the file. */
4759 
4760     if ( pass ) {
4761 
4762     if ( H5Gclose(proc_gid) < 0 ) {
4763 
4764             pass = FALSE;
4765             failure_mssg = "H5Gclose(proc_gid) failed. (1)";
4766         }
4767     }
4768 
4769     if ( pass ) {
4770 
4771         if ( H5Fclose(file_id) < 0  ) {
4772 
4773             pass = FALSE;
4774             failure_mssg = "H5Fclose() failed.\n";
4775 
4776         }
4777     }
4778 
4779     if ( show_progress )
4780         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4781 
4782     while ( ( pass ) && ( max_group < MAX_NUM_GROUPS ) )
4783     {
4784 
4785         /* 5) Open the file.
4786          *
4787          *    Verify that the metadata cache is instructed to load the
4788          *    metadata cache image.
4789          */
4790 
4791         if ( pass ) {
4792 
4793             open_hdf5_file(/* create_file        */ FALSE,
4794                     /* mdci_sbem_expected */ TRUE,
4795                            /* read_only          */ FALSE,
4796                            /* set_mdci_fapl      */ TRUE,
4797                 /* config_fsm         */ FALSE,
4798                 /* set_eoc            */ FALSE,
4799                            /* hdf_file_name      */ filename,
4800                            /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
4801                            /* file_id_ptr        */ &file_id,
4802                            /* file_ptr_ptr       */ &file_ptr,
4803                            /* cache_ptr_ptr      */ &cache_ptr);
4804         }
4805 
4806         if ( show_progress )
4807             HDfprintf(stdout, "%s:L1 cp = %d, max_group = %d, pass = %d.\n",
4808                       fcn_name, cp, max_group, pass);
4809 
4810 
4811         /* 6) Validate the "zoo" created in the previous file open. */
4812         if ( pass )
4813             validate_zoo(file_id, process_group_name, max_group);
4814 
4815 #if H5C_COLLECT_CACHE_STATS
4816         if ( pass ) {
4817 
4818             if ( cache_ptr->images_loaded == 0 ) {
4819 
4820                 pass = FALSE;
4821                 failure_mssg = "metadata cache image block not loaded(1).";
4822             }
4823         }
4824 #endif /* H5C_COLLECT_CACHE_STATS */
4825 
4826         if ( show_progress )
4827             HDfprintf(stdout, "%s:L2 cp = %d, max_group = %d, pass = %d.\n",
4828                       fcn_name, cp + 1, max_group, pass);
4829 
4830 
4831     /* 7) Create a process specific group for this file open */
4832         if ( pass ) {
4833 
4834         max_group++;
4835         HDsprintf(process_group_name, "/process_%d", max_group);
4836 
4837             proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT,
4838                                   H5P_DEFAULT, H5P_DEFAULT);
4839 
4840             if ( proc_gid < 0 ) {
4841 
4842             pass = FALSE;
4843             failure_mssg = "H5Gcreate2() failed (2).\n";
4844             }
4845         }
4846 
4847         if ( show_progress )
4848             HDfprintf(stdout, "%s:L3 cp = %d, max_group = %d, pass = %d.\n",
4849                       fcn_name, cp + 2, max_group, pass);
4850 
4851 
4852     /* 8) Construct a "zoo" in the above group, and validate it. */
4853         if ( pass )
4854             create_zoo(file_id, process_group_name, max_group);
4855 
4856         if ( show_progress )
4857             HDfprintf(stdout, "%s:L4 cp = %d, max_group = %d, pass = %d.\n",
4858                       fcn_name, cp + 3, max_group, pass);
4859 
4860 
4861         /* 9) Close the file. */
4862 
4863         if ( pass ) {
4864 
4865         if ( H5Gclose(proc_gid) < 0 ) {
4866 
4867                 pass = FALSE;
4868                 failure_mssg = "H5Gclose(process_gid) failed. (2)";
4869             }
4870         }
4871 
4872         if ( pass ) {
4873 
4874             if ( H5Fclose(file_id) < 0  ) {
4875 
4876                 pass = FALSE;
4877                 failure_mssg = "H5Fclose() failed.\n";
4878 
4879             }
4880         }
4881 
4882         if ( show_progress )
4883             HDfprintf(stdout, "%s:L5 cp = %d, max_group = %d, pass = %d.\n",
4884                       fcn_name, cp + 4, max_group, pass);
4885     } /* end while */
4886     cp += 5;
4887 
4888     /* 10) Open the file read only.
4889      *
4890      *    Verify that the file contains a metadata cache image
4891      *    superblock extension message.
4892      */
4893     if(pass) {
4894         open_hdf5_file(/* create_file        */ FALSE,
4895             /* mdci_sbem_expected */ TRUE,
4896                        /* read_only          */ TRUE,
4897                        /* set_mdci_fapl      */ FALSE,
4898             /* config_fsm         */ FALSE,
4899             /* set_eoc            */ FALSE,
4900                        /* hdf_file_name      */ filename,
4901                        /* cache_image_flags  */ 0,
4902                        /* file_id_ptr        */ &file_id,
4903                        /* file_ptr_ptr       */ &file_ptr,
4904                        /* cache_ptr_ptr      */ &cache_ptr);
4905     }
4906 
4907     if(show_progress)
4908         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4909 
4910 
4911     /* 11) Validate all the zoos. */
4912     i = min_group;
4913     while(pass && i <= max_group) {
4914         HDsprintf(process_group_name, "/process_%d", i);
4915         validate_zoo(file_id, process_group_name, i++);
4916     }
4917 
4918 #if H5C_COLLECT_CACHE_STATS
4919     if( pass) {
4920         if(cache_ptr->images_loaded == 0) {
4921             pass = FALSE;
4922             failure_mssg = "metadata cache image block not loaded(2).";
4923         }
4924     }
4925 #endif /* H5C_COLLECT_CACHE_STATS */
4926 
4927     if(show_progress)
4928         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4929 
4930     /* 12) Close the file. */
4931     if(pass) {
4932         if(H5Fclose(file_id) < 0) {
4933             pass = FALSE;
4934             failure_mssg = "H5Fclose() failed.\n";
4935         }
4936     }
4937 
4938     /* 13) Open the file R/W.
4939      *
4940      *    Verify that the file contains a metadata cache image
4941      *    superblock extension message.
4942      */
4943 
4944     if ( pass ) {
4945 
4946         open_hdf5_file(/* create_file        */ FALSE,
4947             /* mdci_sbem_expected */ TRUE,
4948                        /* read_only          */ FALSE,
4949                        /* set_mdci_fapl      */ FALSE,
4950             /* config_fsm         */ FALSE,
4951             /* set_eoc            */ FALSE,
4952                        /* hdf_file_name      */ filename,
4953                        /* cache_image_flags  */ 0,
4954                        /* file_id_ptr        */ &file_id,
4955                        /* file_ptr_ptr       */ &file_ptr,
4956                        /* cache_ptr_ptr      */ &cache_ptr);
4957     }
4958 
4959     if ( show_progress )
4960         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4961 
4962 
4963     /* 14) Validate all the zoos. */
4964     i = min_group;
4965     while ( ( pass ) && ( i <= max_group ) ) {
4966 
4967         HDsprintf(process_group_name, "/process_%d", i);
4968         validate_zoo(file_id, process_group_name, i++);
4969     }
4970 
4971 #if H5C_COLLECT_CACHE_STATS
4972     if ( pass ) {
4973 
4974         if ( cache_ptr->images_loaded == 0 ) {
4975 
4976             pass = FALSE;
4977             failure_mssg = "metadata cache image block not loaded(2).";
4978         }
4979     }
4980 #endif /* H5C_COLLECT_CACHE_STATS */
4981 
4982 
4983     if ( show_progress )
4984         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
4985 
4986 
4987     /* 15) Close the file. */
4988 
4989     if ( pass ) {
4990 
4991         if ( H5Fclose(file_id) < 0  ) {
4992 
4993             pass = FALSE;
4994             failure_mssg = "H5Fclose() failed.\n";
4995         }
4996     }
4997 
4998 
4999     /* 16) Open the file.
5000      *
5001      *    Verify that the file doesn't contain a metadata cache image
5002      *    superblock extension message.
5003      */
5004 
5005     if ( pass ) {
5006 
5007         open_hdf5_file(/* create_file        */ FALSE,
5008             /* mdci_sbem_expected */ FALSE,
5009                        /* read_only          */ FALSE,
5010                        /* set_mdci_fapl      */ FALSE,
5011             /* config_fsm         */ FALSE,
5012             /* set_eoc            */ FALSE,
5013                        /* hdf_file_name      */ filename,
5014                        /* cache_image_flags  */ 0,
5015                        /* file_id_ptr        */ &file_id,
5016                        /* file_ptr_ptr       */ &file_ptr,
5017                        /* cache_ptr_ptr      */ &cache_ptr);
5018     }
5019 
5020     if ( show_progress )
5021         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5022 
5023 
5024     /* 17) Validate all the zoos.
5025      *
5026      *    Verify that the metadata cache image superblock
5027      *    extension message has been deleted.
5028      */
5029     i = min_group;
5030     while ( ( pass ) && ( i <= max_group ) ) {
5031         HDsprintf(process_group_name, "/process_%d", i);
5032         validate_zoo(file_id, process_group_name, i++);
5033     }
5034 
5035 #if H5C_COLLECT_CACHE_STATS
5036     if ( pass ) {
5037 
5038         if ( cache_ptr->images_loaded != 0 ) {
5039 
5040             pass = FALSE;
5041             failure_mssg = "metadata cache image block loaded(2).";
5042         }
5043     }
5044 #endif /* H5C_COLLECT_CACHE_STATS */
5045 
5046 
5047     if ( show_progress )
5048         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5049 
5050 
5051     /* 18) Close the file. */
5052 
5053     if ( pass ) {
5054 
5055         if ( H5Fclose(file_id) < 0  ) {
5056 
5057             pass = FALSE;
5058             failure_mssg = "H5Fclose() failed.\n";
5059         }
5060     }
5061 
5062     if ( show_progress )
5063         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5064 
5065 
5066     /* 19) Delete the file */
5067 
5068     if ( pass ) {
5069 
5070         if ( HDremove(filename) < 0 ) {
5071 
5072             pass = FALSE;
5073             failure_mssg = "HDremove() failed.\n";
5074         }
5075     }
5076 
5077 
5078     if ( pass ) { PASSED(); } else { H5_FAILED(); }
5079 
5080     if ( ! pass )
5081         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
5082                   FUNC, failure_mssg);
5083 
5084     return !pass;
5085 
5086 } /* cache_image_smoke_check_5() */
5087 
5088 
5089 /*-------------------------------------------------------------------------
5090  * Function:    cache_image_smoke_check_6()
5091  *
5092  * Purpose:     As the free space manager metadata is now included in the
5093  *        cache image, a smoke check to verify generally correct
5094  *        behaviour of the persistent free space managers seems
5095  *        prudent.
5096  *
5097  *        The basic idea of this test is to construct a long
5098  *        sequence of dataset creations and deletions, all separated
5099  *        by file open/close cycles with cache image enabled.  If the
5100  *        perisistant free space managers are performing as expected,
5101  *        the size of the file should stabilize.
5102  *
5103  *        To implement this, proceed as outlined in the cycle of
5104  *        operation below:
5105  *
5106  *        Cycle of operation
5107  *
5108  *        1) Create a HDF5 file with the cache image FAPL entry.
5109  *
5110  *           Verify that the cache is informed of the cache image
5111  *           FAPL entry.
5112  *
5113  *           Set all cache image flags, forcing full functionality.
5114  *
5115  *        2) Create and write a dataset in the file.
5116  *
5117  *        3) Close the file.
5118  *
5119  *        4) Open the file with the cache image FAPL entry.
5120  *
5121  *           Verify that the file contains a metadata cache
5122  *           image superblock extension message.
5123  *
5124  *        5) Create and write a new dataset.
5125  *
5126  *        6) Verify and delete the old dataset.
5127  *
5128  *        7) Close the file.
5129  *
5130  *           If sufficient datasets have been created, and then
5131  *           deleteded continue to 8).  Otherwise goto 4)
5132  *
5133  *        8) Open the file.
5134  *
5135  *           Verify that the file contains a metadata cache
5136  *           image superblock extension message.
5137  *
5138  *            9) Verify the last dataset created.
5139  *
5140  *           10) Close the file.
5141  *
5142  *           11) Open the file.
5143  *
5144  *           12) Verify and delete the last dataset.
5145  *
5146  *           Verify that a metadata cache image is not loaded.
5147  *
5148  *           13) Close the file.
5149  *
5150  *             14) Get the size of the file.  Verify that it is less
5151  *           than 20 KB.  Without deletions and persistent free
5152  *           space managers, size size is about 167 MB, so this
5153  *           is sufficient to verify that the persistent free
5154  *           space managers are more or less doing their job.
5155  *
5156  *                 Note that in the absence of paged allocation, file
5157  *                 size gets below 1 KB.
5158  *
5159  *           15) Delete the file.
5160  *
5161  * Return:      void
5162  *
5163  * Programmer:  John Mainzer
5164  *              10/31/16
5165  *
5166  *-------------------------------------------------------------------------
5167  */
5168 
5169 static unsigned
cache_image_smoke_check_6(void)5170 cache_image_smoke_check_6(void)
5171 {
5172     const char * fcn_name = "cache_image_smoke_check_6()";
5173     char filename[512];
5174     hbool_t show_progress = FALSE;
5175     hid_t file_id = -1;
5176     H5F_t *file_ptr = NULL;
5177     H5C_t *cache_ptr = NULL;
5178     h5_stat_size_t file_size;
5179     int cp = 0;
5180     int min_dset = 0;
5181     int max_dset = 0;
5182 
5183     TESTING("metadata cache image smoke check 6");
5184 
5185     pass = TRUE;
5186 
5187     if ( show_progress )
5188         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5189 
5190 
5191     /* setup the file name */
5192     if ( pass ) {
5193 
5194         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
5195             == NULL ) {
5196 
5197             pass = FALSE;
5198             failure_mssg = "h5_fixname() failed.\n";
5199         }
5200     }
5201 
5202     if ( show_progress )
5203         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5204 
5205 
5206     /* 1) Create a HDF5 file with the cache image FAPL entry.
5207      *
5208      *      Verify that the cache is informed of the cache image FAPL entry.
5209      *
5210      *    Set flags forcing full function of the cache image feature.
5211      */
5212 
5213     if ( pass ) {
5214 
5215         open_hdf5_file(/* create_file        */ TRUE,
5216                        /* mdci_sbem_expected */ FALSE,
5217                        /* read_only          */ FALSE,
5218                        /* set_mdci_fapl      */ TRUE,
5219             /* config_fsm         */ TRUE,
5220             /* set_eoc            */ FALSE,
5221                        /* hdf_file_name      */ filename,
5222                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
5223                        /* file_id_ptr        */ &file_id,
5224                        /* file_ptr_ptr       */ &file_ptr,
5225                        /* cache_ptr_ptr      */ &cache_ptr);
5226     }
5227 
5228     if ( show_progress )
5229         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5230 
5231 
5232     /* 2) Create a dataset in the file. */
5233 
5234     if ( pass ) {
5235 
5236         create_datasets(file_id, min_dset++, max_dset++);
5237     }
5238 
5239 #if H5C_COLLECT_CACHE_STATS
5240     if ( pass ) {
5241 
5242         if ( cache_ptr->images_loaded != 0 ) {
5243 
5244             pass = FALSE;
5245             failure_mssg = "metadata cache image block loaded(1).";
5246         }
5247     }
5248 #endif /* H5C_COLLECT_CACHE_STATS */
5249 
5250     if ( show_progress )
5251         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5252 
5253 
5254     /* 3) Close the file. */
5255 
5256     if ( pass ) {
5257 
5258         if ( H5Fclose(file_id) < 0  ) {
5259 
5260             pass = FALSE;
5261             failure_mssg = "H5Fclose() failed.\n";
5262 
5263         }
5264     }
5265 
5266     if ( show_progress )
5267         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5268 
5269     while ( ( pass ) && ( max_dset < MAX_NUM_DSETS ) )
5270     {
5271 
5272         /* 4) Open the file.
5273          *
5274          *    Verify that the metadata cache is instructed to load the
5275          *    metadata cache image.
5276          */
5277 
5278         if ( pass ) {
5279 
5280             open_hdf5_file(/* create_file        */ FALSE,
5281                     /* mdci_sbem_expected */ TRUE,
5282                            /* read_only          */ FALSE,
5283                            /* set_mdci_fapl      */ TRUE,
5284                 /* config_fsm         */ FALSE,
5285                 /* set_eoc            */ FALSE,
5286                            /* hdf_file_name      */ filename,
5287                            /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
5288                            /* file_id_ptr        */ &file_id,
5289                            /* file_ptr_ptr       */ &file_ptr,
5290                            /* cache_ptr_ptr      */ &cache_ptr);
5291         }
5292 
5293         if ( show_progress )
5294             HDfprintf(stdout, "%s:L1 cp = %d, max_dset = %d, pass = %d.\n",
5295                       fcn_name, cp, max_dset, pass);
5296 
5297 
5298         /* 5) Create a dataset in the file. */
5299 
5300         if ( pass ) {
5301 
5302             create_datasets(file_id, min_dset++, max_dset++);
5303         }
5304 
5305 #if H5C_COLLECT_CACHE_STATS
5306         if ( pass ) {
5307 
5308             if ( cache_ptr->images_loaded == 0 ) {
5309 
5310                 pass = FALSE;
5311                 failure_mssg = "metadata cache image block not loaded(1).";
5312             }
5313         }
5314 #endif /* H5C_COLLECT_CACHE_STATS */
5315 
5316         if ( show_progress )
5317             HDfprintf(stdout, "%s:L2 cp = %d, max_dset = %d, pass = %d.\n",
5318                       fcn_name, cp + 1, max_dset, pass);
5319 
5320 
5321     /* 6) Verify and delete the old dataset. */
5322     if ( pass ) {
5323 
5324         delete_datasets(file_id, min_dset - 2, max_dset - 2);
5325     }
5326 
5327         if ( show_progress )
5328             HDfprintf(stdout, "%s:L3 cp = %d, max_dset = %d, pass = %d.\n",
5329                       fcn_name, cp + 2, max_dset, pass);
5330 
5331 
5332         /* 7) Close the file. */
5333 
5334         if ( pass ) {
5335 
5336             if ( H5Fclose(file_id) < 0  ) {
5337 
5338                 pass = FALSE;
5339                 failure_mssg = "H5Fclose() failed.\n";
5340 
5341             }
5342         }
5343 
5344         if ( show_progress )
5345             HDfprintf(stdout, "%s:L4 cp = %d, max_dset = %d, pass = %d.\n",
5346                       fcn_name, cp + 3, max_dset, pass);
5347     } /* end while */
5348     cp += 4;
5349 
5350 
5351     /* 8) Open the file.
5352      *
5353      *    Verify that the file contains a metadata cache image
5354      *    superblock extension message.
5355      */
5356 
5357     if ( pass ) {
5358 
5359         open_hdf5_file(/* create_file        */ FALSE,
5360             /* mdci_sbem_expected */ TRUE,
5361                        /* read_only          */ FALSE,
5362                        /* set_mdci_fapl      */ FALSE,
5363             /* config_fsm         */ FALSE,
5364             /* set_eoc            */ FALSE,
5365                        /* hdf_file_name      */ filename,
5366                        /* cache_image_flags  */ 0,
5367                        /* file_id_ptr        */ &file_id,
5368                        /* file_ptr_ptr       */ &file_ptr,
5369                        /* cache_ptr_ptr      */ &cache_ptr);
5370     }
5371 
5372     if ( show_progress )
5373         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5374 
5375 
5376     /* 9) Verify the last dataset created. */
5377 
5378     if ( pass ) {
5379 
5380        verify_datasets(file_id, min_dset - 1, max_dset - 1);
5381     }
5382 
5383 #if H5C_COLLECT_CACHE_STATS
5384     if ( pass ) {
5385 
5386         if ( cache_ptr->images_loaded == 0 ) {
5387 
5388             pass = FALSE;
5389             failure_mssg = "metadata cache image block not loaded(2).";
5390         }
5391     }
5392 #endif /* H5C_COLLECT_CACHE_STATS */
5393 
5394 
5395     if ( show_progress )
5396         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5397 
5398 
5399     /* 10) Close the file. */
5400 
5401     if ( pass ) {
5402 
5403         if ( H5Fclose(file_id) < 0  ) {
5404 
5405             pass = FALSE;
5406             failure_mssg = "H5Fclose() failed.\n";
5407         }
5408     }
5409 
5410 
5411     /* 11) Open the file.
5412      *
5413      *    Verify that the file doesn't contain a metadata cache image
5414      *    superblock extension message.
5415      */
5416 
5417     if ( pass ) {
5418 
5419         open_hdf5_file(/* create_file        */ FALSE,
5420             /* mdci_sbem_expected */ FALSE,
5421                        /* read_only          */ FALSE,
5422                        /* set_mdci_fapl      */ FALSE,
5423             /* config_fsm         */ FALSE,
5424             /* set_eoc            */ FALSE,
5425                        /* hdf_file_name      */ filename,
5426                        /* cache_image_flags  */ 0,
5427                        /* file_id_ptr        */ &file_id,
5428                        /* file_ptr_ptr       */ &file_ptr,
5429                        /* cache_ptr_ptr      */ &cache_ptr);
5430     }
5431 
5432     if ( show_progress )
5433         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5434 
5435 
5436     /* 12) Verify and delete the last dataset.
5437      *
5438      *     Verify that a metadata cache image is not loaded.
5439      */
5440 
5441     if ( pass ) {
5442 
5443        delete_datasets(file_id, min_dset - 1, max_dset - 1);
5444     }
5445 
5446 #if H5C_COLLECT_CACHE_STATS
5447     if ( pass ) {
5448 
5449         if ( cache_ptr->images_loaded != 0 ) {
5450 
5451             pass = FALSE;
5452             failure_mssg = "metadata cache image block loaded(2).";
5453         }
5454     }
5455 #endif /* H5C_COLLECT_CACHE_STATS */
5456 
5457 
5458 
5459     /* 13) Close the file. */
5460 
5461     if ( pass ) {
5462 
5463         if ( H5Fclose(file_id) < 0  ) {
5464 
5465             pass = FALSE;
5466             failure_mssg = "H5Fclose() failed.\n";
5467         }
5468     }
5469 
5470     if ( show_progress )
5471         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5472 
5473 
5474     /* 14) Get the size of the file.  Verify that it is less
5475      *     than 20 KB.  Without deletions and persistent free
5476      *     space managers, size size is about 167 MB, so this
5477      *     is sufficient to verify that the persistent free
5478      *     space managers are more or less doing their job.
5479      *
5480      *     Note that in the absence of paged allocation, file
5481      *     size gets below 1 KB, but since this test is run both
5482      *     with and without paged allocation, we must leave some
5483      *     extra space for the paged allocation case.
5484      */
5485     if(pass) {
5486         if((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) {
5487             pass = FALSE;
5488             failure_mssg = "h5_get_file_size() failed.\n";
5489         } else if(file_size > 20 * 1024) {
5490             pass = FALSE;
5491             failure_mssg = "unexpectedly large file size.\n";
5492         }
5493     }
5494 
5495     if ( show_progress )
5496         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5497 
5498 
5499     /* 15) Delete the file */
5500     if ( pass ) {
5501 
5502         if ( HDremove(filename) < 0 ) {
5503 
5504             pass = FALSE;
5505             failure_mssg = "HDremove() failed.\n";
5506         }
5507     }
5508 
5509 
5510     if ( pass ) { PASSED(); } else { H5_FAILED(); }
5511 
5512     if ( ! pass )
5513         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
5514                   FUNC, failure_mssg);
5515 
5516     return !pass;
5517 
5518 } /* cache_image_smoke_check_6() */
5519 
5520 
5521 /*-------------------------------------------------------------------------
5522  * Function:    cache_image_api_error_check_1()
5523  *
5524  * Purpose:     This test is one of a sequence of tests intended
5525  *        to verify correct management of API errors.
5526  *
5527  *        The object of this test is to verify that a file without
5528  *        a pre-existing cache image that is opened both read only
5529  *        and with a cache image requested is handle correctly
5530  *        (the cache image request should be ignored silently).
5531  *
5532  *        The test is set up as follows:
5533  *
5534  *        1) Create a HDF5 file.
5535  *
5536  *        2) Create some datasets in the file.
5537  *
5538  *        3) Close the file.
5539  *
5540  *        4) Open the file read only with a cache image FAPL entry
5541  *           requested.
5542  *
5543  *        5) Open a dataset.
5544  *
5545  *           Verify that it contains the expected data
5546  *
5547  *           Verify that the cache image was not loaded.
5548  *
5549  *        6) Close the file.
5550  *
5551  *        7) Open the file read only.
5552  *
5553  *        8) Open a dataset.
5554  *
5555  *           Verify that it contains the expected data.
5556  *
5557  *           Verify that the cache image was not loaded.
5558  *
5559  *        9) Close the file.
5560  *
5561  *            10) Open the file read write.
5562  *
5563  *           11) Open a dataset.
5564  *
5565  *           Verify that it contains the expected data.
5566  *
5567  *           12) Close the file.
5568  *
5569  *           13) Delete the file.
5570  *
5571  * Return:      void
5572  *
5573  * Programmer:  John Mainzer
5574  *              9/25/15
5575  *
5576  *-------------------------------------------------------------------------
5577  */
5578 
5579 static unsigned
cache_image_api_error_check_1(void)5580 cache_image_api_error_check_1(void)
5581 {
5582     const char * fcn_name = "cache_image_api_error_check_1()";
5583     char filename[512];
5584     hbool_t show_progress = FALSE;
5585     hid_t file_id = -1;
5586     H5F_t *file_ptr = NULL;
5587     H5C_t *cache_ptr = NULL;
5588     int cp = 0;
5589 
5590     TESTING("metadata cache image api error check 1");
5591 
5592     pass = TRUE;
5593 
5594     if ( show_progress )
5595         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5596 
5597 
5598     /* setup the file name */
5599     if ( pass ) {
5600 
5601         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
5602             == NULL ) {
5603 
5604             pass = FALSE;
5605             failure_mssg = "h5_fixname() failed.\n";
5606         }
5607     }
5608 
5609     if ( show_progress )
5610         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5611 
5612 
5613     /* 1) Create a HDF5 file. */
5614 
5615     if ( pass ) {
5616 
5617         open_hdf5_file(/* create_file        */ TRUE,
5618                        /* mdci_sbem_expected */ FALSE,
5619                        /* read_only          */ FALSE,
5620                        /* set_mdci_fapl      */ FALSE,
5621             /* config_fsm         */ TRUE,
5622             /* set_eoc            */ FALSE,
5623                        /* hdf_file_name      */ filename,
5624                        /* cache_image_flags  */ 0,
5625                        /* file_id_ptr        */ &file_id,
5626                        /* file_ptr_ptr       */ &file_ptr,
5627                        /* cache_ptr_ptr      */ &cache_ptr);
5628     }
5629 
5630     if ( show_progress )
5631         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5632 
5633 
5634     /* 2) Create some datasets in the file. */
5635 
5636     if ( pass ) {
5637 
5638         create_datasets(file_id, 0, 5);
5639     }
5640 
5641 #if H5C_COLLECT_CACHE_STATS
5642     if ( pass ) {
5643 
5644         if ( cache_ptr->images_loaded != 0 ) {
5645 
5646             pass = FALSE;
5647             failure_mssg = "metadata cache image block loaded(1).";
5648         }
5649     }
5650 #endif /* H5C_COLLECT_CACHE_STATS */
5651 
5652 
5653 
5654     if ( show_progress )
5655         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5656 
5657 
5658     /* 3) Close the file. */
5659 
5660     if ( pass ) {
5661 
5662         if ( H5Fclose(file_id) < 0  ) {
5663 
5664             pass = FALSE;
5665             failure_mssg = "H5Fclose() failed.\n";
5666 
5667         }
5668     }
5669 
5670     if ( show_progress )
5671         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5672 
5673 
5674     /* 4) Open the file read only with a cache image FAPL entry requested. */
5675 
5676     if ( pass ) {
5677 
5678         open_hdf5_file(/* create_file        */ FALSE,
5679                 /* mdci_sbem_expected */ FALSE,
5680                        /* read_only          */ TRUE,
5681                        /* set_mdci_fapl      */ TRUE,
5682             /* config_fsm         */ FALSE,
5683             /* set_eoc            */ FALSE,
5684                        /* hdf_file_name      */ filename,
5685                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
5686                        /* file_id_ptr        */ &file_id,
5687                        /* file_ptr_ptr       */ &file_ptr,
5688                        /* cache_ptr_ptr      */ &cache_ptr);
5689     }
5690 
5691     if ( show_progress )
5692         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5693 
5694 
5695     /* 5) Open and close a dataset.
5696      *
5697      *    Verify that it contains the expected data.
5698      *
5699      *    Verify that the cache image was not loaded.
5700      */
5701 
5702     if ( pass ) {
5703 
5704        verify_datasets(file_id, 0, 5);
5705     }
5706 
5707 #if H5C_COLLECT_CACHE_STATS
5708     if ( pass ) {
5709 
5710         if ( cache_ptr->images_loaded != 0 ) {
5711 
5712             pass = FALSE;
5713             failure_mssg = "metadata cache image block loaded(2).";
5714         }
5715     }
5716 #endif /* H5C_COLLECT_CACHE_STATS */
5717 
5718     if ( show_progress )
5719         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5720 
5721 
5722     /* 6) Close the file. */
5723 
5724     if ( pass ) {
5725 
5726         if ( H5Fclose(file_id) < 0  ) {
5727 
5728             pass = FALSE;
5729             failure_mssg = "H5Fclose() failed.\n";
5730         }
5731     }
5732 
5733     if ( show_progress )
5734         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5735 
5736 
5737     /* 7) Open the file read only. */
5738 
5739     if ( pass ) {
5740 
5741         open_hdf5_file(/* create_file        */ FALSE,
5742             /* mdci_sbem_expected */ FALSE,
5743                        /* read_only          */ TRUE,
5744                        /* set_mdci_fapl      */ FALSE,
5745             /* config_fsm         */ FALSE,
5746             /* set_eoc            */ FALSE,
5747                        /* hdf_file_name      */ filename,
5748                        /* cache_image_flags  */ 0,
5749                        /* file_id_ptr        */ &file_id,
5750                        /* file_ptr_ptr       */ &file_ptr,
5751                        /* cache_ptr_ptr      */ &cache_ptr);
5752     }
5753 
5754     if ( show_progress )
5755         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5756 
5757 
5758     /* 8) Open and close a dataset.
5759      *
5760      *    Verify that it contains the expected data.
5761      *
5762      *    Verify that the cache image was not loaded.
5763      */
5764 
5765     if ( pass ) {
5766 
5767        verify_datasets(file_id, 0, 5);
5768     }
5769 
5770 #if H5C_COLLECT_CACHE_STATS
5771     if ( pass ) {
5772 
5773         if ( cache_ptr->images_loaded != 0 ) {
5774 
5775             pass = FALSE;
5776             failure_mssg = "metadata cache image block loaded(3).";
5777         }
5778     }
5779 #endif /* H5C_COLLECT_CACHE_STATS */
5780 
5781 
5782     if ( show_progress )
5783         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5784 
5785 
5786     /* 9) Close the file. */
5787 
5788     if ( pass ) {
5789 
5790         if ( H5Fclose(file_id) < 0  ) {
5791 
5792             pass = FALSE;
5793             failure_mssg = "H5Fclose() failed.\n";
5794         }
5795     }
5796 
5797     if ( show_progress )
5798         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5799 
5800 
5801     /* 10) Open the file read / write. */
5802 
5803     if ( pass ) {
5804 
5805         open_hdf5_file(/* create_file        */ FALSE,
5806                 /* mdci_sbem_expected */ FALSE,
5807                        /* read_only          */ FALSE,
5808                        /* set_mdci_fapl      */ FALSE,
5809             /* config_fsm         */ FALSE,
5810             /* set_eoc            */ FALSE,
5811                        /* hdf_file_name      */ filename,
5812                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
5813                        /* file_id_ptr        */ &file_id,
5814                        /* file_ptr_ptr       */ &file_ptr,
5815                        /* cache_ptr_ptr      */ &cache_ptr);
5816     }
5817 
5818     if ( show_progress )
5819         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5820 
5821     /* 11) Open and close a dataset.
5822      *
5823      *     Verify that it contains the expected data.
5824      *
5825      *     Verify that the cache image was not loaded.
5826      */
5827 
5828     if ( pass ) {
5829 
5830        verify_datasets(file_id, 0, 5);
5831     }
5832 
5833 #if H5C_COLLECT_CACHE_STATS
5834     if ( pass ) {
5835 
5836         if ( cache_ptr->images_loaded != 0 ) {
5837 
5838             pass = FALSE;
5839             failure_mssg = "metadata cache image block loaded(4).";
5840         }
5841     }
5842 #endif /* H5C_COLLECT_CACHE_STATS */
5843 
5844     if ( show_progress )
5845         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5846 
5847 
5848     /* 12) Close the file.  */
5849 
5850     if ( pass ) {
5851 
5852         if ( H5Fclose(file_id) < 0  ) {
5853 
5854             pass = FALSE;
5855             failure_mssg = "H5Fclose() failed.\n";
5856         }
5857     }
5858 
5859     if ( show_progress )
5860         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5861 
5862 
5863     /* 13) Delete the file */
5864 
5865     if ( pass ) {
5866 
5867         if ( HDremove(filename) < 0 ) {
5868 
5869             pass = FALSE;
5870             failure_mssg = "HDremove() failed.\n";
5871         }
5872     }
5873 
5874     if ( pass ) { PASSED(); } else { H5_FAILED(); }
5875 
5876     if ( ! pass )
5877         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
5878                   FUNC, failure_mssg);
5879 
5880     return !pass;
5881 
5882 } /* cache_image_api_error_check_1() */
5883 
5884 
5885 /*-------------------------------------------------------------------------
5886  * Function:    cache_image_api_error_check_2()
5887  *
5888  * Purpose:     This test is one of a sequence of tests intended
5889  *        to verify correct management of API errors.
5890  *
5891  *        The object of this test is to verify that a file with
5892  *        a pre-existing cache image that is opened both read only
5893  *        and with a cache image requested is handled correctly
5894  *        (the cache image request should be ignored silently).
5895  *
5896  *        The test is set up as follows:
5897  *
5898  *        1) Create a HDF5 file with a cache image requested..
5899  *
5900  *        2) Create some datasets in the file.
5901  *
5902  *        3) Close the file.
5903  *
5904  *        4) Open the file read only with a cache image FAPL entry
5905  *           requested.
5906  *
5907  *        5) Open a dataset.
5908  *
5909  *           Verify that it contains the expected data
5910  *
5911  *           Verify that the cache image was loaded.
5912  *
5913  *        6) Close the file.
5914  *
5915  *        7) Open the file read only.
5916  *
5917  *        8) Open a dataset.
5918  *
5919  *           Verify that it contains the expected data.
5920  *
5921  *           Verify that the cache image was loaded.
5922  *
5923  *        9) Close the file.
5924  *
5925  *            10) Open the file read write.
5926  *
5927  *           11) Open a dataset.
5928  *
5929  *           Verify that it contains the expected data.
5930  *
5931  *           Verify that the cache image was loaded.
5932  *
5933  *           12) Close the file.
5934  *
5935  *            13) Open the file read write.
5936  *
5937  *           14) Open a dataset.
5938  *
5939  *           Verify that it contains the expected data.
5940  *
5941  *           Verify that the cache image was NOT loaded.
5942  *
5943  *           15) Close the file.
5944  *
5945  *           16) Delete the file.
5946  *
5947  * Return:      void
5948  *
5949  * Programmer:  John Mainzer
5950  *              9/25/15
5951  *
5952  *-------------------------------------------------------------------------
5953  */
5954 
5955 static unsigned
cache_image_api_error_check_2(void)5956 cache_image_api_error_check_2(void)
5957 {
5958     const char * fcn_name = "cache_image_api_error_check_2()";
5959     char filename[512];
5960     hbool_t show_progress = FALSE;
5961     hid_t file_id = -1;
5962     H5F_t *file_ptr = NULL;
5963     H5C_t *cache_ptr = NULL;
5964     int cp = 0;
5965 
5966     TESTING("metadata cache image api error check 2");
5967 
5968     pass = TRUE;
5969 
5970     if ( show_progress )
5971         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5972 
5973 
5974     /* setup the file name */
5975     if ( pass ) {
5976 
5977         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
5978             == NULL ) {
5979 
5980             pass = FALSE;
5981             failure_mssg = "h5_fixname() failed.\n";
5982         }
5983     }
5984 
5985     if ( show_progress )
5986         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
5987 
5988 
5989     /* 1) Create a HDF5 file with a cache image requested. */
5990 
5991     if ( pass ) {
5992 
5993         open_hdf5_file(/* create_file        */ TRUE,
5994                        /* mdci_sbem_expected */ FALSE,
5995                        /* read_only          */ FALSE,
5996                        /* set_mdci_fapl      */ TRUE,
5997             /* config_fsm         */ TRUE,
5998             /* set_eoc            */ FALSE,
5999                        /* hdf_file_name      */ filename,
6000                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
6001                        /* file_id_ptr        */ &file_id,
6002                        /* file_ptr_ptr       */ &file_ptr,
6003                        /* cache_ptr_ptr      */ &cache_ptr);
6004     }
6005 
6006     if ( show_progress )
6007         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6008 
6009 
6010     /* 2) Create some datasets in the file. */
6011 
6012     if ( pass ) {
6013 
6014         create_datasets(file_id, 0, 5);
6015     }
6016 
6017 #if H5C_COLLECT_CACHE_STATS
6018     if ( pass ) {
6019 
6020         if ( cache_ptr->images_loaded != 0 ) {
6021 
6022             pass = FALSE;
6023             failure_mssg = "metadata cache image block loaded(1).";
6024         }
6025     }
6026 #endif /* H5C_COLLECT_CACHE_STATS */
6027 
6028 
6029 
6030     if ( show_progress )
6031         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6032 
6033 
6034     /* 3) Close the file. */
6035 
6036     if ( pass ) {
6037 
6038         if ( H5Fclose(file_id) < 0  ) {
6039 
6040             pass = FALSE;
6041             failure_mssg = "H5Fclose() failed.\n";
6042 
6043         }
6044     }
6045 
6046     if ( show_progress )
6047         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6048 
6049 
6050     /* 4) Open the file read only with a cache image FAPL entry requested. */
6051 
6052     if ( pass ) {
6053 
6054         open_hdf5_file(/* create_file        */ FALSE,
6055                 /* mdci_sbem_expected */ TRUE,
6056                        /* read_only          */ TRUE,
6057                        /* set_mdci_fapl      */ TRUE,
6058             /* config_fsm         */ FALSE,
6059             /* set_eoc            */ FALSE,
6060                        /* hdf_file_name      */ filename,
6061                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
6062                        /* file_id_ptr        */ &file_id,
6063                        /* file_ptr_ptr       */ &file_ptr,
6064                        /* cache_ptr_ptr      */ &cache_ptr);
6065     }
6066 
6067     if ( show_progress )
6068         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6069 
6070 
6071     /* 5) Open and close a dataset.
6072      *
6073      *    Verify that it contains the expected data.
6074      *
6075      *    Verify that the cache image was loaded.
6076      */
6077 
6078     if ( pass ) {
6079 
6080        verify_datasets(file_id, 0, 5);
6081     }
6082 
6083 #if H5C_COLLECT_CACHE_STATS
6084     if ( pass ) {
6085 
6086         if ( cache_ptr->images_loaded != 1 ) {
6087 
6088             pass = FALSE;
6089             failure_mssg = "metadata cache image block was not loaded(1).";
6090         }
6091     }
6092 #endif /* H5C_COLLECT_CACHE_STATS */
6093 
6094     if ( show_progress )
6095         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6096 
6097 
6098     /* 6) Close the file. */
6099 
6100     if ( pass ) {
6101 
6102         if ( H5Fclose(file_id) < 0  ) {
6103 
6104             pass = FALSE;
6105             failure_mssg = "H5Fclose() failed.\n";
6106         }
6107     }
6108 
6109     if ( show_progress )
6110         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6111 
6112 
6113     /* 7) Open the file read only. */
6114 
6115     if ( pass ) {
6116 
6117         open_hdf5_file(/* create_file        */ FALSE,
6118             /* mdci_sbem_expected */ TRUE,
6119                        /* read_only          */ TRUE,
6120                        /* set_mdci_fapl      */ FALSE,
6121             /* config_fsm         */ FALSE,
6122             /* set_eoc            */ FALSE,
6123                        /* hdf_file_name      */ filename,
6124                        /* cache_image_flags  */ 0,
6125                        /* file_id_ptr        */ &file_id,
6126                        /* file_ptr_ptr       */ &file_ptr,
6127                        /* cache_ptr_ptr      */ &cache_ptr);
6128     }
6129 
6130     if ( show_progress )
6131         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6132 
6133 
6134     /* 8) Open and close a dataset.
6135      *
6136      *    Verify that it contains the expected data.
6137      *
6138      *    Verify that the cache image was loaded.
6139      */
6140 
6141     if ( pass ) {
6142 
6143        verify_datasets(file_id, 0, 5);
6144     }
6145 
6146 #if H5C_COLLECT_CACHE_STATS
6147     if ( pass ) {
6148 
6149         if ( cache_ptr->images_loaded != 1 ) {
6150 
6151             pass = FALSE;
6152             failure_mssg = "metadata cache image block was not loaded(2).";
6153         }
6154     }
6155 #endif /* H5C_COLLECT_CACHE_STATS */
6156 
6157 
6158     if ( show_progress )
6159         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6160 
6161 
6162     /* 9) Close the file. */
6163 
6164     if ( pass ) {
6165 
6166         if ( H5Fclose(file_id) < 0  ) {
6167 
6168             pass = FALSE;
6169             failure_mssg = "H5Fclose() failed.\n";
6170         }
6171     }
6172 
6173     if ( show_progress )
6174         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6175 
6176 
6177     /* 10) Open the file read / write. */
6178 
6179     if ( pass ) {
6180 
6181         open_hdf5_file(/* create_file        */ FALSE,
6182                 /* mdci_sbem_expected */ TRUE,
6183                        /* read_only          */ FALSE,
6184                        /* set_mdci_fapl      */ FALSE,
6185             /* config_fsm         */ FALSE,
6186             /* set_eoc            */ FALSE,
6187                        /* hdf_file_name      */ filename,
6188                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
6189                        /* file_id_ptr        */ &file_id,
6190                        /* file_ptr_ptr       */ &file_ptr,
6191                        /* cache_ptr_ptr      */ &cache_ptr);
6192     }
6193 
6194     if ( show_progress )
6195         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6196 
6197     /* 11) Open and close a dataset.
6198      *
6199      *     Verify that it contains the expected data.
6200      *
6201      *     Verify that the cache image was loaded.
6202      */
6203 
6204     if ( pass ) {
6205 
6206        verify_datasets(file_id, 0, 5);
6207     }
6208 
6209 #if H5C_COLLECT_CACHE_STATS
6210     if ( pass ) {
6211 
6212         if ( cache_ptr->images_loaded != 1 ) {
6213 
6214             pass = FALSE;
6215             failure_mssg = "metadata cache image block was not loaded(3).";
6216         }
6217     }
6218 #endif /* H5C_COLLECT_CACHE_STATS */
6219 
6220     if ( show_progress )
6221         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6222 
6223 
6224     /* 12) Close the file.  */
6225 
6226     if ( pass ) {
6227 
6228         if ( H5Fclose(file_id) < 0  ) {
6229 
6230             pass = FALSE;
6231             failure_mssg = "H5Fclose() failed.\n";
6232         }
6233     }
6234 
6235     if ( show_progress )
6236         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6237 
6238 
6239     /* 13) Open the file read / write. */
6240 
6241     if ( pass ) {
6242 
6243         open_hdf5_file(/* create_file        */ FALSE,
6244                 /* mdci_sbem_expected */ FALSE,
6245                        /* read_only          */ FALSE,
6246                        /* set_mdci_fapl      */ FALSE,
6247             /* config_fsm         */ FALSE,
6248             /* set_eoc            */ FALSE,
6249                        /* hdf_file_name      */ filename,
6250                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
6251                        /* file_id_ptr        */ &file_id,
6252                        /* file_ptr_ptr       */ &file_ptr,
6253                        /* cache_ptr_ptr      */ &cache_ptr);
6254     }
6255 
6256     if ( show_progress )
6257         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6258 
6259     /* 14) Open and close a dataset.
6260      *
6261      *     Verify that it contains the expected data.
6262      *
6263      *     Verify that the cache image was not loaded.
6264      */
6265 
6266     if ( pass ) {
6267 
6268        verify_datasets(file_id, 0, 5);
6269     }
6270 
6271 #if H5C_COLLECT_CACHE_STATS
6272     if ( pass ) {
6273 
6274         if ( cache_ptr->images_loaded != 0 ) {
6275 
6276             pass = FALSE;
6277             failure_mssg = "metadata cache image block was loaded(2).";
6278         }
6279     }
6280 #endif /* H5C_COLLECT_CACHE_STATS */
6281 
6282     if ( show_progress )
6283         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6284 
6285 
6286     /* 15) Close the file.  */
6287 
6288     if ( pass ) {
6289 
6290         if ( H5Fclose(file_id) < 0  ) {
6291 
6292             pass = FALSE;
6293             failure_mssg = "H5Fclose() failed.\n";
6294         }
6295     }
6296 
6297     if ( show_progress )
6298         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6299 
6300 
6301     /* 13) Delete the file */
6302 
6303     if ( pass ) {
6304 
6305         if ( HDremove(filename) < 0 ) {
6306 
6307             pass = FALSE;
6308             failure_mssg = "HDremove() failed.\n";
6309         }
6310     }
6311 
6312     if ( pass ) { PASSED(); } else { H5_FAILED(); }
6313 
6314     if ( ! pass )
6315         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
6316                   FUNC, failure_mssg);
6317 
6318     return !pass;
6319 
6320 } /* cache_image_api_error_check_2() */
6321 
6322 
6323 /*-------------------------------------------------------------------------
6324  * Function:    cache_image_api_error_check_3()
6325  *
6326  * Purpose:     This test is one of a sequence of tests intended
6327  *        to verify correct management of API errors.
6328  *
6329  *        At present, SWMR and cache image may not be active
6330  *        at the same time.  The purpose of this test is to
6331  *        verify that attempts to run SWMR and cache image
6332  *        at the same time will fail.
6333  *
6334  *        The test is set up as follows:
6335  *
6336  *        1) Create a HDF5 file with a cache image requested..
6337  *
6338  *        2) Try to start SWMR write -- should fail.
6339  *
6340  *              3) Discard the file if necessary
6341  *
6342  *              4) Attempt to create a HDF5 file with SWMR write
6343  *           access and cache image requested -- should fail.
6344  *
6345  *              5) Discard the file if necessary
6346  *
6347  *              6) Create a HDF5 file with a cache image requested.
6348  *
6349  *        7) Create some datasets in the file.
6350  *
6351  *        8) Close the file.
6352  *
6353  *              9) Attempt to open the file with SWMR write access --
6354  *                 should fail.
6355  *
6356  *             10) Discard the file if necessary.
6357  *
6358  * Return:      void
6359  *
6360  * Programmer:  John Mainzer
6361  *              12/29/16
6362  *
6363  *-------------------------------------------------------------------------
6364  */
6365 
6366 static unsigned
cache_image_api_error_check_3(void)6367 cache_image_api_error_check_3(void)
6368 {
6369     const char * fcn_name = "cache_image_api_error_check_3()";
6370     char filename[512];
6371     hbool_t show_progress = FALSE;
6372     hid_t file_id = -1;
6373     H5F_t *file_ptr = NULL;
6374     H5C_t *cache_ptr = NULL;
6375     int cp = 0;
6376 
6377     TESTING("metadata cache image api error check 3");
6378 
6379     pass = TRUE;
6380 
6381     if ( show_progress )
6382         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6383 
6384 
6385     /* setup the file name */
6386     if ( pass ) {
6387 
6388         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
6389             == NULL ) {
6390 
6391             pass = FALSE;
6392             failure_mssg = "h5_fixname() failed.\n";
6393         }
6394     }
6395 
6396     if ( show_progress )
6397         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6398 
6399 
6400     /* 1) Create a HDF5 file with a cache image requested. */
6401 
6402     if ( pass ) {
6403 
6404         open_hdf5_file(/* create_file        */ TRUE,
6405                        /* mdci_sbem_expected */ FALSE,
6406                        /* read_only          */ FALSE,
6407                        /* set_mdci_fapl      */ TRUE,
6408             /* config_fsm         */ TRUE,
6409             /* set_eoc            */ FALSE,
6410                        /* hdf_file_name      */ filename,
6411                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
6412                        /* file_id_ptr        */ &file_id,
6413                        /* file_ptr_ptr       */ &file_ptr,
6414                        /* cache_ptr_ptr      */ &cache_ptr);
6415     }
6416 
6417     if ( show_progress )
6418         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6419 
6420 
6421     /* 2) Try to start SWMR write -- should fail. */
6422 
6423     if ( pass ) {
6424 
6425         H5E_BEGIN_TRY {
6426             if ( H5Fstart_swmr_write(file_id) == SUCCEED ) {
6427 
6428                 pass = FALSE;
6429                 failure_mssg = "SWMR start succeeded in file with cache image.";
6430             }
6431         } H5E_END_TRY;
6432     }
6433 
6434     if ( show_progress )
6435         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6436 
6437 
6438     /* 3) Discard the file if necessary */
6439 
6440     if ( pass ) {
6441 
6442         if ( H5Fclose(file_id) < 0  ) {
6443 
6444             pass = FALSE;
6445             failure_mssg = "H5Fclose() failed.\n";
6446 
6447         }
6448 
6449         if ( HDremove(filename) < 0 ) {
6450 
6451             pass = FALSE;
6452             failure_mssg = "HDremove() failed.\n";
6453         }
6454     }
6455 
6456     if ( show_progress )
6457         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6458 
6459 
6460     /* 4) Attempt to create a HDF5 file with SWMR write
6461      *    access and cache image requested -- should fail.
6462      */
6463 
6464      attempt_swmr_open_hdf5_file(/* create_file   */ TRUE,
6465                                  /* set_mdci_fapl */ TRUE,
6466                                  /* hdf_file_name */ filename);
6467 
6468     if ( show_progress )
6469         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6470 
6471 
6472     /* 5) Discard the file if necessary */
6473 
6474     if ( pass ) {
6475 
6476         /* file probably doesn't exist, so don't
6477          * error check the remove call.
6478          */
6479         HDremove(filename);
6480     }
6481 
6482     if ( show_progress )
6483         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6484 
6485 
6486     /* 6) Create a HDF5 file with a cache image requested. */
6487 
6488     if ( pass ) {
6489 
6490         open_hdf5_file(/* create_file        */ TRUE,
6491                        /* mdci_sbem_expected */ FALSE,
6492                        /* read_only          */ FALSE,
6493                        /* set_mdci_fapl      */ TRUE,
6494             /* config_fsm         */ TRUE,
6495             /* set_eoc            */ FALSE,
6496                        /* hdf_file_name      */ filename,
6497                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
6498                        /* file_id_ptr        */ &file_id,
6499                        /* file_ptr_ptr       */ &file_ptr,
6500                        /* cache_ptr_ptr      */ &cache_ptr);
6501     }
6502 
6503     if ( show_progress )
6504         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6505 
6506 
6507     /* 7) Create some datasets in the file. */
6508 
6509     if ( pass ) {
6510 
6511         create_datasets(file_id, 0, 5);
6512     }
6513 
6514 #if H5C_COLLECT_CACHE_STATS
6515     if ( pass ) {
6516 
6517         if ( cache_ptr->images_loaded != 0 ) {
6518 
6519             pass = FALSE;
6520             failure_mssg = "metadata cache image block loaded(1).";
6521         }
6522     }
6523 #endif /* H5C_COLLECT_CACHE_STATS */
6524 
6525     if ( show_progress )
6526         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6527 
6528 
6529     /* 8) Close the file. */
6530 
6531     if ( pass ) {
6532 
6533         if ( H5Fclose(file_id) < 0  ) {
6534 
6535             pass = FALSE;
6536             failure_mssg = "H5Fclose() failed.\n";
6537 
6538         }
6539     }
6540 
6541     if ( show_progress )
6542         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6543 
6544 
6545     /* 9) Attempt to open the file with SWMR write access -- should fail. */
6546 
6547     attempt_swmr_open_hdf5_file(/* create_file   */ FALSE,
6548                                 /* set_mdci_fapl */ TRUE,
6549                                 /* hdf_file_name */ filename);
6550 
6551     if ( show_progress )
6552         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6553 
6554 
6555     /* 10) Discard the file if necessary. */
6556 
6557     if ( pass ) {
6558 
6559         if ( HDremove(filename) < 0 ) {
6560 
6561             pass = FALSE;
6562             failure_mssg = "HDremove() failed.\n";
6563         }
6564     }
6565 
6566     if ( show_progress )
6567         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6568 
6569 
6570     if ( pass ) { PASSED(); } else { H5_FAILED(); }
6571 
6572     if ( ! pass )
6573         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
6574                   FUNC, failure_mssg);
6575 
6576     return !pass;
6577 
6578 } /* cache_image_api_error_check_3() */
6579 
6580 
6581 /*-------------------------------------------------------------------------
6582  * Function:    cache_image_api_error_check_4()
6583  *
6584  * Purpose:     This test is one of a sequence of tests intended
6585  *        to verify correct management of API errors.
6586  *
6587  *        The object of this test is to verify that a request for
6588  *        a cache image when a version 2 superblock is not available/
6589  *        not requested is handled correctly.
6590  *        (the cache image request should be ignored silently).
6591  *
6592  *        The test is set up as follows:
6593  *
6594  *        1) Create a FAPL requesting  a cache image, but WITHOUT
6595  *           specifying the latest file format.
6596  *
6597  *        2) Create a HDF5 file using the above FAPL.
6598  *
6599  *        3) Create some datasets in the file.
6600  *
6601  *        4) Close the file.
6602  *
6603  *        5) Open the file read only.  Verify that the file doesn't
6604  *           contain a cache image.
6605  *
6606  *        6) Verify that the datasets exist and contain the
6607  *           expected data
6608  *
6609  *           Verify that the cache image was not loaded.
6610  *
6611  *        7) Close the file.
6612  *
6613  *        8) Open the file R/W using the FAPL defined in 1) above.
6614  *           Verify that the file does not contain a cache image.
6615  *
6616  *        9) Close the file.
6617  *
6618  *           10) Open the file R/W using the FAPL defined in 1) above.
6619  *               Verify that the file does not contain a cache image.
6620  *
6621  *           11) Verify that the data sets contain the expected data
6622  *
6623  *           Verify that a cache image was not loaded.
6624  *
6625  *           12) Create several more data sets.
6626  *
6627  *           13) Close the file.
6628  *
6629  *            14) Open the file read write.
6630  *
6631  *                Verify that the file does not contain a cache image.
6632  *
6633  *           15) Verify the data sets exist and contain the expected
6634  *               data.
6635  *
6636  *           Verify that a cache image was not loaded.
6637  *
6638  *           16) Close the file.
6639  *
6640  *           17) Delete the file.
6641  *
6642  * Return:      void
6643  *
6644  * Programmer:  John Mainzer
6645  *              9/25/15
6646  *
6647  *-------------------------------------------------------------------------
6648  */
6649 
6650 static unsigned
cache_image_api_error_check_4(void)6651 cache_image_api_error_check_4(void)
6652 {
6653     const char * fcn_name = "cache_image_api_error_check_4()";
6654     char filename[512];
6655     hbool_t show_progress = FALSE;
6656     hid_t fapl_id = -1;
6657     hid_t file_id = -1;
6658     H5F_t *file_ptr = NULL;
6659     H5C_t *cache_ptr = NULL;
6660     int cp = 0;
6661     H5AC_cache_image_config_t cache_image_config;
6662 
6663     TESTING("metadata cache image api error check 4");
6664 
6665     pass = TRUE;
6666 
6667     if ( show_progress )
6668         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6669 
6670 
6671     /* setup the file name */
6672     if ( pass ) {
6673 
6674         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
6675             == NULL ) {
6676 
6677             pass = FALSE;
6678             failure_mssg = "h5_fixname() failed.\n";
6679         }
6680     }
6681 
6682     if ( show_progress )
6683         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6684 
6685     /*    1) Create a FAPL requesting  a cache image, but WITHOUT
6686      *           specifying the latest file format.
6687      */
6688     if ( pass ) {
6689 
6690         fapl_id = H5Pcreate(H5P_FILE_ACCESS);
6691 
6692         if ( fapl_id < 0 ) {
6693 
6694             pass = FALSE;
6695             failure_mssg = "H5Pcreate() failed.\n";
6696         }
6697     }
6698 
6699     if ( show_progress )
6700         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6701 
6702     if ( pass ) {
6703 
6704         /* set cache image config fields to taste */
6705         cache_image_config.version = H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION;
6706         cache_image_config.generate_image = TRUE;
6707         cache_image_config.save_resize_status = FALSE;
6708         cache_image_config.entry_ageout = H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE;
6709 
6710         if ( H5Pset_mdc_image_config(fapl_id, &cache_image_config) < 0 ) {
6711 
6712             pass = FALSE;
6713             failure_mssg = "H5Pset_mdc_image_config() failed.\n";
6714         }
6715     }
6716 
6717     if ( show_progress )
6718         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6719 
6720 
6721     /* 2) Create a HDF5 file using the above FAPL. */
6722 
6723     if ( pass ) {
6724 
6725         file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
6726 
6727         if ( file_id < 0 ) {
6728 
6729             pass = FALSE;
6730             failure_mssg = "H5Fcreate() failed.\n";
6731 
6732         } else {
6733 
6734             file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE);
6735 
6736             if ( file_ptr == NULL ) {
6737 
6738                 pass = FALSE;
6739                 failure_mssg = "Can't get file_ptr.";
6740 
6741             }
6742         }
6743     }
6744 
6745     if ( show_progress )
6746         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6747 
6748     /* get a pointer to the files internal data structure and then
6749      * to the cache structure
6750      */
6751     if ( pass ) {
6752 
6753         if ( file_ptr->shared->cache == NULL ) {
6754 
6755             pass = FALSE;
6756             failure_mssg = "can't get cache pointer(1).\n";
6757 
6758         } else {
6759 
6760             cache_ptr = file_ptr->shared->cache;
6761         }
6762     }
6763 
6764     if ( show_progress )
6765         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6766 
6767 
6768     /* 3) Create some datasets in the file. */
6769 
6770     if ( pass ) {
6771 
6772         create_datasets(file_id, 0, 5);
6773     }
6774 
6775 #if H5C_COLLECT_CACHE_STATS
6776     if ( pass ) {
6777 
6778         HDassert(cache_ptr);
6779 
6780         if ( cache_ptr->images_loaded != 0 ) {
6781 
6782             pass = FALSE;
6783             failure_mssg = "metadata cache image block loaded(1).";
6784         }
6785     }
6786 #endif /* H5C_COLLECT_CACHE_STATS */
6787 
6788     if ( show_progress )
6789         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6790 
6791 
6792     /* 4) Close the file. */
6793 
6794     if ( pass ) {
6795 
6796         if ( H5Fclose(file_id) < 0  ) {
6797 
6798             pass = FALSE;
6799             failure_mssg = "H5Fclose() failed.\n";
6800 
6801         }
6802     }
6803 
6804     if ( show_progress )
6805         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6806 
6807 
6808     /* 5) Open the file read only. */
6809 
6810     if ( pass ) {
6811 
6812         open_hdf5_file(/* create_file        */ FALSE,
6813                 /* mdci_sbem_expected */ FALSE,
6814                        /* read_only          */ TRUE,
6815                        /* set_mdci_fapl      */ FALSE,
6816             /* config_fsm         */ FALSE,
6817             /* set_eoc            */ FALSE,
6818                        /* hdf_file_name      */ filename,
6819                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
6820                        /* file_id_ptr        */ &file_id,
6821                        /* file_ptr_ptr       */ &file_ptr,
6822                        /* cache_ptr_ptr      */ &cache_ptr);
6823     }
6824 
6825     if ( show_progress )
6826         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6827 
6828 
6829     /* 6) Verify that the datasets exist and contain the
6830      *    expected data
6831      */
6832 
6833     if ( pass ) {
6834 
6835        verify_datasets(file_id, 0, 5);
6836     }
6837 
6838 #if H5C_COLLECT_CACHE_STATS
6839     if ( pass ) {
6840 
6841         if ( cache_ptr->images_loaded != 0 ) {
6842 
6843             pass = FALSE;
6844             failure_mssg = "metadata cache image block loaded(2).";
6845         }
6846     }
6847 #endif /* H5C_COLLECT_CACHE_STATS */
6848 
6849     if ( show_progress )
6850         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6851 
6852 
6853     /* 7) Close the file. */
6854 
6855     if ( pass ) {
6856 
6857         if ( H5Fclose(file_id) < 0  ) {
6858 
6859             pass = FALSE;
6860             failure_mssg = "H5Fclose() failed.\n";
6861         }
6862     }
6863 
6864     if ( show_progress )
6865         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6866 
6867 
6868     /* 8) Open the file R/W using the FAPL defined in 1) above.
6869      *
6870      *    Verify that the file does not contain a cache image.
6871      */
6872 
6873     if ( pass ) {
6874 
6875         file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id);
6876 
6877         if ( file_id < 0 ) {
6878 
6879             pass = FALSE;
6880             failure_mssg = "H5Fopen() failed.\n";
6881 
6882         } else {
6883 
6884             file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE);
6885 
6886             if ( file_ptr == NULL ) {
6887 
6888                 pass = FALSE;
6889                 failure_mssg = "Can't get file_ptr.";
6890 
6891             }
6892         }
6893     }
6894 
6895     if ( show_progress )
6896         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6897 
6898     /* get a pointer to the files internal data structure and then
6899      * to the cache structure
6900      */
6901     if ( pass ) {
6902 
6903         if ( file_ptr->shared->cache == NULL ) {
6904 
6905             pass = FALSE;
6906             failure_mssg = "can't get cache pointer(1).\n";
6907 
6908         } else {
6909 
6910             cache_ptr = file_ptr->shared->cache;
6911         }
6912     }
6913 
6914     if ( show_progress )
6915         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6916 
6917     if ( pass ) {
6918 
6919         if ( ( cache_ptr->load_image == TRUE ) ||
6920              ( cache_ptr->delete_image == TRUE ) ) {
6921 
6922             pass = FALSE;
6923             failure_mssg = "mdci sb extension message present?\n";
6924         }
6925     }
6926 
6927     if ( show_progress )
6928         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6929 
6930 
6931     /* 9) Close the file. */
6932 
6933     if ( pass ) {
6934 
6935         if ( H5Fclose(file_id) < 0  ) {
6936 
6937             pass = FALSE;
6938             failure_mssg = "H5Fclose() failed.\n";
6939         }
6940     }
6941 
6942     if ( show_progress )
6943         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6944 
6945 
6946 
6947     /* 10) Open the file R/W using the FAPL defined in 1) above.
6948      *     Verify that the file does not contain a cache image.
6949      */
6950 
6951     if ( pass ) {
6952 
6953         file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id);
6954 
6955         if ( file_id < 0 ) {
6956 
6957             pass = FALSE;
6958             failure_mssg = "H5Fopen() failed.\n";
6959 
6960         } else {
6961 
6962             file_ptr = (struct H5F_t *)H5I_object_verify(file_id, H5I_FILE);
6963 
6964             if ( file_ptr == NULL ) {
6965 
6966                 pass = FALSE;
6967                 failure_mssg = "Can't get file_ptr.";
6968 
6969             }
6970         }
6971     }
6972 
6973     if ( show_progress )
6974         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6975 
6976     /* get a pointer to the files internal data structure and then
6977      * to the cache structure
6978      */
6979     if ( pass ) {
6980 
6981         if ( file_ptr->shared->cache == NULL ) {
6982 
6983             pass = FALSE;
6984             failure_mssg = "can't get cache pointer(1).\n";
6985 
6986         } else {
6987 
6988             cache_ptr = file_ptr->shared->cache;
6989         }
6990     }
6991 
6992     if ( show_progress )
6993         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
6994 
6995     if ( pass ) {
6996 
6997         if ( ( cache_ptr->load_image == TRUE ) ||
6998              ( cache_ptr->delete_image == TRUE ) ) {
6999 
7000             pass = FALSE;
7001             failure_mssg = "mdci sb extension message present?\n";
7002         }
7003     }
7004 
7005     if ( show_progress )
7006         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7007 
7008 
7009     /* 11) Verify that the data sets contain the expected data
7010      *
7011      *     Verify that a cache image was not loaded.
7012      */
7013 
7014     if ( pass ) {
7015 
7016        verify_datasets(file_id, 0, 5);
7017     }
7018 
7019 #if H5C_COLLECT_CACHE_STATS
7020     if ( pass ) {
7021 
7022         if ( cache_ptr->images_loaded != 0 ) {
7023 
7024             pass = FALSE;
7025             failure_mssg = "metadata cache image block loaded(2).";
7026         }
7027     }
7028 #endif /* H5C_COLLECT_CACHE_STATS */
7029 
7030     if ( show_progress )
7031         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7032 
7033 
7034     /* 12) Create several more data sets. */
7035 
7036     if ( pass ) {
7037 
7038         create_datasets(file_id, 6, 10);
7039     }
7040 
7041     if ( show_progress )
7042         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7043 
7044 
7045     /* 13) Close the file. */
7046 
7047     if ( pass ) {
7048 
7049         if ( H5Fclose(file_id) < 0  ) {
7050 
7051             pass = FALSE;
7052             failure_mssg = "H5Fclose() failed.\n";
7053         }
7054     }
7055 
7056     if ( show_progress )
7057         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7058 
7059 
7060     /* 14) Open the file read write.
7061      *
7062      *     Verify that the file does not contain a cache image.
7063      */
7064 
7065     if ( pass ) {
7066 
7067         open_hdf5_file(/* create_file        */ FALSE,
7068                 /* mdci_sbem_expected */ FALSE,
7069                        /* read_only          */ FALSE,
7070                        /* set_mdci_fapl      */ FALSE,
7071             /* config_fsm         */ FALSE,
7072             /* set_eoc            */ FALSE,
7073                        /* hdf_file_name      */ filename,
7074                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7075                        /* file_id_ptr        */ &file_id,
7076                        /* file_ptr_ptr       */ &file_ptr,
7077                        /* cache_ptr_ptr      */ &cache_ptr);
7078     }
7079 
7080     if ( show_progress )
7081         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7082 
7083 
7084     /* 15) Verify the data sets exist and contain the expected  data.
7085      *
7086      *     Verify that a cache image was not loaded.
7087      */
7088 
7089     if ( pass ) {
7090 
7091        verify_datasets(file_id, 0, 10);
7092     }
7093 
7094 #if H5C_COLLECT_CACHE_STATS
7095     if ( pass ) {
7096 
7097         if ( cache_ptr->images_loaded != 0 ) {
7098 
7099             pass = FALSE;
7100             failure_mssg = "metadata cache image block loaded(2).";
7101         }
7102     }
7103 #endif /* H5C_COLLECT_CACHE_STATS */
7104 
7105     if ( show_progress )
7106         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7107 
7108 
7109     /* 16) Close the file. */
7110 
7111     if ( pass ) {
7112 
7113         if ( H5Fclose(file_id) < 0  ) {
7114 
7115             pass = FALSE;
7116             failure_mssg = "H5Fclose() failed.\n";
7117         }
7118     }
7119 
7120     if ( show_progress )
7121         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7122 
7123 
7124     /* 17) Delete the file */
7125 
7126     if ( pass ) {
7127 
7128         if ( HDremove(filename) < 0 ) {
7129 
7130             pass = FALSE;
7131             failure_mssg = "HDremove() failed.\n";
7132         }
7133     }
7134 
7135     if ( show_progress )
7136         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7137 
7138 
7139     /* tidy up */
7140     if ( fapl_id != -1 )
7141         H5Pclose(fapl_id);
7142 
7143 
7144     if ( pass ) { PASSED(); } else { H5_FAILED(); }
7145 
7146     if ( ! pass )
7147         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
7148                   FUNC, failure_mssg);
7149 
7150     return !pass;
7151 
7152 } /* cache_image_api_error_check_4() */
7153 
7154 
7155 /*-------------------------------------------------------------------------
7156  * Function:    get_free_sections_test()
7157  *
7158  * Purpose:     It is possible that H5Fget_free_sections() to be
7159  *        called before any activity on the metadata cache.
7160  *              This is a potential problem, as satisfying the
7161  *              H5Fget_free_sections() call requires access to all
7162  *              free space managers.  When persistent free space
7163  *              managers are enabled, this will require calling
7164  *              H5MF_tidy_self_referential_fsm_hack().  This is a
7165  *              non issue in the absence of a cache image.  However,
7166  *        this is a problem if a cache image exists, as
7167  *        the call to H5MF_tidy_self_referential_fsm_hack()
7168  *        will free the file space allocated to the cache
7169  *        image.
7170  *
7171  *        The objective of this test is to create a test file
7172  *        with both non-empty self referential presistant
7173  *              free space managers, and a cache image, and then
7174  *              verify that this situation is handled correctly if
7175  *              H5Fget_free_sections() is called before the metadata
7176  *              cache image is loaded.
7177  *
7178  *        The test is set up as follows:
7179  *
7180  *         1) Create a HDF5 file with a cache image requested
7181  *                  and persistent free space managers enabled.
7182  *
7183  *         2) Create some data sets, and then delete some of
7184  *                  of those near the beginning of the file.
7185  *
7186  *               3) Close the file.
7187  *
7188  *               4) Open the file read only.
7189  *
7190  *               5) Verify that a cache image exists, and has not
7191  *                  been loaded.
7192  *
7193  *               6) Verify that one or more self referential FSMs
7194  *                  have been stored at the end of the file just
7195  *                  before the cache image.
7196  *
7197  *               7) Call H5Fget_free_sections().
7198  *
7199  *               8) Verify that the cache image has been loaded and
7200  *                  that the self referential FSMs have been floated.
7201  *
7202  *               9) Verify that the remaining data sets contain the
7203  *                  expected data.
7204  *
7205  *              10) Close the file.
7206  *
7207  *              11) Open the file R/W.
7208  *
7209  *              12) Verify that a cache image exists, and has not
7210  *                  been loaded.
7211  *
7212  *              13) Verify that one or more self referential FSMs
7213  *                  have been stored at the end of the file just
7214  *                  before the cache image.
7215  *
7216  *              14) Call H5Fget_free_sections().
7217  *
7218  *              15) Verify that the cache image has been loaded and
7219  *                  that the self referential FSMs have been floated.
7220  *
7221  *              16) Verify that the remaining data sets contain the
7222  *                  expected data.
7223  *
7224  *              17) Delete the remaining data sets.
7225  *
7226  *        18) Close the file.
7227  *
7228  *              19) Verify that file space has been reclaimed.
7229  *
7230  *              20) Discard the file.
7231  *
7232  * Return:      void
7233  *
7234  * Programmer:  John Mainzer
7235  *              1/10/17
7236  *
7237  *-------------------------------------------------------------------------
7238  */
7239 static unsigned
get_free_sections_test(void)7240 get_free_sections_test(void)
7241 {
7242     const char * fcn_name = "get_free_sections_test()";
7243     char filename[512];
7244     hbool_t show_progress = FALSE;
7245     hid_t file_id = -1;
7246     H5F_t *file_ptr = NULL;
7247     H5C_t *cache_ptr = NULL;
7248     h5_stat_size_t file_size;
7249     int cp = 0;
7250 
7251     TESTING("Cache image / H5Fget_free_sections() interaction");
7252 
7253     pass = TRUE;
7254 
7255     if ( show_progress )
7256         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7257 
7258 
7259     /* setup the file name */
7260     if ( pass ) {
7261 
7262         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
7263             == NULL ) {
7264 
7265             pass = FALSE;
7266             failure_mssg = "h5_fixname() failed.\n";
7267         }
7268     }
7269 
7270     if ( show_progress )
7271         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7272 
7273 
7274     /* 1) Create a HDF5 file with a cache image requested
7275      *    and persistent free space managers enabled.
7276      */
7277 
7278     if ( pass ) {
7279 
7280         open_hdf5_file(/* create_file        */ TRUE,
7281                        /* mdci_sbem_expected */ FALSE,
7282                        /* read_only          */ FALSE,
7283                        /* set_mdci_fapl      */ TRUE,
7284             /* config_fsm         */ TRUE,
7285             /* set_eoc            */ FALSE,
7286                        /* hdf_file_name      */ filename,
7287                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7288                        /* file_id_ptr        */ &file_id,
7289                        /* file_ptr_ptr       */ &file_ptr,
7290                        /* cache_ptr_ptr      */ &cache_ptr);
7291     }
7292 
7293     if ( show_progress )
7294         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7295 
7296 
7297     /* 2) Create some data sets, and then delete some of
7298      *    of those near the beginning of the file.
7299      */
7300 
7301     if ( pass ) {
7302 
7303         create_datasets(file_id, 1, 10);
7304     }
7305 
7306     if ( show_progress )
7307         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7308 
7309     if ( pass ) {
7310 
7311         verify_datasets(file_id, 1, 10);
7312     }
7313 
7314     if ( show_progress )
7315         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7316 
7317     if ( pass ) {
7318 
7319         delete_datasets(file_id, 1, 5);
7320     }
7321 
7322     if ( show_progress )
7323         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7324 
7325 
7326     /* 3) Close the file. */
7327 
7328     if ( pass ) {
7329 
7330         if ( H5Fclose(file_id) < 0  ) {
7331 
7332             pass = FALSE;
7333             failure_mssg = "H5Fclose() failed (1).\n";
7334 
7335         }
7336     }
7337 
7338     if ( show_progress )
7339         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7340 
7341 
7342     /* 4) Open the file read only. */
7343 
7344     if ( pass ) {
7345 
7346         open_hdf5_file(/* create_file        */ FALSE,
7347                        /* mdci_sbem_expected */ TRUE,
7348                        /* read_only          */ TRUE,
7349                        /* set_mdci_fapl      */ FALSE,
7350             /* config_fsm         */ FALSE,
7351             /* set_eoc            */ FALSE,
7352                        /* hdf_file_name      */ filename,
7353                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7354                        /* file_id_ptr        */ &file_id,
7355                        /* file_ptr_ptr       */ &file_ptr,
7356                        /* cache_ptr_ptr      */ &cache_ptr);
7357     }
7358 
7359     if ( show_progress )
7360         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7361 
7362 
7363     /* 5) Verify that a cache image exists, and has not been loaded. */
7364 
7365     if ( pass ) {
7366 
7367         if ( ( ! file_ptr->shared->cache->load_image ) ||
7368              ( file_ptr->shared->cache->image_loaded ) ) {
7369 
7370             pass = FALSE;
7371             failure_mssg = "unexpected cache image status.\n";
7372         }
7373     }
7374 
7375     if ( show_progress )
7376         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7377 
7378 
7379     /* 6) Verify that one or more self referential FSMs
7380      *    have been stored at the end of the file just
7381      *    before the cache image.
7382      */
7383 
7384     if ( pass ) {
7385 
7386         /* file_ptr->shared->first_alloc_dealloc is set to FALSE if the
7387          * file is opened R/O.
7388          */
7389         if ( ( file_ptr->shared->first_alloc_dealloc ) ||
7390              ( ! H5F_addr_defined(file_ptr->shared->eoa_pre_fsm_fsalloc) ) ||
7391              ( ! H5F_addr_defined(file_ptr->shared->cache->image_addr) ) ||
7392              ( H5F_addr_gt(file_ptr->shared->eoa_pre_fsm_fsalloc,
7393                            file_ptr->shared->cache->image_addr) ) ) {
7394 
7395             pass = FALSE;
7396             failure_mssg = "unexpected cache image status (1).\n";
7397         }
7398     }
7399 
7400     if ( show_progress )
7401         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7402 
7403 
7404     /* 7) Call H5Fget_free_sections(). */
7405 
7406     if ( pass ) {
7407 
7408         if ( H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL)
7409              < 0 ){
7410 
7411             pass = FALSE;
7412             failure_mssg = "H5Fget_free_sections() failed (1).\n";
7413         }
7414     }
7415 
7416     if ( show_progress )
7417         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7418 
7419 
7420     /* 8) Verify that the cache image has been loaded and
7421      *    that the self referential FSMs have been floated.
7422      */
7423     if ( pass ) {
7424 
7425         if ( ! file_ptr->shared->cache->image_loaded ) {
7426 
7427             pass = FALSE;
7428             failure_mssg = "cache image not loaded (1).\n";
7429 
7430         } else if ( file_ptr->shared->first_alloc_dealloc ) {
7431 
7432             pass = FALSE;
7433             failure_mssg = "self referential FSMs not floated (1).\n";
7434         }
7435     }
7436 
7437     if ( show_progress )
7438         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7439 
7440 
7441     /* 9) Verify that the remaining data sets contain the expected data. */
7442 
7443     if ( pass ) {
7444 
7445         verify_datasets(file_id, 6, 10);
7446     }
7447 
7448     if ( show_progress )
7449         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7450 
7451 
7452     /* 10) Close the file. */
7453 
7454     if ( pass ) {
7455 
7456         if ( H5Fclose(file_id) < 0  ) {
7457 
7458             pass = FALSE;
7459             failure_mssg = "H5Fclose() failed (2).\n";
7460         }
7461     }
7462 
7463     if ( show_progress )
7464         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7465 
7466 
7467     /* 11) Open the file R/W. */
7468 
7469     if ( pass ) {
7470 
7471         open_hdf5_file(/* create_file        */ FALSE,
7472                        /* mdci_sbem_expected */ TRUE,
7473                        /* read_only          */ FALSE,
7474                        /* set_mdci_fapl      */ FALSE,
7475             /* config_fsm         */ FALSE,
7476             /* set_eoc            */ FALSE,
7477                        /* hdf_file_name      */ filename,
7478                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7479                        /* file_id_ptr        */ &file_id,
7480                        /* file_ptr_ptr       */ &file_ptr,
7481                        /* cache_ptr_ptr      */ &cache_ptr);
7482     }
7483 
7484     if ( show_progress )
7485         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7486 
7487 
7488     /* 12) Verify that a cache image exists, and has not been loaded. */
7489 
7490     if ( pass ) {
7491 
7492         if ( ( ! file_ptr->shared->cache->load_image ) ||
7493              ( file_ptr->shared->cache->image_loaded ) ) {
7494 
7495             pass = FALSE;
7496             failure_mssg = "unexpected cache image status.\n";
7497         }
7498     }
7499 
7500     if ( show_progress )
7501         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7502 
7503 
7504     /* 13) Verify that one or more self referential FSMs
7505      *     have been stored at the end of the file just
7506      *     before the cache image.
7507      */
7508     if ( pass ) {
7509 
7510         if ( ( ! file_ptr->shared->first_alloc_dealloc ) ||
7511              ( ! H5F_addr_defined(file_ptr->shared->eoa_pre_fsm_fsalloc) ) ||
7512              ( ! H5F_addr_defined(file_ptr->shared->cache->image_addr) ) ||
7513              ( H5F_addr_gt(file_ptr->shared->eoa_pre_fsm_fsalloc,
7514                            file_ptr->shared->cache->image_addr) ) ) {
7515 
7516             pass = FALSE;
7517             failure_mssg = "unexpected cache image status (2).\n";
7518         }
7519     }
7520 
7521     if ( show_progress )
7522         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7523 
7524 
7525     /* 14) Call H5Fget_free_sections(). */
7526 
7527     if ( pass ) {
7528 
7529         if ( H5Fget_free_sections(file_id, H5FD_MEM_DEFAULT, (size_t)0, NULL)
7530              < 0 ){
7531 
7532             pass = FALSE;
7533             failure_mssg = "H5Fget_free_sections() failed (2).\n";
7534         }
7535     }
7536 
7537     if ( show_progress )
7538         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7539 
7540 
7541     /* 15) Verify that the cache image has been loaded and
7542      *     that the self referential FSMs have been floated.
7543      */
7544     if ( pass ) {
7545 
7546         if ( ! file_ptr->shared->cache->image_loaded ) {
7547 
7548             pass = FALSE;
7549             failure_mssg = "cache image not loaded (2).\n";
7550 
7551         } else if ( file_ptr->shared->first_alloc_dealloc ) {
7552 
7553             pass = FALSE;
7554             failure_mssg = "self referential FSMs not floated (2).\n";
7555         }
7556     }
7557 
7558     if ( show_progress )
7559         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7560 
7561 
7562     /* 16) Verify that the remaining data sets contain the expected data. */
7563 
7564     if ( pass ) {
7565 
7566         verify_datasets(file_id, 6, 10);
7567     }
7568 
7569     if ( show_progress )
7570         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7571 
7572 
7573     /* 17) Delete the remaining data sets. */
7574 
7575     if ( pass ) {
7576 
7577         delete_datasets(file_id, 6, 10);
7578     }
7579 
7580     if ( show_progress )
7581         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7582 
7583 
7584     /* 18) Close the file. */
7585 
7586     if ( pass ) {
7587 
7588         if ( H5Fclose(file_id) < 0  ) {
7589 
7590             pass = FALSE;
7591             failure_mssg = "H5Fclose() failed (3).\n";
7592         }
7593     }
7594 
7595     if ( show_progress )
7596         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7597 
7598 
7599     /* 19) Verify that file space has been reclaimed. */
7600 
7601     if ( pass ) {
7602 
7603         if((file_size = h5_get_file_size(filename, H5P_DEFAULT)) < 0) {
7604 
7605             pass = FALSE;
7606             failure_mssg = "h5_get_file_size() failed.\n";
7607 
7608         } else if ( file_size > 20 * 1024 ) {
7609 
7610             pass = FALSE;
7611             failure_mssg = "unexpectedly large file size.\n";
7612         }
7613     }
7614 
7615     if ( show_progress )
7616         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7617 
7618 
7619     /* 20) Discard the file. */
7620 
7621     if ( pass ) {
7622 
7623         if ( HDremove(filename) < 0 ) {
7624 
7625             pass = FALSE;
7626             failure_mssg = "HDremove() failed.\n";
7627         }
7628     }
7629 
7630     if ( show_progress )
7631         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7632 
7633     if ( pass ) { PASSED(); } else { H5_FAILED(); }
7634 
7635     if ( ! pass )
7636         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
7637                   FUNC, failure_mssg);
7638 
7639     return !pass;
7640 
7641 } /* get_free_sections_test() */
7642 
7643 
7644 /*-------------------------------------------------------------------------
7645  * Function:    evict_on_close_test()
7646  *
7647  * Purpose:     If a file containing a cache image which in turn
7648  *              contains dirty entries is opened R/O, the metadata
7649  *              cache must refuse to evict the dirty entries, as
7650  *              it will not be able to reload them from file.  This
7651  *              is a bit tricky, as the dirty entries must marked as
7652  *              clean in the metadata cache so that the MDC will not
7653  *              attempt to flush then on file close.
7654  *
7655  *              The objective of this test is to verify that the
7656  *              metadata will not evict dirty entries in the above
7657  *              context when the file is opened with the evict on close
7658  *              FAPL entry.
7659  *
7660  *              Do this by creating a HDF5 file with a cache image
7661  *              containing dirty metadata.
7662  *
7663  *              Then close the file, re-open it R/O, and scan its
7664  *              contents twice.  If evict on close succeeds in evicting
7665  *              the dirty metadata, the second scan will fail, as valid
7666  *              versions of the dirty metadata will not be available.
7667  *
7668  *              To make the test more useful, enable persistent free
7669  *              space managers.
7670  *
7671  *        The test is set up as follows:
7672  *
7673  *         1) Create a HDF5 file without a cache image requested
7674  *                  and persistent free space managers enabled.
7675  *
7676  *         2) Create some data sets and verify them.
7677  *
7678  *               3) Close the file.
7679  *
7680  *               4) Open the file R/W, and with cache image requested.
7681  *
7682  *               5) Verify the datasets created in 2) above.  This will
7683  *                  force their (clean) metadata into the metadata cache,
7684  *                  and hence into the cache image.
7685  *
7686  *               6) Create some more datasets.
7687  *
7688  *               7) Close the file.
7689  *
7690  *               8) Open the file R/O and with evict on close enabled.
7691  *
7692  *               9) Verify all datasets twice.
7693  *
7694  *              10) Close the file.
7695  *
7696  *              11) Open the file R/W and with evict on close enabled.
7697  *
7698  *              12) Verify all datasets twice.
7699  *
7700  *              13) Close the file.
7701  *
7702  *              14) Discard the file.
7703  *
7704  * Return:      void
7705  *
7706  * Programmer:  John Mainzer
7707  *              3/23/17
7708  *
7709  *-------------------------------------------------------------------------
7710  */
7711 static unsigned
evict_on_close_test(void)7712 evict_on_close_test(void)
7713 {
7714 #ifndef H5_HAVE_PARALLEL
7715     const char * fcn_name = "evict_on_close_test()";
7716     char filename[512];
7717     hbool_t show_progress = FALSE;
7718     hbool_t verbose = FALSE;
7719     hid_t file_id = -1;
7720     H5F_t *file_ptr = NULL;
7721     H5C_t *cache_ptr = NULL;
7722     int cp = 0;
7723 #endif /* H5_HAVE_PARALLEL */
7724 
7725     TESTING("Cache image / evict on close interaction");
7726 
7727 #ifdef H5_HAVE_PARALLEL
7728     SKIPPED();
7729     HDputs("    EoC not supported in the parallel library.");
7730     return 0;
7731 #else
7732 
7733     pass = TRUE;
7734 
7735     if ( show_progress )
7736         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7737 
7738 
7739     /* setup the file name */
7740     if ( pass ) {
7741 
7742         if ( h5_fixname(FILENAMES[0], H5P_DEFAULT, filename, sizeof(filename))
7743             == NULL ) {
7744 
7745             pass = FALSE;
7746             failure_mssg = "h5_fixname() failed.\n";
7747         }
7748     }
7749 
7750     if ( show_progress )
7751         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7752 
7753 
7754     /* 1) Create a HDF5 file without a cache image requested
7755      *    and persistent free space managers enabled.
7756      */
7757     if ( pass ) {
7758 
7759         open_hdf5_file(/* create_file        */ TRUE,
7760                        /* mdci_sbem_expected */ FALSE,
7761                        /* read_only          */ FALSE,
7762                        /* set_mdci_fapl      */ FALSE,
7763             /* config_fsm         */ TRUE,
7764             /* set_eoc            */ FALSE,
7765                        /* hdf_file_name      */ filename,
7766                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7767                        /* file_id_ptr        */ &file_id,
7768                        /* file_ptr_ptr       */ &file_ptr,
7769                        /* cache_ptr_ptr      */ &cache_ptr);
7770     }
7771 
7772     if ( show_progress )
7773         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7774 
7775 
7776     /* 2) Create some data sets and verify them.  */
7777 
7778     if ( pass ) {
7779 
7780         create_datasets(file_id, 1, 10);
7781     }
7782 
7783     if ( show_progress )
7784         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7785 
7786     if ( pass ) {
7787 
7788         verify_datasets(file_id, 1, 10);
7789     }
7790 
7791     if ( show_progress )
7792         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7793 
7794 
7795     /* 3) Close the file. */
7796 
7797     if ( pass ) {
7798 
7799         if ( H5Fclose(file_id) < 0  ) {
7800 
7801             pass = FALSE;
7802             failure_mssg = "H5Fclose() failed (1).\n";
7803 
7804         }
7805     }
7806 
7807     if ( show_progress )
7808         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7809 
7810 
7811     /* 4) Open the file R/W, and with cache image requested. */
7812 
7813     if ( pass ) {
7814 
7815         open_hdf5_file(/* create_file        */ FALSE,
7816                        /* mdci_sbem_expected */ FALSE,
7817                        /* read_only          */ FALSE,
7818                        /* set_mdci_fapl      */ TRUE,
7819             /* config_fsm         */ FALSE,
7820             /* set_eoc            */ FALSE,
7821                        /* hdf_file_name      */ filename,
7822                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7823                        /* file_id_ptr        */ &file_id,
7824                        /* file_ptr_ptr       */ &file_ptr,
7825                        /* cache_ptr_ptr      */ &cache_ptr);
7826     }
7827 
7828     if ( show_progress )
7829         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7830 
7831 
7832     /* 5) Verify the datasets created in 2) above.  This will
7833      *    force their (clean) metadata into the metadata cache,
7834      *    and hence into the cache image.
7835      */
7836 
7837     if ( pass ) {
7838 
7839         verify_datasets(file_id, 1, 10);
7840     }
7841 
7842     if ( show_progress )
7843         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7844 
7845 
7846     /* 6) Create some more datasets and verify them */
7847 
7848     if ( pass ) {
7849 
7850         create_datasets(file_id, 11, 20);
7851     }
7852 
7853     if ( show_progress )
7854         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7855 
7856     if ( pass ) {
7857 
7858         verify_datasets(file_id, 11, 20);
7859     }
7860 
7861     if ( verbose ) {
7862 
7863         HDassert(cache_ptr);
7864         HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC);
7865 
7866         HDfprintf(stdout, "index size / index dirty size = %lld / %lld\n",
7867                   (long long)(cache_ptr->index_size),
7868                   (long long)(cache_ptr->dirty_index_size));
7869     }
7870 
7871     if ( show_progress )
7872         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7873 
7874 
7875     /* 7) Close the file. */
7876 
7877     if ( pass ) {
7878 
7879         if ( H5Fclose(file_id) < 0  ) {
7880 
7881             pass = FALSE;
7882             failure_mssg = "H5Fclose() failed (2).\n";
7883         }
7884     }
7885 
7886     if ( show_progress )
7887         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7888 
7889 
7890     /* 8) Open the file R/O and with evict on close enabled. */
7891 
7892     if ( pass ) {
7893 
7894         open_hdf5_file(/* create_file        */ FALSE,
7895                        /* mdci_sbem_expected */ TRUE,
7896                        /* read_only          */ TRUE,
7897                        /* set_mdci_fapl      */ FALSE,
7898             /* config_fsm         */ FALSE,
7899             /* set_eoc            */ TRUE,
7900                        /* hdf_file_name      */ filename,
7901                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7902                        /* file_id_ptr        */ &file_id,
7903                        /* file_ptr_ptr       */ &file_ptr,
7904                        /* cache_ptr_ptr      */ &cache_ptr);
7905     }
7906 
7907     if ( show_progress )
7908         HDfprintf(stdout, "%s*: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7909 
7910 
7911     /* 9) Verify all datasets twice */
7912 
7913     if ( pass ) {
7914 
7915         verify_datasets(file_id, 1, 20);
7916     }
7917 
7918     if ( show_progress )
7919         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7920 
7921     if ( pass ) {
7922 
7923         verify_datasets(file_id, 1, 20);
7924     }
7925 
7926     if ( show_progress )
7927         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7928 
7929 
7930     /* 10) Close the file. */
7931 
7932     if ( pass ) {
7933 
7934         if ( H5Fclose(file_id) < 0  ) {
7935 
7936             pass = FALSE;
7937             failure_mssg = "H5Fclose() failed (3).\n";
7938         }
7939     }
7940 
7941     if ( show_progress )
7942         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7943 
7944 
7945     /* 11) Open the file R/w and with evict on close enabled. */
7946 
7947     if ( pass ) {
7948 
7949         open_hdf5_file(/* create_file        */ FALSE,
7950                        /* mdci_sbem_expected */ TRUE,
7951                        /* read_only          */ FALSE,
7952                        /* set_mdci_fapl      */ FALSE,
7953             /* config_fsm         */ FALSE,
7954             /* set_eoc            */ TRUE,
7955                        /* hdf_file_name      */ filename,
7956                        /* cache_image_flags  */ H5C_CI__ALL_FLAGS,
7957                        /* file_id_ptr        */ &file_id,
7958                        /* file_ptr_ptr       */ &file_ptr,
7959                        /* cache_ptr_ptr      */ &cache_ptr);
7960     }
7961 
7962     if ( show_progress )
7963         HDfprintf(stdout, "%s*: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7964 
7965 
7966     /* 12) Verify all datasets twice */
7967 
7968     if ( pass ) {
7969 
7970         verify_datasets(file_id, 1, 20);
7971     }
7972 
7973     if ( show_progress )
7974         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7975 
7976     if ( pass ) {
7977 
7978         verify_datasets(file_id, 1, 20);
7979     }
7980 
7981     if ( show_progress )
7982         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7983 
7984 
7985     /* 13) Close the file. */
7986 
7987     if ( pass ) {
7988 
7989         if ( H5Fclose(file_id) < 0  ) {
7990 
7991             pass = FALSE;
7992             failure_mssg = "H5Fclose() failed (3).\n";
7993         }
7994     }
7995 
7996     if ( show_progress )
7997         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
7998 
7999 
8000     /* 14) Discard the file. */
8001 
8002     if ( pass ) {
8003 
8004         if ( HDremove(filename) < 0 ) {
8005 
8006             pass = FALSE;
8007             failure_mssg = "HDremove() failed.\n";
8008         }
8009     }
8010 
8011     if ( show_progress )
8012         HDfprintf(stdout, "%s: cp = %d, pass = %d.\n", fcn_name, cp++, pass);
8013 
8014     if ( pass ) { PASSED(); } else { H5_FAILED(); }
8015 
8016     if ( ! pass )
8017         HDfprintf(stdout, "%s: failure_mssg = \"%s\".\n",
8018                   FUNC, failure_mssg);
8019 
8020     return !pass;
8021 #endif /* H5_HAVE_PARALLEL */
8022 
8023 } /* evict_on_close_test() */
8024 
8025 
8026 /*-------------------------------------------------------------------------
8027  * Function:    main
8028  *
8029  * Purpose:     Run tests on the cache code contained in H5C.c
8030  *
8031  * Return:      Success:
8032  *
8033  *              Failure:
8034  *
8035  * Programmer:  John Mainzer
8036  *              6/24/04
8037  *
8038  *-------------------------------------------------------------------------
8039  */
8040 int
main(void)8041 main(void)
8042 {
8043     unsigned nerrs = 0;
8044     int express_test;
8045 
8046     H5open();
8047 
8048     express_test = GetTestExpress();
8049 
8050     HDprintf("=========================================\n");
8051     HDprintf("Cache image tests\n");
8052     HDprintf("        express_test = %d\n", express_test);
8053     HDprintf("=========================================\n");
8054 
8055     nerrs += check_cache_image_ctl_flow_1();
8056     nerrs += check_cache_image_ctl_flow_2();
8057     nerrs += check_cache_image_ctl_flow_3();
8058     nerrs += check_cache_image_ctl_flow_4();
8059     nerrs += check_cache_image_ctl_flow_5();
8060     nerrs += check_cache_image_ctl_flow_6();
8061 
8062     nerrs += cache_image_smoke_check_1();
8063     nerrs += cache_image_smoke_check_2();
8064     nerrs += cache_image_smoke_check_3();
8065     nerrs += cache_image_smoke_check_4();
8066     nerrs += cache_image_smoke_check_5();
8067     nerrs += cache_image_smoke_check_6();
8068 
8069     nerrs += cache_image_api_error_check_1();
8070     nerrs += cache_image_api_error_check_2();
8071     nerrs += cache_image_api_error_check_3();
8072     nerrs += cache_image_api_error_check_4();
8073 
8074     nerrs += get_free_sections_test();
8075     nerrs += evict_on_close_test();
8076 
8077     return(nerrs > 0);
8078 
8079 } /* main() */
8080 
8081