summaryrefslogtreecommitdiffstats
path: root/src/H5Gprivate.h
blob: 2ef99fdb4778fcd5d6dbf82a17cbcaaeba2f8580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*-------------------------------------------------------------------------
 *
 * Created:             H5Gprivate.h
 *                      Jul 11 1997
 *                      Robb Matzke <matzke@llnl.gov>
 *
 * Purpose:             Library-visible declarations.
 *
 *-------------------------------------------------------------------------
 */

#ifndef _H5Gprivate_H
#define _H5Gprivate_H

/* Include package's public header */
#include "H5Gpublic.h"

/* Private headers needed by this file */
#include "H5private.h"		/* Generic Functions			*/
#include "H5Bprivate.h"		/* B-trees				*/
#include "H5Fprivate.h"		/* File access				*/
#include "H5RSprivate.h"        /* Reference-counted strings            */

/*
 * The disk size for a symbol table entry...
 */
#define H5G_SIZEOF_SCRATCH      16
#define H5G_SIZEOF_ENTRY(sizeof_addr, sizeof_size)                            \
   ((sizeof_size) +             /*offset of name into heap              */    \
    (sizeof_addr) +             /*address of object header              */    \
    4 +                         /*entry type                            */    \
    4 +				/*reserved				*/    \
    H5G_SIZEOF_SCRATCH)         /*scratch pad space                     */
#define H5G_SIZEOF_ENTRY_FILE(F)                                              \
    H5G_SIZEOF_ENTRY(H5F_SIZEOF_ADDR(F), H5F_SIZEOF_SIZE(F))

/* ========= Group Creation properties ============ */

/* Defaults for link info values */
#define H5G_CRT_LINFO_TRACK_CORDER              FALSE
#define H5G_CRT_LINFO_INDEX_CORDER              FALSE
#define H5G_CRT_LINFO_NLINKS                    0
#define H5G_CRT_LINFO_MAX_CORDER                0
#define H5G_CRT_LINFO_LINK_FHEAP_ADDR           HADDR_UNDEF
#define H5G_CRT_LINFO_NAME_BT2_ADDR             HADDR_UNDEF
#define H5G_CRT_LINFO_CORDER_BT2_ADDR           HADDR_UNDEF

/* Definitions for link info settings */
#define H5G_CRT_LINK_INFO_NAME                  "link info"
#define H5G_CRT_LINK_INFO_SIZE                  sizeof(H5O_linfo_t)
#define H5G_CRT_LINK_INFO_DEF                   {H5G_CRT_LINFO_TRACK_CORDER, \
                                                    H5G_CRT_LINFO_INDEX_CORDER, \
                                                    H5G_CRT_LINFO_MAX_CORDER, \
                                                    H5G_CRT_LINFO_CORDER_BT2_ADDR, \
                                                    H5G_CRT_LINFO_NLINKS, \
                                                    H5G_CRT_LINFO_LINK_FHEAP_ADDR, \
                                                    H5G_CRT_LINFO_NAME_BT2_ADDR \
                                                }

/* Defaults for group info values */
#define H5G_CRT_GINFO_LHEAP_SIZE_HINT           0
#define H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE   FALSE
#define H5G_CRT_GINFO_MAX_COMPACT               8
#define H5G_CRT_GINFO_MIN_DENSE                 6
#define H5G_CRT_GINFO_STORE_EST_ENTRY_INFO      FALSE
#define H5G_CRT_GINFO_EST_NUM_ENTRIES           4
#define H5G_CRT_GINFO_EST_NAME_LEN              8

