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
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
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Programmer: Quincey Koziol <koziol@hdfgroup.org>
* Tuesday, June 17, 2008
*/
#include "h5test.h"
/*
* This file needs to access private datatypes from the H5EA package.
* This file also needs to access the extensible array testing code.
*/
#define H5EA_FRIEND /*suppress error about including H5EApkg */
#define H5EA_TESTING
#include "H5EApkg.h" /* Extensible Arrays */
/* Other private headers that this test requires */
#include "H5Iprivate.h" /* IDs */
#include "H5VMprivate.h" /* Vectors and arrays */
/* Local macros */
/* Max. testfile name length */
#define EARRAY_FILENAME_LEN 1024
/* Extensible array creation values */
#define ELMT_SIZE sizeof(uint64_t)
#define MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */
#define IDX_BLK_ELMTS 4
#define SUP_BLK_MIN_DATA_PTRS 4
#define DATA_BLK_MIN_ELMTS 16
#define MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */
/* Convenience macros for computing earray state */
#define EA_HDR_SIZE 72 /* (hard-coded, current size) */
#define EA_IBLOCK_SIZE 298 /* (hard-coded, current size) */
#define EA_NELMTS(cparam, tparam, idx, sblk_idx) \
(hsize_t)(cparam->idx_blk_elmts + \
tparam->sblk_info[sblk_idx].start_idx + \
((1 + ((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / tparam->sblk_info[sblk_idx].dblk_nelmts)) \
* tparam->sblk_info[sblk_idx].dblk_nelmts))
#define EA_NDATA_BLKS(cparam, tparam, idx, sblk_idx) \
(1 + tparam->sblk_info[sblk_idx].start_dblk + \
((idx - (cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].start_idx)) / tparam->sblk_info[sblk_idx].dblk_nelmts))
/* Iterator parameter values */
#define EA_RND2_SCALE 100
#define EA_CYC_COUNT 4
/* Local typedefs */
/* Types of tests to perform */
typedef enum {
EARRAY_TEST_NORMAL, /* "Normal" test, with no testing parameters set */
EARRAY_TEST_REOPEN, /* Set the reopen_array flag */
EARRAY_TEST_NTESTS /* The number of test types, must be last */
} earray_test_type_t;
/* Types of iteration to perform */
typedef enum {
EARRAY_ITER_FW, /* "Forward" iteration */
EARRAY_ITER_RV, /* "Reverse" iteration */
EARRAY_ITER_RND, /* "Random" iteration */
EARRAY_ITER_CYC, /* "Cyclic" iteration */
EARRAY_ITER_RND2, /* "Random #2" iteration */
EARRAY_ITER_NITERS /* The number of iteration types, must be last */
} earray_iter_type_t;
/* Orders to operate on entries */
typedef enum {
EARRAY_DIR_FORWARD, /* Insert objects from 0 -> nobjs */
EARRAY_DIR_RANDOM, /* Insert objects randomly from 0 - nobjs */
EARRAY_DIR_CYCLIC, /* Insert every n'th object cyclicly: 0, n, 2n, 3n, ..., nobjs/n, 1+nobjs/n, 1+n+nobjs/n, 1+2n+nobjs/n, ..., nobjs */
EARRAY_DIR_REVERSE, /* Insert objects from nobjs -> 0 */
EARRAY_DIR_INWARD, /* Insert objects from outside to in: 0, nobjs, 1, nobjs-1, 2, nobjs-2, ..., nobjs/2 */
EARRAY_DIR_OUTWARD, /* Insert objects from inside to out: nobjs/2, (nobjs/2)-1, (nobjs/2)+1, ..., 0, nobjs */
EARRAY_DIR_NDIRS /* The number of different insertion orders, must be last */
} earray_test_dir_t;
/* Whether to compress data blocks */
typedef enum {
EARRAY_TEST_NO_COMPRESS, /* Don't compress data blocks */
EARRAY_TEST_COMPRESS, /* Compress data blocks */
EARRAY_TEST_COMP_N /* The number of different ways to test compressing array blocks, must be last */
} earray_test_comp_t;
/* Extensible array state information */
typedef struct earray_state_t {
hsize_t hdr_size; /* Size of header */
hsize_t nindex_blks; /* # of index blocks */
hsize_t index_blk_size; /* Size of index blocks */
hsize_t nsuper_blks; /* # of super blocks */
hsize_t super_blk_size; /* Size of super blocks */
hsize_t ndata_blks; /* # of data blocks */
hsize_t data_blk_size; /* Size of data blocks */
hsize_t max_idx_set; /* Highest element index stored (+1 - i.e. if element 0 has been set, this value with be '1', if no elements have been stored, this value will be '0') */
hsize_t nelmts; /* # of elements "realized" */
} earray_state_t;
/* Forward decl. */
typedef struct earray_test_param_t earray_test_param_t;
/* Extensible array iterator class */
typedef struct earray_iter_t {
void *(*init)(const H5EA_create_t *cparam, const earray_test_param_t *tparam,
hsize_t cnt); /* Initialize/allocate iterator private info */
hssize_t (*next)(void *info); /* Get the next element to test */
hssize_t (*max_elem)(const void *info); /* Get the max. element set */
int (*state)(void *_eiter, const H5EA_create_t *cparam,
const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx); /* Get the state of the extensible array */
herr_t (*term)(void *info); /* Shutdown/free iterator private info */
} earray_iter_t;
/* Testing parameters */
struct earray_test_param_t {
earray_test_type_t reopen_array; /* Whether to re-open the array during the test */
earray_test_comp_t comp; /* Whether to compress the blocks or not */
const earray_iter_t *eiter; /* Iterator to use for this test */
/* Super block information */
size_t nsblks; /* Number of superblocks needed for array */
H5EA_sblk_info_t *sblk_info; /* Array of information for each super block */
};
/* Flush depend test context */
typedef struct earray_flush_depend_ctx_t {
hbool_t base_obj; /* Flag to indicate that base object has been flushed */
hbool_t idx0_obj; /* Flag to indicate that index 0's object has been flushed */
hbool_t idx0_elem; /* Flag to indicate that index 0's element has been flushed */
hbool_t idx1_obj; /* Flag to indicate that index 1's object has been flushed */
hbool_t idx1_elem; /* Flag to indicate that index 1's element has been flushed */
hbool_t idx10000_obj; /* Flag to indicate that index 10000's object has been flushed */
hbool_t idx10000_elem; /* Flag to indicate that index 10000's element has been flushed */
} earray_flush_depend_ctx_t;
/* Extensible array test cache object */
typedef struct earray_test_t {
/* Information for H5AC cache functions, _must_ be first field in structure */
H5AC_info_t cache_info;
/* Entry information */
uint64_t idx; /* Index that entry corresponds to */
earray_flush_depend_ctx_t *fd_info; /* Context information for flush depend test */
} earray_test_t;
/* Local prototypes */
/* Metadata cache (H5AC) callbacks */
static herr_t earray_cache_test_get_load_size(const void *udata_ptr,
size_t *image_len_ptr);
static void *earray_cache_test_deserialize(const void *image_ptr,
size_t len,
void *udata_ptr,
hbool_t *dirty_ptr);
static herr_t earray_cache_test_image_len(const void *thing,
size_t *image_len_ptr,
hbool_t *compressed_ptr,
size_t * compressed_len_ptr);
static herr_t earray_cache_test_serialize(const H5F_t *f,
void *image_ptr,
size_t len,
void *thing);
static herr_t earray_cache_test_free_icr(void *thing);
/* Local variables */
const char *FILENAME[] = {
"earray",
"earray_tmp",
NULL
};
/* Filename to use for all tests */
char filename_g[EARRAY_FILENAME_LEN];
/* Empty file size */
h5_stat_size_t empty_size_g;
/* H5EA test object inherits cache-like properties from H5AC */
const H5AC_class_t H5AC_EARRAY_TEST[1] = {{
/* id */ H5AC_TEST_ID,
/* name */ "earray test",
/* mem_type */ H5FD_MEM_DEFAULT,
/* flags */ H5AC__CLASS_NO_IO_FLAG,
/* get_load_size */ (H5AC_get_load_size_func_t)earray_cache_test_get_load_size,
/* deserialize */ (H5AC_deserialize_func_t)earray_cache_test_deserialize,
/* image_len */ (H5AC_image_len_func_t)earray_cache_test_image_len,
/* pre_serialize */ (H5AC_pre_serialize_func_t)NULL,
/* serialize */ (H5AC_serialize_func_t)earray_cache_test_serialize,
/* notify */ (H5AC_notify_func_t)NULL,
/* free_icr */ (H5AC_free_icr_func_t)earray_cache_test_free_icr,
/* clear */ NULL,
/* fsf_size */ NULL,
}};
/*-------------------------------------------------------------------------
* Function: init_cparam
*
* Purpose: Initialize array creation parameter structure
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 21, 2008
*
*-------------------------------------------------------------------------
*/
static int
init_cparam(H5EA_create_t *cparam)
{
/* Wipe out background */
HDmemset(cparam, 0, sizeof(*cparam));
/* General parameters */
cparam->cls = H5EA_CLS_TEST;
cparam->raw_elmt_size = ELMT_SIZE;
cparam->max_nelmts_bits = MAX_NELMTS_BITS;
cparam->idx_blk_elmts = IDX_BLK_ELMTS;
cparam->sup_blk_min_data_ptrs = SUP_BLK_MIN_DATA_PTRS;
cparam->data_blk_min_elmts = DATA_BLK_MIN_ELMTS;
cparam->max_dblk_page_nelmts_bits = MAX_DBLOCK_PAGE_NELMTS_BITS;
return(0);
} /* init_cparam() */
/*-------------------------------------------------------------------------
* Function: init_tparam
*
* Purpose: Initialize array testing parameter structure
*
* Note: This initialization is the same as that in H5EA_hdr_init()
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, September 25, 2008
*
*-------------------------------------------------------------------------
*/
static int
init_tparam(earray_test_param_t *tparam, const H5EA_create_t *cparam)
{
hsize_t start_idx; /* First element index for each super block */
hsize_t start_dblk; /* First data block index for each super block */
size_t u; /* Local index variable */
/* Wipe out background */
HDmemset(tparam, 0, sizeof(*tparam));
/* Compute general information */
tparam->nsblks = 1 + (cparam->max_nelmts_bits - H5VM_log2_of2(cparam->data_blk_min_elmts));
/* Allocate information for each super block */
tparam->sblk_info = (H5EA_sblk_info_t *)HDmalloc(sizeof(H5EA_sblk_info_t) * tparam->nsblks);
HDassert(tparam->sblk_info);
/* Compute information about each super block */
start_idx = 0;
start_dblk = 0;
for(u = 0; u < tparam->nsblks; u++) {
tparam->sblk_info[u].ndblks = (size_t)H5_EXP2(u / 2);
tparam->sblk_info[u].dblk_nelmts = (size_t)H5_EXP2((u + 1) / 2) * cparam->data_blk_min_elmts;
tparam->sblk_info[u].start_idx = start_idx;
tparam->sblk_info[u].start_dblk = start_dblk;
/* Advance starting indices for next super block */
start_idx += (hsize_t)tparam->sblk_info[u].ndblks * (hsize_t)tparam->sblk_info[u].dblk_nelmts;
start_dblk += (hsize_t)tparam->sblk_info[u].ndblks;
} /* end for */
return(0);
} /* init_tparam() */
/*-------------------------------------------------------------------------
* Function: finish_tparam
*
* Purpose: Close down array testing parameter structure
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, September 25, 2008
*
*-------------------------------------------------------------------------
*/
static int
finish_tparam(earray_test_param_t *tparam)
{
/* Release super block information */
HDfree(tparam->sblk_info);
tparam->sblk_info = NULL;
return(0);
} /* finish_tparam() */
/*-------------------------------------------------------------------------
* Function: create_file
*
* Purpose: Create file and retrieve pointer to internal file object
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static int
create_file(unsigned flags, hid_t fapl, hid_t *file, H5F_t **f)
{
/* Create the file to work on */
if((*file = H5Fcreate(filename_g, flags, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
if(NULL == (*f = (H5F_t *)H5I_object(*file)))
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
if(H5AC_ignore_tags(*f) < 0)
FAIL_STACK_ERROR
/* Success */
return(0);
error:
return(-1);
} /* create_file() */
/*-------------------------------------------------------------------------
* Function: check_stats
*
* Purpose: Verify stats for an extensible array
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 21, 2008
*
*-------------------------------------------------------------------------
*/
static int
check_stats(const H5EA_t *ea, const earray_state_t *state)
{
H5EA_stat_t earray_stats; /* Statistics about the array */
/* Get statistics for extensible array and verify they are correct */
if(H5EA_get_stats(ea, &earray_stats) < 0)
FAIL_STACK_ERROR
/* Compare information */
if(earray_stats.stored.max_idx_set != state->max_idx_set) {
HDfprintf(stdout, "earray_stats.stored.max_idx_set = %Hu, state->max_idx_set = %Hu\n", earray_stats.stored.max_idx_set, state->max_idx_set);
TEST_ERROR
} /* end if */
if(earray_stats.stored.nelmts != state->nelmts) {
HDfprintf(stdout, "earray_stats.stored.nelmts = %Hu, state->nelmts = %Hu\n", earray_stats.stored.nelmts, state->nelmts);
TEST_ERROR
} /* end if */
if(earray_stats.computed.hdr_size != state->hdr_size) {
HDfprintf(stdout, "earray_stats.computed.hdr_size = %Hu, state->hdr_size = %Hu\n", earray_stats.computed.hdr_size, state->hdr_size);
TEST_ERROR
} /* end if */
if(earray_stats.computed.nindex_blks != state->nindex_blks) {
HDfprintf(stdout, "earray_stats.computed.nindex_blks = %Hu, state->nindex_blks = %Hu\n", earray_stats.computed.nindex_blks, state->nindex_blks);
TEST_ERROR
} /* end if */
if(earray_stats.computed.index_blk_size != state->index_blk_size) {
HDfprintf(stdout, "earray_stats.computed.index_blk_size = %Hu, state->index_blk_size = %Hu\n", earray_stats.computed.index_blk_size, state->index_blk_size);
TEST_ERROR
} /* end if */
if(earray_stats.stored.ndata_blks != state->ndata_blks) {
HDfprintf(stdout, "earray_stats.stored.ndata_blks = %Hu, state->ndata_blks = %Hu\n", earray_stats.stored.ndata_blks, state->ndata_blks);
TEST_ERROR
} /* end if */
/* Don't compare this currently, it's very hard to compute */
#ifdef NOT_YET
if(earray_stats.stored.data_blk_size != state->data_blk_size) {
HDfprintf(stdout, "earray_stats.stored.data_blk_size = %Hu, state->data_blk_size = %Hu\n", earray_stats.stored.data_blk_size, state->data_blk_size);
TEST_ERROR
} /* end if */
#endif /* NOT_YET */
if(earray_stats.stored.nsuper_blks != state->nsuper_blks) {
HDfprintf(stdout, "earray_stats.stored.nsuper_blks = %Hu, state->nsuper_blks = %Hu\n", earray_stats.stored.nsuper_blks, state->nsuper_blks);
TEST_ERROR
} /* end if */
/* Don't compare this currently, it's very hard to compute */
#ifdef NOT_YET
if(earray_stats.stored.super_blk_size != state->super_blk_size) {
HDfprintf(stdout, "earray_stats.stored.super_blk_size = %Hu, state->super_blk_size = %Hu\n", earray_stats.stored.super_blk_size, state->super_blk_size);
TEST_ERROR
} /* end if */
#endif /* NOT_YET */
#ifdef QAK
HDfprintf(stderr, "nelmts = %Hu, total EA size = %Hu\n", earray_stats.stored.nelmts,
(earray_stats.computed.hdr_size + earray_stats.computed.index_blk_size + earray_stats.stored.super_blk_size + earray_stats.stored.data_blk_size));
#endif /* QAK */
/* All tests passed */
return(0);
error:
return(-1);
} /* check_stats() */
/*-------------------------------------------------------------------------
* Function: reopen_file
*
* Purpose: Perform common "re-open" operations on file & array for testing
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static int
reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl,
H5EA_t **ea, haddr_t ea_addr, const earray_test_param_t *tparam)
{
/* Check for closing & re-opening the array */
/* (actually will close & re-open the file as well) */
if(tparam->reopen_array) {
/* Close array, if given */
if(ea && *ea) {
if(H5EA_close(*ea, dxpl) < 0)
FAIL_STACK_ERROR
*ea = NULL;
} /* end if */
/* Close file */
if(*file) {
if(H5Fclose(*file) < 0)
FAIL_STACK_ERROR
*file = (-1);
*f = NULL;
} /* end if */
/* Re-open the file */
if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
if(NULL == (*f = (H5F_t *)H5I_object(*file)))
FAIL_STACK_ERROR
/* Ignore metadata tags in the file's cache */
if(H5AC_ignore_tags(*f) < 0)
FAIL_STACK_ERROR
/* Re-open array, if given */
if(ea)
if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL)))
FAIL_STACK_ERROR
} /* end if */
/* Success */
return(0);
error:
return(-1);
} /* reopen_file() */
/*-------------------------------------------------------------------------
* Function: create_array
*
* Purpose: Create an extensible array and perform initial checks
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static int
create_array(H5F_t *f, hid_t dxpl, const H5EA_create_t *cparam,
H5EA_t **ea, haddr_t *ea_addr, H5EA__ctx_cb_t *cb)
{
hsize_t nelmts; /* Number of elements in array */
earray_state_t state; /* State of extensible array */
/* Create array */
if(NULL == (*ea = H5EA_create(f, dxpl, cparam, cb)))
FAIL_STACK_ERROR
/* Check status of array */
nelmts = (hsize_t)ULLONG_MAX;
if(H5EA_get_nelmts(*ea, &nelmts) < 0)
FAIL_STACK_ERROR
if(nelmts > 0)
TEST_ERROR
if(H5EA_get_addr(*ea, ea_addr) < 0)
FAIL_STACK_ERROR
if(!H5F_addr_defined(*ea_addr))
TEST_ERROR
HDmemset(&state, 0, sizeof(state));
state.hdr_size = EA_HDR_SIZE;
if(check_stats(*ea, &state))
TEST_ERROR
/* Success */
return(0);
error:
return(-1);
} /* create_array() */
/*-------------------------------------------------------------------------
* Function: verify_cparam
*
* Purpose: Verify creation parameters are correct
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static int
verify_cparam(const H5EA_t *ea, const H5EA_create_t *cparam)
{
H5EA_create_t test_cparam; /* Creation parameters for array */
/* Retrieve creation parameters */
HDmemset(&test_cparam, 0, sizeof(H5EA_create_t));
if(H5EA_get_cparam_test(ea, &test_cparam) < 0)
FAIL_STACK_ERROR
/* Verify creation parameters */
if(H5EA_cmp_cparam_test(cparam, &test_cparam))
TEST_ERROR
/* Success */
return(0);
error:
return(-1);
} /* verify_cparam() */
/*-------------------------------------------------------------------------
* Function: finish
*
* Purpose: Close array, delete array, close file and verify that file
* is empty size
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static int
finish(hid_t file, hid_t fapl, H5F_t *f, H5EA_t *ea, haddr_t ea_addr)
{
h5_stat_size_t file_size; /* File size, after deleting array */
/* Close the extensible array */
if(H5EA_close(ea, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
#ifdef QAK
HDfprintf(stderr, "ea_addr = %a\n", ea_addr);
H5Fflush(file, H5F_SCOPE_GLOBAL);
HDsystem("cp earray.h5 earray.h5.save");
#endif /* QAK */
/* Delete array */
if(H5EA_delete(f, H5AC_ind_read_dxpl_id, ea_addr, NULL) < 0)
FAIL_STACK_ERROR
/* Close the file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
/* Get the size of the file */
if((file_size = h5_get_file_size(filename_g, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size_g)
TEST_ERROR
/* Success */
return(0);
error:
return(-1);
} /* finish() */
/*-------------------------------------------------------------------------
* Function: earray_cache_test_get_load_size()
*
* Purpose: place holder function -- should never be called
*
*
* A generic discussion of metadata cache callbacks of this type
* may be found in H5Cprivate.h:
*
* Return: Success: SUCCEED
* Failure: FAIL
*
* Programmer: John Mainzer
* 8/2/14
*
*-------------------------------------------------------------------------
*/
static herr_t
earray_cache_test_get_load_size(const void *udata_ptr, size_t *image_len_ptr)
{
HDassert(udata_ptr);
HDassert(image_len_ptr);
/* Should never be called */
HDassert(0 && "Can't be called!");
*image_len_ptr = 0;
return(SUCCEED);
} /* end earray_cache_test_get_load_size() */
/*-------------------------------------------------------------------------
* Function: earray_cache_test_deserialize
*
* Purpose: place holder function -- should never be called.
*
*
* A generic discussion of metadata cache callbacks of this type
* may be found in H5Cprivate.h:
*
* Return: Success: Pointer to in core representation
* Failure: NULL
*
* Programmer: John Mainzer
* 8/2/14
*
*-------------------------------------------------------------------------
*/
static void *
earray_cache_test_deserialize(const void *image_ptr,
size_t len,
void *udata_ptr,
hbool_t *dirty_ptr)
{
HDassert(image_ptr);
HDassert(len > 0 );
HDassert(udata_ptr);
HDassert(dirty_ptr);
/* Should never be called */
HDassert(0 && "Can't be called!");
return(NULL);
} /* end earray_cache_test_deserialize() */
/*-------------------------------------------------------------------------
* Function: earray_cache_test_image_len
*
* Purpose: test code place holder function -- just set *image_len_ptr to
* one.
*
*
* A generic discussion of metadata cache callbacks of this type
* may be found in H5Cprivate.h:
*
* Return: Success: SUCCEED
* Failure: FAIL
*
* Programmer: John Mainzer
* 8/2/14
*
*-------------------------------------------------------------------------
*/
static herr_t
earray_cache_test_image_len(const void *thing, size_t *image_len_ptr,
hbool_t H5_ATTR_UNUSED * compressed_ptr, size_t H5_ATTR_UNUSED * compressed_len_ptr)
{
HDassert(thing);
HDassert(image_len_ptr);
/* Set size value */
/* (hard-code to 1) */
*image_len_ptr = 1;
return(SUCCEED);
} /* end earray_cache_test_image_len() */
/********************************/
/* no H5O_cache_pre_serialize() */
/********************************/
/*-------------------------------------------------------------------------
* Function: earray_cache_test_serialize
*
* Purpose: Validate the contents of the instance of earray_test_t.
*
*
* A generic discussion of metadata cache callbacks of this type
* may be found in H5Cprivate.h:
*
*
* Return: Success: SUCCEED
* Failure: FAIL
*
* Programmer: John Mainzer
* 8/2/14
*
*-------------------------------------------------------------------------
*/
static herr_t
earray_cache_test_serialize(const H5F_t *f,
void *image_ptr,
H5_ATTR_UNUSED size_t len,
void *thing)
{
earray_test_t *test = NULL;
HDassert(f);
HDassert(image_ptr);
HDassert(thing);
test = (earray_test_t *)thing;
HDassert(test);
HDassert(test->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_MAGIC);
HDassert((const H5AC_class_t *)(test->cache_info.type) ==
&(H5AC_EARRAY_TEST[0]));
/* Check for out of order flush */
if(test->fd_info->base_obj)
TEST_ERROR
/* Check which index this entry corresponds to */
if((uint64_t)0 == test->idx) {
/* Check for out of order flush */
if(test->fd_info->idx0_obj || test->fd_info->idx0_elem)
TEST_ERROR
/* Set flag for object flush */
test->fd_info->idx0_obj = TRUE;
} /* end if */
else if((uint64_t)1 == test->idx) {
/* Check for out of order flush */
if(test->fd_info->idx1_obj || test->fd_info->idx1_elem)
TEST_ERROR
/* Set flag for object flush */
test->fd_info->idx1_obj = TRUE;
} /* end if */
else if((uint64_t)10000 == test->idx) {
/* Check for out of order flush */
if(test->fd_info->idx10000_obj || test->fd_info->idx10000_elem)
TEST_ERROR
/* Set flag for object flush */
test->fd_info->idx10000_obj = TRUE;
} /* end if */
else if((uint64_t)-1 == test->idx) {
/* Set flag for object flush */
test->fd_info->base_obj = TRUE;
} /* end if */
return(SUCCEED);
error:
return(FAIL);
} /* end earray_cache_test_serialize() */
/******************************************/
/* no earray_cache_test_notify() function */
/******************************************/
/*-------------------------------------------------------------------------
* Function: earray_cache_test_free_icr
*
* Purpose: Destroy an extensible array test object in memory.
*
*
* A generic discussion of metadata cache callbacks of this type
* may be found in H5Cprivate.h:
*
*
* Return: Success: SUCCEED
* Failure: FAIL
*
* Programmer: John Mainzer
* 8/2/14
*
*-------------------------------------------------------------------------
*/
static herr_t
earray_cache_test_free_icr(void *thing)
{
earray_test_t *test = NULL;
HDassert(thing);
test = (earray_test_t *)thing;
HDassert(test);
/* the metadata cache sets cache_info.magic to
* H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC before calling the
* free_icr routine. Hence the following assert:
*/
HDassert(test->cache_info.magic == H5C__H5C_CACHE_ENTRY_T_BAD_MAGIC);
HDassert((const H5AC_class_t *)(test->cache_info.type) ==
&(H5AC_EARRAY_TEST[0]));
/* Free the shared info itself */
HDfree(test);
return(SUCCEED);
} /* end earray_cache_test_free_icr() */
/*-------------------------------------------------------------------------
* Function: test_create
*
* Purpose: Test creating extensible array
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Thursday, August 7, 2008
*
*-------------------------------------------------------------------------
*/
static unsigned
test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSED *tparam)
{
hid_t file = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
* Display testing message
*/
TESTING("invalid extensible array creation parameters");
#ifndef NDEBUG
{
H5EA_create_t test_cparam; /* Creation parameters for array */
/* Set invalid element size */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.raw_elmt_size = 0;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
/* Set invalid max. # of elements bits */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.max_nelmts_bits = 0;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.max_nelmts_bits = 65;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
/* Set invalid min. # of data block pointers in super blocks */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.sup_blk_min_data_ptrs = 0;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.sup_blk_min_data_ptrs = 1;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.sup_blk_min_data_ptrs = 6;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
/* Set invalid min. # of elements per data block */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.data_blk_min_elmts = 0;
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
/* Set invalid max. # of elements per data block page bits */
if(test_cparam.idx_blk_elmts > 0) {
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1);
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
} /* end if */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.max_dblk_page_nelmts_bits = 4; /* corresponds to 16 elements in data block page, which is less than the 64 elements for the default settings */
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
HDmemcpy(&test_cparam, cparam, sizeof(test_cparam));
test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1);
H5E_BEGIN_TRY {
ea = H5EA_create(f, H5AC_ind_read_dxpl_id, &test_cparam, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened extensible array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
ea = NULL;
/* Indicate error */
TEST_ERROR
} /* end if */
PASSED()
}
#else /* NDEBUG */
SKIPPED();
puts(" Not tested when assertions are disabled");
#endif /* NDEBUG */
/*
* Display testing message
*/
TESTING("extensible array creation");
/* Create array */
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, NULL) < 0)
TEST_ERROR
PASSED()
/* Verify the creation parameters */
TESTING("verify array creation parameters");
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
/* Close array, delete array, close file & verify file is empty */
if(finish(file, fapl, f, ea, ea_addr) < 0)
TEST_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
H5Fclose(file);
} H5E_END_TRY;
return 1;
} /* end test_create() */
/*-------------------------------------------------------------------------
* Function: test_reopen
*
* Purpose: Create & reopen an extensible array
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static unsigned
test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
* Display testing message
*/
TESTING("create, close & reopen extensible array");
/* Create array */
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, NULL) < 0)
TEST_ERROR
/* Close the extensible array */
if(H5EA_close(ea, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
/* Check for closing & re-opening the file */
if(reopen_file(&file, &f, fapl, H5AC_ind_read_dxpl_id, NULL, HADDR_UNDEF, tparam) < 0)
TEST_ERROR
/* Re-open the array */
if(NULL == (ea = H5EA_open(f, H5AC_ind_read_dxpl_id, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
/* Close array, delete array, close file & verify file is empty */
if(finish(file, fapl, f, ea, ea_addr) < 0)
TEST_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
H5Fclose(file);
} H5E_END_TRY;
return 1;
} /* test_reopen() */
/*-------------------------------------------------------------------------
* Function: test_open_twice
*
* Purpose: Open an extensible array twice
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static unsigned
test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
hid_t file2 = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5F_t *f2 = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
H5EA_t *ea2 = NULL; /* Extensible array wrapper */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
* Display testing message
*/
TESTING("open extensible array twice");
/* Create array */
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, NULL) < 0)
TEST_ERROR
/* Open the array again, through the first file handle */
if(NULL == (ea2 = H5EA_open(f, H5AC_ind_read_dxpl_id, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
if(verify_cparam(ea2, cparam) < 0)
TEST_ERROR
/* Close the second extensible array wrapper */
if(H5EA_close(ea2, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
ea2 = NULL;
/* Check for closing & re-opening the file */
if(reopen_file(&file, &f, fapl, H5AC_ind_read_dxpl_id, &ea, ea_addr, tparam) < 0)
TEST_ERROR
/* Re-open the file */
if((file2 = H5Freopen(file)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
FAIL_STACK_ERROR
/* Open the extensible array through the second file handle */
if(NULL == (ea2 = H5EA_open(f2, H5AC_ind_read_dxpl_id, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
/* Close the first extensible array wrapper */
if(H5EA_close(ea, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
ea = NULL;
/* Close the first file */
/* (close before second file, to detect error on internal array header's
* shared file information)
*/
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
/* Close array, delete array, close file & verify file is empty */
if(finish(file2, fapl, f2, ea2, ea_addr) < 0)
TEST_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
if(ea2)
H5EA_close(ea2, H5AC_ind_read_dxpl_id);
H5Fclose(file);
H5Fclose(file2);
} H5E_END_TRY;
return 1;
} /* test_open_twice() */
/*-------------------------------------------------------------------------
* Function: test_open_twice_diff
*
* Purpose: Open an extensible array twice, through different "top" file
* handles, with an intermediate file open that takes the "shared"
* file handle from the first extensible array's file pointer.
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Friday, December 18, 2015
*
*-------------------------------------------------------------------------
*/
static unsigned
test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
{
char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */
hid_t file = -1; /* File ID */
hid_t file2 = -1; /* File ID */
hid_t file0 = -1; /* File ID */
hid_t file00 = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5F_t *f2 = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
H5EA_t *ea2 = NULL; /* Extensible array wrapper */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
* Display testing message
*/
TESTING("open extensible array twice, through different file handles");
/* Create array */
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, NULL) < 0)
TEST_ERROR
/* Open the array again, through the first file handle */
if(NULL == (ea2 = H5EA_open(f, H5AC_ind_read_dxpl_id, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
if(verify_cparam(ea2, cparam) < 0)
TEST_ERROR
/* Close the second extensible array wrapper */
if(H5EA_close(ea2, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
ea2 = NULL;
/* Re-open the file */
/* (So that there is something holding the file open when the extensible
* array is closed)
*/
if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
/* Check for closing & re-opening the file */
if(reopen_file(&file, &f, fapl, H5AC_ind_read_dxpl_id, &ea, ea_addr, tparam) < 0)
TEST_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
/* Close the first extensible array wrapper */
if(H5EA_close(ea, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
ea = NULL;
/* Close the first file */
/* (close before second file, to detect error on internal array header's
* shared file information)
*/
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
file = -1;
/* Open a different file */
/* (This re-allocates the 'top' file pointer and assigns it a different
* 'shared' file pointer, making the file pointer in the extensible array's
* header stale)
*/
h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp));
if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
/* Re-open the file with the extensible array */
if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0)
FAIL_STACK_ERROR
/* Get a pointer to the internal file object */
if(NULL == (f2 = (H5F_t *)H5I_object(file2)))
FAIL_STACK_ERROR
/* Open the extensible array through the second file handle */
if(NULL == (ea2 = H5EA_open(f2, H5AC_ind_read_dxpl_id, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea2, cparam) < 0)
TEST_ERROR
/* Close the extra file handles */
if(H5Fclose(file0) < 0)
FAIL_STACK_ERROR
if(H5Fclose(file00) < 0)
FAIL_STACK_ERROR
/* Close array, delete array, close file & verify file is empty */
if(finish(file2, fapl, f2, ea2, ea_addr) < 0)
TEST_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
if(ea2)
H5EA_close(ea2, H5AC_ind_read_dxpl_id);
H5Fclose(file);
H5Fclose(file2);
H5Fclose(file0);
H5Fclose(file00);
} H5E_END_TRY;
return 1;
} /* test_open_twice_diff() */
/*-------------------------------------------------------------------------
* Function: test_delete_open
*
* Purpose: Delete opened extensible array (& open deleted array)
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Thursday, August 28, 2008
*
*-------------------------------------------------------------------------
*/
static unsigned
test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam)
{
hid_t file = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
H5EA_t *ea2 = NULL; /* Extensible array wrapper */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
h5_stat_size_t file_size; /* File size, after deleting array */
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
* Display testing message
*/
TESTING("deleting open extensible array");
/* Create array */
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, NULL) < 0)
TEST_ERROR
/* Open the array again */
if(NULL == (ea2 = H5EA_open(f, H5AC_ind_read_dxpl_id, ea_addr, NULL)))
FAIL_STACK_ERROR
/* Request that the array be deleted */
if(H5EA_delete(f, H5AC_ind_read_dxpl_id, ea_addr, NULL) < 0)
FAIL_STACK_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
if(verify_cparam(ea2, cparam) < 0)
TEST_ERROR
/* Close the second extensible array wrapper */
if(H5EA_close(ea2, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
ea2 = NULL;
/* Try re-opening the array again (should fail, as array will be deleted) */
H5E_BEGIN_TRY {
ea2 = H5EA_open(f, H5AC_ind_read_dxpl_id, ea_addr, NULL);
} H5E_END_TRY;
if(ea2) {
/* Close opened array */
H5EA_close(ea2, H5AC_ind_read_dxpl_id);
/* Indicate error */
TEST_ERROR
} /* end if */
/* Close the first extensible array wrapper */
if(H5EA_close(ea, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
ea = NULL;
/* Check for closing & re-opening the file */
if(reopen_file(&file, &f, fapl, H5AC_ind_read_dxpl_id, NULL, HADDR_UNDEF, tparam) < 0)
TEST_ERROR
/* Try re-opening the array again (should fail, as array is now deleted) */
H5E_BEGIN_TRY {
ea = H5EA_open(f, H5AC_ind_read_dxpl_id, ea_addr, NULL);
} H5E_END_TRY;
if(ea) {
/* Close opened array */
H5EA_close(ea, H5AC_ind_read_dxpl_id);
/* Indicate error */
TEST_ERROR
} /* end if */
/* Close the file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
/* Get the size of the file */
if((file_size = h5_get_file_size(filename_g, fapl)) < 0)
TEST_ERROR
/* Verify the file is correct size */
if(file_size != empty_size_g)
TEST_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
if(ea2)
H5EA_close(ea2, H5AC_ind_read_dxpl_id);
H5Fclose(file);
} H5E_END_TRY;
return 1;
} /* test_delete_open() */
/*-------------------------------------------------------------------------
* Function: test_flush_depend_cb
*
* Purpose: Callback for flush dependency 'depend'/'undepend' and
* 'support'/'unsupport' routines
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, May 26, 2009
*
*-------------------------------------------------------------------------
*/
static herr_t
test_flush_depend_cb(const void *_elmt, size_t nelmts, void *udata)
{
earray_flush_depend_ctx_t *ctx = (earray_flush_depend_ctx_t *)udata;
const uint64_t *elmt = (const uint64_t *)_elmt; /* Convenience pointer to native elements */
/* Check for out of order flush */
if(ctx->base_obj)
return(FAIL);
/* Look for magic values */
while(nelmts > 0) {
/* Check for elements of interest */
if((uint64_t)0 == *elmt) {
/* Check for out-of-order flush */
if(!ctx->idx0_obj)
return(FAIL);
/* Indicate that the element was flushed */
ctx->idx0_elem = TRUE;
} /* end if */
else if((uint64_t)1 == *elmt) {
/* Check for out-of-order flush */
if(!ctx->idx1_obj)
return(FAIL);
/* Indicate that the element was flushed */
ctx->idx1_elem = TRUE;
} /* end if */
else if((uint64_t)10000 == *elmt) {
/* Check for out-of-order flush */
if(!ctx->idx10000_obj)
return(FAIL);
/* Indicate that the element was flushed */
ctx->idx10000_elem = TRUE;
} /* end if */
/* Decrement elements left to inspect */
nelmts--;
elmt++;
} /* end while */
return(SUCCEED);
} /* end test_flush_depend_cb() */
/*-------------------------------------------------------------------------
* Function: test_flush_depend
*
* Purpose: Exercise flush dependency 'depend'/'undepend' routines
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Thursday, May 21, 2009
*
*-------------------------------------------------------------------------
*/
static unsigned
test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSED *tparam)
{
hid_t file = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
H5EA__ctx_cb_t cb; /* Extensible array context action info */
earray_flush_depend_ctx_t fd_info; /* Context information for flush depend test */
haddr_t base_addr; /* Base test entry address */
earray_test_t *base_entry; /* Pointer to base test entry */
haddr_t addr1; /* Test entry #1 address */
earray_test_t *entry1; /* Pointer to test entry #1 */
haddr_t addr2; /* Test entry #2 address */
earray_test_t *entry2; /* Pointer to test entry #2 */
haddr_t addr3; /* Test entry #3 address */
earray_test_t *entry3; /* Pointer to test entry #3 */
uint64_t welmt; /* Element to write */
hsize_t idx; /* Index value of element */
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/*
* Display testing message
*/
TESTING("flush dependencies on array metadata");
/* Create array */
cb.encode = test_flush_depend_cb;
HDmemset(&fd_info, 0, sizeof(earray_flush_depend_ctx_t));
cb.udata = &fd_info;
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, &cb) < 0)
TEST_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
/* Create base entry to insert */
if(NULL == (base_entry = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
TEST_ERROR
HDmemset(base_entry, 0, sizeof(earray_test_t));
base_entry->idx = (uint64_t)-1;
base_entry->fd_info = &fd_info;
/* Insert test entry into cache */
base_addr = HADDR_MAX;
if(H5AC_insert_entry(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, base_addr, base_entry, H5AC__PIN_ENTRY_FLAG) < 0)
TEST_ERROR
/* Set the base entry as a flush dependency for the array */
if(H5EA_depend((H5AC_info_t *)base_entry, ea) < 0)
TEST_ERROR
/* Create entry #1 to insert */
if(NULL == (entry1 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
TEST_ERROR
HDmemset(entry1, 0, sizeof(earray_test_t));
entry1->fd_info = &fd_info;
/* Insert test entry into cache */
addr1 = HADDR_MAX - 1;
if(H5AC_insert_entry(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr1, entry1, H5AC__PIN_ENTRY_FLAG) < 0)
TEST_ERROR
/* Set the test entry as a flush dependency for 0th index in the array */
if(H5EA_support(ea, H5AC_ind_read_dxpl_id, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
TEST_ERROR
/* Set element of array */
welmt = (uint64_t)0;
idx = 0;
if(H5EA_set(ea, H5AC_ind_read_dxpl_id, idx, &welmt) < 0)
FAIL_STACK_ERROR
/* Create entry #2 to insert */
if(NULL == (entry2 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
TEST_ERROR
HDmemset(entry2, 0, sizeof(earray_test_t));
entry2->idx = (uint64_t)1;
entry2->fd_info = &fd_info;
/* Insert test entry into cache */
addr2 = HADDR_MAX - 2;
if(H5AC_insert_entry(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr2, entry2, H5AC__PIN_ENTRY_FLAG) < 0)
TEST_ERROR
/* Set the test entry as a flush dependency for 1st index in the array */
if(H5EA_support(ea, H5AC_ind_read_dxpl_id, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
TEST_ERROR
/* Set element of array */
welmt = (uint64_t)1;
idx = 1;
if(H5EA_set(ea, H5AC_ind_read_dxpl_id, idx, &welmt) < 0)
FAIL_STACK_ERROR
/* Create entry #3 to insert */
if(NULL == (entry3 = (earray_test_t *)HDmalloc(sizeof(earray_test_t))))
TEST_ERROR
HDmemset(entry3, 0, sizeof(earray_test_t));
entry3->idx = (uint64_t)10000;
entry3->fd_info = &fd_info;
/* Insert test entry into cache */
addr3 = HADDR_MAX - 3;
if(H5AC_insert_entry(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr3, entry3, H5AC__PIN_ENTRY_FLAG) < 0)
TEST_ERROR
/* Set the test entry as a flush dependency for 10,000th index in the array */
if(H5EA_support(ea, H5AC_ind_read_dxpl_id, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
TEST_ERROR
/* Set element of array */
welmt = (uint64_t)10000;
idx = 10000;
if(H5EA_set(ea, H5AC_ind_read_dxpl_id, idx, &welmt) < 0)
FAIL_STACK_ERROR
/* Flush the cache */
if(H5Fflush(file, H5F_SCOPE_GLOBAL) < 0)
TEST_ERROR
/* Check that all callback flags have been set */
if(!fd_info.base_obj)
TEST_ERROR
if(!fd_info.idx0_obj)
TEST_ERROR
if(!fd_info.idx0_elem)
TEST_ERROR
if(!fd_info.idx1_obj)
TEST_ERROR
if(!fd_info.idx1_elem)
TEST_ERROR
if(!fd_info.idx10000_obj)
TEST_ERROR
if(!fd_info.idx10000_elem)
TEST_ERROR
/* Remove the base entry as a flush dependency for the array */
if(H5EA_undepend((H5AC_info_t *)base_entry, ea) < 0)
TEST_ERROR
/* Protect the base entry */
if(NULL == (base_entry = (earray_test_t *)H5AC_protect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, base_addr, NULL, H5AC__NO_FLAGS_SET)))
TEST_ERROR
/* Unprotect & unpin the base entry */
if(H5AC_unprotect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, base_addr, base_entry, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
TEST_ERROR
/* Remove the test entry as a flush dependency for 0th index in the array */
if(H5EA_unsupport(ea, H5AC_ind_read_dxpl_id, (hsize_t)0, (H5AC_info_t *)entry1) < 0)
TEST_ERROR
/* Protect the test entry */
if(NULL == (entry1 = (earray_test_t *)H5AC_protect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr1, NULL, H5AC__NO_FLAGS_SET)))
TEST_ERROR
/* Unprotect & unpin the test entry */
if(H5AC_unprotect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr1, entry1, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
TEST_ERROR
/* Remove the test entry as a flush dependency for 1st index in the array */
if(H5EA_unsupport(ea, H5AC_ind_read_dxpl_id, (hsize_t)1, (H5AC_info_t *)entry2) < 0)
TEST_ERROR
/* Protect the test entry */
if(NULL == (entry2 = (earray_test_t *)H5AC_protect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr2, NULL, H5AC__NO_FLAGS_SET)))
TEST_ERROR
/* Unprotect & unpin the test entry */
if(H5AC_unprotect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr2, entry2, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
TEST_ERROR
/* Remove the test entry as a flush dependency for 10,000th index in the array */
if(H5EA_unsupport(ea, H5AC_ind_read_dxpl_id, (hsize_t)10000, (H5AC_info_t *)entry3) < 0)
TEST_ERROR
/* Protect the test entry */
if(NULL == (entry3 = (earray_test_t *)H5AC_protect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr3, NULL, H5AC__NO_FLAGS_SET)))
TEST_ERROR
/* Unprotect & unpin the test entry */
if(H5AC_unprotect(f, H5AC_ind_read_dxpl_id, H5AC_EARRAY_TEST, addr3, entry3, (H5AC__UNPIN_ENTRY_FLAG | H5AC__DELETED_FLAG)) < 0)
TEST_ERROR
/* Close the extensible array */
if(H5EA_close(ea, H5AC_ind_read_dxpl_id) < 0)
FAIL_STACK_ERROR
ea = NULL;
/* Close the file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
H5Fclose(file);
} H5E_END_TRY;
return 1;
} /* test_flush_depend() */
/* Extensible array iterator info for forward iteration */
typedef struct eiter_fw_t {
hsize_t idx; /* Index of next array location */
unsigned base_sblk_idx; /* Starting index for actual superblocks */
} eiter_fw_t;
/*-------------------------------------------------------------------------
* Function: eiter_fw_init
*
* Purpose: Initialize element interator (forward iteration)
*
* Return: Success: Pointer to iteration status object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Thursday, October 2, 2008
*
*-------------------------------------------------------------------------
*/
static void *
eiter_fw_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam,
hsize_t H5_ATTR_UNUSED cnt)
{
eiter_fw_t *eiter; /* Forward element iteration object */
/* Allocate space for the element iteration object */
eiter = (eiter_fw_t *)HDmalloc(sizeof(eiter_fw_t));
HDassert(eiter);
/* Initialize the element iteration object */
eiter->idx = 0;
eiter->base_sblk_idx = UINT_MAX;
/* Return iteration object */
return(eiter);
} /* end eiter_fw_init() */
/*-------------------------------------------------------------------------
* Function: eiter_fw_next
*
* Purpose: Get next element index (forward iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static hssize_t
eiter_fw_next(void *_eiter)
{
eiter_fw_t *eiter = (eiter_fw_t *)_eiter;
hssize_t ret_val;
/* Sanity check */
HDassert(eiter);
/* Get the next array index to test */
ret_val = (hssize_t)eiter->idx++;
return(ret_val);
} /* end eiter_fw_next() */
/*-------------------------------------------------------------------------
* Function: eiter_fw_max
*
* Purpose: Get max. element index (forward iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
eiter_fw_max(const void *_eiter)
{
const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter;
/* Sanity check */
HDassert(eiter);
/* Return the max. array index used */
return((hssize_t)(eiter->idx - 1));
} /* end eiter_fw_max() */
/*-------------------------------------------------------------------------
* Function: eiter_fw_state
*
* Purpose: Get extensible array state (forward iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static int
eiter_fw_state(void *_eiter, const H5EA_create_t *cparam,
const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx)
{
eiter_fw_t *eiter = (eiter_fw_t *)_eiter;
/* Sanity check */
HDassert(eiter);
HDassert(cparam);
HDassert(tparam);
HDassert(state);
/* Compute the state of the extensible array */
state->hdr_size = EA_HDR_SIZE;
state->nindex_blks = 1;
state->index_blk_size = EA_IBLOCK_SIZE;
state->max_idx_set = idx + 1;
if(idx < cparam->idx_blk_elmts) {
state->nelmts = (hsize_t)cparam->idx_blk_elmts;
state->nsuper_blks = state->ndata_blks = (hsize_t)0;
state->super_blk_size = state->data_blk_size = (hsize_t)0;
} /* end if */
else {
unsigned sblk_idx; /* Which superblock does this index fall in? */
/* Compute super block index for element index */
/* (same eqn. as in H5EA__dblock_sblk_idx()) */
sblk_idx = H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
#ifdef QAK
HDfprintf(stderr, "idx = %Hu, tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx, sblk_idx, tparam->sblk_info[sblk_idx].ndblks, tparam->sblk_info[sblk_idx].dblk_nelmts, tparam->sblk_info[sblk_idx].start_idx, tparam->sblk_info[sblk_idx].start_dblk);
#endif /* QAK */
state->nelmts = EA_NELMTS(cparam, tparam, idx, sblk_idx);
#ifdef QAK
HDfprintf(stderr, "state->nelmts = %Hu\n", state->nelmts);
#endif /* QAK */
state->ndata_blks = EA_NDATA_BLKS(cparam, tparam, idx, sblk_idx);
#ifdef QAK
HDfprintf(stderr, "state->ndata_blks = %Hu\n", state->ndata_blks);
#endif /* QAK */
/* Check if we have any super blocks yet */
if(tparam->sblk_info[sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) {
/* Check if this is the first superblock */
if(sblk_idx < eiter->base_sblk_idx)
eiter->base_sblk_idx = sblk_idx;
state->nsuper_blks = (sblk_idx - eiter->base_sblk_idx) + 1;
#ifdef QAK
HDfprintf(stderr, "state->nsuper_blks = %Hu\n", state->nsuper_blks);
#endif /* QAK */
} /* end if */
else
state->nsuper_blks = 0;
} /* end else */
return(0);
} /* end eiter_fw_state() */
/*-------------------------------------------------------------------------
* Function: eiter_fw_term
*
* Purpose: Shut down element interator (forward iteration)
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Thursday, October 2, 2008
*
*-------------------------------------------------------------------------
*/
static int
eiter_fw_term(void *eiter)
{
/* Sanity check */
HDassert(eiter);
/* Free iteration object */
HDfree(eiter);
return(0);
} /* end eiter_fw_term() */
/* Extensible array iterator class for forward iteration */
static const earray_iter_t ea_iter_fw = {
eiter_fw_init, /* Iterator init */
eiter_fw_next, /* Next array index */
eiter_fw_max, /* Max. array index */
eiter_fw_state, /* State of the extensible array */
eiter_fw_term /* Iterator term */
};
/* Extensible array iterator info for reverse iteration */
typedef struct eiter_rv_t {
hsize_t idx; /* Index of next array location */
hsize_t max; /* Index of max. array location */
hsize_t max_sblk_idx; /* Which superblock does the max. array location fall in? */
hsize_t max_nelmts; /* Max. # of elements for array */
hsize_t max_ndata_blks; /* Max. # of data blocks for array */
hsize_t idx_blk_nsblks; /* Number of superblocks directly pointed to in the index block */
} eiter_rv_t;
/*-------------------------------------------------------------------------
* Function: eiter_rv_init
*
* Purpose: Initialize element interator (reverse iteration)
*
* Return: Success: Pointer to iteration status object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static void *
eiter_rv_init(const H5EA_create_t *cparam, const earray_test_param_t *tparam,
hsize_t cnt)
{
eiter_rv_t *eiter; /* Reverse element iteration object */
/* Allocate space for the element iteration object */
eiter = (eiter_rv_t *)HDmalloc(sizeof(eiter_rv_t));
HDassert(eiter);
/* Initialize reverse iteration info */
eiter->idx = cnt - 1;
eiter->max = cnt - 1;
if(cnt > cparam->idx_blk_elmts) {
eiter->max_sblk_idx = H5VM_log2_gen((uint64_t)(((eiter->max - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
eiter->max_nelmts = EA_NELMTS(cparam, tparam, eiter->max, eiter->max_sblk_idx);
eiter->max_ndata_blks = EA_NDATA_BLKS(cparam, tparam, eiter->max, eiter->max_sblk_idx);
eiter->idx_blk_nsblks = 2 * H5VM_log2_of2((uint32_t)cparam->sup_blk_min_data_ptrs);
} /* end if */
else {
eiter->max_sblk_idx = (hsize_t)0;
eiter->max_nelmts = (hsize_t)0;
eiter->max_ndata_blks = (hsize_t)0;
eiter->idx_blk_nsblks = (hsize_t)0;
} /* end else */
/* Return iteration object */
return(eiter);
} /* end eiter_rv_init() */
/*-------------------------------------------------------------------------
* Function: eiter_rv_next
*
* Purpose: Get next element index (reverse iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static hssize_t
eiter_rv_next(void *_eiter)
{
eiter_rv_t *eiter = (eiter_rv_t *)_eiter;
hssize_t ret_val;
/* Sanity check */
HDassert(eiter);
/* Get the next array index to test */
ret_val = (hssize_t)eiter->idx--;
return(ret_val);
} /* end eiter_rv_next() */
/*-------------------------------------------------------------------------
* Function: eiter_rv_max
*
* Purpose: Get max. element index (reverse iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
eiter_rv_max(const void *_eiter)
{
const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter;
/* Sanity check */
HDassert(eiter);
/* Return the max. array index used */
return((hssize_t)eiter->max);
} /* end eiter_rv_max() */
/*-------------------------------------------------------------------------
* Function: eiter_rv_state
*
* Purpose: Get extensible array state (reverse iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static int
eiter_rv_state(void *_eiter, const H5EA_create_t *cparam,
const earray_test_param_t *tparam, earray_state_t *state, hsize_t idx)
{
eiter_rv_t *eiter = (eiter_rv_t *)_eiter;
/* Sanity check */
HDassert(eiter);
HDassert(cparam);
HDassert(tparam);
HDassert(state);
/* Compute the state of the extensible array */
state->hdr_size = EA_HDR_SIZE;
state->nindex_blks = 1;
state->index_blk_size = EA_IBLOCK_SIZE;
state->max_idx_set = eiter->max + 1;
if(eiter->max < cparam->idx_blk_elmts) {
state->nelmts = (hsize_t)cparam->idx_blk_elmts;
state->nsuper_blks = state->ndata_blks = (hsize_t)0;
} /* end if */
else {
hsize_t idx_nelmts; /* # of elements for array index */
hsize_t idx_ndata_blks; /* # of data blocks for array index */
hsize_t loc_idx = 0; /* Local index, for computing an offset in next lower data block */
unsigned idx_sblk_idx; /* Which superblock does this index fall in? */
unsigned loc_sblk_idx = 0; /* Which superblock does the local index fall in? */
/* Compute super block index for element index */
/* (same eqn. as in H5EA__dblock_sblk_idx()) */
if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts)
idx_sblk_idx = 0;
else {
hsize_t tmp_idx; /* Temporary index in superblock */
hsize_t dblk_idx; /* Index of data block within superblock */
idx_sblk_idx = H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
tmp_idx = idx - (cparam->idx_blk_elmts + tparam->sblk_info[idx_sblk_idx].start_idx);
dblk_idx = tmp_idx / tparam->sblk_info[idx_sblk_idx].dblk_nelmts;
if(dblk_idx > 0)
loc_idx = idx - tparam->sblk_info[idx_sblk_idx].dblk_nelmts;
else
loc_idx = cparam->idx_blk_elmts + tparam->sblk_info[idx_sblk_idx].start_idx - 1;
loc_sblk_idx = H5VM_log2_gen((uint64_t)(((loc_idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
} /* end else */
#ifdef QAK
HDfprintf(stderr, "idx = %Hu, loc_idx = %Hu, eiter->max_sblk_idx = %u, idx_sblk_idx = %u, loc_sblk_idx = %u\n", idx, loc_idx, eiter->max_sblk_idx, idx_sblk_idx, loc_sblk_idx);
HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", idx_sblk_idx, tparam->sblk_info[idx_sblk_idx].ndblks, tparam->sblk_info[idx_sblk_idx].dblk_nelmts, tparam->sblk_info[idx_sblk_idx].start_idx, tparam->sblk_info[idx_sblk_idx].start_dblk);
HDfprintf(stderr, "tparam->sblk_info[%u] = {%Zu, %Zu, %Hu, %Hu}\n", eiter->max_sblk_idx, tparam->sblk_info[eiter->max_sblk_idx].ndblks, tparam->sblk_info[eiter->max_sblk_idx].dblk_nelmts, tparam->sblk_info[eiter->max_sblk_idx].start_idx, tparam->sblk_info[eiter->max_sblk_idx].start_dblk);
#endif /* QAK */
if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts)
idx_nelmts = (hsize_t)cparam->idx_blk_elmts;
else
idx_nelmts = EA_NELMTS(cparam, tparam, loc_idx, loc_sblk_idx);
state->nelmts = (eiter->max_nelmts - idx_nelmts) + cparam->idx_blk_elmts;
#ifdef QAK
HDfprintf(stderr, "eiter->max_nelmts = %Hu, idx_nelmts = %Hu, state->nelmts = %Hu\n", eiter->max_nelmts, idx_nelmts, state->nelmts);
#endif /* QAK */
if(idx < cparam->idx_blk_elmts + cparam->data_blk_min_elmts)
idx_ndata_blks = 0;
else
idx_ndata_blks = EA_NDATA_BLKS(cparam, tparam, loc_idx, loc_sblk_idx);
state->ndata_blks = eiter->max_ndata_blks - idx_ndata_blks;
#ifdef QAK
HDfprintf(stderr, "eiter->max_ndata_blks = %Hu, idx_ndata_blks = %Hu, state->ndata_blks = %Hu\n", eiter->max_ndata_blks, idx_ndata_blks, state->ndata_blks);
#endif /* QAK */
/* Check if we have any super blocks yet */
if(tparam->sblk_info[eiter->max_sblk_idx].ndblks >= cparam->sup_blk_min_data_ptrs) {
if(idx_sblk_idx > eiter->idx_blk_nsblks)
state->nsuper_blks = (eiter->max_sblk_idx - idx_sblk_idx) + 1;
else
state->nsuper_blks = (eiter->max_sblk_idx - eiter->idx_blk_nsblks) + 1;
#ifdef QAK
HDfprintf(stderr, "eiter->idx_blk_nsblks = %Hu, state->nsuper_blks = %Hu\n", eiter->idx_blk_nsblks, state->nsuper_blks);
#endif /* QAK */
} /* end if */
} /* end else */
return(0);
} /* end eiter_rv_state() */
/*-------------------------------------------------------------------------
* Function: eiter_rv_term
*
* Purpose: Shut down element interator (reverse iteration)
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Tuesday, November 4, 2008
*
*-------------------------------------------------------------------------
*/
static int
eiter_rv_term(void *eiter)
{
/* Sanity check */
HDassert(eiter);
/* Free iteration object */
HDfree(eiter);
return(0);
} /* end eiter_rv_term() */
/* Extensible array iterator class for reverse iteration */
static const earray_iter_t ea_iter_rv = {
eiter_rv_init, /* Iterator init */
eiter_rv_next, /* Next array index */
eiter_rv_max, /* Max. array index written */
eiter_rv_state, /* State of the extensible array */
eiter_rv_term /* Iterator term */
};
/* Extensible array iterator info for random iteration */
typedef struct eiter_rnd_t {
hsize_t max; /* Max. array index used */
hsize_t pos; /* Position in shuffled array */
hsize_t *idx; /* Array of shuffled indices */
} eiter_rnd_t;
/*-------------------------------------------------------------------------
* Function: eiter_rnd_init
*
* Purpose: Initialize element interator (random iteration)
*
* Return: Success: Pointer to iteration status object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Thursday, November 6, 2008
*
*-------------------------------------------------------------------------
*/
static void *
eiter_rnd_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam,
hsize_t cnt)
{
eiter_rnd_t *eiter; /* Random element iteration object */
size_t u; /* Local index variable */
/* Allocate space for the element iteration object */
eiter = (eiter_rnd_t *)HDmalloc(sizeof(eiter_rnd_t));
HDassert(eiter);
/* Allocate space for the array of shuffled indices */
eiter->idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)cnt);
HDassert(eiter->idx);
/* Initialize reverse iteration info */
eiter->max = 0;
eiter->pos = 0;
for(u = 0; u < (size_t)cnt; u++)
eiter->idx[u] = (hsize_t)u;
/* Randomly shuffle array indices */
if(cnt > 1) {
for(u = 0; u < (size_t)cnt; u++) {
size_t swap_idx; /* Location to swap with when shuffling */
hsize_t temp_idx; /* Temporary index */
swap_idx = ((size_t)HDrandom() % ((size_t)cnt - u)) + u;
temp_idx = eiter->idx[u];
eiter->idx[u] = eiter->idx[swap_idx];
eiter->idx[swap_idx] = temp_idx;
} /* end for */
} /* end if */
/* Return iteration object */
return(eiter);
} /* end eiter_rnd_init() */
/*-------------------------------------------------------------------------
* Function: eiter_rnd_next
*
* Purpose: Get next element index (random iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Thursday, November 6, 2008
*
*-------------------------------------------------------------------------
*/
static hssize_t
eiter_rnd_next(void *_eiter)
{
eiter_rnd_t *eiter = (eiter_rnd_t *)_eiter;
hssize_t ret_val;
/* Sanity check */
HDassert(eiter);
/* Get the next array index to test */
ret_val = (hssize_t)eiter->idx[eiter->pos];
eiter->pos++;
/* Check for new max. value */
if((hsize_t)ret_val > eiter->max)
eiter->max = (hsize_t)ret_val;
return(ret_val);
} /* end eiter_rnd_next() */
/*-------------------------------------------------------------------------
* Function: eiter_rnd_max
*
* Purpose: Get max. element index (random iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 6, 2008
*
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
eiter_rnd_max(const void *_eiter)
{
const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter;
/* Sanity check */
HDassert(eiter);
/* Return the max. array index used */
return((hssize_t)eiter->max);
} /* end eiter_rnd_max() */
/*-------------------------------------------------------------------------
* Function: eiter_rnd_term
*
* Purpose: Shut down element interator (random iteration)
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Tuesday, November 6, 2008
*
*-------------------------------------------------------------------------
*/
static int
eiter_rnd_term(void *_eiter)
{
eiter_rnd_t *eiter = (eiter_rnd_t *)_eiter;
/* Sanity check */
HDassert(eiter);
HDassert(eiter->idx);
/* Free shuffled index array */
HDfree(eiter->idx);
/* Free iteration object */
HDfree(eiter);
return(0);
} /* end eiter_rnd_term() */
/* Extensible array iterator class for random iteration */
static const earray_iter_t ea_iter_rnd = {
eiter_rnd_init, /* Iterator init */
eiter_rnd_next, /* Next array index */
eiter_rnd_max, /* Max. array index written */
NULL, /* State of the extensible array */
eiter_rnd_term /* Iterator term */
};
/*-------------------------------------------------------------------------
* Function: eiter_rnd2_init
*
* Purpose: Initialize element interator (random #2 iteration)
*
* Return: Success: Pointer to iteration status object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Thursday, November 11, 2008
*
*-------------------------------------------------------------------------
*/
static void *
eiter_rnd2_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam,
hsize_t cnt)
{
eiter_rnd_t *eiter; /* Random element iteration object */
size_t u; /* Local index variable */
/* Allocate space for the element iteration object */
eiter = (eiter_rnd_t *)HDmalloc(sizeof(eiter_rnd_t));
HDassert(eiter);
/* Allocate space for the array of shuffled indices */
eiter->idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)cnt);
HDassert(eiter->idx);
/* Initialize reverse iteration info */
eiter->max = 0;
eiter->pos = 0;
/* Randomly shuffle array indices */
if(cnt > 1) {
hsize_t *tmp_idx; /* Temporary index array */
hsize_t sparse_cnt = (hsize_t)(cnt * EA_RND2_SCALE); /* Sparse range to choose from */
/* Allocate temporary index array */
tmp_idx = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)sparse_cnt);
HDassert(tmp_idx);
/* Initialize temporary index array, for shuffling */
for(u = 0; u < (size_t)sparse_cnt; u++)
tmp_idx[u] = (hsize_t)u;
/* Shuffle index elements & store in final array */
for(u = 0; u < (size_t)cnt; u++) {
size_t swap_idx; /* Location to swap with when shuffling */
swap_idx = ((size_t)HDrandom() % ((size_t)sparse_cnt - u)) + u;
eiter->idx[u] = tmp_idx[swap_idx];
tmp_idx[swap_idx] = tmp_idx[u];
} /* end for */
/* Release temporary array */
HDfree(tmp_idx);
} /* end if */
else {
for(u = 0; u < (size_t)cnt; u++)
eiter->idx[u] = (hsize_t)u;
} /* end else */
/* Return iteration object */
return(eiter);
} /* end eiter_rnd2_init() */
/* Extensible array iterator class for random iteration */
static const earray_iter_t ea_iter_rnd2 = {
eiter_rnd2_init, /* Iterator init */
eiter_rnd_next, /* Next array index */
eiter_rnd_max, /* Max. array index written */
NULL, /* State of the extensible array */
eiter_rnd_term /* Iterator term */
};
/* Extensible array iterator info for cyclic iteration */
typedef struct eiter_cyc_t {
hsize_t max; /* Max. array index used */
hsize_t pos; /* Position in shuffled array */
hsize_t cnt; /* # of elements to store */
hsize_t cyc; /* Cycle of elements to choose from */
} eiter_cyc_t;
/*-------------------------------------------------------------------------
* Function: eiter_cyc_init
*
* Purpose: Initialize element interator (cyclic iteration)
*
* Return: Success: Pointer to iteration status object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Tuesday, November 11, 2008
*
*-------------------------------------------------------------------------
*/
static void *
eiter_cyc_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_param_t H5_ATTR_UNUSED *tparam,
hsize_t cnt)
{
eiter_cyc_t *eiter; /* Cyclic element iteration object */
/* Allocate space for the element iteration object */
eiter = (eiter_cyc_t *)HDmalloc(sizeof(eiter_cyc_t));
HDassert(eiter);
/* Initialize reverse iteration info */
eiter->max = 0;
eiter->pos = 0;
eiter->cnt = cnt;
eiter->cyc = 0;
/* Return iteration object */
return(eiter);
} /* end eiter_cyc_init() */
/*-------------------------------------------------------------------------
* Function: eiter_cyc_next
*
* Purpose: Get next element index (cyclic iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 11, 2008
*
*-------------------------------------------------------------------------
*/
static hssize_t
eiter_cyc_next(void *_eiter)
{
eiter_cyc_t *eiter = (eiter_cyc_t *)_eiter;
hssize_t ret_val;
/* Sanity check */
HDassert(eiter);
/* Get the next array index to test */
ret_val = (hssize_t)eiter->pos;
eiter->pos += EA_CYC_COUNT;
if(eiter->pos >= eiter->cnt)
eiter->pos = ++eiter->cyc;
/* Check for new max. value */
if((hsize_t)ret_val > eiter->max)
eiter->max = (hsize_t)ret_val;
return(ret_val);
} /* end eiter_cyc_next() */
/*-------------------------------------------------------------------------
* Function: eiter_cyc_max
*
* Purpose: Get max. element index (cyclic iteration)
*
* Return: Success: Non-negative
* Failure: Negative
*
* Programmer: Quincey Koziol
* Tuesday, November 11, 2008
*
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
eiter_cyc_max(const void *_eiter)
{
const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter;
/* Sanity check */
HDassert(eiter);
/* Return the max. array index used */
return((hssize_t)eiter->max);
} /* end eiter_cyc_max() */
/*-------------------------------------------------------------------------
* Function: eiter_cyc_term
*
* Purpose: Shut down element interator (cyclic iteration)
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Tuesday, November 11, 2008
*
*-------------------------------------------------------------------------
*/
static int
eiter_cyc_term(void *_eiter)
{
eiter_cyc_t *eiter = (eiter_cyc_t *)_eiter;
/* Sanity check */
HDassert(eiter);
/* Free iteration object */
HDfree(eiter);
return(0);
} /* end eiter_cyc_term() */
/* Extensible array iterator class for cyclic iteration */
static const earray_iter_t ea_iter_cyc = {
eiter_cyc_init, /* Iterator init */
eiter_cyc_next, /* Next array index */
eiter_cyc_max, /* Max. array index written */
NULL, /* State of the extensible array */
eiter_cyc_term /* Iterator term */
};
/*-------------------------------------------------------------------------
* Function: test_set_elmts
*
* Purpose: Set all elements from 0 through 'nelmts' in extensible array
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Thursday, September 22, 2008
*
*-------------------------------------------------------------------------
*/
static unsigned
test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
hsize_t nelmts, const char *test_str)
{
hid_t file = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
void *eiter_info; /* Extensible array iterator info */
earray_state_t state; /* State of extensible array */
uint64_t welmt; /* Element to write */
uint64_t relmt; /* Element to read */
hsize_t nelmts_written; /* Highest element written in array */
hsize_t cnt; /* Count of array indices */
hssize_t smax; /* Index value of max. element set */
hsize_t max; /* Index value of max. element set */
hssize_t sidx; /* Index value of first element of first data block */
hsize_t idx; /* Index value of first element of first data block */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/*
* Display testing message
*/
TESTING(test_str);
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/* Create array */
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, NULL) < 0)
TEST_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
/* Check for closing & re-opening the file */
if(reopen_file(&file, &f, fapl, H5AC_ind_read_dxpl_id, &ea, ea_addr, tparam) < 0)
TEST_ERROR
/* Verify high-water # of elements written */
nelmts_written = (hsize_t)ULLONG_MAX;
if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
FAIL_STACK_ERROR
if(nelmts_written != 0)
TEST_ERROR
/* Verify array state */
HDmemset(&state, 0, sizeof(state));
state.hdr_size = EA_HDR_SIZE;
if(check_stats(ea, &state))
TEST_ERROR
/* Get all elements from empty array */
/* Initialize iterator */
if(NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts)))
TEST_ERROR
/* Get elements of array */
for(cnt = 0; cnt < nelmts; cnt++) {
/* Get the array index */
if((sidx = tparam->eiter->next(eiter_info)) < 0)
TEST_ERROR
idx = (hsize_t)sidx;
/* Retrieve element of array (not set yet) */
relmt = (uint64_t)0;
if(H5EA_get(ea, H5AC_ind_read_dxpl_id, idx, &relmt) < 0)
FAIL_STACK_ERROR
/* Verify element is fill value for array */
if(relmt != H5EA_TEST_FILL)
TEST_ERROR
} /* end for */
/* Shutdown iterator */
if(tparam->eiter->term(eiter_info) < 0)
TEST_ERROR
/* Set (& get) all elements from empty array */
/* Initialize iterator */
if(NULL == (eiter_info = tparam->eiter->init(cparam, tparam, nelmts)))
TEST_ERROR
/* Set elements of array */
for(cnt = 0; cnt < nelmts; cnt++) {
/* Get the array index */
if((sidx = tparam->eiter->next(eiter_info)) < 0)
TEST_ERROR
idx = (hsize_t)sidx;
/* Retrieve element of array (not set yet) */
relmt = (uint64_t)0;
if(H5EA_get(ea, H5AC_ind_read_dxpl_id, idx, &relmt) < 0)
FAIL_STACK_ERROR
/* Verify element is fill value for array */
if(relmt != H5EA_TEST_FILL)
TEST_ERROR
/* Set element of array */
welmt = (uint64_t)7 + idx;
if(H5EA_set(ea, H5AC_ind_read_dxpl_id, idx, &welmt) < 0)
FAIL_STACK_ERROR
/* Get the max. array index */
if((smax = tparam->eiter->max_elem(eiter_info)) < 0)
TEST_ERROR
max = (hsize_t)smax;
/* Verify high-water # of elements written */
nelmts_written = (hsize_t)ULLONG_MAX;
if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
FAIL_STACK_ERROR
if(nelmts_written != (max + 1))
TEST_ERROR
/* Check if array state is available */
if(tparam->eiter->state) {
/* Get the extensible array state */
if(tparam->eiter->state(eiter_info, cparam, tparam, &state, idx) < 0)
TEST_ERROR
/* Verify array state */
if(check_stats(ea, &state))
TEST_ERROR
} /* end if */
/* Retrieve element of array (set now) */
relmt = (uint64_t)0;
if(H5EA_get(ea, H5AC_ind_read_dxpl_id, idx, &relmt) < 0)
FAIL_STACK_ERROR
/* Verify element is value written */
if(relmt != welmt)
TEST_ERROR
} /* end for */
/* Shutdown iterator */
if(tparam->eiter->term(eiter_info) < 0)
TEST_ERROR
/* Close array, delete array, close file & verify file is empty */
if(finish(file, fapl, f, ea, ea_addr) < 0)
TEST_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
H5Fclose(file);
} H5E_END_TRY;
return 1;
} /* test_set_elmts() */
/*-------------------------------------------------------------------------
* Function: test_skip_elmts
*
* Purpose: Skip some elements when writing element
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, November 11, 2008
*
*-------------------------------------------------------------------------
*/
static unsigned
test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam,
hsize_t skip_elmts, const char *test_str)
{
hid_t file = -1; /* File ID */
H5F_t *f = NULL; /* Internal file object pointer */
H5EA_t *ea = NULL; /* Extensible array wrapper */
earray_state_t state; /* State of extensible array */
uint64_t welmt; /* Element to write */
uint64_t relmt; /* Element to read */
hsize_t nelmts_written; /* Highest element written in array */
hsize_t idx; /* Index value of element to get */
hsize_t cnt; /* Count of array indices */
haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */
/*
* Display testing message
*/
TESTING(test_str);
/* Create file & retrieve pointer to internal file object */
if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0)
TEST_ERROR
/* Create array */
if(create_array(f, H5AC_ind_read_dxpl_id, cparam, &ea, &ea_addr, NULL) < 0)
TEST_ERROR
/* Verify the creation parameters */
if(verify_cparam(ea, cparam) < 0)
TEST_ERROR
/* Check for closing & re-opening the file */
if(reopen_file(&file, &f, fapl, H5AC_ind_read_dxpl_id, &ea, ea_addr, tparam) < 0)
TEST_ERROR
/* Verify high-water # of elements written */
nelmts_written = (hsize_t)ULLONG_MAX;
if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
FAIL_STACK_ERROR
if(nelmts_written != 0)
TEST_ERROR
/* Verify array state */
HDmemset(&state, 0, sizeof(state));
state.hdr_size = EA_HDR_SIZE;
if(check_stats(ea, &state))
TEST_ERROR
/* Set (& get) element after skipping elements */
idx = skip_elmts;
/* Retrieve element of array (not set yet) */
relmt = (uint64_t)0;
if(H5EA_get(ea, H5AC_ind_read_dxpl_id, idx, &relmt) < 0)
FAIL_STACK_ERROR
/* Verify element is fill value for array */
if(relmt != H5EA_TEST_FILL)
TEST_ERROR
/* Set element of array */
welmt = (uint64_t)7 + idx;
if(H5EA_set(ea, H5AC_ind_read_dxpl_id, idx, &welmt) < 0)
FAIL_STACK_ERROR
/* Verify high-water # of elements written */
nelmts_written = (hsize_t)ULLONG_MAX;
if(H5EA_get_nelmts(ea, &nelmts_written) < 0)
FAIL_STACK_ERROR
if(nelmts_written != (idx + 1))
TEST_ERROR
/* Set array state */
HDmemset(&state, 0, sizeof(state));
state.hdr_size = EA_HDR_SIZE;
state.nindex_blks = 1;
state.index_blk_size = EA_IBLOCK_SIZE;
state.max_idx_set = idx + 1;
if(1 == skip_elmts) {
state.nelmts = (hsize_t)cparam->idx_blk_elmts;
state.nsuper_blks = state.ndata_blks = (hsize_t)0;
} /* end if */
else if(cparam->idx_blk_elmts == skip_elmts) {
state.nelmts = (hsize_t)cparam->idx_blk_elmts + cparam->data_blk_min_elmts;
state.ndata_blks = (hsize_t)1;
state.nsuper_blks = (hsize_t)0;
} /* end if */
else {
unsigned sblk_idx; /* Which superblock does this index fall in? */
/* Compute super block index for element index */
/* (same eqn. as in H5EA__dblock_sblk_idx()) */
sblk_idx = H5VM_log2_gen((uint64_t)(((idx - cparam->idx_blk_elmts) / cparam->data_blk_min_elmts) + 1));
state.nelmts = (hsize_t)cparam->idx_blk_elmts + tparam->sblk_info[sblk_idx].dblk_nelmts;
state.ndata_blks = (hsize_t)1;
state.nsuper_blks = (hsize_t)1;
} /* end if */
/* Verify array state */
if(check_stats(ea, &state))
TEST_ERROR
/* Retrieve element of array (set now) */
relmt = (uint64_t)0;
if(H5EA_get(ea, H5AC_ind_read_dxpl_id, idx, &relmt) < 0)
FAIL_STACK_ERROR
/* Verify element is value written */
if(relmt != welmt)
TEST_ERROR
/* Get unset elements of array */
for(cnt = 0; cnt < skip_elmts; cnt++) {
/* Retrieve element of array (not set yet) */
relmt = (uint64_t)0;
if(H5EA_get(ea, H5AC_ind_read_dxpl_id, cnt, &relmt) < 0)
FAIL_STACK_ERROR
/* Verify element is fill value for array */
if(relmt != H5EA_TEST_FILL)
TEST_ERROR
} /* end for */
/* Close array, delete array, close file & verify file is empty */
if(finish(file, fapl, f, ea, ea_addr) < 0)
TEST_ERROR
/* All tests passed */
PASSED()
return 0;
error:
H5E_BEGIN_TRY {
if(ea)
H5EA_close(ea, H5AC_ind_read_dxpl_id);
H5Fclose(file);
} H5E_END_TRY;
return 1;
} /* test_skip_elmts() */
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Test the extensible array code
*
* Return: Success: 0
* Failure: 1
*
* Programmer: Quincey Koziol
* Tuesday, June 17, 2008
*
*-------------------------------------------------------------------------
*/
int
main(void)
{
H5EA_create_t cparam; /* Creation parameters for extensible array */
earray_test_param_t tparam; /* Testing parameters */
earray_test_type_t curr_test; /* Current test being worked on */
earray_iter_type_t curr_iter; /* Current iteration type being worked on */
hid_t fapl = -1; /* File access property list for data files */
unsigned nerrors = 0; /* Cumulative error count */
time_t curr_time; /* Current time, for seeding random number generator */
int ExpressMode; /* Test express value */
/* Reset library */
h5_reset();
fapl = h5_fileaccess();
ExpressMode = GetTestExpress();
if(ExpressMode > 1)
printf("***Express test mode on. Some tests may be skipped\n");
/* Set the filename to use for this test (dependent on fapl) */
h5_fixname(FILENAME[0], fapl, filename_g, sizeof(filename_g));
/* Seed random #'s */
curr_time = HDtime(NULL);
HDsrandom((unsigned)curr_time);
/* Create an empty file to retrieve size */
{
hid_t file; /* File ID */
if((file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
/* Close file */
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
/* Get the size of a file w/no array */
if((empty_size_g = h5_get_file_size(filename_g, fapl)) < 0)
TEST_ERROR
}
/* Initialize extensible array creation parameters */
init_cparam(&cparam);
/* Iterate over the testing parameters */
for(curr_test = EARRAY_TEST_NORMAL; curr_test < EARRAY_TEST_NTESTS; H5_INC_ENUM(earray_test_type_t, curr_test)) {
/* Initialize the testing parameters */
init_tparam(&tparam, &cparam);
/* Set appropriate testing parameters for each test */
switch(curr_test) {
/* "Normal" testing parameters */
case EARRAY_TEST_NORMAL:
puts("Testing with normal parameters");
break;
/* "Re-open array" testing parameters */
case EARRAY_TEST_REOPEN:
puts("Testing with reopen array flag set");
tparam.reopen_array = EARRAY_TEST_REOPEN;
break;
/* An unknown test? */
case EARRAY_TEST_NTESTS:
default:
goto error;
} /* end switch */
/* Basic capability tests */
nerrors += test_create(fapl, &cparam, &tparam);
nerrors += test_reopen(fapl, &cparam, &tparam);
nerrors += test_open_twice(fapl, &cparam, &tparam);
nerrors += test_open_twice_diff(fapl, &cparam, &tparam);
nerrors += test_delete_open(fapl, &cparam, &tparam);
nerrors += test_flush_depend(fapl, &cparam, &tparam);
/* Iterate over the type of capacity tests */
for(curr_iter = EARRAY_ITER_FW; curr_iter < EARRAY_ITER_NITERS; H5_INC_ENUM(earray_iter_type_t, curr_iter)) {
hsize_t sblk; /* Super block index */
hsize_t dblk; /* Data block index */
hsize_t nelmts; /* # of elements to test */
char test_str[128]; /* String for describing test */
hsize_t ndblks; /* # of data blocks tested */
/* Set appropriate parameters for each type of iteration */
switch(curr_iter) {
/* "Forward" testing parameters */
case EARRAY_ITER_FW:
puts("Testing with forward iteration");
tparam.eiter = &ea_iter_fw;
break;
/* "Reverse" testing parameters */
case EARRAY_ITER_RV:
puts("Testing with reverse iteration");
tparam.eiter = &ea_iter_rv;
break;
/* "Random" testing parameters */
case EARRAY_ITER_RND:
puts("Testing with random iteration");
tparam.eiter = &ea_iter_rnd;
break;
/* "Random #2" testing parameters */
case EARRAY_ITER_RND2:
puts("Testing with random #2 iteration");
tparam.eiter = &ea_iter_rnd2;
break;
/* "Cyclic" testing parameters */
case EARRAY_ITER_CYC:
puts("Testing with cyclic iteration");
tparam.eiter = &ea_iter_cyc;
break;
/* An unknown iteration? */
case EARRAY_ITER_NITERS:
default:
goto error;
} /* end switch */
/* Basic capacity tests */
nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)1, "setting first element of array");
nerrors += test_set_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, "setting index block elements of array");
/* Super Block capacity tests */
ndblks = 0;
for(sblk = 0; sblk < 9; sblk++) {
for(dblk = 0; dblk < tparam.sblk_info[sblk].ndblks; dblk ++) {
/* Test first element in data block */
nelmts = (hsize_t)((hsize_t)1 + cparam.idx_blk_elmts +
tparam.sblk_info[sblk].start_idx +
(tparam.sblk_info[sblk].dblk_nelmts * dblk));
sprintf(test_str, "setting first element of array's data block #%llu", (unsigned long long)ndblks);
nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str);
/* Test all elements in data block */
nelmts = (hsize_t)(cparam.idx_blk_elmts +
tparam.sblk_info[sblk].start_idx +
(tparam.sblk_info[sblk].dblk_nelmts * (dblk + 1)));
sprintf(test_str, "setting all elements of array's data block #%llu", (unsigned long long)ndblks);
nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str);
/* Increment data block being tested */
ndblks++;
} /* end for */
} /* end for */
} /* end for */
/* Check skipping elements */
nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)1, "skipping 1st element");
nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)cparam.idx_blk_elmts, "skipping index block elements");
nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (15 * cparam.data_blk_min_elmts) + 1), "skipping index block & data block elements");
nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (31 * cparam.data_blk_min_elmts) + 1), "skipping 1st super block elements");
nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (63 * cparam.data_blk_min_elmts) + 1), "skipping 2nd super block elements");
nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (127 * cparam.data_blk_min_elmts) + 1), "skipping 3rd super block elements");
nerrors += test_skip_elmts(fapl, &cparam, &tparam, (hsize_t)(cparam.idx_blk_elmts + (255 * cparam.data_blk_min_elmts) + 1), "skipping 4th super block elements");
/* Close down testing parameters */
finish_tparam(&tparam);
} /* end for */
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
if(nerrors)
goto error;
puts("All extensible array tests passed.");
/* Clean up file used */
h5_cleanup(FILENAME, fapl);
return 0;
error:
puts("*** TESTS FAILED ***");
H5E_BEGIN_TRY {
H5Pclose(fapl);
} H5E_END_TRY;
return 1;
} /* end main() */
|