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 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF. The full HDF copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
*
* Vset tests
*
*
* This file needs another pass at making sure all the return
* values from function calls are checked in addition to
* verifying that the proper tests are performed on all Vxx fcns - GV 9/5/97
*
*/
#include "hdf.h"
#include "hfile_priv.h"
#include "tproto.h"
#define VDATA_COUNT 256 /* make this many Vdatas to check for memory leaks */
#define FNAME0 "tvset.hdf"
#define EXTFNM "tvsetext.hdf"
#define EMPTYNM "tvsempty.hdf"
#define LONGNAMES "tlongnames.hdf"
#define LKBLK_FILE "tvsblkinfo.hdf"
#define FIELD1 "FIELD_name_HERE"
#define FIELD1_UPPER "FIELD_NAME_HERE"
#define FIELD2 "DIFFERENT_FIELD_NAME"
#define FIELD1_NAME "Field1" /* contains three integers */
#define FIELD2_NAME "Field2" /* contains one integer */
#define FIELD3_NAME "Field3" /* contains two integers */
#define FIELD_NAME_LIST "Field1,Field2,Field3"
#define ORDER_1 3 /* order of first field of 1st vdata */
#define ORDER_2 1 /* order of second field of 1st vdata */
#define ORDER_3 2 /* order of third field of 1st vdata */
#define ST "STATION_NAME"
#define VL "VALUES"
#define FL "FLOATS"
#define MX "STATION_NAME,VALUES,FLOATS"
#define EMPTY_VDATA "Empty"
#define VGROUP1 "VGROUP1"
#define VG_LONGNAME "Vgroup with more than 64 characters in length, 74 characters to be exact!"
#define VG_LONGCLASS "Very long class name to classify all Vgroups with more than 64 characters in name"
#define APPENDABLE_VDATA "Appendable"
static int32 write_vset_stuff(void);
static int32 read_vset_stuff(void);
static void test_vsdelete(void);
static void test_vdelete(void);
static void test_vdeletetagref(void);
static void test_emptyvdata(void);
static void test_vglongnames(void);
static void test_getvgroups(void);
static void test_getvdatas(void);
static void test_blockinfo_oneLB(void);
static void test_blockinfo_multLBs(void);
static void test_VSofclass(void);
/* write some stuff to the file */
static int32
write_vset_stuff(void)
{
int32 status;
int32 fid, aid;
int32 vg1, vg2;
int32 vs1;
int32 count, i, j, num, max_order;
int32 ibuf[2000]; /* integer buffer */
float32 fbuf[2000]; /* floating point buffer */
char gbuf[2000]; /* generic buffer */
uint8 *gbuf1 = NULL; /* buffer for uint8 */
float32 *gbuf2 = NULL; /* buffer for float32 */
const char *name;
char *p;
char8 c;
float32 f;
/* allocate these buffers dynamically and not off the stack
as they were previously handled */
if (gbuf1 == NULL) {
gbuf1 = (uint8 *)malloc(sizeof(uint8) * 65536);
}
if (gbuf2 == NULL) {
gbuf2 = (float32 *)malloc(sizeof(float32) * 20000);
}
fid = Hopen(FNAME0, DFACC_CREATE, 100);
if (fid == FAIL) {
num_errs++;
return FAIL;
}
if (Vstart(fid) == FAIL) {
num_errs++;
return FAIL;
}
/*
* Vgroup Generation routines
*
*/
/*
* start simple --- create a simple Vgroup
*/
vg1 = Vattach(fid, -1, "w");
if (vg1 == FAIL) {
num_errs++;
printf(">>> Failed creating initial Vgroup\n");
}
status = Vsetname(vg1, "Simple Vgroup");
CHECK(status, FAIL, "Vsetname:vg1");
status = Vsetclass(vg1, "Test object");
CHECK(status, FAIL, "Vsetclass:vg1");
MESSAGE(5, printf("created Vgroup %s (empty)\n", "Simple Vgroup"););
/*
* Lets do some more complex ones now
*/
vg2 = Vattach(fid, -1, "w");
if (vg2 == FAIL) {
num_errs++;
printf(">>> Failed creating second Vgroup\n");
}
/* keep track of how many in Vgroup */
num = 0;
/* add first group into the other */
status = Vinsert(vg2, vg1);
if (status == FAIL) {
num_errs++;
printf(">>> Vinsert failed\n");
}
else
num++;
/* add a bogus element */
status = Vaddtagref(vg2, (int32)1000, (int32)12345);
if (status == FAIL) {
num_errs++;
printf(">>> Vaddtagref failed for bogus element\n");
}
else
num++;
/* create an element and insert that */
aid = Hstartwrite(fid, (uint16)123, (uint16)1234, 10);
if (aid == FAIL) {
num_errs++;
printf(">>> Hstartwrite failed\n");
}
status = Hendaccess(aid);
CHECK(status, FAIL, "Hendaccess:aid");
/* add an existing HDF element */
status = Vaddtagref(vg2, (int32)123, (int32)1234);
if (status == FAIL) {
num_errs++;
printf(">>> Vaddtagref failed for legit element\n");
}
else
num++;
#ifdef NO_DUPLICATES
/* attempt to add an element already in the Vgroup */
status = Vaddtagref(vg2, (int32)123, (int32)1234);
if (status != FAIL) {
num_errs++;
printf(">>> Vaddtagref added a duplicate element\n");
}
/* check that the number is correct */
if (num != Vntagrefs(vg2)) {
num_errs++;
printf(">>> Vntagrefs returned %d was expecting %d\n", Vntagrefs(vg2), num);
}
#endif /* NO_DUPLICATES */
/* lets check the contents */
/* look for a valid one first */
if (Vinqtagref(vg2, 1000, 12345) == FALSE) {
num_errs++;
printf(">>> Vinqtagref couldn't find valid element\n");
}
/* look for a bogus one */
if (Vinqtagref(vg2, 1000, 123456) != FALSE) {
num_errs++;
printf(">>> Vinqtagref found a bogus element\n");
}
status = Vsetname(vg2, "Second Vgroup");
CHECK(status, FAIL, "Vsetname:for vg2");
Vsetclass(vg2, "Test object");
CHECK(status, FAIL, "Vsetclass: for vg2");
status = Vdetach(vg1);
CHECK(status, FAIL, "Vdetach:vg1");
status = Vdetach(vg2);
CHECK(status, FAIL, "Vdetach:vg2");
MESSAGE(5, printf("created Vgroup %s with %d elements\n", "Second Vgroup", (int)num););
/*
* Vdata Generation routines
*
*/
/* Float32 Vdata */
vs1 = VSattach(fid, -1, "w");
CHECK(vs1, FAIL, "VSattach");
name = "Float Vdata";
status = VSsetname(vs1, name);
CHECK(status, FAIL, "VSsetname");
status = VSsetclass(vs1, "Test object");
CHECK(status, FAIL, "VSsetclass");
status = VSfdefine(vs1, FIELD1, DFNT_FLOAT32, 1);
CHECK(status, FAIL, "VSfdefine");
/* Verify that VSsetfields will return FAIL when passing in a NULL
for field name list (bug #554) - BMR 5/17/01 */
status = VSsetfields(vs1, NULL);
VERIFY(status, FAIL, "VSsetfields");
status = VSsetfields(vs1, FIELD1);
if (status == FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
/* create some bogus data */
for (i = 0, count = 100; i < count; i++)
fbuf[i] = (float32)i;
/* store it */
status = VSwrite(vs1, (unsigned char *)fbuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSwrite:vs1");
/* Test VSgetexternalfile on a vdata without external element */
/* status = VSgetexternalfile(vs1, 0, NULL, NULL);
VERIFY_VOID(status, FAIL, "VSgetexternalfile");
*/
/* Test VSgetexternalinfo on a vdata without external element */
status = VSgetexternalinfo(vs1, 0, NULL, NULL, NULL);
VERIFY(status, 0, "VSgetexternalinfo");
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
MESSAGE(5, printf("created VDATA %s with %d elements\n", name, (int)count););
/* Int32 Vdata */
vs1 = VSattach(fid, -1, "w");
CHECK(vs1, FAIL, "VSattach:vs1");
name = "Integer Vdata";
status = VSsetname(vs1, name);
CHECK(status, FAIL, "VSsetname:vs1");
status = VSsetclass(vs1, "Test object");
CHECK(status, FAIL, "VSsetclass:vs1");
status = VSfdefine(vs1, FIELD2, DFNT_INT32, 2);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSsetfields(vs1, FIELD2);
if (status == FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
/* change this vdata to store in an external file */
status = VSsetexternalfile(vs1, EXTFNM, (int32)0);
if (status == FAIL) {
num_errs++;
printf(">>> VSsetexternalfile failed\n");
}
/* create some bogus data */
for (i = 0, count = 100; i < 2 * count; i++)
ibuf[i] = i;
/* store it */
status = VSwrite(vs1, (unsigned char *)ibuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSwrite:vs1");
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
MESSAGE(5, printf("created VDATA %s with %d elements\n", name, (int)count););
/* Int32 and Float32 Vdata */
vs1 = VSattach(fid, -1, "w");
CHECK(vs1, FAIL, "VSattach:vs1");
name = "Mixed Vdata";
status = VSsetname(vs1, name);
CHECK(status, FAIL, "VSsetname:vs1");
status = VSsetclass(vs1, "No class specified");
CHECK(status, FAIL, "VSsetclass:vs1");
status = VSfdefine(vs1, "A", DFNT_FLOAT32, 1);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSfdefine(vs1, "B", DFNT_INT32, 1);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSsetfields(vs1, "A, B");
if (status == FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
/* create some bogus data */
p = gbuf;
for (i = 0, count = 100; i < count; i++) {
float32 tf = (float32)(i * 2);
memcpy(p, &tf, sizeof(float32));
p += sizeof(float32);
memcpy(p, &i, sizeof(int32));
p += sizeof(int32);
}
/* store it */
status = VSwrite(vs1, (unsigned char *)gbuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSwrite:vs1");
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
MESSAGE(5, printf("created VDATA %s with %d elements\n", name, (int)count););
/* mixed order Vdata */
vs1 = VSattach(fid, -1, "w");
CHECK(vs1, FAIL, "VSattach:vs1");
name = "Multi-Order Vdata";
status = VSsetname(vs1, name);
CHECK(status, FAIL, "VSsetname:vs1");
status = VSsetclass(vs1, "No class specified");
CHECK(status, FAIL, "VSsetclass:vs1");
status = VSfdefine(vs1, ST, DFNT_CHAR8, 2);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSfdefine(vs1, VL, DFNT_INT32, 3);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSfdefine(vs1, FL, DFNT_FLOAT32, 1);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSsetfields(vs1, MX);
if (status == FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
/* create some bogus data */
p = gbuf;
c = 'a';
j = 0;
f = (float32)15.5;
for (i = 0, count = 10; i < count; i++) {
memcpy(p, &c, sizeof(char8));
p += sizeof(char8);
c++;
memcpy(p, &c, sizeof(char8));
p += sizeof(char8);
c++;
memcpy(p, &j, sizeof(int32));
p += sizeof(int32);
j++;
memcpy(p, &j, sizeof(int32));
p += sizeof(int32);
j++;
memcpy(p, &j, sizeof(int32));
p += sizeof(int32);
j++;
memcpy(p, &f, sizeof(float32));
p += sizeof(float32);
f += (float32)0.5;
}
/* store it */
status = VSwrite(vs1, (unsigned char *)gbuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSwrite:vs1");
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
MESSAGE(5, printf("created VDATA %s with %d elements\n", name, (int)count););
/* test MAX_ORDER and MAX_FIELD_SIZE */
vs1 = VSattach(fid, -1, "w");
CHECK(vs1, FAIL, "VSattach:vs1");
name = "Max_Order Vdata";
status = VSsetname(vs1, name);
CHECK(status, FAIL, "VSsetname:vs1");
status = VSfdefine(vs1, "max_order", DFNT_UINT8, MAX_ORDER);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSsetfields(vs1, "max_order");
if (status == FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
/* create some bogus data */
for (i = 0; i < MAX_ORDER; i++)
gbuf1[i] = (uint8)(i % 256);
status = VSwrite(vs1, (unsigned char *)gbuf1, 1, FULL_INTERLACE);
CHECK(status, FAIL, "VSwrite:vs1");
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
MESSAGE(5, printf("created VDATA %s with %d order\n", name, (int)MAX_ORDER););
vs1 = VSattach(fid, -1, "w");
CHECK(vs1, FAIL, "VSattach:vs1");
name = "Max_Fldsize Vdata";
status = VSsetname(vs1, name);
CHECK(status, FAIL, "VSsetname:vs1");
max_order = MAX_FIELD_SIZE / SIZE_FLOAT32;
status = VSfdefine(vs1, "max_fldsize", DFNT_FLOAT32, max_order);
CHECK(status, FAIL, "VSfdefine:vs1");
status = VSsetfields(vs1, "max_fldsize");
if (status == FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
/* create some bogus data */
for (i = 0; i < max_order; i++)
gbuf2[i] = (float32)i * (float32)0.11;
status = VSwrite(vs1, (unsigned char *)gbuf2, 1, FULL_INTERLACE);
CHECK(status, FAIL, "VSwrite:vs1");
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
MESSAGE(5, printf("created VDATA %s with %d order\n", name, (int)max_order););
/* create vdata exceeding MAX_FIELD_SIZE, should fail */
vs1 = VSattach(fid, -1, "w");
CHECK(vs1, FAIL, "VSattach:vs1");
name = "Bad_Fldsize Vdata";
status = VSsetname(vs1, name);
CHECK(status, FAIL, "VSsetname:vs1");
max_order = MAX_FIELD_SIZE / SIZE_FLOAT32 + 1;
status = VSfdefine(vs1, "bad_fldsize", DFNT_FLOAT32, max_order);
if (status != FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
status = VSsetfields(vs1, "bad_fldsize");
if (status != FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", name);
}
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
/* create a whole bunch of Vdatas to check for memory leakage */
for (i = 0; i < VDATA_COUNT; i++) {
char name2[80];
vs1 = VSattach(fid, -1, "w");
if (vs1 == FAIL) {
num_errs++;
printf(">>> Vsattach failed on loop %d\n", (int)i);
continue;
}
sprintf(name2, "VdataLoop-%d", (int)i);
status = VSsetname(vs1, name2);
CHECK(status, FAIL, "VSsetname:vs1");
status = VSfdefine(vs1, "A", DFNT_CHAR8, 1);
if (status == FAIL) {
num_errs++;
printf(">>> VSfdefine failed on loop %d\n", (int)i);
continue;
}
status = VSsetfields(vs1, "A");
if (status == FAIL) {
num_errs++;
printf(">>> VSsetfields failed on loop %d\n", (int)i);
continue;
}
status = VSwrite(vs1, (unsigned char *)name2, 1, FULL_INTERLACE);
CHECK(status, FAIL, "VSwrite:vs1");
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
}
status = Vend(fid);
CHECK(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK(status, FAIL, "Hclose:vs1");
free(gbuf1);
free(gbuf2);
return SUCCEED;
} /* write_vset_stuff */
/* read everything back in and check it */
static int32
read_vset_stuff(void)
{
int32 ibuf[2000]; /* integer buffer */
float32 fbuf[2000]; /* floating point buffer */
char gbuf[2000]; /* generic buffer */
int32 list[50];
int32 tags[100], refs[100], tag, ref;
char vsname[512], vsclass[512], fields[512];
char *vgname, *vgclass;
char *p;
int32 fid;
int32 vg1;
int32 vs1;
int32 status, num, i, count, intr, sz;
float32 fl_expected;
int32 in_expected;
char8 c_expected;
uint16 name_len;
fid = Hopen(FNAME0, DFACC_RDONLY, 0);
if (fid == FAIL) {
num_errs++;
return FAIL;
}
status = Vstart(fid);
CHECK(status, FAIL, "Vstart:fid");
/*
* Verify the Vgroups
*/
/* test Vlone */
num = 1;
status = Vlone(fid, list, 10);
if (status != num) {
num_errs++;
printf(">>> Vlone found %d was expecting %d\n", (int)status, (int)num);
}
/* test Vgetname and Vgetclass */
vg1 = Vattach(fid, list[0], "r");
if (vg1 == FAIL) {
num_errs++;
printf(">>> Was not able to attach (r) Vgroup %d\n", (int)list[0]);
}
status = Vgetnamelen(vg1, &name_len);
CHECK(status, FAIL, "Vgetnamelen:vg1");
vgname = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(vgname, "vgname", "read_vset_stuff");
status = Vgetname(vg1, vgname);
CHECK(status, FAIL, "Vgetname:vg1");
status = Vgetclassnamelen(vg1, &name_len);
CHECK(status, FAIL, "Vgetclassnamelen:vg1");
vgclass = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(vgclass, "vgclass", "read_vset_stuff");
status = Vgetclass(vg1, vgclass);
CHECK(status, FAIL, "Vgetclass:vg1");
if (strcmp(vgname, "Second Vgroup")) {
num_errs++;
printf(">>> Got bogus Vgroup name : %s\n", vgname);
}
free(vgname);
if (strcmp(vgclass, "Test object")) {
num_errs++;
printf(">>> Got bogus Vgroup class : %s\n", vgclass);
}
free(vgclass);
num = 3;
status = Vgettagrefs(vg1, tags, refs, 100);
if (status == FAIL) {
num_errs++;
printf(">>> Vgettagrefs found %d was expecting %d\n", (int)status, (int)num);
}
for (i = 0; i < num; i++) {
status = Vgettagref(vg1, i, &tag, &ref);
if (status == FAIL) {
num_errs++;
printf(">>> Vgettagref failed on call %d\n", (int)i);
}
if (tag != tags[i]) {
num_errs++;
printf(">>> Vgettagref Tag #%d disagrees %d %d\n", (int)i, (int)tag, (int)tags[i]);
}
if (ref != refs[i]) {
num_errs++;
printf(">>> Vgettagref Ref #%d disagrees %d %d\n", (int)i, (int)ref, (int)refs[i]);
}
}
status = Vdetach(vg1);
CHECK(status, FAIL, "Vdetach:vg1");
/* test Vgetid */
ref = Vgetid(fid, -1);
if (ref == FAIL) {
num_errs++;
printf(">>> Vgetid was unable to find first Vgroup\n");
}
ref = Vgetid(fid, ref);
if (ref != list[0]) {
num_errs++;
printf(">>> Vgetid was unable to find second Vgroup (should have been first lone one)\n");
}
/*
* Verify the Vdatas
*
*/
/* test VSgetid */
ref = VSgetid(fid, -1);
if (ref == FAIL) {
num_errs++;
printf(">>> VSgetid was unable to find first Vdata\n");
}
/* read in the first data and verify metadata and contents */
vs1 = VSattach(fid, ref, "r");
CHECK(vs1, FAIL, "VSattach:vs1");
status = VSgetname(vs1, vsname);
CHECK(status, FAIL, "VSgetname:vs1");
status = VSgetclass(vs1, vsclass);
CHECK(status, FAIL, "VSgetclass:vs1");
if (strcmp(vsname, "Float Vdata")) {
num_errs++;
printf(">>> Got bogus Vdata name (VSgetname) : %s\n", vsname);
}
if (strcmp(vsclass, "Test object")) {
num_errs++;
printf(">>> Got bogus Vdata class : %s\n", vsclass);
}
status = VSinquire(vs1, &count, &intr, fields, &sz, vsname);
if (status == FAIL) {
num_errs++;
printf(">>> VSinquire failed on float Vdata\n");
}
if (strcmp(vsname, "Float Vdata")) {
num_errs++;
printf(">>> Got bogus Float Vdata name (VSinquire) : %s\n", vsname);
}
if (count != 100) {
num_errs++;
printf(">>> Got wrong count %d expecting 100\n", (int)count);
}
if ((size_t)sz != sizeof(float32)) {
num_errs++;
printf(">>> Got wrong data size %d should be sizeof(float32)\n", (int)sz);
}
#ifndef VDATA_FIELDS_ALL_UPPER
if (strcmp(fields, FIELD1)) {
num_errs++;
printf(">>> Got bogus field name %s\n", fields);
}
#else
if (strcmp(fields, FIELD1_UPPER)) {
num_errs++;
printf(">>> Got bogus field name %s\n", fields);
}
#endif /* VDATA_FIELDS_ALL_UPPER */
/* read it */
status = VSsetfields(vs1, fields);
CHECK(status, FAIL, "VSsetfields:vs1");
for (i = 0; i < count; i++)
fbuf[i] = 0.0F;
status = VSread(vs1, (unsigned char *)fbuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSread:vs1");
/* verify */
for (i = 0; i < count; i++) {
if (!H4_FLT_ABS_EQUAL(fbuf[i], (float32)i)) {
num_errs++;
printf(">>> Float value %d was expecting %d got %f\n", (int)i, (int)i, (double)fbuf[i]);
}
}
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
/* Move to the next one (integers) */
ref = VSgetid(fid, ref);
if (ref == FAIL) {
num_errs++;
printf(">>> VSgetid was unable to find second Vdata\n");
}
/* read in the first data and verify metadata and contents */
vs1 = VSattach(fid, ref, "r");
CHECK(vs1, FAIL, "VSattach:vs1");
status = VSgetname(vs1, vsname);
CHECK(status, FAIL, "VSgetname:vs1");
status = VSgetclass(vs1, vsclass);
CHECK(status, FAIL, "VSgetclass:vs1");
if (strcmp(vsname, "Integer Vdata")) {
num_errs++;
printf(">>> Got bogus Vdata name (VSgetname) : %s\n", vsname);
}
if (strcmp(vsclass, "Test object")) {
num_errs++;
printf(">>> Got bogus Vdata class : %s\n", vsclass);
}
status = VSinquire(vs1, &count, &intr, fields, &sz, vsname);
if (status == FAIL) {
num_errs++;
printf(">>> VSinquire failed on float Vdata\n");
}
if (strcmp(vsname, "Integer Vdata")) {
num_errs++;
printf(">>> Got bogus Integer Vdata name (VSinquire) : %s\n", vsname);
}
if (count != 100) {
num_errs++;
printf(">>> Got wrong count %d expecting 100\n", (int)count);
}
if ((size_t)sz != 2 * sizeof(int32)) {
num_errs++;
printf(">>> Got wrong data size %d should be 2 * sizeof(int32)\n", (int)sz);
}
if (strcmp(fields, FIELD2)) {
num_errs++;
printf(">>> Got bogus field name %s\n", fields);
}
/* read it */
status = VSsetfields(vs1, fields);
CHECK(status, FAIL, "VSsetfields:vs1");
for (i = 0; i < 2 * count; i++)
ibuf[i] = 0;
status = VSread(vs1, (unsigned char *)ibuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSread:vs1");
/* verify */
for (i = 0; i < 2 * count; i++) {
if (ibuf[i] != i) {
num_errs++;
printf(">>> Int value %d was expecting %d got %d\n", (int)i, (int)i, (int)ibuf[i]);
}
}
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
/* testing VSsetexternalfile by reading the external file directly */
{
hdf_file_t fd;
int j;
int32 ival;
/* low level open of external file */
fd = HI_OPEN(EXTFNM, DFACC_RDONLY);
if (OPENERR(fd)) {
num_errs++;
printf(">>> Reopen External file %s failed\n", EXTFNM);
}
else {
status = HI_READ(fd, gbuf, (2 * count * DFKNTsize(DFNT_INT32)));
if (status == FAIL) {
num_errs++;
printf(">>> Reading External file data failed\n");
}
else {
j = 0;
for (i = 0; i < 2 * count; i++) {
ival = 0xff & gbuf[j++];
ival = ival << 8 | (0xff & gbuf[j++]);
ival = ival << 8 | (0xff & gbuf[j++]);
ival = ival << 8 | (0xff & gbuf[j++]);
if (ival != i) {
num_errs++;
printf(">>> External value %d was expecting %d got %d\n", (int)i, (int)i, (int)ival);
}
}
}
/* low level close of external file */
HI_CLOSE(fd);
}
}
/* Move to the next one (integers + floats) */
ref = VSgetid(fid, ref);
if (ref == FAIL) {
num_errs++;
printf(">>> VSgetid was unable to find third Vdata\n");
}
/* read in the first data and verify metadata and contents */
vs1 = VSattach(fid, ref, "r");
CHECK(vs1, FAIL, "VSattach:vs1");
status = VSgetname(vs1, vsname);
CHECK(status, FAIL, "VSgetname:vs1");
status = VSgetclass(vs1, vsclass);
CHECK(status, FAIL, "VSgetclass:vs1");
if (strcmp(vsname, "Mixed Vdata")) {
num_errs++;
printf(">>> Got bogus Vdata name (VSgetname) : %s\n", vsname);
}
if (strcmp(vsclass, "No class specified")) {
num_errs++;
printf(">>> Got bogus Vdata class : %s\n", vsclass);
}
status = VSinquire(vs1, &count, &intr, fields, &sz, vsname);
if (status == FAIL) {
num_errs++;
printf(">>> VSinquire failed on float Vdata\n");
}
if (strcmp(vsname, "Mixed Vdata")) {
num_errs++;
printf(">>> Got bogus Mixed Vdata name (VSinquire) : %s\n", vsname);
}
if (count != 100) {
num_errs++;
printf(">>> Got wrong count %d expecting 100\n", (int)count);
}
if ((size_t)sz != sizeof(int32) + sizeof(float32)) {
num_errs++;
printf(">>> Got wrong data size %d should be sizeof(int32) + sizeof(float32)\n", (int)sz);
}
if (strcmp(fields, "A,B")) {
num_errs++;
printf(">>> Got bogus field name %s\n", fields);
}
/* read it */
status = VSsetfields(vs1, fields);
CHECK(status, FAIL, "VSsetfields:vs1");
for (i = 0; i < 1000; i++)
gbuf[i] = 0;
status = VSread(vs1, (unsigned char *)gbuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSread:vs1");
/* verify */
p = gbuf;
for (i = 0; i < count; i++) {
float32 fl = 0.0F;
int32 in = 0;
memcpy(&fl, p, sizeof(float32));
p += sizeof(float32);
memcpy(&in, p, sizeof(int32));
p += sizeof(int32);
if (in != i) {
num_errs++;
printf(">>> Mixed int value %d was expecting %d got %d\n", (int)i, (int)i, (int)in);
}
if (!H4_FLT_ABS_EQUAL(fl, (float32)(i * 2))) {
num_errs++;
printf(">>> Mixed float value %d was expecting %d got %f\n", (int)i, (int)i, (double)fl);
}
}
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
/* Move to the next one (multi-order) */
ref = VSgetid(fid, ref);
if (ref == FAIL) {
num_errs++;
printf(">>> VSgetid was unable to find multi-order Vdata\n");
}
/* read in the first data and verify metadata and contents */
vs1 = VSattach(fid, ref, "r");
CHECK(vs1, FAIL, "VSattach:vs1");
status = VSgetname(vs1, vsname);
CHECK(status, FAIL, "VSgetname:vs1");
status = VSgetclass(vs1, vsclass);
CHECK(status, FAIL, "VSgetclass:vs1");
if (strcmp(vsname, "Multi-Order Vdata")) {
num_errs++;
printf(">>> Got bogus Vdata name (VSgetname) : %s\n", vsname);
}
if (strcmp(vsclass, "No class specified")) {
num_errs++;
printf(">>> Got bogus Vdata class : %s\n", vsclass);
}
status = VSinquire(vs1, &count, &intr, fields, &sz, vsname);
if (status == FAIL) {
num_errs++;
printf(">>> VSinquire failed on multi-order Vdata\n");
}
if (count != 10) {
num_errs++;
printf(">>> Got wrong count %d expecting 10\n", (int)count);
}
if (strcmp(fields, MX)) {
num_errs++;
printf(">>> Got bogus field name %s\n", fields);
}
/*
* verify - read in all fields
*/
/* read it */
status = VSsetfields(vs1, fields);
CHECK(status, FAIL, "VSsetfields:vs1");
for (i = 0; i < 1000; i++)
gbuf[i] = 0;
status = VSread(vs1, (unsigned char *)gbuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSread:vs1");
p = gbuf;
fl_expected = (float32)15.5;
in_expected = 0;
c_expected = 'a';
for (i = 0; i < count; i++) {
float32 fl = 0.0F;
int32 in = 0;
char8 c = 0;
/* read and verify characters */
memcpy(&c, p, sizeof(char8));
p += sizeof(char8);
if (c != c_expected) {
num_errs++;
printf(">>> Multi-order char value %d.0 was expecting %c got %c\n", (int)i, c_expected, c);
}
c_expected++;
memcpy(&c, p, sizeof(char8));
p += sizeof(char8);
if (c != c_expected) {
num_errs++;
printf(">>> Multi-order char value %d.1 was expecting %c got %c\n", (int)i, c_expected, c);
}
c_expected++;
/* read and verify integers */
memcpy(&in, p, sizeof(int32));
p += sizeof(int32);
if (in != in_expected) {
num_errs++;
printf(">>> Multi-order int value %d.0 was expecting %d got %d\n", (int)i, (int)in_expected,
(int)in);
}
in_expected++;
memcpy(&in, p, sizeof(int32));
p += sizeof(int32);
if (in != in_expected) {
num_errs++;
printf(">>> Multi-order int value %d.1 was expecting %d got %d\n", (int)i, (int)in_expected,
(int)in);
}
in_expected++;
memcpy(&in, p, sizeof(int32));
p += sizeof(int32);
if (in != in_expected) {
num_errs++;
printf(">>> Multi-order int value %d.2 was expecting %d got %d\n", (int)i, (int)in_expected,
(int)in);
}
in_expected++;
/* read and verify floating point value */
memcpy(&fl, p, sizeof(float32));
p += sizeof(float32);
if (!H4_FLT_ABS_EQUAL(fl, fl_expected)) {
num_errs++;
printf(">>> Multi-order float value %d was expecting %f got %f\n", (int)i, (double)fl_expected,
(double)fl);
}
fl_expected += 0.5F;
}
/*
* verify - just read in the character field with FULL_INTERLACE
*/
/* read it */
status = VSseek(vs1, 0);
CHECK(status, FAIL, "VSseek:vs1");
status = VSsetfields(vs1, ST);
CHECK(status, FAIL, "VSsetfields:vs1");
for (i = 0; i < 1000; i++)
gbuf[i] = 0;
status = VSread(vs1, (unsigned char *)gbuf, count, FULL_INTERLACE);
CHECK(status, FAIL, "VSread:vs1");
p = gbuf;
c_expected = 'a';
for (i = 0; i < count; i++) {
char8 c = '\0';
/* read and verify characters */
memcpy(&c, p, sizeof(char8));
p += sizeof(char8);
if (c != c_expected) {
num_errs++;
printf(">>> FULL_INTERLACE read char value %d.0 (%c) got %c %d\n", (int)i, c_expected, c, c);
}
c_expected++;
memcpy(&c, p, sizeof(char8));
p += sizeof(char8);
if (c != c_expected) {
num_errs++;
printf(">>> FULL_INTERLACE read char value %d.1 (%c) %c got %c\n", (int)i, c_expected, c, c);
}
c_expected++;
}
/*
* verify - just read in the character field with NO_INTERLACE
*/
/* read it */
status = VSseek(vs1, 0);
CHECK(status, FAIL, "VSseek:vs1");
status = VSsetfields(vs1, ST);
CHECK(status, FAIL, "VSsetfields:vs1");
for (i = 0; i < 1000; i++)
gbuf[i] = 0;
status = VSread(vs1, (unsigned char *)gbuf, count, NO_INTERLACE);
CHECK(status, FAIL, "VSread:vs1");
p = gbuf;
c_expected = 'a';
for (i = 0; i < count; i++) {
char8 c = '\0';
/* read and verify characters */
memcpy(&c, p, sizeof(char8));
p += sizeof(char8);
if (c != c_expected) {
num_errs++;
printf(">>> NO_INTERLACE read char value %d.0 (%c) got %c\n", (int)i, c_expected, c);
}
c_expected++;
memcpy(&c, p, sizeof(char8));
p += sizeof(char8);
if (c != c_expected) {
num_errs++;
printf(">>> NO_INTERLACE read char value %d.1 (%c) %c got\n", (int)i, c_expected, c);
}
c_expected++;
}
/* verify that VSfind does not mess up the AIDs of attached Vdatas */
status = VSfind(fid, "foo");
CHECK(status, FAIL, "VSfind:fid");
if (VSseek(vs1, 0) == FAIL) {
num_errs++;
printf(">>> VSseek failed after VSfind call\n");
}
status = VSdetach(vs1);
CHECK(status, FAIL, "VSdetach:vs1");
status = Vend(fid);
CHECK(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK(status, FAIL, "Hclose:fid");
return SUCCEED;
} /* read_vset_stuff */
/*
Testing VSdelete for vdatas.
Modification:
2011/12/22: added a test for VSgetexternalinfo on non-external vdata.
*/
static void
test_vsdelete(void)
{
#define FIELD_NAME "Field Entries"
#define NUMBER_OF_ROWS 10
#define ORDER 3
int32 fid;
int32 vdata_id;
int32 status;
int32 num_of_elements;
int16 vdata_buf[NUMBER_OF_ROWS * ORDER];
int32 v_ref;
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* Create a new vdata. */
vdata_id = VSattach(fid, -1, "w");
CHECK_VOID(vdata_id, FAIL, "VSattach:vdata_id");
/* Define the field data name, type and order. */
status = VSfdefine(vdata_id, FIELD_NAME, DFNT_INT16, ORDER);
CHECK_VOID(status, FAIL, "VSfdefine:vdata_id");
/* Specify the field(s) that will be written to. */
status = VSsetfields(vdata_id, FIELD_NAME);
CHECK_VOID(status, FAIL, "VSsetfields:vdata_id");
/* Generate the Vset data. */
for (int16 i = 0; i < NUMBER_OF_ROWS * ORDER; i += ORDER) {
vdata_buf[i] = i;
vdata_buf[i + 1] = i + 1;
vdata_buf[i + 2] = i + 2;
}
/* Write the data to the Vset. */
num_of_elements = VSwrite(vdata_id, (const uint8 *)vdata_buf, NUMBER_OF_ROWS, FULL_INTERLACE);
CHECK_VOID(num_of_elements, FAIL, "VSwrite:");
/* Set the name and class. */
status = VSsetname(vdata_id, "Vdata should have been deleted");
CHECK_VOID(status, FAIL, "VSsetname:vdata_id");
status = VSsetclass(vdata_id, "Vdata should have been deleted");
CHECK_VOID(status, FAIL, "VSsetclass:vdata_id");
/* get ref of Vdata */
v_ref = VSQueryref(vdata_id);
CHECK_VOID(v_ref, FAIL, "VSQueryref:vdata_id");
/* Terminate access to the vdata. */
status = VSdetach(vdata_id);
CHECK_VOID(status, FAIL, "VSdetach:vdata_id");
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
/* Now open the file again and delete the vdata */
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* attach to Vdata */
vdata_id = VSattach(fid, v_ref, "w");
CHECK_VOID(vdata_id, FAIL, "VSattach:vdata_id");
/* Test VSgetexternalinfo on this vdata that doesn't have external
element, should return 0 for length of external file name */
{
intn name_len = 0;
name_len = VSgetexternalinfo(vdata_id, 0, NULL, NULL, NULL);
VERIFY_VOID(name_len, 0, "VSgetexternalinfo:vdata_id");
}
/* Delete this Vdata */
status = VSdelete(fid, v_ref);
CHECK_VOID(status, FAIL, "VSdelete:vdata_id");
/* Terminate access to the vdata. */
status = VSdetach(vdata_id);
CHECK_VOID(status, FAIL, "VSdetach:vdata_id");
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
/* Now open file again and try to attach to vdata with 'v_ref'.
The VSattach should fail. */
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDONLY, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent the vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* Try to attach to Vdata. This should fail now */
vdata_id = VSattach(fid, v_ref, "w");
if (vdata_id != FAIL) {
num_errs++;
printf(">>> VSdelete failed to delete vdata \n");
}
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
} /* test_vsdelete */
/* Testing Vdelete for vgroups. */
static void
test_vdelete(void)
{
int32 fid;
int32 vgroup_id;
int32 status;
int32 vg_ref;
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* Create a new vgroup. */
vgroup_id = Vattach(fid, -1, "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach:vgroup_id");
/* Set the name and class. */
status = Vsetname(vgroup_id, "Vgroup should have been deleted");
CHECK_VOID(status, FAIL, "Vsetname:vgroup_id");
status = Vsetclass(vgroup_id, "Vgroup should have been deleted");
CHECK_VOID(status, FAIL, "Vsetclass:vgroup_id");
/* get ref of vgroup */
vg_ref = VQueryref(vgroup_id);
CHECK_VOID(vg_ref, FAIL, "VQueryref:vgroup_id");
/* Terminate access to the vgroup. */
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "Vdetach:vgroup_id");
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
/* Now open the file again and delete the vgroup */
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* attach to vgroup */
vgroup_id = Vattach(fid, vg_ref, "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach:vgroup_id");
/* delete this vgroup */
status = Vdelete(fid, vg_ref);
CHECK_VOID(status, FAIL, "Vdelete:vgroup_id");
/* Terminate access to the vgroup. */
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "VSdetach:vgroup_id");
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
/* Now open file again and try to attach to vgroup with 'vg_ref'.
The Vattach should fail. */
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDONLY, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent the vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* Try to attach to vgroup. This should fail now */
vgroup_id = Vattach(fid, vg_ref, "w");
if (vgroup_id != FAIL) {
num_errs++;
printf(">>> Vdelete failed to delete vdata \n");
}
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
} /* test_vdelete */
/* Testing Vdeletetagref() for vgroups. */
static void
test_vdeletetagref(void)
{
int32 fid;
int32 vgroup_id;
int32 status;
int32 vg_ref;
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* Create a new vgroup. */
vgroup_id = Vattach(fid, -1, "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach:vgroup_id");
/* Set the name and class. */
status = Vsetname(vgroup_id, "Vgroup to delete elements from");
CHECK_VOID(status, FAIL, "Vsetname:vgroup_id");
status = Vsetclass(vgroup_id, "Vgroup to delete elements from");
CHECK_VOID(status, FAIL, "Vsetclass:vgroup_id");
/* add a few tag/ref pairs to Vgroup */
status = Vaddtagref(vgroup_id, 1000, 12345);
CHECK_VOID(status, FAIL, "Vaddtagref");
status = Vaddtagref(vgroup_id, 1000, 12346);
CHECK_VOID(status, FAIL, "Vaddtagref");
#ifndef NO_DUPLICATES
/* duplicate tag/ref pairs allowed.
So add a duplicate */
status = Vaddtagref(vgroup_id, 1000, 12346);
CHECK_VOID(status, FAIL, "Vaddtagref");
#endif /* NO_DUPLICATES */
status = Vaddtagref(vgroup_id, 2000, 12345);
CHECK_VOID(status, FAIL, "Vaddtagref");
status = Vaddtagref(vgroup_id, 2000, 12346);
CHECK_VOID(status, FAIL, "Vaddtagref");
status = Vaddtagref(vgroup_id, 3000, 12345);
CHECK_VOID(status, FAIL, "Vaddtagref");
status = Vaddtagref(vgroup_id, 3000, 12346);
CHECK_VOID(status, FAIL, "Vaddtagref");
/* get ref of vgroup */
vg_ref = VQueryref(vgroup_id);
CHECK_VOID(vg_ref, FAIL, "VQueryref:vgroup_id");
/* delete one item in vgroup during this round */
status = Vdeletetagref(vgroup_id, 1000, 12346);
CHECK_VOID(status, FAIL, "Vdeletetagref:vgroup_id");
/* Terminate access to the vgroup. */
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "Vdetach:vgroup_id");
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
/* Now open the file again and delete two elements in the vgroup
during this round. */
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* attach to vgroup */
vgroup_id = Vattach(fid, vg_ref, "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach:vgroup_id");
#ifndef NO_DUPLICATES
/* inquire about number of elements in Vgroup.
There should only be 6 of them including one duplicate. */
if (6 != Vntagrefs(vgroup_id)) {
num_errs++;
printf(">>> Vntagrefs returned %d was expecting %d\n", (int)Vntagrefs(vgroup_id), 6);
}
/* delete a duplicate in this vgroup */
status = Vdeletetagref(vgroup_id, 1000, 12346);
CHECK_VOID(status, FAIL, "Vdeletetagref:vgroup_id");
#else /* NO_DUPLICATES */
/* inquire about number of elements in Vgroup.
There should only be 5 of them since no duplicates . */
if (5 != Vntagrefs(vgroup_id)) {
num_errs++;
printf(">>> Vntagrefs returned %d was expecting %d\n", (int)Vntagrefs(vgroup_id), 5);
}
#endif /* NO_DUPLICATES */
/* delete some tag/refs in this vgroup */
status = Vdeletetagref(vgroup_id, 2000, 12346);
CHECK_VOID(status, FAIL, "Vdeletetagref:vgroup_id");
/* this should be the last element in the vgroup if I have
the order right */
status = Vdeletetagref(vgroup_id, 3000, 12346);
CHECK_VOID(status, FAIL, "Vdeletetagref:vgroup_id");
/* Terminate access to the vgroup. */
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "VSdetach:vgroup_id");
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
/* Now open file again and try to attach to vgroup with 'vg_ref'.
There should only be 3 elements left in Vgroup left . */
/* Open the HDF file. */
fid = Hopen(FNAME0, DFACC_RDONLY, 0);
CHECK_VOID(fid, FAIL, "Hopen:tvset.hdf");
/* Initialize HDF for subsequent the vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart:fid");
/* attach to vgroup, read only */
vgroup_id = Vattach(fid, vg_ref, "r");
CHECK_VOID(vgroup_id, FAIL, "Vattach:vgroup_id");
/* inquire about number of elements left in Vgroup.
There should only be 3 of them now. */
if (3 != Vntagrefs(vgroup_id)) {
num_errs++;
printf(">>> Vntagrefs returned %d was expecting %d\n", (int)Vntagrefs(vgroup_id), 3);
}
/* check tag/ref pair of those 3 elements */
if (Vinqtagref(vgroup_id, 1000, 12345) == FALSE) {
num_errs++;
printf(">>> Vinqtagref couldn't find valid element\n");
}
if (Vinqtagref(vgroup_id, 2000, 12345) == FALSE) {
num_errs++;
printf(">>> Vinqtagref couldn't find valid element\n");
}
if (Vinqtagref(vgroup_id, 3000, 12345) == FALSE) {
num_errs++;
printf(">>> Vinqtagref couldn't find valid element\n");
}
/* Terminate access to the vgroup. */
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "VSdetach:vgroup_id");
/* Terminate access to the Vxxx interface and close the file. */
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend:fid");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose:fid");
} /* test_vdeletetagref */
static void
test_emptyvdata(void)
{
int32 status; /* Status values from routines */
int32 fid; /* File ID */
int32 vs1; /* Vdata ID */
int32 ref; /* Vdata ref */
char vsname[VSNAMELENMAX], fields[FIELDNAMELENMAX * VSFIELDMAX];
/* Open the HDF file. */
fid = Hopen(EMPTYNM, DFACC_CREATE, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Create a new vdata. */
vs1 = VSattach(fid, -1, "w");
CHECK_VOID(vs1, FAIL, "VSattach");
status = VSsetname(vs1, EMPTY_VDATA);
CHECK_VOID(status, FAIL, "VSsetname");
status = VSdetach(vs1);
CHECK_VOID(status, FAIL, "Vdetach");
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
MESSAGE(5, printf("created empty VDATA %s\n", EMPTY_VDATA););
/* Re-open the HDF file. */
fid = Hopen(EMPTYNM, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Find the empty vdata. */
ref = VSfind(fid, EMPTY_VDATA);
CHECK_VOID(ref, FAIL, "VSfind");
vs1 = VSattach(fid, ref, "r");
CHECK_VOID(vs1, FAIL, "VSattach");
status = VSgetname(vs1, vsname);
CHECK_VOID(status, FAIL, "VSgetname");
if (strcmp(vsname, EMPTY_VDATA)) {
num_errs++;
printf(">>> Got bogus Vdata name : %s\n", vsname);
}
status = VFnfields(vs1);
VERIFY_VOID(status, 0, "VFnfields");
/* Verify that VSgetfields will return FAIL when passing in a NULL
for field name list (from bug #554), although this might never
happen - BMR 5/17/01 */
status = VSgetfields(vs1, NULL);
VERIFY_VOID(status, FAIL, "VSgetfields");
status = VSgetfields(vs1, fields);
CHECK_VOID(status, FAIL, "VSgetfields");
if (strcmp(fields, "")) {
num_errs++;
printf(">>> Got bogus field names : %s\n", fields);
}
status = VSdetach(vs1);
CHECK_VOID(status, FAIL, "Vdetach");
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
MESSAGE(5, printf("read back in empty VDATA %s\n", EMPTY_VDATA););
/* Re-open the HDF file. */
fid = Hopen(EMPTYNM, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Find the empty vdata. */
ref = VSfind(fid, EMPTY_VDATA);
CHECK_VOID(ref, FAIL, "VSfind");
vs1 = VSattach(fid, ref, "w");
CHECK_VOID(vs1, FAIL, "VSattach");
/* Write out simple vdata fields */
status = VSfdefine(vs1, FIELD1, DFNT_FLOAT32, 1);
CHECK_VOID(status, FAIL, "VSfdefine");
status = VSfdefine(vs1, FIELD2, DFNT_INT32, 2);
CHECK_VOID(status, FAIL, "VSfdefine");
status = VSsetfields(vs1, FIELD1 "," FIELD2);
if (status == FAIL) {
num_errs++;
printf(">>> Vsetfields failed for %s\n", vsname);
}
status = VSdetach(vs1);
CHECK_VOID(status, FAIL, "Vdetach");
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
MESSAGE(5, printf("changed empty VDATA %s to have two fields\n", EMPTY_VDATA););
/* Re-open the HDF file. */
fid = Hopen(EMPTYNM, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Find the empty vdata. */
ref = VSfind(fid, EMPTY_VDATA);
CHECK_VOID(ref, FAIL, "VSfind");
vs1 = VSattach(fid, ref, "r");
CHECK_VOID(vs1, FAIL, "VSattach");
status = VFnfields(vs1);
VERIFY_VOID(status, 2, "VFnfields");
status = VSgetfields(vs1, fields);
CHECK_VOID(status, FAIL, "VSgetfields");
if (strcmp(fields, FIELD1 "," FIELD2)) {
num_errs++;
printf(">>> Got bogus field names : %s\n", fields);
}
status = VSdetach(vs1);
CHECK_VOID(status, FAIL, "Vdetach");
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
} /* test_emptyvdata() */
static void
test_vglongnames(void)
{
int32 status; /* Status values from routines */
int32 fid; /* File ID */
int32 vg1; /* Vdata ID */
int32 ref; /* Vdata ref */
uint16 name_len; /* Length of a vgroup's name or class name */
char *vgname, *vgclass;
/* Open the HDF file. */
fid = Hopen(LONGNAMES, DFACC_CREATE, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Create a new vgroup. */
vg1 = Vattach(fid, -1, "w");
CHECK_VOID(vg1, FAIL, "VSattach");
status = Vsetname(vg1, VG_LONGNAME);
CHECK_VOID(status, FAIL, "VSsetname");
status = Vsetclass(vg1, VG_LONGCLASS);
CHECK_VOID(status, FAIL, "VSsetname");
status = Vdetach(vg1);
CHECK_VOID(status, FAIL, "Vdetach");
/* Create another vgroup of the same class. */
vg1 = Vattach(fid, -1, "w");
CHECK_VOID(vg1, FAIL, "VSattach");
status = Vsetname(vg1, VGROUP1);
CHECK_VOID(status, FAIL, "VSsetname");
status = Vsetclass(vg1, VG_LONGCLASS);
CHECK_VOID(status, FAIL, "VSsetname");
status = Vdetach(vg1);
CHECK_VOID(status, FAIL, "Vdetach");
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
/* Re-open the HDF file. */
fid = Hopen(LONGNAMES, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize HDF for subsequent vgroup/vdata access. */
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Find the long name vgroup. */
ref = Vfind(fid, VG_LONGNAME);
CHECK_VOID(ref, FAIL, "VSfind");
vg1 = Vattach(fid, ref, "r");
CHECK_VOID(vg1, FAIL, "VSattach");
/* get the vgroup's name */
status = Vgetnamelen(vg1, &name_len);
CHECK_VOID(status, FAIL, "Vgetnamelen");
vgname = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(vgname, "vgname", "test_vglongnames");
status = Vgetname(vg1, vgname);
CHECK_VOID(status, FAIL, "VSgetname");
if (strcmp(vgname, VG_LONGNAME)) {
num_errs++;
printf(">>> Got bogus Vgroup name : %s\n", vgname);
}
free(vgname);
/* get the vgroup's class */
status = Vgetclassnamelen(vg1, &name_len);
CHECK_VOID(status, FAIL, "Vgetnamelen");
vgclass = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(vgclass, "vgclass", "test_vglongnames");
status = Vgetclass(vg1, vgclass);
CHECK_VOID(status, FAIL, "VSgetclass");
if (strcmp(vgclass, VG_LONGCLASS)) {
num_errs++;
printf(">>> Got bogus Vgroup class : %s\n", vgclass);
}
free(vgclass);
status = Vdetach(vg1);
CHECK_VOID(status, FAIL, "Vdetach");
/* Find the vgroup VGROUP1. */
ref = Vfind(fid, VGROUP1);
CHECK_VOID(ref, FAIL, "VSfind");
vg1 = Vattach(fid, ref, "r");
CHECK_VOID(vg1, FAIL, "VSattach");
/* get the vgroup's name */
status = Vgetnamelen(vg1, &name_len);
CHECK_VOID(status, FAIL, "Vgetnamelen");
vgname = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(vgname, "vgname", "test_vglongnames");
status = Vgetname(vg1, vgname);
CHECK_VOID(status, FAIL, "VSgetname");
if (strcmp(vgname, VGROUP1)) {
num_errs++;
printf(">>> Got bogus Vgroup name : %s\n", vgname);
}
free(vgname);
/* get the vgroup's class */
status = Vgetclassnamelen(vg1, &name_len);
CHECK_VOID(status, FAIL, "Vgetnamelen");
vgclass = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(vgclass, "vgclass", "test_vglongnames");
status = Vgetclass(vg1, vgclass);
CHECK_VOID(status, FAIL, "VSgetclass");
if (strcmp(vgclass, VG_LONGCLASS)) {
num_errs++;
printf(">>> Got bogus Vgroup class : %s\n", vgclass);
}
free(vgclass);
status = Vdetach(vg1);
CHECK_VOID(status, FAIL, "Vdetach");
status = Vend(fid);
CHECK_VOID(status, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
} /* test_vglongnames() */
#define USERVGROUPS "tuservgs.hdf"
#define NUM_VGROUPS 10
static void
test_getvgroups(void)
{
int32 fid; /* File ID */
int32 vgroup_id, vgroup0_id, vgroup1_id, vgroup2_id, vgroup3_id, vgroup4_id,
vgroup5_id; /* Various vgroup IDs */
int32 vgroup_ref; /* Vgroup ref */
uintn n_vgs = 0;
uint16 *refarray;
int32 ref_list[NUM_VGROUPS];
char vgclass[20];
int ii;
int32 status; /* Status values from routines */
intn status_n; /* returned status for functions returning an intn */
/* Create HDF file and initialize the interface. */
fid = Hopen(USERVGROUPS, DFACC_CREATE, 0);
CHECK_VOID(fid, FAIL, "Hopen");
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Create NUM_VGROUPS vgroups and set classname */
for (ii = 0; ii < NUM_VGROUPS; ii++) {
/* Create a vgroup. */
vgroup_id = Vattach(fid, -1, "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach");
/* Record its reference number for later access */
vgroup_ref = VQueryref(vgroup_id);
CHECK_VOID(vgroup_ref, FAIL, "VQueryref:vgroup_id");
ref_list[ii] = vgroup_ref;
/* Set its class name */
sprintf(vgclass, "VG-CLASS-%d", ii);
status = Vsetclass(vgroup_id, vgclass);
CHECK_VOID(status, FAIL, "Vsetclass");
/* Detach it */
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "Vdetach");
}
/* Insert some vgroups into some other vgroups to build some sort of
vgroup structure */
/* Insert "VG-CLASS-1" and "VG-CLASS-2" into "VG-CLASS-0" */
vgroup0_id = Vattach(fid, ref_list[0], "w");
CHECK_VOID(vgroup0_id, FAIL, "Vattach");
vgroup1_id = Vattach(fid, ref_list[1], "w");
CHECK_VOID(vgroup1_id, FAIL, "Vattach");
vgroup2_id = Vattach(fid, ref_list[2], "w");
CHECK_VOID(vgroup2_id, FAIL, "Vattach");
status = Vinsert(vgroup0_id, vgroup1_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup1_id into vgroup0_id");
status = Vinsert(vgroup0_id, vgroup2_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup2_id into vgroup0_id");
/* Insert "VG-CLASS-3", "VG-CLASS-4", and "VG-CLASS-5" into "VG-CLASS-1" */
vgroup3_id = Vattach(fid, ref_list[3], "w");
CHECK_VOID(vgroup3_id, FAIL, "Vattach");
vgroup4_id = Vattach(fid, ref_list[4], "w");
CHECK_VOID(vgroup4_id, FAIL, "Vattach");
vgroup5_id = Vattach(fid, ref_list[5], "w");
CHECK_VOID(vgroup5_id, FAIL, "Vattach");
status = Vinsert(vgroup1_id, vgroup3_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup3_id into vgroup1_id");
status = Vinsert(vgroup1_id, vgroup4_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup4_id into vgroup1_id");
status = Vinsert(vgroup1_id, vgroup5_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup5_id into vgroup1_id");
/**************************************************************
The vgroup structure should look like this:
vg0 vg6 vg7 vg8 vg9
|
/ \
vg1 vg2
|
/ | \
/ | \
vg3 vg4 vg5
Calling Vgetvgroups on the file should return all ten vgroups.
Calling Vgetvgroups on vg0 should return 2, vg1 and vg2.
Calling Vgetvgroups on vg1 should return 3, vg3, vg4, and vg5
Calling Vgetvgroups on vg6, vg7, vg8, and vg9 should return 0
***************************************************************/
/* Get and verify the number of vgroups in the file */
n_vgs = Vgetvgroups(fid, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups fid");
VERIFY_VOID(n_vgs, NUM_VGROUPS, "Vgetvgroups fid");
/* Allocate space to retrieve the reference numbers of n_vgs vgroups */
refarray = (uint16 *)malloc(sizeof(uint16) * n_vgs);
/* Get all the vgroups in the file */
n_vgs = Vgetvgroups(fid, 0, n_vgs, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups fid");
VERIFY_VOID(n_vgs, NUM_VGROUPS, "Vgetvgroups fid");
/* Verify refarray from this Vgetvgroups, it should contain:
2 3 4 5 6 7 8 9 10 11 */
{
uint16 result[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* Get 5 vgroups starting from vgroup number 5 */
n_vgs = Vgetvgroups(fid, 5, 5, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups fid (5,5)");
VERIFY_VOID(n_vgs, 5, "Vgetvgroups fid (5,5)");
/* Verify refarray from this Vgetvgroups, it should contain:
7 8 9 10 11 */
{
uint16 result[] = {7, 8, 9, 10, 11};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* Get and verify the number of vgroups in vgroup0_id */
n_vgs = Vgetvgroups(vgroup0_id, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup0_id");
VERIFY_VOID(n_vgs, 2, "Vgetvgroups vgroup0_id");
/* Get all the vgroups in vgroup0_id (refarray already allocated to max */
n_vgs = Vgetvgroups(vgroup0_id, 0, n_vgs, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup0_id");
VERIFY_VOID(n_vgs, 2, "Vgetvgroups vgroup0_id");
/* Verify refarray from this Vgetvgroups, it should contain: 3 4 */
{
uint16 result[] = {3, 4};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* Get and verify the number of vgroups in vgroup1_id */
n_vgs = Vgetvgroups(vgroup1_id, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup1_id");
VERIFY_VOID(n_vgs, 3, "Vgetvgroups vgroup1_id");
/* Get all the vgroups in vgroup1_id */
n_vgs = Vgetvgroups(vgroup1_id, 0, n_vgs, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup1_id");
VERIFY_VOID(n_vgs, 3, "Vgetvgroups vgroup1_id");
/* Verify refarray from this Vgetvgroups, it should contain: 5 6 7 */
{
uint16 result[] = {5, 6, 7};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* This vgroup should have no sub-vgroup */
n_vgs = Vgetvgroups(vgroup5_id, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup5_id");
VERIFY_VOID(n_vgs, 0, "Vgetvgroups vgroup5_id");
/* These vgroups are not needed anymore. */
status = Vdetach(vgroup2_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup2_id");
status = Vdetach(vgroup3_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup3_id");
status = Vdetach(vgroup4_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup4_id");
status = Vdetach(vgroup5_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup5_id");
/* Change class name of vg6 and vg7 to an internal class name to
simulate that they are internally created by the library. */
vgroup_id = Vattach(fid, ref_list[6], "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach vg6");
status = Vsetclass(vgroup_id, _HDF_VARIABLE);
CHECK_VOID(status, FAIL, "Vsetclass _HDF_VARIABLE");
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "Vdetach vg6");
vgroup_id = Vattach(fid, ref_list[7], "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach vg7");
status = Vsetclass(vgroup_id, _HDF_DIMENSION);
CHECK_VOID(status, FAIL, "Vsetclass _HDF_DIMENSION");
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "Vdetach vg7");
/**************************************************************
Calling Vgetvgroups on the file now should return 8 because vg6
and vg7 are no longer seen as user-created vgroups due to their
class name change.
***************************************************************/
/* Get the number of vgroups in the file, which shouldn't include the
simulated internal vgroups */
n_vgs = Vgetvgroups(fid, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups fid");
VERIFY_VOID(n_vgs, 8, "Vgetvgroups fid");
/* Get these vgroups */
n_vgs = Vgetvgroups(fid, 0, n_vgs, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups fid");
VERIFY_VOID(n_vgs, 8, "Vgetvgroups fid");
/* Verify refarray from this Vgetvgroups, it should contain:
2 3 4 5 6 7 10 11 */
{
uint16 result[] = {2, 3, 4, 5, 6, 7, 10, 11};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* Get 5 vgroups starting from vgroup number 5, the result shouldn't
include the simulated internal vgroups */
n_vgs = Vgetvgroups(fid, 5, 5, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups fid");
VERIFY_VOID(n_vgs, 3, "Vgetvgroups fid");
/* Verify refarray from this Vgetvgroups, it should contain: 7 10 11 */
{
uint16 result[] = {7, 10, 11};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* Check on vgroup0_id again */
n_vgs = Vgetvgroups(vgroup0_id, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup0_id");
VERIFY_VOID(n_vgs, 2, "Vgetvgroups vgroup0_id");
n_vgs = Vgetvgroups(vgroup0_id, 0, n_vgs, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup0_id");
VERIFY_VOID(n_vgs, 2, "Vgetvgroups vgroup0_id");
/* Verify refarray from this Vgetvgroups, it should contain: 3 4 */
{
uint16 result[] = {3, 4};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* Passing in more info count (3) than the actual number of vgrous to
be retrieved (1) */
n_vgs = Vgetvgroups(vgroup1_id, 2, 3, refarray);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup1_id");
VERIFY_VOID(n_vgs, 1, "Vgetvgroups vgroup1_id");
/* Verify refarray from this Vgetvgroups, it should contain: 7 */
{
uint16 result[] = {7};
for (ii = 0; ii < n_vgs; ii++)
if (refarray[ii] != result[ii])
fprintf(stderr,
"test_getvgroups: incorrect vgroup retrieved at line %d - ref# %d should be %d\n",
__LINE__, refarray[ii], result[ii]);
}
/* Passing in info count as 0 for a non-null array, should fail */
n_vgs = Vgetvgroups(fid, 0, 0, refarray);
VERIFY_VOID(n_vgs, FAIL, "Vgetvgroups with info_count = 0");
/* Passing in the starting vgroup beyond the number of user-created vgroups,
should fail */
n_vgs = Vgetvgroups(fid, 9, 3, refarray);
VERIFY_VOID(n_vgs, FAIL, "Vgetvgroups with start_vg = 9");
free(refarray);
/* Close remaining vgroups */
status = Vdetach(vgroup0_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup0_id");
status = Vdetach(vgroup1_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup1_id");
/* Terminate access to the V interface and close the HDF file. */
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status_n = Hclose(fid);
CHECK_VOID(status_n, FAIL, "Hclose");
} /* test_getvgroups() */
intn
check_vgs(int32 id, uintn start_vg, uintn n_vgs,
const char *ident_text, /* just for debugging, remove when done */
uintn resultcount, /* expected number of vgroups */
uint16 *resultarray) /* array containing expected values */
{
uint16 *refarray = NULL;
uintn count = 0, ii;
char message[30];
intn ret_value = SUCCEED;
strcpy(message, "Vgetvgroups: ");
strcat(message, ident_text);
/* Get and verify the number of vgroups in the file */
count = Vgetvgroups(id, start_vg, n_vgs, NULL);
CHECK(count, FAIL, "Vgetvgroups");
VERIFY(count, resultcount, "Vgetvgroups");
/* Allocate space to retrieve the reference numbers of 'count' vgroups */
refarray = (uint16 *)malloc(sizeof(uint16) * count);
if (refarray == NULL) {
fprintf(stderr, "check_vgs: Allocation refarray failed\n");
return -1;
}
/* Get all the vgroups in the file */
count = Vgetvgroups(id, start_vg, count, refarray);
CHECK(count, FAIL, "Vgetvgroups");
VERIFY(count, resultcount, "Vgetvgroups");
for (ii = 0; ii < count; ii++)
if (refarray[ii] != resultarray[ii])
fprintf(stderr, "%s: at index %d - read value=%d, should be %d\n", ident_text, ii, refarray[ii],
resultarray[ii]);
free(refarray);
return ret_value;
}
static int
check_vds(int32 id, uintn start_vd, uintn n_vds,
const char *ident_text, /* just for debugging, remove when done */
uintn resultcount, /* expected number of vdatas */
uint16 *resultarray) /* array containing expected values */
{
uint16 *refarray = NULL;
uintn count = 0, ii;
char message[30];
intn ret_value = SUCCEED;
strcpy(message, "VSgetvdatas: ");
strcat(message, ident_text);
/* Get and verify the number of vdatas in the file */
count = VSgetvdatas(id, start_vd, n_vds, NULL);
CHECK(count, FAIL, message);
VERIFY(count, resultcount, message);
/* Allocate space to retrieve the reference numbers of 'count' vdatas */
refarray = (uint16 *)malloc(sizeof(uint16) * count);
if (refarray == NULL) {
fprintf(stderr, "check_vds: Allocation refarray failed\n");
return -1;
}
/* Get all the vdatas in the file */
count = VSgetvdatas(id, start_vd, count, refarray);
CHECK(count, FAIL, message);
VERIFY(count, resultcount, message);
for (ii = 0; ii < count; ii++)
if (refarray[ii] != resultarray[ii])
fprintf(stderr, "%s: at index %d - read value=%d, should be %d\n", ident_text, ii, refarray[ii],
resultarray[ii]);
free(refarray);
return ret_value;
}
#define USERVDATAS "tuservds.hdf"
#define NUM_VDATAS 8
static void
test_getvdatas(void)
{
int32 vgroup_id;
int32 vgroup_ref;
int32 vdata_id;
int32 vdata_ref;
int32 fid; /* File ID */
int32 vgroup0_id, vgroup1_id, vgroup2_id, vgroup4_id, vgroup6_id, vgroup7_id,
vgroup9_id; /* Various vgroup IDs */
int32 vdata1_id, vdata2_id, vdata3_id, vdata4_id, vdata5_id, vdata6_id, vdata7_id; /* Various vdata IDs */
uintn n_vgs = 0;
int32 ref_list[NUM_VGROUPS], vdref_list[NUM_VDATAS];
char vgclass[20];
int ii;
int32 status; /* Status values from routines */
intn status_n; /* returned status for functions returning an intn */
/* Create HDF file and initialize the interface. */
fid = Hopen(USERVDATAS, DFACC_CREATE, 0);
CHECK_VOID(fid, FAIL, "Hopen");
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Create NUM_VGROUPS vgroups and set classname */
for (ii = 0; ii < NUM_VGROUPS; ii++) {
/* Create a vgroup. */
vgroup_id = Vattach(fid, -1, "w");
CHECK_VOID(vgroup_id, FAIL, "Vattach");
/* Record its reference number for later access */
vgroup_ref = VQueryref(vgroup_id);
CHECK_VOID(vgroup_ref, FAIL, "VQueryref:vgroup_id");
ref_list[ii] = vgroup_ref;
/* Set its class name */
sprintf(vgclass, "VG-CLASS-%d", ii);
status = Vsetclass(vgroup_id, vgclass);
CHECK_VOID(status, FAIL, "Vsetclass");
/* Detach it */
status = Vdetach(vgroup_id);
CHECK_VOID(status, FAIL, "Vdetach");
}
/* Create NUM_VDATAS vgroups and set classname */
for (ii = 0; ii < NUM_VDATAS; ii++) {
/* Create a vdata. */
vdata_id = VSattach(fid, -1, "w");
CHECK_VOID(vdata_id, FAIL, "VSattach");
/* Record its reference number for later access */
vdata_ref = VSQueryref(vdata_id);
CHECK_VOID(vdata_ref, FAIL, "VSQueryref:vdata_id");
vdref_list[ii] = vdata_ref;
/* Set its class name */
sprintf(vgclass, "VS-CLASS-%d", ii);
status = VSsetclass(vdata_id, vgclass);
CHECK_VOID(status, FAIL, "VSsetclass");
/* Detach it */
status = VSdetach(vdata_id);
CHECK_VOID(status, FAIL, "VSdetach");
}
/* Insert some vdatas/vgroups into some other vgroups to build some sort of
vgroup/vdata structure */
/* Insert "VD-CLASS-1" and "VD-CLASS-2" into "VG-CLASS-0" */
vgroup0_id = Vattach(fid, ref_list[0], "w"); /* "VG-CLASS-0" */
CHECK_VOID(vgroup0_id, FAIL, "Vattach");
vdata1_id = VSattach(fid, vdref_list[1], "w"); /* "VD-CLASS-1" */
CHECK_VOID(vdata1_id, FAIL, "VSattach");
vdata2_id = VSattach(fid, vdref_list[2], "w"); /* "VD-CLASS-2" */
CHECK_VOID(vdata2_id, FAIL, "VSattach");
status = Vinsert(vgroup0_id, vdata1_id);
CHECK_VOID(status, FAIL, "Vinsert vdata1_id into vgroup0_id");
status = Vinsert(vgroup0_id, vdata2_id);
CHECK_VOID(status, FAIL, "Vinsert vdata2_id into vgroup0_id");
/* Insert "VG-CLASS-7" and "VG-CLASS-9" into "VG-CLASS-0" */
vgroup7_id = Vattach(fid, ref_list[7], "w");
CHECK_VOID(vgroup7_id, FAIL, "Vattach");
vgroup9_id = Vattach(fid, ref_list[9], "w");
CHECK_VOID(vgroup9_id, FAIL, "Vattach");
status = Vinsert(vgroup0_id, vgroup7_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup7_id into vgroup0_id");
status = Vinsert(vgroup0_id, vgroup9_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup9_id into vgroup0_id");
/* Insert "VD-CLASS-3", "VD-CLASS-4", and "VD-CLASS-5" into "VG-CLASS-9" */
vdata3_id = VSattach(fid, vdref_list[3], "w");
CHECK_VOID(vdata3_id, FAIL, "Vattach");
vdata4_id = VSattach(fid, vdref_list[4], "w");
CHECK_VOID(vdata4_id, FAIL, "Vattach");
vdata5_id = VSattach(fid, vdref_list[5], "w");
CHECK_VOID(vdata4_id, FAIL, "Vattach");
status = Vinsert(vgroup9_id, vdata3_id);
CHECK_VOID(status, FAIL, "Vinsert vdata3_id into vgroup9_id");
status = Vinsert(vgroup9_id, vdata4_id);
CHECK_VOID(status, FAIL, "Vinsert vdata4_id into vgroup9_id");
status = Vinsert(vgroup9_id, vdata5_id);
CHECK_VOID(status, FAIL, "Vinsert vdata5_id into vgroup9_id");
/* Insert "VG-CLASS-4", "VG-CLASS-6", and "VD-CLASS-7" into "VG-CLASS-1" */
vgroup1_id = Vattach(fid, ref_list[1], "w");
CHECK_VOID(vgroup1_id, FAIL, "Vattach");
vgroup4_id = Vattach(fid, ref_list[4], "w");
CHECK_VOID(vgroup4_id, FAIL, "Vattach");
vgroup6_id = Vattach(fid, ref_list[6], "w");
CHECK_VOID(vgroup6_id, FAIL, "Vattach");
vdata7_id = VSattach(fid, vdref_list[7], "w");
CHECK_VOID(vdata7_id, FAIL, "VSattach");
status = Vinsert(vgroup1_id, vgroup4_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup4_id into vgroup1_id");
status = Vinsert(vgroup1_id, vgroup6_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup6_id into vgroup1_id");
status = Vinsert(vgroup1_id, vdata7_id);
CHECK_VOID(status, FAIL, "Vinsert vdata7_id into vgroup1_id");
/* Insert "VD-CLASS-6", "VG-CLASS-2" into "VG-CLASS-6" */
vdata6_id = VSattach(fid, vdref_list[6], "w");
CHECK_VOID(vdata6_id, FAIL, "VSattach");
vgroup2_id = Vattach(fid, ref_list[2], "w");
CHECK_VOID(vgroup2_id, FAIL, "Vattach");
status = Vinsert(vgroup6_id, vgroup2_id);
CHECK_VOID(status, FAIL, "Vinsert vgroup2_id into vgroup6_id");
status = Vinsert(vgroup6_id, vdata6_id);
CHECK_VOID(status, FAIL, "Vinsert vdata6_id into vgroup6_id");
status = Vdetach(vgroup0_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup0_id");
status = Vdetach(vgroup1_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup1_id");
status = Vdetach(vgroup2_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup2_id");
status = Vdetach(vgroup4_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup4_id");
status = Vdetach(vgroup6_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup6_id");
status = Vdetach(vgroup7_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup7_id");
status = Vdetach(vgroup9_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup9_id");
status = VSdetach(vdata1_id);
CHECK_VOID(status, FAIL, "VSdetach vdata1_id");
status = VSdetach(vdata2_id);
CHECK_VOID(status, FAIL, "VSdetach vdata2_id");
status = VSdetach(vdata3_id);
CHECK_VOID(status, FAIL, "VSdetach vdata3_id");
status = VSdetach(vdata4_id);
CHECK_VOID(status, FAIL, "VSdetach vdata4_id");
status = VSdetach(vdata5_id);
CHECK_VOID(status, FAIL, "VSdetach vdata5_id");
status = VSdetach(vdata6_id);
CHECK_VOID(status, FAIL, "VSdetach vdata6_id");
status = VSdetach(vdata7_id);
CHECK_VOID(status, FAIL, "VSdetach vdata7_id");
/* Terminate access to the V interface and close the HDF file. */
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status_n = Hclose(fid);
CHECK_VOID(status_n, FAIL, "Hclose");
/**************************************************************
The vgroup structure should look like this:
vg0 vg1
| |
+--+-+-----+ / | \
| | / | \
/\ / \ vg4 vg6 vd7
/ \ / \ |
vd1 vd2 vg7 vg9 / \
| / \
/ | \ / \
/ | \ vd6 vg2
vd3 vd4 vd5
Calling Vgetvgroups on the file should return all NUM_VGROUPS vgroups
Calling VSgetvdatas on the file should return all NUM_VDATAS vdatas
Calling Vgetvgroups on vg0 should return 2, vg7 and vg9
Calling VSgetvdatas on vg0 should return 2, vd1 and vd2
Calling Vgetvgroups on vg1 should return 2, vg4 and vg6
Calling VSgetvdatas on vg1 should return 1, vd7
Calling Vgetvgroups on vg6 should return 1, vg2
Calling VSgetvdatas on vg6 should return 1, vd6
Calling Vgetvgroups on vg9 should return 0
Calling Vgetvgroups on vg7 should return 0
Calling VSgetvdatas on vg9 starting at 2, with n_vds=2, should return 1, vd5
Calling Vgetvgroups on vg1 starting at 1, with n_vgs=3, should return 1, vg6
***************************************************************/
/* Open the file to test Vgetvgroups and Vgetdatas */
fid = Hopen(USERVDATAS, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
status = Vstart(fid);
CHECK_VOID(status, FAIL, "Vstart");
/* Test getting all vgroups in the file: fid, start_vg=0, n_vgs=0 */
{
uint16 result[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
status = check_vgs(fid, 0, 0, "file, 0, 0", NUM_VGROUPS, result);
CHECK_VOID(status, FAIL, "Vgetvgroups fid");
}
/* Test getting all vdatas in the file: fid, start_vd=0, n_vds=0 */
{
uint16 result[] = {12, 13, 14, 15, 16, 17, 18, 19};
status = check_vds(fid, 0, 0, "file, 0, 0", NUM_VDATAS, result);
CHECK_VOID(status, FAIL, "VSgetvdatas fid");
}
vgroup0_id = Vattach(fid, ref_list[0], "w"); /* "VG-CLASS-0" */
CHECK_VOID(vgroup0_id, FAIL, "Vattach vgroup0_id");
/* Test getting vgroups in vg0: vgroup0_id, start_vd=0, n_vds=0 */
{
uint16 result[] = {9, 11};
status = check_vgs(vgroup0_id, 0, 0, "vgroup0_id, 0, 0", 2, result);
CHECK_VOID(status, FAIL, "VSgetvgroups vgroup0_id");
}
/* Test getting vdatas in vg0: vgroup0_id, start_vd=0, n_vds=0 */
{
uint16 result[] = {13, 14};
status = check_vds(vgroup0_id, 0, 0, "vgroup0_id, 0, 0", 2, result);
CHECK_VOID(status, FAIL, "VSgetvdatas fid");
}
vgroup1_id = Vattach(fid, ref_list[1], "w"); /* "VG-CLASS-1" */
CHECK_VOID(vgroup1_id, FAIL, "Vattach vgroup1_id");
/* Test getting vgroups in vg1: vgroup1_id, start_vd=0, n_vds=0 */
{
uint16 result[] = {6, 8}; /* vg4 and vg6 */
status = check_vgs(vgroup1_id, 0, 0, "vgroup1_id, 0, 0", 2, result);
CHECK_VOID(status, FAIL, "Vgetvgroups vgroup1_id");
}
/* Test getting vdatas in vg1: vgroup1_id, start_vd=0, n_vds=0 */
{
uint16 result[] = {19}; /* vd7 */
status = check_vds(vgroup1_id, 0, 0, "vgroup1_id, 0, 0", 1, result);
CHECK_VOID(status, FAIL, "VSgetvdata vgroup1_id");
}
vgroup6_id = Vattach(fid, ref_list[6], "w"); /* "VG-CLASS-6" */
CHECK_VOID(vgroup6_id, FAIL, "Vattach vgroup6_id");
/* Test getting vgroups in vg6: vgroup6_id, start_vd=0, n_vds=0 */
{
uint16 result[] = {4}; /* vg2 */
status = check_vgs(vgroup6_id, 0, 0, "vgroup6_id, 0, 0", 1, result);
CHECK_VOID(status, FAIL, "Vgetvgroups vgroup6_id");
}
/* Test getting vdatas in vg6: vgroup6_id, start_vd=0, n_vds=0 */
{
uint16 result[] = {18}; /* vd6 */
status = check_vds(vgroup6_id, 0, 0, "vgroup6_id, 0, 0", 1, result);
CHECK_VOID(status, FAIL, "VSgetvdata vgroup6_id");
}
/* Test getting vgroups in vg9: vgroup9_id, start_vd=0, n_vds=0 */
vgroup9_id = Vattach(fid, ref_list[9], "w"); /* "VG-CLASS-9" */
CHECK_VOID(vgroup9_id, FAIL, "Vattach vgroup9_id");
{
n_vgs = Vgetvgroups(vgroup9_id, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup9_id");
VERIFY_VOID(n_vgs, 0, "Vgetvgroups vgroup9_id");
}
/* Test getting vgroups in vg7: vgroup7_id, start_vd=0, n_vds=0 */
vgroup7_id = Vattach(fid, ref_list[7], "w"); /* "VG-CLASS-7" */
CHECK_VOID(vgroup7_id, FAIL, "Vattach vgroup7_id");
{
n_vgs = Vgetvgroups(vgroup7_id, 0, 0, NULL);
CHECK_VOID(n_vgs, FAIL, "Vgetvgroups vgroup7_id");
VERIFY_VOID(n_vgs, 0, "Vgetvgroups vgroup7_id");
}
/* Test getting vdatas in vg9: vgroup9_id, start_vd=2, n_vds=2 */
{
uint16 result[] = {17}; /* vd5 */
status = check_vds(vgroup9_id, 2, 2, "vgroup9_id, 2, 2", 1, result);
CHECK_VOID(status, FAIL, "VSgetvdata vgroup9_id");
}
/* Test getting vgroups in vg1: vgroup1_id, start_vd=1, n_vds=3 */
{
uint16 result[] = {8}; /* vg6 */
status = check_vgs(vgroup1_id, 1, 3, "vgroup1_id, 1, 3", 1, result);
CHECK_VOID(status, FAIL, "Vgetvgroups vgroup1_id");
}
status = Vdetach(vgroup0_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup0_id");
status = Vdetach(vgroup1_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup1_id");
status = Vdetach(vgroup6_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup6_id");
status = Vdetach(vgroup7_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup7_id");
status = Vdetach(vgroup9_id);
CHECK_VOID(status, FAIL, "Vdetach vgroup9_id");
/* Terminate access to the V interface and close the HDF file. */
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status_n = Hclose(fid);
CHECK_VOID(status_n, FAIL, "Hclose");
} /* test_getvgroups() */
/*************************** test_extfile ***************************
This test routine creates an hdf file, "tvset_ext.hdf" (excerpted and
modified from Ruth's program used in hmap project), and creates and
writes a vdata with external element. The external file is named
Tables_External_File.
***********************************************************************/
#define EXTFILE "tvset_ext.hdf"
#define EXTERNAL_FILE "Tables_External_File"
#define MULTI_NAME "Table AR with Attributes in External File"
#define CLASSMULTI_NAME "Multi-Type, Multi-Entries per Cell, Store By Row in External File"
#define NROWS \
5 /* number of records to be written to the \
vdatas at every write */
static void
test_extfile(void)
{
int32 fid, vdata1_id, vdata_ref = -1; /* ref number of a vdata, set to -1 to create */
int32 vdata1_ref;
int32 offset = -1, length = -1;
const char hibuf[2] = "hi";
const char byebuf[3] = "bye";
char *extfile_name;
void *columnPtrs[3];
int bufsize;
void *databuf;
intn name_len = 0;
intn status_n; /* returned status for functions returning an intn */
int32 status; /* returned status for functions returning an int32 */
char8 col1buf[NROWS][2] = {{'A', 'B'}, {'B', 'C'}, {'C', 'D'}, {'D', 'E'}, {'E', 'F'}};
uint16 col2buf[NROWS] = {1, 2, 3, 4, 5};
float32 col3buf[NROWS][2] = {{.01F, .1F}, {.02F, .2F}, {.03F, .3F}, {.04F, .4F}, {.05F, .5F}};
/* Create the HDF file for data used in this test routine */
fid = Hopen(EXTFILE, DFACC_CREATE, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the VS interface */
status_n = Vstart(fid);
CHECK_VOID(status_n, FAIL, "Vstart");
/*
* Compute the buffer size that will be needed to hold the data for the
* mixed-data columns. Allocate the buffers.
*/
bufsize = (2 * sizeof(char8) + sizeof(uint16) + 2 * sizeof(float32)) * NROWS;
databuf = malloc((unsigned)bufsize);
/* Initialize the pointers to the column data. */
columnPtrs[0] = &col1buf[0][0];
columnPtrs[1] = &col2buf[0];
columnPtrs[2] = &col3buf[0][0];
/* Create the first vdata */
vdata1_id = VSattach(fid, vdata_ref, "w");
CHECK_VOID(vdata1_id, FAIL, "VSattach");
/* Set name and class name of the vdata. */
status = VSsetname(vdata1_id, MULTI_NAME);
CHECK_VOID(status, FAIL, "VSsetname");
status = VSsetclass(vdata1_id, CLASSMULTI_NAME);
CHECK_VOID(status, FAIL, "VSsetclass");
status = VSsetexternalfile(vdata1_id, EXTERNAL_FILE, 10);
CHECK_VOID(status, FAIL, "VSsetexternalfile");
/* Introduce each field's name, data type, and order. This is the first
part in defining a field. */
status_n = VSfdefine(vdata1_id, FIELD1_NAME, DFNT_CHAR8, ORDER_3);
CHECK_VOID(status_n, FAIL, "VSfdefine");
status_n = VSfdefine(vdata1_id, FIELD2_NAME, DFNT_UINT16, ORDER_2);
CHECK_VOID(status_n, FAIL, "VSfdefine");
status_n = VSfdefine(vdata1_id, FIELD3_NAME, DFNT_LFLOAT32, ORDER_3);
CHECK_VOID(status_n, FAIL, "VSfdefine");
/* Finalize the definition of the fields. */
status_n = VSsetfields(vdata1_id, FIELD_NAME_LIST);
CHECK_VOID(status_n, FAIL, "VSsetfields");
/* Pack the buffer that will be used to write the data to the file. */
status = VSfpack(vdata1_id, _HDF_VSPACK, NULL, databuf, bufsize, NROWS, NULL, columnPtrs);
CHECK_VOID(status, FAIL, "VSfpack");
/* Write to the vdata in FULL_INTERLACE */
status = VSwrite(vdata1_id, databuf, NROWS, FULL_INTERLACE);
CHECK_VOID(status, FAIL, "VSwrite");
/* Add Attribute for vdata */
status = VSsetattr(vdata1_id, _HDF_VDATA, "HDF4 Attribute Table", DFNT_CHAR8, 2, &hibuf);
CHECK_VOID(status, FAIL, "VSsetattr");
/* Add Attribute for Column C */
status = VSsetattr(vdata1_id, 2, "HDF4 Attribute Field 3", DFNT_CHAR8, 3, &byebuf);
CHECK_VOID(status, FAIL, "VSsetattr");
/* Get vdata ref */
vdata1_ref = VSQueryref(vdata1_id);
CHECK_VOID(vdata1_ref, FAIL, "VSQueryref");
status_n = VSdetach(vdata1_id);
CHECK_VOID(status_n, FAIL, "VSdetach");
free(databuf);
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
/* Reopen the file and the vdata and verify external file information */
/* Open the HDF file */
fid = Hopen(EXTFILE, DFACC_RDONLY, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the VS interface */
status_n = Vstart(fid);
CHECK_VOID(status_n, FAIL, "Vstart");
/* Create the first vdata */
vdata1_id = VSattach(fid, vdata1_ref, "r");
CHECK_VOID(vdata1_id, FAIL, "VSattach");
{ /* This is an old test, will be removed when VSgetexternalfile is */
/* Get the length of the external file name first - VSgetexternalfile
is deprecated as of 4.2.7 */
name_len = VSgetexternalfile(vdata1_id, 0, NULL, NULL);
VERIFY_VOID(name_len, (intn)strlen(EXTERNAL_FILE), "VSgetexternalfile");
extfile_name = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(extfile_name, "extfile_name", "test_extfile");
/* Old function: Get the external file name - VSgetexternalfile
is deprecated as of 4.2.7 */
name_len = VSgetexternalfile(vdata1_id, name_len + 1, extfile_name, &offset);
VERIFY_VOID(name_len, (intn)strlen(EXTERNAL_FILE), "VSgetexternalfile");
VERIFY_CHAR_VOID(extfile_name, EXTERNAL_FILE, "VSgetexternalfile");
free(extfile_name);
} /* old test */
/* Get the length of the external file name first */
name_len = VSgetexternalinfo(vdata1_id, 0, NULL, NULL, NULL);
VERIFY_VOID(name_len, (intn)strlen(EXTERNAL_FILE), "VSgetexternalinfo");
extfile_name = (char *)malloc(sizeof(char) * (name_len + 1));
CHECK_ALLOC(extfile_name, "extfile_name", "test_extfile");
/* Get the external file name */
name_len = VSgetexternalinfo(vdata1_id, name_len + 1, extfile_name, &offset, &length);
VERIFY_VOID(name_len, (intn)strlen(EXTERNAL_FILE), "VSgetexternalinfo");
VERIFY_CHAR_VOID(extfile_name, EXTERNAL_FILE, "VSgetexternalinfo");
free(extfile_name);
/* Test passing in smaller buffer for external file name than actual;
name should be truncated */
{
/* Make a shorter string to verify later */
char *short_name = (char *)malloc(sizeof(char) * (name_len));
memset(short_name, '\0', name_len);
strncpy(short_name, EXTERNAL_FILE, name_len - 2);
/* Prepare buffer for external file name in the following test */
extfile_name = (char *)malloc(sizeof(char) * (name_len - 1));
memset(extfile_name, '\0', name_len - 1);
/* Call VSgetexternalinfo again with smaller buffer size and make sure
VSgetexternalinfo reads the name truncated to the given buffer size*/
name_len = VSgetexternalinfo(vdata1_id, name_len - 2, extfile_name, &offset, &length);
VERIFY_VOID(name_len, (intn)strlen(extfile_name), "VSgetexternalinfo");
VERIFY_CHAR_VOID(extfile_name, short_name, "VSgetexternalinfo");
free(short_name);
free(extfile_name);
}
/* Release resources */
status_n = VSdetach(vdata1_id);
CHECK_VOID(status_n, FAIL, "VSdetach");
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
} /* test_extfile() */
/****************************************************************************
Name: test_blockinfo_oneLB() - tests setting/getting block info in the
simple case, only one linked block storage occur
Description:
The test does the following steps:
- Create the file and the first vdata, "Appendable Vdata"
- Test calling VSsetblocksize with invalid values and verify that failures occur
- Set block size and number of blocks to BLOCK_SIZE1 and NUM_BLOCKS for this vdata
- Close the vdata and the file
- Reopen the file and the first vdata, "Appendable Vdata"
- Verify that the block size of this vdata remains the default,
HDF_APPENDABLE_BLOCK_LEN. This shows when no data and no linked-block
storage created, the block size remains as the default.
- Call VSsetblocksize again with BLOCK_SIZE1 and NUM_BLOCKS
- Write 5 records to this vdata
- Create and write 5 records to the second vdata, "Another Vdata". The
purpose of this second vdata is to cause the subsequent write to the
first vdata to promote the first vdata's storage to a linked-block element.
- Append 5 records to the first vdata.
- Verify that the block size is changed to BLOCK_SIZE1 and number of
blocks to NUM_BLOCKS
- Close both vdatas and the file.
BMR - Jan 2014
****************************************************************************/
#define APPENDABLE_VD "Appendable Vdata"
#define ANOTHER_VD "Another Vdata"
#define CLASS_NAME "Linked-block Vdata"
#define ANOTHER_FD "Another field" /* contains one integer */
#define ANOTHER_FD_LIST "Another field"
#define N_RECORDS \
5 /* number of records to be written to the \
vdatas at every write */
#define N_VALS_PER_REC_2 1 /* # of values per record in the 2nd vdata */
#define N_VALS_PER_REC_1 (ORDER_1 + ORDER_2 + ORDER_3) /* # of vals/rec. in 1st vd*/
#define BLOCK_SIZE1 20 /* arbitrary number for block size */
#define BLOCK_SIZE2 100 /* arbitrary number for block size */
#define NUM_BLOCKS 8 /* arbitrary number for number of blocks */
static void
test_blockinfo_oneLB(void)
{
intn status_n; /* returned status for functions returning an intn */
int32 status; /* returned status for functions returning an int32 */
int16 rec_num; /* current record number */
int32 fid, vdata1_id, vdata2_id;
int32 vdata_ref = -1, /* ref number of a vdata, set to -1 to create */
num_of_records, /* number of records actually written to vdata */
data_buf1[N_RECORDS][N_VALS_PER_REC_1], /* for first vdata's data */
data_buf2[N_RECORDS][N_VALS_PER_REC_2], /* for second vdata's data */
block_size, num_blocks; /* retrieved by VSgetblockinfo */
/* Create the HDF file for data used in this test routine */
fid = Hopen(LKBLK_FILE, DFACC_CREATE, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the VS interface */
status_n = Vstart(fid);
CHECK_VOID(status_n, FAIL, "Vstart");
/* Create the first vdata */
vdata1_id = VSattach(fid, vdata_ref, "w");
CHECK_VOID(vdata1_id, FAIL, "VSattach");
/* Set name and class name of the vdata. */
status = VSsetname(vdata1_id, APPENDABLE_VD);
CHECK_VOID(status, FAIL, "VSsetname");
status = VSsetclass(vdata1_id, CLASS_NAME);
CHECK_VOID(status, FAIL, "VSsetclass");
/* Introduce each field's name, data type, and order. This is the first
part in defining a field. */
status_n = VSfdefine(vdata1_id, FIELD1_NAME, DFNT_INT32, ORDER_1);
CHECK_VOID(status_n, FAIL, "VSfdefine");
status_n = VSfdefine(vdata1_id, FIELD2_NAME, DFNT_INT32, ORDER_2);
CHECK_VOID(status_n, FAIL, "VSfdefine");
status_n = VSfdefine(vdata1_id, FIELD3_NAME, DFNT_INT32, ORDER_3);
CHECK_VOID(status_n, FAIL, "VSfdefine");
/* Finalize the definition of the fields. */
status_n = VSsetfields(vdata1_id, FIELD_NAME_LIST);
CHECK_VOID(status_n, FAIL, "VSsetfields");
/*
* Buffer the data by the record for fully interlaced mode. Note that the
* first three elements contain the three values of the first field, the
* fourth element contains the value of the second field, and the last two
* elements contain the two values of the third field.
*/
for (rec_num = 0; rec_num < N_RECORDS; rec_num++) {
data_buf1[rec_num][0] = 1 + rec_num;
data_buf1[rec_num][1] = 2 + rec_num;
data_buf1[rec_num][2] = 3 + rec_num;
data_buf1[rec_num][3] = 10 + rec_num;
data_buf1[rec_num][4] = 10;
data_buf1[rec_num][5] = 65;
}
status_n = VSgetblockinfo(vdata1_id, &block_size, NULL);
CHECK_VOID(status_n, FAIL, "VSgetblockinfo");
VERIFY_VOID(block_size, HDF_APPENDABLE_BLOCK_LEN, "VSgetblockinfo");
/* Test for invalid arguments passed in these functions */
status_n = VSsetblocksize(vdata1_id, -2);
VERIFY_VOID(status_n, FAIL, "VSsetblocksize");
status_n = VSsetnumblocks(vdata1_id, 0);
VERIFY_VOID(status_n, FAIL, "VSsetnumblocks");
/* Set the block size and the number of blocks the first vdata */
status_n = VSsetblocksize(vdata1_id, BLOCK_SIZE1);
CHECK_VOID(status_n, FAIL, "VSsetblocksize");
status_n = VSsetnumblocks(vdata1_id, NUM_BLOCKS);
CHECK_VOID(status_n, FAIL, "VSsetnumblocks");
status = VSdetach(vdata1_id);
CHECK_VOID(status, FAIL, "Vdetach");
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
/******************************************************************
* Reopen the file, and the vdata APPENDABLE_VDATA, verify that block
* size is still the default, then set block size again, and attempt
* to write data and test for block information.
******************************************************************/
fid = Hopen(LKBLK_FILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the VS interface */
status_n = Vstart(fid);
CHECK_VOID(status_n, FAIL, "Vstart");
vdata_ref = -1;
vdata_ref = VSfind(fid, APPENDABLE_VD);
CHECK_VOID(vdata_ref, FAIL, "VSfind");
vdata1_id = VSattach(fid, vdata_ref, "w");
CHECK_VOID(vdata1_id, FAIL, "VSattach");
status_n = VSgetblockinfo(vdata1_id, &block_size, NULL);
CHECK_VOID(status_n, FAIL, "VSgetblockinfo");
VERIFY_VOID(block_size, HDF_APPENDABLE_BLOCK_LEN, "VSgetblockinfo");
/* Set the block size and the number of blocks the first vdata */
status_n = VSsetblocksize(vdata1_id, BLOCK_SIZE1);
CHECK_VOID(status_n, FAIL, "VSsetblocksize");
status_n = VSsetnumblocks(vdata1_id, NUM_BLOCKS);
CHECK_VOID(status_n, FAIL, "VSsetnumblocks");
/* Write the data from data_buf1 to the vdata with full interlacing mode. */
num_of_records = VSwrite(vdata1_id, (uint8 *)data_buf1, N_RECORDS, FULL_INTERLACE);
VERIFY_VOID(num_of_records, N_RECORDS, "VSwrite:vdata1_id");
/* The block size should change properly */
status_n = VSgetblockinfo(vdata1_id, &block_size, &num_blocks);
CHECK_VOID(status_n, FAIL, "VSgetblockinfo");
VERIFY_VOID(block_size, BLOCK_SIZE1, "VSgetblockinfo");
/******************************************************************
* Creates and writes another vdata right after APPENDABLE_VDATA.
* This will cause the storage of APPENDABLE_VDATA to be promoted to a
* linked-block element if a subsequent write to APPENDABLE_VDATA occurs.
******************************************************************/
/* Create another vdata. */
vdata_ref = -1;
vdata2_id = VSattach(fid, vdata_ref, "w");
CHECK_VOID(vdata2_id, FAIL, "VSattach");
/* Set name and class name of the vdata. */
status = VSsetname(vdata2_id, ANOTHER_VD);
CHECK_VOID(status, FAIL, "VSsetname");
status = VSsetclass(vdata2_id, CLASS_NAME);
CHECK_VOID(status, FAIL, "VSsetclass");
/* Define the vdata's field. */
status_n = VSfdefine(vdata2_id, ANOTHER_FD, DFNT_INT32, ORDER_2);
CHECK_VOID(status_n, FAIL, "VSfdefine");
status_n = VSsetfields(vdata2_id, ANOTHER_FD_LIST);
CHECK_VOID(status_n, FAIL, "VSsetfields");
/* Buffer the data for ANOTHER_VDATA */
for (rec_num = 0; rec_num < N_RECORDS; rec_num++) {
data_buf2[rec_num][0] = 100 + rec_num;
}
/* Write the data from data_buf2 to the second vdata with full
interlacing mode. */
num_of_records = VSwrite(vdata2_id, (uint8 *)data_buf2, N_RECORDS, FULL_INTERLACE);
VERIFY_VOID(num_of_records, N_RECORDS, "VSwrite:vdata2_id");
/******************************************************************
* Writes more data to APPENDABLE_VDATA, i.e. first vdata. Its
* storage will be promoted to a linked-block element.
******************************************************************/
for (rec_num = 0; rec_num < N_RECORDS; rec_num++) {
data_buf1[rec_num][0] = 10 + rec_num;
data_buf1[rec_num][1] = 20 + rec_num;
data_buf1[rec_num][2] = 30 + rec_num;
data_buf1[rec_num][3] = 100 + rec_num;
data_buf1[rec_num][4] = 100;
data_buf1[rec_num][5] = 650;
}
/* Append the data to the first vdata. */
VSseek(vdata1_id, N_RECORDS);
num_of_records = VSwrite(vdata1_id, (uint8 *)data_buf1, N_RECORDS, FULL_INTERLACE);
VERIFY_VOID(num_of_records, N_RECORDS, "VSwrite:vdata1_id");
/* Retrieve the first vdata's block size and number of blocks and
verify them */
status_n = VSgetblockinfo(vdata1_id, &block_size, &num_blocks);
CHECK_VOID(status_n, FAIL, "VSgetblockinfo");
VERIFY_VOID(block_size, BLOCK_SIZE1, "VSgetblockinfo");
VERIFY_VOID(num_blocks, NUM_BLOCKS, "VSgetblockinfo");
/* Terminate access to the vdatas and to the VS interface, then
close the HDF file. */
status = VSdetach(vdata1_id);
CHECK_VOID(status, FAIL, "Vdetach");
status = VSdetach(vdata2_id);
CHECK_VOID(status, FAIL, "Vdetach");
/* Terminate access to the V interface and close the file. */
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
} /* test_blockinfo_oneLB() */
/****************************************************************************
Name: test_blocksize_multLBs() - tests setting block info in the case of
multiple linked block element
Description:
The test opens the file again, open the first vdata, "Appendable Vdata",
- Open the file and the first vdata, APPENDABLE_VD.
- Verify that the block size had changed to BLOCK_SIZE1 and number of
blocks to NUM_BLOCKS
- Attempt to change the block size to something else, and verify that it
is not changed, then close the vdata.
- Open the second vdata, ANOTHER_VD.
- Verify that the block size and number of blocks are the default values,
HDF_APPENDABLE_BLOCK_LEN and HDF_APPENDABLE_BLOCK_NUM.
- Change block size to BLOCK_SIZE2
- Append 5 records to ANOTHER_VD, which triggers its storage to be
converted into a linked-block element.
- Close the vdata and the file.
- Open the file to verify block info stay changed.
BMR - Jan 2014
****************************************************************************/
static void
test_blockinfo_multLBs(void)
{
intn status_n; /* returned status for functions returning an intn */
int32 status; /* returned status for functions returning an int32 */
int16 rec_num; /* current record number */
int32 fid, vdata1_id, vdata2_id;
int32 vdata_ref = -1, /* ref number of a vdata, set to -1 to create */
num_of_records, /* number of records actually written to vdata */
data_buf2[N_RECORDS][N_VALS_PER_REC_2], /* for second vdata's data */
block_size, num_blocks; /* retrieved by VSgetblockinfo */
/******************************************************************
* Reopen the file, and the vdata APPENDABLE_VDATA, then append more
* data and test for block information.
******************************************************************/
fid = Hopen(LKBLK_FILE, DFACC_RDWR, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the VS interface */
status_n = Vstart(fid);
CHECK_VOID(status_n, FAIL, "Vstart");
/* Locate and open vdata APPENDABLE_VD */
vdata_ref = -1;
vdata_ref = VSfind(fid, APPENDABLE_VD);
CHECK_VOID(vdata_ref, FAIL, "VSfind");
vdata1_id = VSattach(fid, vdata_ref, "w");
CHECK_VOID(vdata1_id, FAIL, "VSattach");
/* Retrieve the first vdata's block size and number of blocks and
verify them again. This used to return the old value. (HDFFR-1357) */
status_n = VSgetblockinfo(vdata1_id, &block_size, &num_blocks);
CHECK_VOID(status_n, FAIL, "VSsetfields");
VERIFY_VOID(block_size, BLOCK_SIZE1, "VSgetblockinfo");
VERIFY_VOID(num_blocks, NUM_BLOCKS, "VSgetblockinfo");
/* Set the block size to the first vdata again, but this is when vdata
already has a linked-block element. If the block size is different
than the previously specified block size, then the change will not
take effect. */
status_n = VSsetblocksize(vdata1_id, BLOCK_SIZE1 + 100);
CHECK_VOID(status_n, FAIL, "VSsetblocksize");
/* Retrieve the first vdata's block size and verify that it did not
change */
status_n = VSgetblockinfo(vdata1_id, &block_size, NULL);
CHECK_VOID(status_n, FAIL, "VSgetblockinfo");
VERIFY_VOID(block_size, BLOCK_SIZE1, "VSgetblockinfo");
/* Close the vdata */
status = VSdetach(vdata1_id);
CHECK_VOID(status, FAIL, "Vdetach");
/* Next test:
Open the second vdata, ANOTHER_VD, check block size, set block
size, write to it, then check block size again */
/* Locate and open the vdata ANOTHER_VD */
vdata_ref = -1;
vdata_ref = VSfind(fid, ANOTHER_VD);
CHECK_VOID(vdata_ref, FAIL, "VSfind");
vdata2_id = VSattach(fid, vdata_ref, "w");
CHECK_VOID(vdata2_id, FAIL, "VSattach");
/* Check block size of ANOTHER_VD */
status_n = VSgetblockinfo(vdata2_id, &block_size, &num_blocks);
VERIFY_VOID(block_size, HDF_APPENDABLE_BLOCK_LEN, "VSgetblockinfo");
/* Set the block size to ANOTHER_VD to BLOCK_SIZE2 */
status_n = VSsetblocksize(vdata2_id, BLOCK_SIZE2);
CHECK_VOID(status_n, FAIL, "VSsetblocksize");
/* Retrieve the block size of ANOTHER_VD */
status_n = VSgetblockinfo(vdata2_id, &block_size, NULL);
CHECK_VOID(status_n, FAIL, "VSgetblockinfo");
VERIFY_VOID(block_size, BLOCK_SIZE2, "VSgetblockinfo");
/* Buffer the data for ANOTHER_VDATA */
for (rec_num = 0; rec_num < N_RECORDS; rec_num++) {
data_buf2[rec_num][0] = 200 + rec_num;
}
/* Write the data from data_buf2 to the vdata with full interlacing mode. */
VSseek(vdata2_id, N_RECORDS);
num_of_records = VSwrite(vdata2_id, (uint8 *)data_buf2, N_RECORDS, FULL_INTERLACE);
VERIFY_VOID(num_of_records, N_RECORDS, "VSwrite:vdata2_id");
/* Retrieve the first vdata's block size and number of blocks and
verify them */
status_n = VSgetblockinfo(vdata2_id, &block_size, &num_blocks);
CHECK_VOID(status_n, FAIL, "VSsetfields");
VERIFY_VOID(block_size, BLOCK_SIZE2, "VSgetblockinfo");
/* Close the vdata and file */
status = VSdetach(vdata2_id);
CHECK_VOID(status, FAIL, "Vdetach");
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
/*
* Open the file one more time and verify the block size and number
* of blocks of the vdatas that have linked-block storage.
*/
/* Open file again. */
fid = Hopen(LKBLK_FILE, DFACC_RDONLY, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the VS interface */
status_n = Vstart(fid);
CHECK_VOID(status_n, FAIL, "Vstart");
/* Locate and open vdata APPENDABLE_VD. */
vdata_ref = -1;
vdata_ref = VSfind(fid, APPENDABLE_VD);
CHECK_VOID(vdata_ref, FAIL, "VSfind");
vdata1_id = VSattach(fid, vdata_ref, "r");
CHECK_VOID(vdata1_id, FAIL, "VSattach");
/* Verify its block size and number of blks. */
status_n = VSgetblockinfo(vdata1_id, &block_size, &num_blocks);
CHECK_VOID(status_n, FAIL, "VSsetfields");
VERIFY_VOID(block_size, BLOCK_SIZE1, "VSgetblockinfo");
VERIFY_VOID(num_blocks, NUM_BLOCKS, "VSgetblockinfo");
/* Close APPENDABLE_VD. */
status = VSdetach(vdata1_id);
CHECK_VOID(status, FAIL, "Vdetach");
/* Locate and open vdata ANOTHER_VD, and verify its block size and number of blks. */
vdata_ref = -1;
vdata_ref = VSfind(fid, ANOTHER_VD);
CHECK_VOID(vdata_ref, FAIL, "VSfind");
vdata2_id = VSattach(fid, vdata_ref, "r");
CHECK_VOID(vdata2_id, FAIL, "VSattach");
/* Verify its block size and number of blks. */
status_n = VSgetblockinfo(vdata2_id, &block_size, &num_blocks);
CHECK_VOID(status_n, FAIL, "VSsetfields");
VERIFY_VOID(block_size, BLOCK_SIZE2, "VSgetblockinfo");
VERIFY_VOID(num_blocks, HDF_APPENDABLE_BLOCK_NUM, "VSgetblockinfo");
/* Close ANOTHER_VD and the file. */
status = VSdetach(vdata2_id);
CHECK_VOID(status, FAIL, "Vdetach");
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
} /* test_blockinfo_multLBs() */
/*
* This test is here to use the file LKBLK_FILE, but it will be moved to
* another file in the future when more organization is done for tests.
* This function tests that VSofclass gets the reference numbers of the
* vdatas belonging to a class.
*/
static void
test_VSofclass()
{
intn status_n; /* returned status for functions returning an intn */
int32 status; /* returned status for functions returning an int32 */
int32 fid;
intn n_vds = 0;
uint16 *refarray = NULL;
/* Open file LKBLK_FILE for reading. */
fid = Hopen(LKBLK_FILE, DFACC_RDONLY, 0);
CHECK_VOID(fid, FAIL, "Hopen");
/* Initialize the VS interface */
status_n = Vstart(fid);
CHECK_VOID(status_n, FAIL, "Vstart");
/* VSofclass returns the number of vdatas belonging to CLASS_NAME correctly */
n_vds = VSofclass(fid, CLASS_NAME, 0, 0, NULL);
VERIFY_VOID(n_vds, 2, "VSofclass");
/* Allocate space for the ref array to pass into VSofclass. */
refarray = (uint16 *)malloc(sizeof(uint16) * n_vds);
CHECK_ALLOC(refarray, "refarray", "test_blockinfo_multLBs");
/* The following tests rely on the reference numbers of the two vdatas of
class CLASS_NAME. If data is added to the file before these vdatas,
the reference numbers (2 and 3 below) need to be adjusted accordingly or
tests will fail -BMR (will have a better tests later) */
n_vds = VSofclass(fid, CLASS_NAME, 0, n_vds, refarray);
VERIFY_VOID(refarray[0], 2, "VSofclass");
VERIFY_VOID(refarray[1], 3, "VSofclass");
refarray[0] = refarray[1] = 0;
n_vds = VSofclass(fid, CLASS_NAME, 0, 1, refarray);
VERIFY_VOID(refarray[0], 2, "VSofclass");
VERIFY_VOID(refarray[1], 0, "VSofclass");
n_vds = VSofclass(fid, CLASS_NAME, 1, n_vds, refarray);
VERIFY_VOID(refarray[0], 3, "VSofclass");
VERIFY_VOID(refarray[1], 0, "VSofclass");
free(refarray);
/* Terminate access to the V interface and close the file. */
status_n = Vend(fid);
CHECK_VOID(status_n, FAIL, "Vend");
status = Hclose(fid);
CHECK_VOID(status, FAIL, "Hclose");
} /* test_VSofclass */
/*************************** test_blockinfo ***************************
Name: ttest_blockinfo() - tests setting/getting block info for a vdata
Description:
This test creates an hdf file, "Block_info.hdf", and creates and
writes two vdatas in a way that one of the vdatas, then later the
other one, will be promoted to linked-block elements.
The first vdata is named "Appendable Vdata", and belongs to a class,
named "Linked-block Vdata". The fields of the vdata include "Field1",
"Field2", and "Field3" and all data are integer. "Field1" has an order
of 3, "Field2" has an order of 1, and "Field3" has an order of 2.
The second vdata named "Another Vdata", and also belongs to class
"Linked-block Vdata". This vdata has only one field of order 1 and
its data are integer.
test_blockinfo is divided into two parts:
test_blockinfo_oneLB
test_blockinfo_multLBs
***********************************************************************/
/* This test is perhaps more suitable somewhere else or in a file by
itself, but keep it here for now since we're running out of time...*/
void
test_blockinfo(void)
{
/* test the case of setting block size doesn't have effect until linked-
block element is created */
test_blockinfo_oneLB();
/* test functionality about set/get linked-block information */
test_blockinfo_multLBs();
/* test VSofclass; relies on the file created and written by the tests
in test_blockinfo_oneLB and test_blockinfo_multLBs */
test_VSofclass();
} /* test_blockinfo */
/* main test driver */
void
test_vsets(void)
{
int32 status;
status = write_vset_stuff();
if (status == FAIL)
return;
status = read_vset_stuff();
if (status == FAIL)
return;
/* test VSdelete() */
test_vsdelete();
/* test Vdelete() */
test_vdelete();
/* test Vdeletetagref() */
test_vdeletetagref();
/* test Vdatas with no fields defined */
test_emptyvdata();
/* test Vgroups with name and class that have more than 64 characters */
test_vglongnames();
/* test functionality about set/get linked-block information */
test_blockinfo();
/* test Vgetgroups - getting user-created vgroups */
test_getvgroups();
/* test VSgetvdatas - getting user-created vdatas */
test_getvdatas();
/* test_extfile - getting external file information */
test_extfile();
} /* test_vsets */
/* TODO:
- should either making all the other test functions to return status as
read_vset_stuff() and write_vset_stuff, or making these two void.
- review each test function and add header/comments
BMR - Jan 16, 2014
*/
|