/* Definitions for group info settings */
#define H5G_CRT_GROUP_INFO_NAME                 "group info"
#define H5G_CRT_GROUP_INFO_SIZE                 sizeof(H5O_ginfo_t)
#define H5G_CRT_GROUP_INFO_DEF                  {H5G_CRT_GINFO_LHEAP_SIZE_HINT, \
                                                    H5G_CRT_GINFO_STORE_LINK_PHASE_CHANGE, \
                                                    H5G_CRT_GINFO_MAX_COMPACT, \
                                                    H5G_CRT_GINFO_MIN_DENSE, \
                                                    H5G_CRT_GINFO_STORE_EST_ENTRY_INFO, \
                                                    H5G_CRT_GINFO_EST_NUM_ENTRIES, \
                                                    H5G_CRT_GINFO_EST_NAME_LEN \
                                                }

/* If the module using this macro is allowed access to the private variables, access them directly */
#ifdef H5G_MODULE
#define H5G_MOUNTED(G)              ((G)->shared->mounted)
#else /* H5G_MODULE */
#define H5G_MOUNTED(G)              (H5G_mounted(G))
#endif /* H5G_MODULE */

/*
 * During name lookups (see H5G_traverse()) we sometimes want information about
 * a symbolic link or a mount point.  The normal operation is to follow the
 * symbolic link or mount point and return information about its target.
 */
#define H5G_TARGET_NORMAL	0x0000
#define H5G_TARGET_SLINK	0x0001
#define H5G_TARGET_MOUNT	0x0002
#define H5G_TARGET_UDLINK	0x0004
#define H5G_TARGET_EXISTS	0x0008
#define H5G_CRT_INTMD_GROUP	0x0010

/* Type of operation being performed for call to H5G_name_replace() */
typedef enum {
    H5G_NAME_MOVE = 0,          /* H5*move call    */
    H5G_NAME_DELETE,            /* H5Ldelete call  */
    H5G_NAME_MOUNT,             /* H5Fmount call   */
    H5G_NAME_UNMOUNT            /* H5Funmount call */
} H5G_names_op_t;

/* Status returned from traversal callbacks; whether the object location
 * or group location need to be closed */
#define H5G_OWN_NONE 0
#define H5G_OWN_OBJ_LOC 1
#define H5G_OWN_GRP_LOC 2
#define H5G_OWN_BOTH 3
typedef int H5G_own_loc_t;

/* Structure to store information about the name an object was opened with */
typedef struct {
    H5RS_str_t  *full_path_r;           /* Path to object, as seen from root of current file mounting hierarchy */
    H5RS_str_t  *user_path_r;           /* Path to object, as opened by user */
    unsigned    obj_hidden;             /* Whether the object is visible in group hier. */
} H5G_name_t;

/* Forward declarations (for prototypes & struct definitions) */
struct H5O_loc_t;
struct H5O_link_t;

/*
 * The "location" of an object in a group hierarchy.  This points to an object
 * location and a group hierarchy path for the object.
 */
typedef struct {
    struct H5O_loc_t *oloc;             /* Object header location            */
    H5G_name_t *path;                   /* Group hierarchy path              */
} H5G_loc_t;

/* Typedef for path traversal operations */
/* grp_loc is the location of the group in which the targeted object is located.
 * name is the last component of the object's name
 * lnk is the link between the group and the object
 * obj_loc is the target of the traversal (or NULL if the object doesn't exist)
 * operator_data is whatever udata was supplied when H5G_traverse was called
 * own_loc should be set to H5G_OWN_OBJ_LOC if this callback takes ownership of obj_loc,
 * H5G_OWN_GRP_LOC if it takes ownership of grp_loc, and H5G_OWN_NONE if obj_loc and
 * grp_loc need to be deleted.
 */
typedef herr_t (*H5G_traverse_t)(H5G_loc_t *grp_loc/*in*/, const char *name,
    const struct H5O_link_t *lnk/*in*/, H5G_loc_t *obj_loc/*out*/, void *operator_data/*in,out*/,
    H5G_own_loc_t *own_loc/*out*/);

/* Describe kind of callback to make for each link */
typedef enum H5G_link_iterate_op_type_t {
#ifndef H5_NO_DEPRECATED_SYMBOLS
    H5G_LINK_OP_OLD,                /* "Old" application callback */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
    H5G_LINK_OP_NEW                 /* "New" application callback */
} H5G_link_iterate_op_type_t;

