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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
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
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* This file contains tests for the API calls associated
* with the cache implemented in H5C.c
*/
#include "cache_common.h"
/* extern declarations */
/* global variable declarations: */
static const char *FILENAME[] = {"cache_api_test", NULL};
/* macro definitions */
/* private function declarations: */
static bool check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id);
static bool check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id);
static bool mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id);
static H5AC_cache_config_t *init_invalid_configs(void);
static bool check_fapl_mdc_api_errs(void);
static bool check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id);
/**************************************************************************/
/**************************************************************************/
/********************************* tests: *********************************/
/**************************************************************************/
/**************************************************************************/
/*-------------------------------------------------------------------------
* Function: check_fapl_mdc_api_calls()
*
* Purpose: Verify that the file access property list related
* metadata cache related API calls are functioning
* correctly.
*
* Since we have tested the H5C code elsewhere, it should
* be sufficient to verify that the desired configuration
* data is getting to the cache.
*
* Return: Test pass status (true/false)
*
*-------------------------------------------------------------------------
*/
static bool
check_fapl_mdc_api_calls(unsigned paged, hid_t fcpl_id)
{
char filename[512];
herr_t result;
hid_t fapl_id = H5I_INVALID_HID;
hid_t test_fapl_id = H5I_INVALID_HID;
hid_t file_id = H5I_INVALID_HID;
H5F_t *file_ptr = NULL;
H5C_t *cache_ptr = NULL;
H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG;
H5AC_cache_config_t mod_config = {
/* int version = */ H5AC__CURR_CACHE_CONFIG_VERSION,
/* bool rpt_fcn_enabled = */ false,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ (1 * 1024 * 1024 + 1),
/* double min_clean_fraction = */ 0.2,
/* size_t max_size = */ (16 * 1024 * 1024 + 1),
/* size_t min_size = */ (1 * 1024 * 1024 + 1),
/* long int epoch_length = */ 50001,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold,
/* double lower_hr_threshold = */ 0.91,
/* double increment = */ 2.1,
/* bool apply_max_increment = */ true,
/* size_t max_increment = */ (4 * 1024 * 1024 + 1),
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out,
/* double upper_hr_threshold = */ 0.998,
/* double decrement = */ 0.91,
/* bool apply_max_decrement = */ true,
/* size_t max_decrement = */ (1 * 1024 * 1024 - 1),
/* int epochs_before_eviction = */ 4,
/* bool apply_empty_reserve = */ true,
/* double empty_reserve = */ 0.05,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
H5AC_cache_config_t scratch;
H5C_auto_size_ctl_t default_auto_size_ctl;
H5C_auto_size_ctl_t mod_auto_size_ctl;
if (paged)
TESTING("MDC/FAPL related API calls for paged aggregation strategy");
else
TESTING("MDC/FAPL related API calls");
pass = true;
XLATE_EXT_TO_INT_MDC_CONFIG(default_auto_size_ctl, default_config)
XLATE_EXT_TO_INT_MDC_CONFIG(mod_auto_size_ctl, mod_config)
/* Create a FAPL and verify that it contains the default
* initial mdc configuration
*/
if (pass) {
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
if (fapl_id < 0) {
pass = false;
failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n";
}
}
if (pass) {
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
result = H5Pget_mdc_config(fapl_id, &scratch);
if (result < 0) {
pass = false;
failure_mssg = "H5Pget_mdc_config() failed.\n";
}
else if (!CACHE_CONFIGS_EQUAL(default_config, scratch, true, true)) {
pass = false;
failure_mssg = "retrieved config doesn't match default.";
}
}
/* Modify the initial mdc configuration in a FAPL, and verify that
* the changes can be read back
*/
if (pass) {
result = H5Pset_mdc_config(fapl_id, &mod_config);
if (result < 0) {
pass = false;
failure_mssg = "H5Pset_mdc_config() failed.\n";
}
}
if (pass) {
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
result = H5Pget_mdc_config(fapl_id, &scratch);
if (result < 0) {
pass = false;
failure_mssg = "H5Pget_mdc_config() failed.\n";
}
else if (!CACHE_CONFIGS_EQUAL(mod_config, scratch, true, true)) {
pass = false;
failure_mssg = "retrieved config doesn't match mod config.";
}
}
if (pass) {
if (H5Pclose(fapl_id) < 0) {
pass = false;
failure_mssg = "H5Pclose() failed.\n";
}
}
/* Open a file using the default FAPL. Verify that the resulting
* metadata cache uses the default configuration as well. Get a
* copy of the FAPL from the file, and verify that it contains the
* default initial meta data cache configuration. Close and delete
* the file.
*/
/* setup the file name */
if (pass) {
if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) {
pass = false;
failure_mssg = "h5_fixname() failed.\n";
}
}
/* create the file using the default FAPL */
if (pass) {
file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
if (file_id < 0) {
pass = false;
failure_mssg = "H5Fcreate() failed.\n";
}
}
/* get a pointer to the files internal data structure */
if (pass) {
file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE);
if (file_ptr == NULL) {
pass = false;
failure_mssg = "Can't get file_ptr.\n";
}
else {
cache_ptr = file_ptr->shared->cache;
}
}
/* verify that we can access the internal version of the cache config */
if (pass) {
if (cache_ptr == NULL || cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER) {
pass = false;
failure_mssg = "Can't access cache resize_ctl.\n";
}
}
/* compare the cache's internal configuration with the expected value */
if (pass) {
if (!resize_configs_are_equal(&default_auto_size_ctl, &cache_ptr->resize_ctl, true)) {
pass = false;
failure_mssg = "Unexpected value(s) in cache resize_ctl 1.\n";
}
}
/* get a copy of the files FAPL */
if (pass) {
fapl_id = H5Fget_access_plist(file_id);
if (fapl_id < 0) {
pass = false;
failure_mssg = "H5Fget_access_plist() failed.\n";
}
}
/* compare the initial cache config from the copy of the file's FAPL
* to the expected value. If all goes well, close the copy of the FAPL.
*/
if (pass) {
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
result = H5Pget_mdc_config(fapl_id, &scratch);
if (result < 0) {
pass = false;
failure_mssg = "H5Pget_mdc_config() failed.\n";
}
else if (!CACHE_CONFIGS_EQUAL(default_config, scratch, true, true)) {
pass = false;
failure_mssg = "config retrieved from file doesn't match default.";
}
else if (H5Pclose(fapl_id) < 0) {
pass = false;
failure_mssg = "H5Pclose() failed.\n";
}
}
/* close the file and delete it */
if (pass) {
if (H5Fclose(file_id) < 0) {
pass = false;
failure_mssg = "H5Fclose() failed.\n";
}
else if (H5Fdelete(filename, H5P_DEFAULT) < 0) {
pass = false;
failure_mssg = "H5Fdelete() failed.\n";
}
}
/* Open a file using a FAPL with a modified initial metadata cache
* configuration. Verify that the resulting metadata cache uses the
* modified configuration as well. Get a copy of the FAPL from the
* file, and verify that it contains the modified initial meta data
* cache configuration. Close and delete the file.
*/
/* Create a FAPL */
if (pass) {
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
if (fapl_id < 0) {
pass = false;
failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n";
}
}
/* Modify the initial mdc configuration in the FAPL. */
if (pass) {
result = H5Pset_mdc_config(fapl_id, &mod_config);
if (result < 0) {
pass = false;
failure_mssg = "H5Pset_mdc_config() failed.\n";
}
}
/* setup the file name */
if (pass) {
if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) {
pass = false;
failure_mssg = "h5_fixname() failed.\n";
}
}
/* create the file using the modified FAPL */
if (pass) {
file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id);
if (file_id < 0) {
pass = false;
failure_mssg = "H5Fcreate() failed.\n";
}
}
/* get a pointer to the files internal data structure */
if (pass) {
file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE);
if (file_ptr == NULL) {
pass = false;
failure_mssg = "Can't get file_ptr.\n";
}
else {
cache_ptr = file_ptr->shared->cache;
}
}
/* verify that we can access the internal version of the cache config */
if (pass) {
if (cache_ptr == NULL || cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER) {
pass = false;
failure_mssg = "Can't access cache resize_ctl.\n";
}
}
/* compare the cache's internal configuration with the expected value */
if (pass) {
if (!resize_configs_are_equal(&mod_auto_size_ctl, &cache_ptr->resize_ctl, true)) {
pass = false;
failure_mssg = "Unexpected value(s) in cache resize_ctl 2.\n";
}
}
/* get a copy of the files FAPL */
if (pass) {
test_fapl_id = H5Fget_access_plist(file_id);
if (test_fapl_id < 0) {
pass = false;
failure_mssg = "H5Fget_access_plist() failed.\n";
}
}
/* compare the initial cache config from the copy of the file's FAPL
* to the expected value. If all goes well, close the copy of the FAPL.
*/
if (pass) {
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
result = H5Pget_mdc_config(test_fapl_id, &scratch);
if (result < 0) {
pass = false;
failure_mssg = "H5Pget_mdc_config() failed.\n";
}
else if (!CACHE_CONFIGS_EQUAL(mod_config, scratch, true, true)) {
pass = false;
failure_mssg = "config retrieved from file doesn't match.";
}
else if (H5Pclose(test_fapl_id) < 0) {
pass = false;
failure_mssg = "H5Pclose() failed.\n";
}
}
/* close the file and delete it */
if (pass) {
if (H5Fclose(file_id) < 0) {
pass = false;
failure_mssg = "H5Fclose() failed.\n";
}
else if (H5Fdelete(filename, fapl_id) < 0) {
pass = false;
failure_mssg = "H5Fdelete() failed.\n";
}
}
/* close the fapl used to create the file */
if (pass) {
if (H5Pclose(fapl_id) < 0) {
pass = false;
failure_mssg = "H5Pclose() failed.\n";
}
}
if (pass) {
PASSED();
}
else {
H5_FAILED();
}
if (!pass) {
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
}
return pass;
} /* check_fapl_mdc_api_calls() */
/*-------------------------------------------------------------------------
* Function: check_file_mdc_api_calls()
*
* Purpose: Verify that the file related metadata cache API calls are
* functioning correctly.
*
* Since we have tested the H5C code elsewhere, it should
* be sufficient to verify that the desired configuration
* data is getting in and out of the cache. Similarly,
* we need only verify that the cache monitoring calls
* return the data that the cache thinks they should return.
* We shouldn't need to verify data correctness beyond that
* point.
*
* Return: Test pass status (true/false)
*
*-------------------------------------------------------------------------
*/
static bool
check_file_mdc_api_calls(unsigned paged, hid_t fcpl_id)
{
char filename[512];
hid_t file_id = H5I_INVALID_HID;
size_t max_size;
size_t min_clean_size;
size_t cur_size;
int cur_num_entries;
double hit_rate;
H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG;
H5AC_cache_config_t mod_config_1 = {
/* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
/* bool rpt_fcn_enabled = */ false,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ (1 * 1024 * 1024 + 1),
/* double min_clean_fraction = */ 0.2,
/* size_t max_size = */ (16 * 1024 * 1024 + 1),
/* size_t min_size = */ (1 * 1024 * 1024 + 1),
/* long int epoch_length = */ 50001,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold,
/* double lower_hr_threshold = */ 0.91,
/* double increment = */ 2.1,
/* bool apply_max_increment = */ true,
/* size_t max_increment = */ (4 * 1024 * 1024 + 1),
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__age_out,
/* double upper_hr_threshold = */ 0.998,
/* double decrement = */ 0.91,
/* bool apply_max_decrement = */ true,
/* size_t max_decrement = */ (1 * 1024 * 1024 - 1),
/* int epochs_before_eviction = */ 4,
/* bool apply_empty_reserve = */ true,
/* double empty_reserve = */ 0.05,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
H5AC_cache_config_t mod_config_2 = {
/* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
/* bool rpt_fcn_enabled = */ true,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ (512 * 1024),
/* double min_clean_fraction = */ 0.1,
/* size_t max_size = */ (8 * 1024 * 1024),
/* size_t min_size = */ (512 * 1024),
/* long int epoch_length = */ 25000,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold,
/* double lower_hr_threshold = */ 0.9,
/* double increment = */ 2.0,
/* bool apply_max_increment = */ true,
/* size_t max_increment = */ (2 * 1024 * 1024),
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 1.5,
/* double flash_threshold = */ 0.4,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__threshold,
/* double upper_hr_threshold = */ 0.9995,
/* double decrement = */ 0.95,
/* bool apply_max_decrement = */ true,
/* size_t max_decrement = */ (512 * 1024),
/* int epochs_before_eviction = */ 4,
/* bool apply_empty_reserve = */ true,
/* double empty_reserve = */ 0.05,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
H5AC_cache_config_t mod_config_3 = {
/* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
/* bool rpt_fcn_enabled = */ false,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ (1 * 1024 * 1024),
/* double min_clean_fraction = */ 0.2,
/* size_t max_size = */ (16 * 1024 * 1024),
/* size_t min_size = */ (1 * 1024 * 1024),
/* long int epoch_length = */ 50000,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off,
/* double lower_hr_threshold = */ 0.90,
/* double increment = */ 2.0,
/* bool apply_max_increment = */ true,
/* size_t max_increment = */ (4 * 1024 * 1024),
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.1,
/* double flash_threshold = */ 0.6,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off,
/* double upper_hr_threshold = */ 0.999,
/* double decrement = */ 0.9,
/* bool apply_max_decrement = */ false,
/* size_t max_decrement = */ (1 * 1024 * 1024 - 1),
/* int epochs_before_eviction = */ 3,
/* bool apply_empty_reserve = */ false,
/* double empty_reserve = */ 0.05,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
H5AC_cache_config_t mod_config_4 = {
/* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
/* bool rpt_fcn_enabled = */ false,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ (1 * 1024 * 1024),
/* double min_clean_fraction = */ 0.15,
/* size_t max_size = */ (20 * 1024 * 1024),
/* size_t min_size = */ (1 * 1024 * 1024),
/* long int epoch_length = */ 75000,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__threshold,
/* double lower_hr_threshold = */ 0.9,
/* double increment = */ 2.0,
/* bool apply_max_increment = */ true,
/* size_t max_increment = */ (2 * 1024 * 1024),
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 1.1,
/* double flash_threshold = */ 0.3,
/* enum H5C_cache_decr_mode decr_mode = */
H5C_decr__age_out_with_threshold,
/* double upper_hr_threshold = */ 0.999,
/* double decrement = */ 0.9,
/* bool apply_max_decrement = */ true,
/* size_t max_decrement = */ (1 * 1024 * 1024),
/* int epochs_before_eviction = */ 3,
/* bool apply_empty_reserve = */ true,
/* double empty_reserve = */ 0.1,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
if (paged)
TESTING("MDC/FILE related API calls for paged aggregation strategy");
else
TESTING("MDC/FILE related API calls");
pass = true;
/* Open a file with the default FAPL. Verify that the cache is
* configured as per the default both by looking at its internal
* configuration, and via the H5Fget_mdc_config() call.
*
* Then set several different configurations, and verify that
* they took as per above.
*/
/* setup the file name */
if (pass) {
if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) {
pass = false;
failure_mssg = "h5_fixname() failed.\n";
}
}
/* create the file using the default FAPL */
if (pass) {
file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
if (file_id < 0) {
pass = false;
failure_mssg = "H5Fcreate() failed.\n";
}
}
/* verify that the cache is set to the default config */
validate_mdc_config(file_id, &default_config, true, 1);
/* set alternate config 1 */
if (pass) {
if (H5Fset_mdc_config(file_id, &mod_config_1) < 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() failed 1.\n";
}
}
/* verify that the cache is now set to the alternate config */
validate_mdc_config(file_id, &mod_config_1, true, 2);
/* set alternate config 2 */
if (pass) {
if (H5Fset_mdc_config(file_id, &mod_config_2) < 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() failed 2.\n";
}
}
/* verify that the cache is now set to the alternate config */
validate_mdc_config(file_id, &mod_config_2, true, 3);
/* set alternate config 3 */
if (pass) {
if (H5Fset_mdc_config(file_id, &mod_config_3) < 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() failed 3.\n";
}
}
/* verify that the cache is now set to the alternate config */
validate_mdc_config(file_id, &mod_config_3, true, 4);
/* set alternate config 4 */
if (pass) {
if (H5Fset_mdc_config(file_id, &mod_config_4) < 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() failed 4.\n";
}
}
/* verify that the cache is now set to the alternate config */
validate_mdc_config(file_id, &mod_config_4, true, 5);
/* Run some quick smoke checks on the cache status monitoring
* calls -- no interesting data as the cache hasn't had a
* chance to do much yet.
*/
if (pass) {
if (H5Fget_mdc_hit_rate(file_id, &hit_rate) < 0) {
pass = false;
failure_mssg = "H5Fget_mdc_hit_rate() failed 1.\n";
}
else if (!H5_DBL_ABS_EQUAL(hit_rate, 0.0)) {
pass = false;
failure_mssg = "H5Fget_mdc_hit_rate() returned unexpected hit rate.\n";
}
}
if (pass) {
if (H5Fget_mdc_size(file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries) < 0) {
pass = false;
failure_mssg = "H5Fget_mdc_size() failed 1.\n";
}
else if ((mod_config_4.initial_size != max_size) ||
(min_clean_size != (size_t)((double)max_size * mod_config_4.min_clean_fraction))) {
pass = false;
failure_mssg = "H5Fget_mdc_size() returned unexpected value(s).\n";
}
}
/* close the file and delete it */
if (pass) {
if (H5Fclose(file_id) < 0) {
pass = false;
failure_mssg = "H5Fclose() failed.\n";
}
else if (H5Fdelete(filename, H5P_DEFAULT) < 0) {
pass = false;
failure_mssg = "H5Fdelete() failed.\n";
}
}
if (pass) {
PASSED();
}
else {
H5_FAILED();
}
if (!pass) {
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
}
return pass;
} /* check_file_mdc_api_calls() */
/*-------------------------------------------------------------------------
* Function: mdc_api_call_smoke_check()
*
* Purpose: Initial basic functional test to see if there are problems
* with the cache API calls.
*
* NOTE: This test takes some time to run and checks the
* testing express level value.
*
* Return: Test pass status (true/false)
*
*-------------------------------------------------------------------------
*/
#define CHUNK_SIZE 2
#define DSET_SIZE (200 * CHUNK_SIZE)
#define NUM_DSETS 6
#define NUM_RANDOM_ACCESSES 200000
static bool
mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id)
{
char filename[512];
bool valid_chunk;
bool dump_hit_rate = false;
int64_t min_accesses = 1000;
double min_hit_rate = 0.90;
bool dump_cache_size = false;
hid_t file_id = H5I_INVALID_HID;
hid_t dataspace_id = H5I_INVALID_HID;
hid_t filespace_ids[NUM_DSETS];
hid_t memspace_id = H5I_INVALID_HID;
hid_t dataset_ids[NUM_DSETS];
hid_t properties = H5I_INVALID_HID;
char dset_name[64];
int i, j, k, l, m, n;
herr_t status;
hsize_t dims[2];
hsize_t a_size[2];
hsize_t offset[2];
hsize_t chunk_size[2];
int data_chunk[CHUNK_SIZE][CHUNK_SIZE];
H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG;
H5AC_cache_config_t mod_config_1 = {
/* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
/* bool rpt_fcn_enabled = */ false,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ 500000,
/* double min_clean_fraction = */ 0.1,
/* size_t max_size = */ 16000000,
/* size_t min_size = */ 250000,
/* long int epoch_length = */ 50000,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off,
/* double lower_hr_threshold = */ 0.95,
/* double increment = */ 2.0,
/* bool apply_max_increment = */ false,
/* size_t max_increment = */ 4000000,
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off,
/* double upper_hr_threshold = */ 0.999,
/* double decrement = */ 0.9,
/* bool apply_max_decrement = */ false,
/* size_t max_decrement = */ 1000000,
/* int epochs_before_eviction = */ 2,
/* bool apply_empty_reserve = */ true,
/* double empty_reserve = */ 0.05,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
H5AC_cache_config_t mod_config_2 = {
/* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
/* bool rpt_fcn_enabled = */ false,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ 12000000,
/* double min_clean_fraction = */ 0.1,
/* size_t max_size = */ 16000000,
/* size_t min_size = */ 250000,
/* long int epoch_length = */ 50000,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off,
/* double lower_hr_threshold = */ 0.95,
/* double increment = */ 2.0,
/* bool apply_max_increment = */ false,
/* size_t max_increment = */ 4000000,
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off,
/* double upper_hr_threshold = */ 0.999,
/* double decrement = */ 0.9,
/* bool apply_max_decrement = */ false,
/* size_t max_decrement = */ 1000000,
/* int epochs_before_eviction = */ 2,
/* bool apply_empty_reserve = */ true,
/* double empty_reserve = */ 0.05,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
H5AC_cache_config_t mod_config_3 = {
/* int version = */ H5C__CURR_AUTO_SIZE_CTL_VER,
/* bool rpt_fcn_enabled = */ false,
/* bool open_trace_file = */ false,
/* bool close_trace_file = */ false,
/* char trace_file_name[] = */ "",
/* bool evictions_enabled = */ true,
/* bool set_initial_size = */ true,
/* size_t initial_size = */ 2000000,
/* double min_clean_fraction = */ 0.1,
/* size_t max_size = */ 16000000,
/* size_t min_size = */ 250000,
/* long int epoch_length = */ 50000,
/* enum H5C_cache_incr_mode incr_mode = */ H5C_incr__off,
/* double lower_hr_threshold = */ 0.95,
/* double increment = */ 2.0,
/* bool apply_max_increment = */ false,
/* size_t max_increment = */ 4000000,
/* enum H5C_cache_flash_incr_mode */
/* flash_incr_mode = */ H5C_flash_incr__off,
/* double flash_multiple = */ 2.0,
/* double flash_threshold = */ 0.5,
/* enum H5C_cache_decr_mode decr_mode = */ H5C_decr__off,
/* double upper_hr_threshold = */ 0.999,
/* double decrement = */ 0.9,
/* bool apply_max_decrement = */ false,
/* size_t max_decrement = */ 1000000,
/* int epochs_before_eviction = */ 2,
/* bool apply_empty_reserve = */ true,
/* double empty_reserve = */ 0.05,
/* int dirty_bytes_threshold = */ (256 * 1024),
/* int metadata_write_strategy = */
H5AC__DEFAULT_METADATA_WRITE_STRATEGY};
if (paged)
TESTING("MDC API smoke check for paged aggregation strategy");
else
TESTING("MDC API smoke check");
pass = true;
if (express_test > 0) {
SKIPPED();
fprintf(stdout, " Long tests disabled.\n");
return pass;
}
/* Open a file with the default FAPL. Verify that the cache is
* configured as per the default both by looking at its internal
* configuration, and via the H5Fget_mdc_config() call.
*
* Then set the cache to mod_config_1, which fixes cache size at
* 500000 bytes, and turns off automatic cache resize.
*/
/* setup the file name */
if (pass) {
if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) {
pass = false;
failure_mssg = "h5_fixname() failed.\n";
}
}
/* create the file using the default FAPL */
if (pass) {
file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
if (file_id < 0) {
pass = false;
failure_mssg = "H5Fcreate() failed.\n";
}
}
/* verify that the cache is set to the default config */
validate_mdc_config(file_id, &default_config, true, 1);
/* set alternate config 1 */
if (pass) {
if (H5Fset_mdc_config(file_id, &mod_config_1) < 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() failed 1.\n";
}
}
/* verify that the cache is now set to the alternate config */
validate_mdc_config(file_id, &mod_config_1, true, 2);
/* create the datasets */
if (pass) {
i = 0;
while ((pass) && (i < NUM_DSETS)) {
/* create a dataspace for the chunked dataset */
dims[0] = DSET_SIZE;
dims[1] = DSET_SIZE;
dataspace_id = H5Screate_simple(2, dims, NULL);
if (dataspace_id < 0) {
pass = false;
failure_mssg = "H5Screate_simple() failed.";
}
/* set the dataset creation plist to specify that the raw data is
* to be partitioned into 10X10 element chunks.
*/
if (pass) {
chunk_size[0] = CHUNK_SIZE;
chunk_size[1] = CHUNK_SIZE;
properties = H5Pcreate(H5P_DATASET_CREATE);
if (properties < 0) {
pass = false;
failure_mssg = "H5Pcreate() failed.";
}
}
if (pass) {
if (H5Pset_chunk(properties, 2, chunk_size) < 0) {
pass = false;
failure_mssg = "H5Pset_chunk() failed.";
}
}
/* create the dataset */
if (pass) {
snprintf(dset_name, sizeof(dset_name), "/dset%03d", i);
dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT,
properties, H5P_DEFAULT);
if (dataset_ids[i] < 0) {
pass = false;
failure_mssg = "H5Dcreate2() failed.";
}
}
/* get the file space ID */
if (pass) {
filespace_ids[i] = H5Dget_space(dataset_ids[i]);
if (filespace_ids[i] < 0) {
pass = false;
failure_mssg = "H5Dget_space() failed.";
}
}
i++;
}
}
/* create the mem space to be used to read and write chunks */
if (pass) {
dims[0] = CHUNK_SIZE;
dims[1] = CHUNK_SIZE;
memspace_id = H5Screate_simple(2, dims, NULL);
if (memspace_id < 0) {
pass = false;
failure_mssg = "H5Screate_simple() failed.";
}
}
/* select in memory hyperslab */
if (pass) {
offset[0] = 0; /*offset of hyperslab in memory*/
offset[1] = 0;
a_size[0] = CHUNK_SIZE; /*size of hyperslab*/
a_size[1] = CHUNK_SIZE;
status = H5Sselect_hyperslab(memspace_id, H5S_SELECT_SET, offset, NULL, a_size, NULL);
if (status < 0) {
pass = false;
failure_mssg = "H5Sselect_hyperslab() failed.";
}
}
/* initialize all datasets on a round robin basis */
i = 0;
while ((pass) && (i < DSET_SIZE)) {
j = 0;
while ((pass) && (j < DSET_SIZE)) {
m = 0;
while ((pass) && (m < NUM_DSETS)) {
/* initialize the slab */
for (k = 0; k < CHUNK_SIZE; k++) {
for (l = 0; l < CHUNK_SIZE; l++) {
data_chunk[k][l] = (DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l;
}
}
/* select on disk hyperslab */
offset[0] = (hsize_t)i; /*offset of hyperslab in file*/
offset[1] = (hsize_t)j;
a_size[0] = CHUNK_SIZE; /*size of hyperslab*/
a_size[1] = CHUNK_SIZE;
status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL);
if (status < 0) {
pass = false;
failure_mssg = "disk H5Sselect_hyperslab() failed.";
}
/* write the chunk to file */
status = H5Dwrite(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT,
data_chunk);
if (status < 0) {
pass = false;
failure_mssg = "H5Dwrite() failed.";
}
m++;
}
j += CHUNK_SIZE;
}
/* check the cache hit rate, and reset the counters.
* Hit rate should be just about unity here, so we will just
* get the data and (possibly) print it without checking it
* beyond ensuring that it agrees with the cache internal
* data structures.
*
* similarly, check cache size.
*/
if ((pass) && (i % (DSET_SIZE / 4) == 0)) {
check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, min_accesses, min_hit_rate);
check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, dump_cache_size);
}
i += CHUNK_SIZE;
}
/* set alternate config 2 */
if (pass) {
if (H5Fset_mdc_config(file_id, &mod_config_2) < 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() failed 2.\n";
}
}
/* verify that the cache is now set to the alternate config */
validate_mdc_config(file_id, &mod_config_2, true, 3);
/* do random reads on all datasets */
n = 0;
while ((pass) && (n < NUM_RANDOM_ACCESSES)) {
m = HDrand() % NUM_DSETS;
i = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE;
j = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE;
/* select on disk hyperslab */
offset[0] = (hsize_t)i; /*offset of hyperslab in file*/
offset[1] = (hsize_t)j;
a_size[0] = CHUNK_SIZE; /*size of hyperslab*/
a_size[1] = CHUNK_SIZE;
status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL);
if (status < 0) {
pass = false;
failure_mssg = "disk hyperslab create failed.";
}
/* read the chunk from file */
if (pass) {
status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT,
data_chunk);
if (status < 0) {
pass = false;
failure_mssg = "disk hyperslab create failed.";
}
}
/* validate the slab */
if (pass) {
valid_chunk = true;
for (k = 0; k < CHUNK_SIZE; k++) {
for (l = 0; l < CHUNK_SIZE; l++) {
if (data_chunk[k][l] != ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) {
valid_chunk = false;
}
}
}
if (!valid_chunk) {
pass = false;
failure_mssg = "slab validation failed.";
}
}
if ((pass) && (n % (NUM_RANDOM_ACCESSES / 4) == 0)) {
check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, min_accesses, min_hit_rate);
check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, dump_cache_size);
}
n++;
}
/* close the file spaces we are done with */
i = 1;
while ((pass) && (i < NUM_DSETS)) {
if (H5Sclose(filespace_ids[i]) < 0) {
pass = false;
failure_mssg = "H5Sclose() failed.";
}
i++;
}
/* close the datasets we are done with */
i = 1;
while ((pass) && (i < NUM_DSETS)) {
if (H5Dclose(dataset_ids[i]) < 0) {
pass = false;
failure_mssg = "H5Dclose() failed.";
}
i++;
}
/* set alternate config 3 */
if (pass) {
if (H5Fset_mdc_config(file_id, &mod_config_3) < 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() failed 3.\n";
}
}
/* verify that the cache is now set to the alternate config */
validate_mdc_config(file_id, &mod_config_3, true, 4);
/* do random reads on data set 0 only */
m = 0;
n = 0;
while ((pass) && (n < NUM_RANDOM_ACCESSES)) {
i = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE;
j = (HDrand() % (DSET_SIZE / CHUNK_SIZE)) * CHUNK_SIZE;
/* select on disk hyperslab */
offset[0] = (hsize_t)i; /*offset of hyperslab in file*/
offset[1] = (hsize_t)j;
a_size[0] = CHUNK_SIZE; /*size of hyperslab*/
a_size[1] = CHUNK_SIZE;
status = H5Sselect_hyperslab(filespace_ids[m], H5S_SELECT_SET, offset, NULL, a_size, NULL);
if (status < 0) {
pass = false;
failure_mssg = "disk hyperslab create failed.";
}
/* read the chunk from file */
if (pass) {
status = H5Dread(dataset_ids[m], H5T_NATIVE_INT, memspace_id, filespace_ids[m], H5P_DEFAULT,
data_chunk);
if (status < 0) {
pass = false;
failure_mssg = "disk hyperslab create failed.";
}
}
/* validate the slab */
if (pass) {
valid_chunk = true;
for (k = 0; k < CHUNK_SIZE; k++) {
for (l = 0; l < CHUNK_SIZE; l++) {
if (data_chunk[k][l] != ((DSET_SIZE * DSET_SIZE * m) + (DSET_SIZE * (i + k)) + j + l)) {
valid_chunk = false;
}
}
}
if (!valid_chunk) {
pass = false;
failure_mssg = "slab validation failed.";
}
}
if ((pass) && (n % (NUM_RANDOM_ACCESSES / 4) == 0)) {
check_and_validate_cache_hit_rate(file_id, NULL, dump_hit_rate, min_accesses, min_hit_rate);
check_and_validate_cache_size(file_id, NULL, NULL, NULL, NULL, dump_cache_size);
}
n++;
}
/* close file space 0 */
if (pass) {
if (H5Sclose(filespace_ids[0]) < 0) {
pass = false;
failure_mssg = "H5Sclose(filespace_ids[0]) failed.";
}
}
/* close the data space */
if (pass) {
if (H5Sclose(dataspace_id) < 0) {
pass = false;
failure_mssg = "H5Sclose(dataspace) failed.";
}
}
/* close the mem space */
if (pass) {
if (H5Sclose(memspace_id) < 0) {
pass = false;
failure_mssg = "H5Sclose(memspace_id) failed.";
}
}
/* close dataset 0 */
if (pass) {
if (H5Dclose(dataset_ids[0]) < 0) {
pass = false;
failure_mssg = "H5Dclose(dataset_ids[0]) failed.";
}
}
/* close the file and delete it */
if (pass) {
if (H5Fclose(file_id) < 0) {
pass = false;
failure_mssg = "H5Fclose() failed.\n";
}
else if (H5Fdelete(filename, H5P_DEFAULT) < 0) {
pass = false;
failure_mssg = "H5Fdelete() failed.\n";
}
}
if (pass) {
PASSED();
}
else {
H5_FAILED();
}
if (!pass) {
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
}
return pass;
} /* mdc_api_call_smoke_check() */
/*-------------------------------------------------------------------------
* Function: init_invalid_configs()
*
* Purpose: Initialize an array of invalid external MDC configurations
* that will be used to test error rejection in the MDC-
* related API calls.
*
* Note: It is assumed that boolean parameters are only set
* to true/false.
*
* Return: Success: Pointer to an array of cache configurations.
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
#define NUM_INVALID_CONFIGS 36
static H5AC_cache_config_t *invalid_configs = NULL;
static H5AC_cache_config_t *
init_invalid_configs(void)
{
int i;
H5AC_cache_config_t *configs = NULL;
/* Allocate memory */
if (NULL == (configs = (H5AC_cache_config_t *)calloc(NUM_INVALID_CONFIGS, sizeof(H5AC_cache_config_t)))) {
return NULL;
}
/* Set defaults for all configs */
for (i = 0; i < NUM_INVALID_CONFIGS; i++) {
configs[i].version = H5C__CURR_AUTO_SIZE_CTL_VER;
configs[i].rpt_fcn_enabled = false;
configs[i].open_trace_file = false;
configs[i].close_trace_file = false;
/* trace file name set to all ASCII NUL by calloc() */
configs[i].evictions_enabled = true;
configs[i].set_initial_size = true;
configs[i].initial_size = (1 * 1024 * 1024);
configs[i].min_clean_fraction = 0.25;
configs[i].max_size = (16 * 1024 * 1024);
configs[i].min_size = (1 * 1024 * 1024);
configs[i].epoch_length = 50000;
configs[i].incr_mode = H5C_incr__threshold;
configs[i].lower_hr_threshold = 0.9;
configs[i].increment = 2.0;
configs[i].apply_max_increment = true;
configs[i].max_increment = (4 * 1024 * 1024);
configs[i].flash_incr_mode = H5C_flash_incr__off;
configs[i].flash_multiple = 2.0;
configs[i].flash_threshold = 0.5;
configs[i].decr_mode = H5C_decr__age_out_with_threshold;
configs[i].upper_hr_threshold = 0.999;
configs[i].decrement = 0.9;
configs[i].apply_max_decrement = true;
configs[i].max_decrement = (1 * 1024 * 1024);
configs[i].epochs_before_eviction = 3;
configs[i].apply_empty_reserve = true;
configs[i].empty_reserve = 0.1;
configs[i].dirty_bytes_threshold = (256 * 1024);
configs[i].metadata_write_strategy = H5AC__DEFAULT_METADATA_WRITE_STRATEGY;
}
/* Set badness for each config */
/* 0 -- bad version */
configs[0].version = -1;
/* 1 -- open_trace_file == true and empty trace_file_name */
configs[1].open_trace_file = true;
/* trace file name set to all ASCII NUL by calloc() */
/* 2 -- max_size too big */
configs[2].max_size = H5C__MAX_MAX_CACHE_SIZE + 1;
/* 3 -- min_size too small */
configs[3].min_size = H5C__MIN_MAX_CACHE_SIZE - 1;
/* 4 -- min_size > max_size */
configs[4].max_size = (16 * 1024 * 1024);
configs[4].min_size = (16 * 1024 * 1024 + 1);
/* 5 -- initial size out of range (too big) */
configs[5].initial_size = (16 * 1024 * 1024 + 1);
/* 6 -- initial_size out of range (too small) */
configs[6].initial_size = (1 * 1024 * 1024 - 1);
/* 7 -- min_clean_fraction too big */
configs[7].min_clean_fraction = 1.000001;
/* 8 -- min_clean_fraction too small */
configs[8].min_clean_fraction = -0.00000001;
/* 9 -- epoch_length too small */
configs[9].epoch_length = H5C__MIN_AR_EPOCH_LENGTH - 1;
/* 10 -- epoch_length too big */
configs[10].epoch_length = H5C__MAX_AR_EPOCH_LENGTH + 1;
/* 11 -- invalid incr_mode */
configs[11].incr_mode = (enum H5C_cache_incr_mode) - 1;
/* 12 -- lower_hr_threshold too small */
configs[12].lower_hr_threshold = -0.000001;
/* 13 -- lower_hr_threshold too big */
configs[13].lower_hr_threshold = 1.00000001;
/* 14 -- increment too small */
configs[14].increment = 0.999999999999;
/* 15 -- invalid flash_incr_mode */
configs[15].flash_incr_mode = (enum H5C_cache_flash_incr_mode) - 1;
/* 16 -- flash_multiple too small */
configs[16].flash_incr_mode = H5C_flash_incr__add_space;
configs[16].flash_multiple = 0.09;
/* 17 -- flash_multiple too big */
configs[17].flash_incr_mode = H5C_flash_incr__add_space;
configs[17].flash_multiple = 10.001;
/* 18 -- flash_threshold too small */
configs[18].flash_incr_mode = H5C_flash_incr__add_space;
configs[18].flash_threshold = 0.099;
/* 19 -- flash_threshold too big */
configs[19].flash_incr_mode = H5C_flash_incr__add_space;
configs[19].flash_threshold = 1.001;
/* 20 -- bad decr_mode */
configs[20].decr_mode = (enum H5C_cache_decr_mode) - 1;
/* 21 -- upper_hr_threshold too big */
configs[21].upper_hr_threshold = 1.00001;
/* 22 -- decrement too small */
configs[22].decr_mode = H5C_decr__threshold;
configs[22].decrement = -0.0000000001;
/* 23 -- decrement too big */
configs[23].decr_mode = H5C_decr__threshold;
configs[23].decrement = 1.0000000001;
/* 24 -- epochs_before_eviction too small */
configs[24].epochs_before_eviction = 0;
/* 25 -- epochs_before_eviction too big */
configs[25].epochs_before_eviction = H5C__MAX_EPOCH_MARKERS + 1;
/* 26 -- empty_reserve too small */
configs[26].empty_reserve = -0.0000000001;
/* 27 -- empty_reserve too big */
configs[27].empty_reserve = 1.00000000001;
/* 28 -- upper_hr_threshold too small */
configs[28].upper_hr_threshold = -0.000000001;
/* 29 -- upper_hr_threshold too big */
configs[29].upper_hr_threshold = 1.00000001;
/* 30 -- upper_hr_threshold <= lower_hr_threshold */
configs[30].lower_hr_threshold = 0.9;
configs[30].upper_hr_threshold = 0.9;
/* 31 -- dirty_bytes_threshold too small */
configs[31].dirty_bytes_threshold = (H5C__MIN_MAX_CACHE_SIZE / 2) - 1;
/* 32 -- dirty_bytes_threshold too big */
configs[32].dirty_bytes_threshold = (H5C__MAX_MAX_CACHE_SIZE / 4) + 1;
/* 33 -- attempt to disable evictions when auto incr enabled */
configs[33].evictions_enabled = false;
configs[33].decr_mode = H5C_decr__off;
/* 34 -- attempt to disable evictions when auto decr enabled */
configs[34].evictions_enabled = false;
configs[34].decr_mode = H5C_decr__age_out;
/* 35 -- unknown metadata write strategy */
configs[35].metadata_write_strategy = -1;
return configs;
} /* initialize_invalid_configs() */
/*-------------------------------------------------------------------------
* Function: check_fapl_mdc_api_errs()
*
* Purpose: Verify that the FAPL related MDC API calls reject input
* errors gracefully.
*
* Return: Test pass status (true/false)
*
*-------------------------------------------------------------------------
*/
static bool
check_fapl_mdc_api_errs(void)
{
static char msg[128];
int i;
herr_t result;
hid_t fapl_id = H5I_INVALID_HID;
H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG;
H5AC_cache_config_t scratch;
TESTING("MDC/FAPL related API input errors");
pass = true;
/* first test H5Pget_mdc_config().
*/
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
if (pass) {
H5E_BEGIN_TRY
{
result = H5Pget_mdc_config((hid_t)H5I_INVALID_HID, &scratch);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Pget_mdc_config() accepted invalid plist_id.";
}
}
/* Create a FAPL for test purposes, and verify that it contains the
* default MDC configuration.
*/
if (pass) {
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
if (fapl_id < 0) {
pass = false;
failure_mssg = "H5Pcreate(H5P_FILE_ACCESS) failed.\n";
}
}
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
if ((pass) && ((H5Pget_mdc_config(fapl_id, &scratch) < 0) ||
(!CACHE_CONFIGS_EQUAL(default_config, scratch, true, true)))) {
pass = false;
failure_mssg = "New FAPL has unexpected metadata cache config?!?!?.\n";
}
if (pass) {
H5E_BEGIN_TRY
{
result = H5Pget_mdc_config(fapl_id, NULL);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Pget_mdc_config() accepted NULL config_ptr.";
}
}
/* one last test for H5Pget_mdc_config() */
scratch.version = -1; /* a convenient, invalid value */
if (pass) {
H5E_BEGIN_TRY
{
result = H5Pget_mdc_config(fapl_id, &scratch);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Pget_mdc_config() accepted bad config version.";
}
}
/* now test H5Pset_mdc_config()
*/
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
if (pass) {
H5E_BEGIN_TRY
{
result = H5Pset_mdc_config((hid_t)H5I_INVALID_HID, &default_config);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Pset_mdc_config() accepted bad invalid plist_id.";
}
}
if (pass) {
H5E_BEGIN_TRY
{
result = H5Pset_mdc_config(fapl_id, NULL);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Pset_mdc_config() accepted NULL config_ptr.";
}
}
i = 0;
while ((pass) && (i < NUM_INVALID_CONFIGS)) {
H5E_BEGIN_TRY
{
result = H5Pset_mdc_config(fapl_id, &(invalid_configs[i]));
}
H5E_END_TRY
if (result >= 0) {
pass = false;
snprintf(msg, (size_t)128, "H5Pset_mdc_config() accepted invalid_configs[%d].", i);
failure_mssg = msg;
}
i++;
}
/* verify that none of the above calls to H5Pset_mdc_config() changed
* the configuration in the FAPL.
*/
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
if ((pass) && ((H5Pget_mdc_config(fapl_id, &scratch) < 0) ||
(!CACHE_CONFIGS_EQUAL(default_config, scratch, true, true)))) {
pass = false;
failure_mssg = "FAPL metadata cache config changed???.\n";
}
if (pass) {
PASSED();
}
else {
H5_FAILED();
}
if (!pass) {
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
}
return pass;
} /* check_fapl_mdc_api_errs() */
/*-------------------------------------------------------------------------
* Function: check_file_mdc_api_errs()
*
* Purpose: Verify that the file related MDC API calls reject input
* errors gracefully.
*
* Return: Test pass status (true/false)
*
*-------------------------------------------------------------------------
*/
static bool
check_file_mdc_api_errs(unsigned paged, hid_t fcpl_id)
{
char filename[512];
static char msg[128];
bool show_progress = false;
int i;
herr_t result;
hid_t file_id = H5I_INVALID_HID;
size_t max_size;
size_t min_clean_size;
size_t cur_size;
int cur_num_entries;
double hit_rate;
H5AC_cache_config_t default_config = H5AC__DEFAULT_CACHE_CONFIG;
H5AC_cache_config_t scratch;
if (paged)
TESTING("MDC/FILE related API input errors for paged aggregation strategy");
else
TESTING("MDC/FILE related API input errors");
pass = true;
/* Create a file for test purposes, and verify that its metadata cache
* set to the default MDC configuration.
*/
/* setup the file name */
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: calling h5_fixname().\n", __func__);
}
if (h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof(filename)) == NULL) {
pass = false;
failure_mssg = "h5_fixname() failed.\n";
}
}
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: calling H5Fcreate().\n", __func__);
}
file_id = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
if (file_id < 0) {
pass = false;
failure_mssg = "H5Fcreate() failed.\n";
}
}
validate_mdc_config(file_id, &default_config, true, 1);
/* test H5Fget_mdc_config(). */
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fget_mdc_config() 1.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fget_mdc_config((hid_t)H5I_INVALID_HID, &scratch);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fget_mdc_config() accepted invalid file_id.";
}
}
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fget_mdc_config() 2.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fget_mdc_config(file_id, NULL);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fget_mdc_config() accepted NULL config_ptr.";
}
}
scratch.version = -1; /* a convenient, invalid value */
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fget_mdc_config() 3.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fget_mdc_config(file_id, &scratch);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fget_mdc_config() accepted bad config version.";
}
}
/* test H5Fset_mdc_config() */
scratch.version = H5C__CURR_AUTO_SIZE_CTL_VER;
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fset_mdc_config() 1.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fset_mdc_config((hid_t)H5I_INVALID_HID, &default_config);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() accepted bad invalid file_id.";
}
}
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fset_mdc_config() 2.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fset_mdc_config(file_id, NULL);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fset_mdc_config() accepted NULL config_ptr.";
}
}
i = 0;
while ((pass) && (i < NUM_INVALID_CONFIGS)) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fset_mdc_config() with invalid config %d.\n", __func__, i);
}
H5E_BEGIN_TRY
{
result = H5Fset_mdc_config(file_id, &(invalid_configs[i]));
}
H5E_END_TRY
if (result >= 0) {
pass = false;
snprintf(msg, (size_t)128, "H5Fset_mdc_config() accepted invalid_configs[%d].", i);
failure_mssg = msg;
}
i++;
}
/* verify that none of the above calls to H5Fset_mdc_config() changed
* the configuration in the FAPL.
*/
validate_mdc_config(file_id, &default_config, true, 2);
/* test H5Fget_mdc_hit_rate() */
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 1.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fget_mdc_hit_rate((hid_t)H5I_INVALID_HID, &hit_rate);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fget_mdc_hit_rate() accepted bad file_id.";
}
}
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fget_mdc_hit_rate() 2.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fget_mdc_hit_rate(file_id, NULL);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fget_mdc_hit_rate() accepted NULL hit_rate_ptr.";
}
}
/* test H5Freset_mdc_hit_rate_stats() */
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Freset_mdc_hit_rate_stats().\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Freset_mdc_hit_rate_stats((hid_t)H5I_INVALID_HID);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Freset_mdc_hit_rate_stats() accepted bad file_id.";
}
}
/* test H5Fget_mdc_size() */
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fget_mdc_size() 1.\n", __func__);
}
H5E_BEGIN_TRY
{
result = H5Fget_mdc_size((hid_t)H5I_INVALID_HID, &max_size, &min_clean_size, &cur_size,
&cur_num_entries);
}
H5E_END_TRY
if (result >= 0) {
pass = false;
failure_mssg = "H5Fget_mdc_size() accepted bad file_id.";
}
}
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: testing H5Fget_mdc_size() 2.\n", __func__);
}
if ((H5Fget_mdc_size(file_id, &max_size, NULL, NULL, NULL) < 0) ||
(H5Fget_mdc_size(file_id, NULL, &min_clean_size, NULL, NULL) < 0) ||
(H5Fget_mdc_size(file_id, NULL, NULL, &cur_size, NULL) < 0) ||
(H5Fget_mdc_size(file_id, NULL, NULL, NULL, &cur_num_entries) < 0) ||
(H5Fget_mdc_size(file_id, NULL, NULL, NULL, NULL) < 0)) {
pass = false;
failure_mssg = "H5Fget_mdc_size() failed to handle NULL params.";
}
}
/* close the file and delete it */
if (pass) {
if (show_progress) {
fprintf(stdout, "%s: cleaning up from tests.\n", __func__);
}
if (H5Fclose(file_id) < 0) {
pass = false;
failure_mssg = "H5Fclose() failed.\n";
}
else if (H5Fdelete(filename, H5P_DEFAULT) < 0) {
pass = false;
failure_mssg = "H5Fdelete() failed.\n";
}
}
if (pass) {
PASSED();
}
else {
H5_FAILED();
}
if (!pass) {
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
}
return pass;
} /* check_file_mdc_api_errs() */
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Run tests on the cache code contained in H5C.c
*
* Return: EXIT_SUCCESS/EXIT_FAILURE
*
*-------------------------------------------------------------------------
*/
int
main(void)
{
unsigned nerrs = 0;
int express_test;
hid_t fcpl_id = H5I_INVALID_HID;
hid_t fcpl2_id = H5I_INVALID_HID;
unsigned paged;
H5open();
express_test = GetTestExpress();
printf("===================================\n");
printf("Cache API tests\n");
printf(" express_test = %d\n", express_test);
printf("===================================\n");
/* Initialize invalid configurations.
*/
invalid_configs = init_invalid_configs();
if (NULL == invalid_configs) {
failure_mssg = "Unable to allocate memory for invalid configs.";
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
return EXIT_FAILURE;
} /* end if */
if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) {
failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n";
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
return EXIT_FAILURE;
} /* end if */
/* Set file space strategy to default or paged aggregation strategy */
if ((fcpl2_id = H5Pcopy(fcpl_id)) < 0) {
failure_mssg = "H5Pcreate(H5P_FILE_CREATE) failed.\n";
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
return EXIT_FAILURE;
} /* end if */
if (H5Pset_file_space_strategy(fcpl2_id, H5F_FSPACE_STRATEGY_PAGE, 1, (hsize_t)1) < 0) {
failure_mssg = "H5Pset_file_space_strategy() failed.\n";
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
return EXIT_FAILURE;
} /* end if */
/* Test with paged aggregation enabled or not */
/* The "my_fcpl" passed to each test has the paged or non-paged strategy set up accordingly */
for (paged = false; paged <= true; paged++) {
hid_t my_fcpl = fcpl_id;
if (paged) {
/* Only run paged aggregation tests with sec2/default driver */
if (!h5_using_default_driver(NULL))
continue;
else
my_fcpl = fcpl2_id;
}
if (!check_fapl_mdc_api_calls(paged, my_fcpl))
nerrs += 1;
if (!check_file_mdc_api_calls(paged, my_fcpl))
nerrs += 1;
if (!mdc_api_call_smoke_check(express_test, paged, my_fcpl))
nerrs += 1;
if (!check_file_mdc_api_errs(paged, my_fcpl))
nerrs += 1;
} /* end for paged */
if (!check_fapl_mdc_api_errs())
nerrs += 1;
if (invalid_configs)
free(invalid_configs);
if (H5Pclose(fcpl_id) < 0) {
failure_mssg = "H5Pclose() failed.\n";
fprintf(stdout, "%s: failure_mssg = \"%s\".\n", __func__, failure_mssg);
return EXIT_FAILURE;
} /* end if */
if (nerrs > 0)
return EXIT_FAILURE;
else
return EXIT_SUCCESS;
} /* main() */
|