typedef struct {
    H5G_link_iterate_op_type_t op_type;
    union {
#ifndef H5_NO_DEPRECATED_SYMBOLS
        H5G_iterate_t op_old;           /* "Old" application callback for each link */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
        H5L_iterate_t op_new;           /* "New" application callback for each link */
    } op_func;
} H5G_link_iterate_t;

typedef struct H5G_t H5G_t;
typedef struct H5G_shared_t H5G_shared_t;
typedef struct H5G_entry_t H5G_entry_t;

/*
 * Library prototypes...  These are the ones that other packages routinely
 * call.
 */
H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp);
H5_DLL H5G_name_t * H5G_nameof(H5G_t *grp);
H5_DLL H5F_t *H5G_fileof(H5G_t *grp);
H5_DLL H5G_t *H5G_open(const H5G_loc_t *loc, hid_t dxpl_id);
H5_DLL herr_t H5G_close(H5G_t *grp);
H5_DLL herr_t H5G_get_shared_count(H5G_t *grp);
H5_DLL herr_t H5G_mount(H5G_t *grp);
H5_DLL hbool_t H5G_mounted(H5G_t *grp);
H5_DLL herr_t H5G_unmount(H5G_t *grp);
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type);
#endif /* H5_NO_DEPRECATED_SYMBOLS */

/*
 * Utility functions
 */
H5_DLL char *H5G_normalize(const char *name);

/*
 * Group hierarchy traversal routines
 */
H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name,
    unsigned target, H5G_traverse_t op, void *op_data, hid_t lapl_id,
    hid_t dxpl_id);
H5_DLL herr_t H5G_iterate(hid_t loc_id, const char *group_name,
    H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk,
    const H5G_link_iterate_t *lnk_op, void *op_data, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5G_visit(hid_t loc_id, const char *group_name,
    H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data,
    hid_t lapl_id, hid_t dxpl_id);

/* 
 * Functions that understand links in groups
 */
H5_DLL herr_t H5G_link_to_info(const struct H5O_link_t *lnk, H5L_info_t *linfo);

/*
 * Functions that understand group objects
 */
H5_DLL herr_t H5G_obj_insert(const struct H5O_loc_t *grp_oloc, const char *name,
    struct H5O_link_t *obj_lnk, hbool_t adj_link, H5O_type_t obj_type,
    const void *crt_info, hid_t dxpl_id);
H5_DLL ssize_t H5G_obj_get_name_by_idx(const struct H5O_loc_t *oloc, H5_index_t idx_type,
    H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id);
H5_DLL herr_t H5G_obj_remove(const struct H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r,
    const char *name, hid_t dxpl_id);
H5_DLL herr_t H5G_obj_remove_by_idx(const struct H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r,
    H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t dxpl_id);
H5_DLL herr_t H5G_obj_lookup_by_idx(const struct H5O_loc_t *grp_oloc, H5_index_t idx_type,
    H5_iter_order_t order, hsize_t n, struct H5O_link_t *lnk, hid_t dxpl_id);
H5_DLL hid_t H5G_get_create_plist(H5G_t *grp);

/*
 * These functions operate on symbol table nodes.
 */
H5_DLL herr_t H5G_node_close(const H5F_t *f);
H5_DLL herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream,
			      int indent, int fwidth, haddr_t heap);

/*
 * These functions operate on group object locations.
 */
H5_DLL herr_t H5G_ent_encode(const H5F_t *f, uint8_t **pp, const H5G_entry_t *ent);
H5_DLL herr_t H5G_ent_decode(const H5F_t *f, const uint8_t **pp, H5G_entry_t *ent);

/*
 * These functions operate on group hierarchy names.
 */
H5_DLL herr_t H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name);
H5_DLL herr_t H5G_name_replace(const struct H5O_link_t *lnk, H5G_names_op_t op,
    H5F_t *src_file, H5RS_str_t *src_full_path_r, H5F_t *dst_file,
    H5RS_str_t *dst_full_path_r, hid_t dxpl_id);
H5_DLL herr_t H5G_name_reset(H5G_name_t *name);
H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth);
H5_DLL herr_t H5G_name_free(H5G_name_t *name);
H5_DLL ssize_t H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size,
    hbool_t *cached, hid_t lapl_id, hid_t dxpl_id);
H5_DLL ssize_t H5G_get_name_by_addr(hid_t fid, hid_t lapl_id, hid_t dxpl_id,
    const struct H5O_loc_t *loc, char* name, size_t size);
H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char *name);

/*
 * These functions operate on group "locations"
 */
H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc);
H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth);
H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name,
    H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5G_loc_find_by_idx(H5G_loc_t *loc, const char *group_name,
    H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
    H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id);
H5_DLL htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name,
    hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5G_loc_info(H5G_loc_t *loc, const char *name,
    hbool_t want_ih_info, H5O_info_t *oinfo/*out*/, hid_t lapl_id,
    hid_t dxpl_id);
H5_DLL herr_t H5G_loc_set_comment(H5G_loc_t *loc, const char *name,
    const char *comment, hid_t lapl_id, hid_t dxpl_id);
H5_DLL ssize_t H5G_loc_get_comment(H5G_loc_t *loc, const char *name,
    char *comment/*out*/, size_t bufsize, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc);
H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc);

/*
 * These functions operate on the root group
 */
H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root);
H5_DLL herr_t H5G_root_loc(H5F_t *f, H5G_loc_t *loc);
H5_DLL herr_t H5G_root_free(H5G_t *grp);
H5_DLL H5G_t *H5G_rootof(H5F_t *f);

#endif /* _H5Gprivate_H */

a> 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* Programmer:  Neil Fortner
 *              December 16, 2010
 */

#include "h5test.h"

#define H5F_PACKAGE
#include "H5Fpkg.h"
#include "H5Iprivate.h"

const char *FILENAME[] = {
    "efc0",
    "efc1",
    "efc2",
    "efc3",
    "efc4",
    "efc5",
    NULL
};

/* Global patched filename buffer */
static char filename[6][1024];

/* Global property lists - just copies of the defaults (necessary to use
 * internal functions */
hid_t fcpl_id = -1;
hid_t fapl_id = -1;
hid_t dxpl_id = -1;


/*-------------------------------------------------------------------------
 * Function:    test_single
 *
 * Purpose:     Tests manipulations on a single external file cache.
 *
 * Return:      Success: 0
 *              Failure: Number of errors
 *
 * Programmer:  Neil Fortner
 *              December 16, 2010
 *
 *-------------------------------------------------------------------------
 */
static unsigned
test_single(void)
{
    H5F_t       *f0 = NULL;     /* Parent file containing EFC */
    H5F_t       *f1 = NULL;     /* Child file */
    H5F_t       *f2 = NULL;     /* Child file */
    H5F_t       *f3 = NULL;     /* Child file */
    H5F_t       *f4 = NULL;     /* Child file */
    H5F_t       *ftmp1 = NULL;  /* Temp file */
    H5F_t       *ftmp2 = NULL;  /* Temp file */
    H5F_t       *ftmp3 = NULL;  /* Temp file */
    H5F_t       *ftmp4 = NULL;  /* Temp file */

    TESTING("single EFC");

    /* Set EFC size to 3.  Do this instead of H5F_efc_create() so we can pass
     * a file pointer to H5F_efc_open containing the EFC. */
    if(H5Pset_elink_file_cache_size(fapl_id, 3) < 0)
        TEST_ERROR

    /* Open parent file */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR

    /* Disable EFC for child files */
    if(H5Pset_elink_file_cache_size(fapl_id, 0) < 0)
        TEST_ERROR


    /* Test 1: Open file 1 through EFC, close, then open normally, verify ref
     * count = 2, release EFC, verify ref count = 1.  Verifies a file can be
     * held open by the EFC. */
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR


    /* Test 2: Verify that subsequent efc_open requests return the cached top
     * level file pointer.  Open file 1 through EFC, close, open again, verify
     * file pointers are the same. */
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    ftmp1 = f1;
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(f1 != ftmp1)
        TEST_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR


    /* Test 3: Verify LRU functionality.  Add four files to the EFC and verify
     * that the one added first is evicted.  Then reopen files in a different
     * order.  Open each file normally after closing through EFC the first time
     * to track ref counts. */
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f3 = H5F_efc_open(f0, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f4 = H5F_efc_open(f0, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (ftmp3 = H5F_efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp3) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (ftmp2 = H5F_efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (ftmp1 = H5F_efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 1)
        TEST_ERROR

    if(NULL == (ftmp4 = H5F_efc_open(f0, filename[4], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp4) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(f4->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f4) < 0)
        FAIL_STACK_ERROR


    /* Test 4: Verify that files kept open through the EFC are not evicted by
     * H5F_efc_release(). */
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR


    /* Test 5: Verify that files kept open through the EFC are not evicted by
     * filling up the cache.  Open 4 files while holding the first open.  Verify
     * that the second file is evicted.  Close the first file, reopen the
     * second, and verify that the first file is evicted. */
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp1->shared != f1->shared)
        TEST_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f3 = H5F_efc_open(f0, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f4 = H5F_efc_open(f0, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f4) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR


    /* Test 6: Verify that having a full EFC filled only with open files
     * prevents further files from being cached.  Open and hold open 3 files
     * through the EFC, then open the fourth and verify that it was not added to
     * the EFC. */
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp1->shared != f1->shared)
        TEST_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp2->shared != f2->shared)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f3 = H5F_efc_open(f0, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp3->shared != f3->shared)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f4 = H5F_efc_open(f0, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp4->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp4->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp4) < 0)
        FAIL_STACK_ERROR


    /* Test 7: Test multiple file opens.  Open a file twice, close it once, then
     * verify that it is not evicted by H5F_efc_release(). */
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR


    /* Close parent file */
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR

    PASSED();

    return 0;

error:
    return 1;
} /* test_single */


/*-------------------------------------------------------------------------
 * Function:    test_graph_nocycle
 *
 * Purpose:     Tests manipulations on a graph of files with external file
 *              caches.  The graph does not contain cycles.
 *
 * Return:      Success: 0
 *              Failure: Number of errors
 *
 * Programmer:  Neil Fortner
 *              January 4, 2011
 *
 *-------------------------------------------------------------------------
 */
static unsigned
test_graph_nocycle(void)
{
    H5F_t       *f0 = NULL;     /* Parent file containing EFC */
    H5F_t       *f1 = NULL;     /* Child file */
    H5F_t       *f2 = NULL;     /* Child file */
    H5F_t       *f3 = NULL;     /* Child file */
    H5F_t       *f4 = NULL;     /* Child file */
    H5F_t       *ftmp1 = NULL;  /* Temp file */
    H5F_t       *ftmp2 = NULL;  /* Temp file */
    H5F_t       *ftmp3 = NULL;  /* Temp file */
    H5F_t       *ftmp4 = NULL;  /* Temp file */

    TESTING("graph of EFCs without cycles");

    /* Set EFC size to 8.  Do this instead of H5F_efc_create() so we can pass
     * a file pointer to H5F_efc_open containing the EFC.  Set to a high number
     * because we don't test the EFC becoming too large in this test. */
    if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0)
        TEST_ERROR


    /* Test 1: Simple 3 file chain.  Open file 1 through file 0, then open file
     * 2 through file 1.  Release file 0's EFC and verify that file 2 gets its
     * ref count reduced (implying file 1 was closed).  Do the same with the
     * opening order reversed. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR

    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(ftmp1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 2: 5 file chain.  The parent file has 2 child files, each of which
     * has their own child file.  Verifies that releasing the parent's EFC
     * closes all 4 children. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR

    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f3 = H5F_efc_open(f0, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f3, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, f4) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp4->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp4->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp4) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 3: Simple "inverted" tree.  Two parent files share a child file,
     * which has its own child file.  Verify that the child's child is not
     * closed until both parents' EFCs are released.  First release through one
     * parent, then reopen through that parent and release the other, then 
     * re-release the first parent. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(NULL == (f2 = H5F_efc_open(f0, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_release(f1->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 4: Simple "diamond" tree.  The parent file has two children, which
     * shared the same child.  Verify that releasing the parent file closes all
     * files. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 3)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 5: Dense 5 file graph.  f0 caches f1, f2, f3 and f4.  f1 and f2
     * each cache f3 and f4.  f3 caches f4.  Verify that releasing f0 closes all
     * files. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f0, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f0, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f4) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f1, filename[4], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f4) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f2, filename[4], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f4) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f3, filename[4], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, f4) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp4->shared->nrefs != 5)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp4->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp4) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    PASSED();

    return 0;

error:
    return 1;
} /* test_graph_nocycle */


/*-------------------------------------------------------------------------
 * Function:    test_graph_cycle
 *
 * Purpose:     Tests manipulations on a graph of files with external file
 *              caches containing cycles.
 *
 * Return:      Success: 0
 *              Failure: Number of errors
 *
 * Programmer:  Neil Fortner
 *              January 6, 2011
 *
 *-------------------------------------------------------------------------
 */
static unsigned
test_graph_cycle(void)
{
    H5F_t       *f0 = NULL;     /* File */
    H5F_t       *f1 = NULL;     /* File */
    H5F_t       *f2 = NULL;     /* File */
    H5F_t       *f3 = NULL;     /* File */
    H5F_t       *f4 = NULL;     /* File */
    H5F_t       *f5 = NULL;     /* File */
    H5F_t       *ftmp0 = NULL;  /* Temp file */
    H5F_t       *ftmp1 = NULL;  /* Temp file */
    H5F_t       *ftmp2 = NULL;  /* Temp file */
    H5F_t       *ftmp3 = NULL;  /* Temp file */

    TESTING("graph of EFCs with cycles");

    /* Set EFC size to 8.  Do this instead of H5F_efc_create() so we can pass
     * a file pointer to H5F_efc_open containing the EFC.  Set to a high number
     * because we don't test the EFC becoming too large in this test. */
    if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0)
        TEST_ERROR


    /* Test 1: File caches itself.  Verify that closing the file causes it to be
     * actually closed, and there is no other unexpected behavior. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR

    if(NULL == (ftmp0 = H5F_efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 2: Indirectly referenced file caches itself.  Same as above except
     * the file is part of another file's EFC. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR

    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR


    /* Test 3: Simple 2 file cycle */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR

    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 4: Simple 2 file cycle (indirectly referenced) */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR


    /* Test 5: Parallel double cycle */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 3)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 6: Parallel double cycle with release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 3)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 7: Chained parallel double cycle */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 8: Chained parallel double cycle with release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 9: Simple 2 file cycle, extra ID on root */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared != ftmp0->shared)
        TEST_ERROR
    if(f0->shared->nrefs != 3)
        TEST_ERROR
    if(H5F_try_close(ftmp0) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 10: Simple 2 file cycle, extra ID on second file */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(ftmp1->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR


    /* Test 11: Parallel double cycle, extra ID on a child file */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 3)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 3)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR


    /* Test 12: Parallel double cycle, extra ID on a child file, with release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 3)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_release(ftmp2->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp2) < 0)
        FAIL_STACK_ERROR


    /* Test 13: Chained parallel double cycle, extra ID on a child file */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR


    /* Test 14: Chained parallel double cycle, extra ID on a child file, with
     * release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(ftmp3->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR


    /* Test 15: One local and one remote cycle */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR


    /* Test 16: One local and one remote cycle, with release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR


    /* Test 17: One local and one remote cycle, remote cycle held open */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR


    /* Test 18: One local and one remote cycle, remote cycle held open, with
     * release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(ftmp3->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_release(ftmp3->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(ftmp3->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(ftmp3) < 0)
        FAIL_STACK_ERROR


    /* Test 19: "Diamond" shape with links moving from bottom (root) to top.
     * Also cycle between bottom (root) and top and cycles on the sides. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f1, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f4, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_efc_open(f2, filename[5],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f5, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f5) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_open(filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f4->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_open(filename[5],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f5->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f5) < 0)
        FAIL_STACK_ERROR


    /* Test 20: "Diamond" shape with links moving from bottom (root) to top.
     * Also cycle between bottom (root) and top, cycles on the sides, and
     * release the files instead of closing. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f1, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f4, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_efc_open(f2, filename[5],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f5, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f5) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_open(filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f4->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_open(filename[5],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f5->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f5) < 0)
        FAIL_STACK_ERROR


    /* Test 21: "Diamond" shape with links moving from bottom (root) to top.
     * Also cycle between bottom (root) and top, cycles on sides held open. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f1, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f4, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_efc_open(f2, filename[5],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f5, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f5) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR
    if(f5->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR
    if(f5->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f4) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f5->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(f5->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR

    if(H5F_try_close(f5) < 0)
        FAIL_STACK_ERROR

    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_open(filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f4->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_open(filename[5],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f5->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f5) < 0)
        FAIL_STACK_ERROR


    /* Test 22: "Diamond" shape with links moving from bottom (root) to top.
     * Also cycle between bottom (root) and top, cycles on sides held open.
     * Also release the files instead of closing. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f0, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_efc_open(f1, filename[4],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f4, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f4, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, f4) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f4 = H5F_open(filename[4], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_efc_open(f2, filename[5],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f5, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f5, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f5) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f5 = H5F_open(filename[5], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR
    if(f5->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 2)
        TEST_ERROR
    if(f5->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 3)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_release(f4->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f4->shared->nrefs != 1)
        TEST_ERROR
    if(f5->shared->nrefs != 2)
        TEST_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_release(f5->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(f4->shared->nrefs != 1)
        TEST_ERROR
    if(f5->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f4) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f5) < 0)
        FAIL_STACK_ERROR


    /* Test 23: Dense "ball" of files.  4 files each cache all files (including
     * itself). */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f0, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR

    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp3) < 0)
        FAIL_STACK_ERROR

    if(NULL == (ftmp0 = H5F_efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f2, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp3) < 0)
        FAIL_STACK_ERROR

    if(NULL == (ftmp0 = H5F_efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_efc_open(f3, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp3) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR


    /* Test 24: Dense "ball" of files.  4 files each cache all files (including
     * itself).  Release the files instead of closing. */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f0, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f0, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR

    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f1, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f1, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_efc_open(f1, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp3) < 0)
        FAIL_STACK_ERROR

    if(NULL == (ftmp0 = H5F_efc_open(f2, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f2, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_efc_open(f2, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, ftmp3) < 0)
        FAIL_STACK_ERROR

    if(NULL == (ftmp0 = H5F_efc_open(f3, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp1 = H5F_efc_open(f3, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp2 = H5F_efc_open(f3, filename[2], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (ftmp3 = H5F_efc_open(f3, filename[3], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f3, ftmp3) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR


    /* Test 25: File held open by EFC client interrupts cycle, with release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 26: File held open by EFC does not interrupt cycle, with release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_efc_open(f0, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_efc_close(f0, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR


    /* Test 27: File held open by EFC client through non-parent file does not
     * interrupt cycle, but parent file does (no valid way around it) */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_efc_close(f2, f1) < 0)
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 3)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR


    /* Test 28: File held open by EFC client through non-parent file does not
     * interrupt cycle, but parent file does (no valid way around it), with
     * release */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f2, filename[1], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_efc_open(f1, filename[3],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f1->shared->nrefs != 2)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_release(f0->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_release(f2->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_efc_close(f1, f3) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f2, f1) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_release(f2->shared->efc) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f3 = H5F_open(filename[3], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f3->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f3) < 0)
        FAIL_STACK_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR


    /* Test 29: File without EFC interrupts cycle */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5Pset_elink_file_cache_size(fapl_id, 0) < 0)
        TEST_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0)
        TEST_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR


    /* Test 30: File without EFC does not interrupt cycle */
    if(NULL == (f0 = H5F_open(filename[0],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_efc_open(f0, filename[1],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(NULL == (ftmp0 = H5F_efc_open(f1, filename[0], H5F_ACC_RDWR, fcpl_id,
            fapl_id, dxpl_id)))
        FAIL_STACK_ERROR
    if(H5F_efc_close(f1, ftmp0) < 0)
        FAIL_STACK_ERROR
    if(H5F_efc_close(f0, f1) < 0)
        FAIL_STACK_ERROR
    if(H5Pset_elink_file_cache_size(fapl_id, 0) < 0)
        TEST_ERROR
    if(NULL == (f2 = H5F_efc_open(f1, filename[2],
            H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0)
        TEST_ERROR
    if(H5F_efc_close(f1, f2) < 0)
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 2)
        TEST_ERROR

    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f0->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f0) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f1 = H5F_open(filename[1], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f1->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f1) < 0)
        FAIL_STACK_ERROR
    if(NULL == (f2 = H5F_open(filename[2], H5F_ACC_RDWR, fcpl_id, fapl_id,
            dxpl_id)))
        FAIL_STACK_ERROR
    if(f2->shared->nrefs != 1)
        TEST_ERROR
    if(H5F_try_close(f2) < 0)
        FAIL_STACK_ERROR


    PASSED();

    return 0;

error:
    return 1;
} /* test_graph_cycle */


/*-------------------------------------------------------------------------
 * Function:    main
 *
 * Purpose:     Test the external file cache code
 *
 * Return:      Success: SUCCEED
 *              Failure: FAIL
 *
 * Programmer:  Neil Fortner
 *              December 16, 2010
 *
 *-------------------------------------------------------------------------
 */
int
main(void)
{
    unsigned nerrors = 0;        /* track errors */

    /* Test Setup */
    puts("Testing the external file cache");

    /* Create property lists */
    fcpl_id = H5Pcreate(H5P_FILE_CREATE);
    fapl_id = h5_fileaccess();
    dxpl_id = H5Pcreate(H5P_DATASET_XFER);

    /* Patch filenames */
    h5_fixname(FILENAME[0], fapl_id, filename[0], sizeof(filename[0]));
    h5_fixname(FILENAME[1], fapl_id, filename[1], sizeof(filename[1]));
    h5_fixname(FILENAME[2], fapl_id, filename[2], sizeof(filename[2]));
    h5_fixname(FILENAME[3], fapl_id, filename[3], sizeof(filename[3]));
    h5_fixname(FILENAME[4], fapl_id, filename[4], sizeof(filename[4]));
    h5_fixname(FILENAME[5], fapl_id, filename[5], sizeof(filename[5]));

    /* Test Functions */
    nerrors += test_single();
    nerrors += test_graph_nocycle();
    nerrors += test_graph_cycle();

    /* Close property lists */
    if(H5Pclose(dxpl_id) < 0)
        TEST_ERROR
    if(H5Pclose(fcpl_id) < 0)
        TEST_ERROR

    /* Verify symbol table messages are cached */
    nerrors += (h5_verify_cached_stabs(FILENAME, fapl_id) < 0 ? 1 : 0);

    if(nerrors)
        goto error;

    puts("All external file cache tests passed.");

    h5_cleanup(FILENAME, fapl_id);

    return 0;

error:
    puts("*** TESTS FAILED ***");

    H5E_BEGIN_TRY {
        H5Pclose(fapl_id);
    } H5E_END_TRY

    return 1;
} /* end main() */