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 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394
|
########## The MySQL Test Framework ##########
/**
@page PAGE_MYSQL_TEST_RUN The MySQL Test Framework
This manual describes the MySQL test framework, consisting of the
test driver and the test script language.
-----
<h3>Table of Contents</h3>
- @subpage PAGE_PREFACE
- @subpage PAGE_INTRODUCTION
- @subpage PAGE_MYSQLTEST_FRAMEWORK_COMPONENTS
- @subpage PAGE_RUNNING_TESTCASES
- @subpage PAGE_WRITING_TESTCASES
- @subpage PAGE_MYSQLTEST_PROGRAMS
- @subpage PAGE_MYSQLTEST_LANGUAGE_REFERENCE
- @subpage PAGE_UNIT_TESTS
- @subpage PAGE_PLUGINS
*/
###############################################################################
## Preface
/**
@page PAGE_PREFACE Preface
MySQL distributions include a set of test cases and programs for
running them. These tools constitute the MySQL test framework that
provides a means for verifying that MySQL Server and its client
programs operate according to expectations. The test cases consist
mostly of SQL statements, but can also use test language constructs
that control how to run tests and verify their results.
This manual describes the MySQL test framework. It describes the
programs used to run tests and the language used to write test
cases.
*/
###############################################################################
## Introduction to the MySQL Test Framework
/**
@page PAGE_INTRODUCTION Introduction to the MySQL Test Framework
MySQL distributions include a test suite: a set of test cases and
programs for running them. (If you find that the test suite is not
included in your distribution, look for a similar distribution with
<b>-test</b> in the name and install that as well.) These tools
constitute the MySQL test framework that provides a means for
verifying that MySQL Server and its client programs operate
according to expectations. The test cases consist mostly of SQL
statements, but can also use test language constructs that control
how to run tests and verify their results. Distributions also
provide facilities for running unit tests and creating new unit
tests.
This document describes the components of the MySQL test framework,
how the test programs work, and the language used for writing test
cases. It also provides a tutorial for developing test cases and
executing them.
The application that runs the test suite is named @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl". Its location is the
<b>mysql-test</b> directory, which is present both in source and
binary MySQL Server distributions.
On platforms other than Windows, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" is also available through the shortened name
<b>mtr</b> in the same directory, as either a symbolic link or a
copy.
The @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" application
starts MySQL servers, restarts them as necessary when a specific
test case needs different start arguments, and presents the test
result. For each test case, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" invokes the @ref PAGE_MYSQLTEST "mysqltest"
program (also referred to as the “test engine”) to read the test
case file, intepret the test language constructs, and send SQL
statements to the server.
Input for each test case is stored in a file, and the expected
result from running the test is stored in another file. The actual
result is compared to the expected result after running the test.
For a MySQL source distribution, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" is located in the <b>mysql-test</b> directory,
and @ref PAGE_MYSQLTEST "mysqltest" is located in the <b>client</b>
directory. The <b>mysql-test</b> and <b>client</b> directories
are located in the root directory of the distribution.
For a MySQL binary distribution, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" is located in the <b>mysql-test</b> directory,
and @ref PAGE_MYSQLTEST "mysqltest" is located in the same directory
where other client programs such as <b>mysql</b> or
<b>mysqladmin</b> are installed. The locations of the
<b>mysql-test</b> and other directories depend on the layout used
for the distribution format.
Within the <b>mysql-test</b> directory, test case input files and
result files are stored in the <b>t</b> and <b>r</b>
directories, respectively. The input and result files have the same
basename, which is the test name, but have extensions of
<b>.test</b> and <b>.result</b>, respectively. For example, for
a test named “decimal”, the input and result files are
<b>mysql-test/t/decimal.test</b> and <b>mysql-test/r/decimal.result</b>.
Each test file is referred to as one test case, but usually consists
of a sequence of related tests. An unexpected failure of a single
statement in a test case makes the test case fail.
There are several ways a test case can fail:
<ul>
<li>
The @ref PAGE_MYSQLTEST "mysqltest" test engine checks the result
codes from executing each SQL statement in the test input. If the
failure is unexpected, the test case fails.
</li>
<li>
A test case can fail if an error was expected but did not occur
(for example, if an SQL statement succeeded when it should have
failed).
</li>
<li>
The test case can fail by producing incorrect output. As a test
runs, it produces output (the results from <b>SELECT</b>,
<b>SHOW</b>, and other statements). This output is compared
to the expected result found in the <b>mysql-test/r</b> directory
(in a file with a <b>.result</b> suffix). If the expected and
actual results differ, the test case fails. The actual test result
is written to a file in the <b>mysql-test/var/log</b> directory
with a <b>.reject</b> suffix, and the difference between the
<b>.result</b> and <b>.reject</b> files is presented for
evaluation.
</li>
<li>
A test case will fail if the MySQL server dies unexpectedly during
the test. If this happens, the @ref PAGE_MYSQLTEST "mysqltest"
test client will usually also report a failure due to loosing the
connection.
</li>
<li>
Finally, the test case will fail if the error log written by the
MySQL server during the test includes warnings or errors which are
not filtered (suppressed). See @ref PAGE_SUPPRESSING_ERRORS_WARNINGS
for more about suppressing warnings.
</li>
</ul>
This method of checking test results puts some restrictions on how
test cases can be written. For example, the result cannot contain
information that varies from run to run, such as the current time.
However, if the information that varies is unimportant for test
evaluation, there are ways to instruct the test engine to replace
those fields in the output with fixed values.
Because the test cases consist mostly of SQL statements in a text
file, there is no direct support for test cases that are written in
C, Java, or other languages. Such tests are not within the scope of
this test framework. But the framework does support executing your
own scripts and initiating them with your own data. Also, a test
case can execute an external program, so in some respects the test
framework can be extended for uses other than testing SQL
statements. Finally, it is possible to embed small pieces of Perl
code within the test. This can sometimes be used to perform actions
or execute logic which is beyond the capabilities of the test
language or SQL.
*/
###############################################################################
## MySQL Test Framework Components
/**
@page PAGE_MYSQLTEST_FRAMEWORK_COMPONENTS MySQL Test Framework Components
<h3>Table of Contents</h3>
- @subpage PAGE_TEST_FRAMEWORK_SYSTEM_REQUIREMENTS
- @subpage PAGE_REPORT_BUGS
The MySQL test framework consists of programs that run tests, and
directories and files used by those programs.
Test Framework Programs
-----------------------
The MySQL test framework uses several programs:
<ul>
<li>
The @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" Perl script
is the main application used to run the test suite. It invokes
@ref PAGE_MYSQLTEST "mysqltest" to run individual test cases.
</li>
<li>
@ref PAGE_MYSQLTEST "mysqltest" runs test cases.
</li>
<li>
The @ref PAGE_MYSQL_CLIENT_TEST "mysql_client_test" program is
used for testing aspects of the MySQL client API that cannot be
tested using @ref PAGE_MYSQLTEST "mysqltest" and its test
language.
</li>
<li>
The @ref PAGE_MYSQL_STRESS_TEST_PL "mysql-stress-test.pl" Perl
script performs stress-testing of the MySQL server.
</li>
<li>
A unit-testing facility is provided so that individual unit test
programs can be created for storage engines and plugins.
</li>
</ul>
Test suite programs can be found in these locations:
<ul>
<li>
For a source distribution, @ref PAGE_MYSQLTEST "mysqltest" is in
the <b>client</b> directory. For a binary distribution, it is in
the MySQL <b>bin</b> directory.
</li>
<li>
For a source distribution, @ref PAGE_MYSQL_CLIENT_TEST
"mysql_client_test" is in the <b>tests</b> directory. For a
binary distribution, it is in the MySQL <b>bin</b> directory.
</li>
<li>
The other programs are located in the <b>mysql-test</b>
directory. For a source distribution, <b>mysql-test</b> is found
under the source tree root. For a binary distribution, the
location of <b>mysql-test</b> depends on the layout used for the
distribution format.
</li>
</ul>
Test Framework Directories and Files
-------------------------------------
The test suite is located in the <tt>mysql-test</tt> directory,
which contains the following components:
<ul>
<li>
The @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" and @ref
PAGE_MYSQL_STRESS_TEST_PL "mysql-stress-test.pl" programs that
are used for running tests.
</li>
<li>
The <b>t</b> directory contains test case input files. A test
case file might also have additional files associated with it.
</li>
<ul>
<li>
A file name of the form <b><em>test_name</em>.test</b> is a
test case file for a test named <b><em>test_name</em></b>. For
example, <b>subquery.test</b> is the test case file for the
test named <b>subquery</b>.
</li>
<li>
A file name of the form <b><em>test_name</em>-master.opt</b>
provides options to associate with the named test case.
<b>mysql-test-run.pl</b> restarts the server with the options
given in the file if the options are different from those
required for the currently running server.
Note that the <b>-master.opt</b> file is used for the “main”
server of a test, even if no replication is involved.
</li>
<li>
A file name of the form <b><em>test_name</em>-slave.opt</b>
provides slave options.
</li>
<li>
Server options which need to be passed during initialization
of the server can be passed in both
<b><em>test_name</em>-master.opt</b> and
<b><em>test_name</em>-slave.opt</b>. Each bootstrap variable
must be passed as the value of a <b>`--initialize`</b> option so
that @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" can
recognize that the variable should be used during server
initialization, remove the existing data directory, and
initialize a new data directory with the options provided.
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will also
start the server afterwards, with the bootstrap options, and
other options specified.
</li>
<li>
A file name of the form <b><em>test_name</em>-client.opt </b>
provides @ref PAGE_MYSQLTEST "mysqltest" client options.
</li>
<li>
A file name of the form <b><em>test_name</em>.cnf</b> contains
additional entries for the config file to be used for this
test.
<ul>
<li>
During a test run, each server is started with a different
<b>defaults-group-suffix</b> value and this suffix value
can be used with a group name to specify server specific
options. For example, section <b>[mysqld.1]</b> is used to
specify options for mysqld server with suffix value
<b>".1"</b>.
</li>
<li>
The <b>[mysqltest]</b> section is used to specify options
for mysqltest client.
</li>
<li>
The <b>[ENV]</b> section is used to specify environment
variables for a test case.
</li>
<li>
To include the options mentioned in another <b>.cnf</b>
file, <b>!include path_to_cnf_file</b> is used. Path to
the included <b>.cnf</b> should either be an absolute path
or a relative path from current location or from
<b>mysql-test</b> directory.
</li>
</ul>
Here is a sample <b>.cnf</b> file.
@verbatim
!include include/default_my.cnf
[mysqld.1]
Options for server mysqld.1
[mysqld.2]
Options for server mysqld.2
[mysqltest]
ps-protocol
...
...
...
[ENV]
SERVER_MYPORT_1= @mysqld.1.port
SERVER_MYPORT_2= @mysqld.2.port
@endverbatim
</li>
<li>
A file name of the form <b><em>test_name</em>.combinations</b>
provides section of options for each test run.
</li>
<li>
A file name of the form <b><em>suite</em>.opt</b> provides
server options to all the tests within the suite it belongs
to.
If a test run is started with more than one server, the
options specified in a <b><em>suite</em>.opt</b> are used by
all of them. It is also possible to pass the server options
needed during the server initialization in the
<b><em>suite</em>.opt</b> file.
The options mentioned in the <b><em>suite</em>.opt</b> file
are overridden by those found in a
<b><em>test_name</em>-master.opt</b> file or in a
<b><em>test_name</em>-slave.opt</b> file.
</li>
<li>
A file name of the form <b><em>test_name</em>-master.sh</b> is
a shell script that will be executed before the server is
started for the named test case. There may also be a
<b><em>test_name</em>-slave.sh</b> which is executed before
the slave server is started.
These files will not work on Windows and may therefore be
replaced with a more portable mechanism in the future.
</li>
<li>
The <b>disabled.def</b> file contains information about
deferred/disabled tests. When a test is failing because of a
bug in the server and you want it to be ignored by @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl", list the test in
this file.
The format of a line in the <b>disabled.def</b> file looks
like this, where fields are separated by one or more spaces.
@verbatim
suite_name.test_name [@platform|@!platform] : <BUG|WL>#<XXXX> [<comment>]
@endverbatim
Example:
@verbatim
main.1st @linux : BUG#18980 Test fails randomly
@endverbatim
<b><em>suite_name</em></b> is the suite name.
<b><em>test_name</em></b> is the test case name.
An additional element after the test name and before the
colon you may add a <b>\@<em>platform</em></b> to have the
test disabled only on a specific platform. Basic OS names as
reported by <b>$^O</b> in Perl, or <b>'windows'</b> are
supported. Alternatively, <b>@!<em>platform</em></b> will
disable the test on all except the named platform.
<b>BUG#<em>nnnnn</em></b> or <b>WL#<em>nnnn</em></b> indicates
the bug or the WL related to the test that causes it to fail
(and thus requires it to be disabled).
The <b><em>comment</em></b> text following the
<b>BUG#<em>nnnnn</em></b> or the <b>WL#<em>nnnn</em></b> is
not part of the mandatory syntax for this file,
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will not
actually care what is written here. Length of a
<b><em>comment</em></b> text must not be more than <b>80</b>
characters.
A comment line can be written in the file by beginning the
line with a “<b>#</b>” character.
</li>
</ul>
<li>
The <b>r</b> directory contains test case result files:
<ul>
<li>
A file name of the form <b><em>test_name</em>.result</b> is
the expected result for the named test case. A file
<b>r/<em>test_name</em>.result</b> is the output that
corresponds to the input in the test case file
<b>t/<em>test_name</em>.test</b>.
</li>
<li>
A file name of the form <b><em>test_name</em>.reject</b>
contains output for the named test case if the test fails
due to output mismatch (but not it it fails for other
reasons).
</li>
</ul>
For a test case that succeeds, the <b>.result</b> file
represents both the expected and actual result. For a test case
that fails, the <b>.result</b> file represents the expected
result, and the <b>.reject</b> file represents the actual
result.
If a <b>.reject</b> file is created because a test fails, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" removes the file
later the next time the test succeeds.
When <b>`--check-testcases`</b> option is enabled, a test case
not having its corresponding <b>.result</b> file is marked as
failed by MTR. See @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl".
</li>
<li>
The <b>include</b> directory contains files that are included by
test case files using the <b>source</b> command. These include
files encapsulate operations of varying complexity into a single
file so that you can perform the operations in a single step.
See @ref PAGE_INCLUDE_FILES.
</li>
<li>
The <b>lib</b> directory contains library files used by @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl", and database
initialization SQL code.
</li>
<li>
The <b>std_data</b> directory contains data files used by some
of the tests.
</li>
<li>
The <b>var</b> directory is used during test runs for various
kinds of files: log files, temporary files, trace files, Unix
socket files for the servers started during the tests, and so
forth. This directory cannot be shared by simultaneous test
runs.
</li>
<li>
The <b>suite</b> directory contains a set of subdirectories
containing named test suites. Each subdirectory represents a
test suite with the same name.
A test suite directory contains the following components:
<ul>
<li>
The <b>t</b> directory contains test cases.
</li>
<li>
The <b>r</b> directory contains test case result files.
</li>
<li>
The <b>include</b> directory contains files that are
included by the test cases belonging to that suite.
</li>
<li>
A file name of the form <b>combinations</b> provides section
of options for each test run. See @ref
PAGE_CONTROLLING_BINARY_LOG_FORMAT.
</li>
<li>
A file name of the form <b><em>my</em>.cnf</b> contains
additional entries for the config file used by all the tests
within the suite it belongs to.
A suite specific <b><em>my</em>.cnf</b> file is overridden
by a <b><em>test_name</em>.cnf</b> file.
</li>
</ul>
</li>
<li>
The <b>collections</b> directory contains collections of test
runs that are run during integration and release testing of
MySQL. They are not directly useful outside this context, but
need to be part of the source repository and are included for
reference.
</li>
</ul>
Unit test-related files are located in the <b>unittest</b>
directory. Additional files specific to storage engines and plugins
may be present under the subdirectories of the <b>storage</b> or
<b>plugin</b> directories.
Test Execution and Evaluation
-----------------------------
There are a number of targets in the top-level <b>Makefile</b> that
can be used to run sets of tests. <b>make test</b> only runs unit
tests. Other targets run subsets of the tests, or run tests with
specific options for the test programs. Have a look at the
<b>Makefile</b> to see what targets are available.
A “test case” is a single file. The case might contain multiple
individual test commands. If any individual command fails, the
entire test case is considered to fail. Note that “fail” means “does
not produce the expected result.” It does <b><em>not</em></b>
necessarily mean “executes without error,” because some tests are
written precisely to verify that an illegal statement does in fact
produce an error. In such an instance, if the statement executes
successfully without producing the expected error, that is
considered failure of the test.
Test case output (the test result) consists of:
<ul>
<li>
Input SQL statements and their output. Each statement is written
to the result followed by its output. Columns in output
resulting from SQL statements are separated by tab characters.
</li>
<li>
The result from @ref PAGE_MYSQLTEST "mysqltest" commands such as
<b>echo</b> and <b>exec</b>. The commands themselves are not
echoed to the result, only their output.
</li>
</ul>
The <b>disable_query_log</b> and <b>enable_query_log</b> commands
control logging of input SQL statements. The
<b>disable_result_log</b> and <b>enable_result_log</b> commands
control logging of SQL statement results, and warning or error
messages resulting from those statements.
@ref PAGE_MYSQLTEST "mysqltest" reads a test case file from its
standard input by default. The <b>`--test-file`</b> or <b>-x</b>
option can be given to name a test case file explicitly.
@ref PAGE_MYSQLTEST "mysqltest" writes test case output to the
standard output by default. The <b>`--result-file`</b> or <b>-R</b>
option can be used to indicate the location of the result file. That
option, together with the <b>`--record`</b> option, determine how
@ref PAGE_MYSQLTEST "mysqltest" treats the test actual and expected
results for a test case:
<ul>
<li>
If the test produces no results, @ref PAGE_MYSQLTEST "mysqltest"
exits with an error message to that effect, unless
<b>`--result-file`</b> is given and this file is empty.
</li>
<li>
Otherwise, if <b>`--result-file`</b> is not given, @ref
PAGE_MYSQLTEST "mysqltest" sends test results to the standard
output.
</li>
<li>
With <b>`--result-file`</b> but not <b>`--record`</b>, @ref
PAGE_MYSQLTEST "mysqltest" reads the expected results from the
given file and compares them with the actual results. If the
results do not match, @ref PAGE_MYSQLTEST "mysqltest" writes a
<b>.reject</b> file in the log directory and exits with an
error. It will also print out a diff of the expected and actual
result, provided it can find an appropriate
<b>diff</b> tool to use.
</li>
<li>
With both <b>`--result-file`</b> and <b>`--record`</b>, @ref
PAGE_MYSQLTEST "mysqltest" updates the given file by writing the
actual test results to it. The file does not need to pre-exist.
</li>
</ul>
@ref PAGE_MYSQLTEST "mysqltest" itself knows nothing of the <b>t</b>
and <b>r</b> directories under the <b>mysql-test</b> directory. The
use of files in those directories is a convention that is used by
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl", which invokes @ref
PAGE_MYSQLTEST "mysqltest" with the appropriate options for each
test case to tell @ref PAGE_MYSQLTEST "mysqltest" where to read input
and write output.
*/
###############################################################################
## Test Framework System Requirements
/**
@page PAGE_TEST_FRAMEWORK_SYSTEM_REQUIREMENTS Test Framework System Requirements
The @ref PAGE_MYSQLTEST "mysqltest" and @ref PAGE_MYSQL_CLIENT_TEST
"mysql_client_test" programs are written in C++ and are available on
any system where MySQL itself can be compiled, or for which a binary
MySQL distribution is available.
Other parts of the test framework such as @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" are Perl scripts and
should run on systems with Perl installed.
@ref PAGE_MYSQLTEST "mysqltest" uses the <b>diff</b> program to
compare expected and actual test results. If <b>diff</b> is not
found, @ref PAGE_MYSQLTEST "mysqltest" writes an error message and
dumps the entire contents of the <b>.result</b> and
<b>.reject</b> files so that you can try to determine why a test
did not succeed. If your system does not have <b>diff</b>, you may
be able to obtain it from one of these sites:
- http://www.gnu.org/software/diffutils/diffutils.html
- http://gnuwin32.sourceforge.net/packages/diffutils.htm
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" cannot function
properly if started from within a directory whose full path includes
a space character, due to the complexities of handling this
correctly in all the different contexts it will be used.
*/
###############################################################################
## How to Report Bugs from Tests in the MySQL Test Suite
/**
@page PAGE_REPORT_BUGS How to Report Bugs from Tests in the MySQL Test Suite
If test cases from the test suite fail, you should do the following:
<ul>
<li>
Do not file a bug report before you have found out as much as
possible about what when wrong. See the instructions at
https://dev.mysql.com/doc/refman/8.0/en/bug-reports.html.
</li>
<li>
Make sure to include the output of @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl", as well as contents of all <b>.reject</b>
files in the <b>mysql-test/var/log</b> directory, or the (often
much shorter) diff that @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" reported.
</li>
<li>
Check whether an individual test in the test suite also fails
when run on its own:
@verbatim
shell> cd mysql-test
shell> ./mysql-test-run.pl test_name
@endverbatim
If this fails, and you are compiling MySQL yourself, you should
configure MySQL with <b>`--with-debug`</b> and run @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" with the
<b>`--debug`</b> option. If this also fails, open a bug report
and upload the trace file <b>mysql-test/var/tmp/master.trace</b>
to the report, so that we can examine it. For instructions, see
[How to Report Bugs or Problems]
(https://dev.mysql.com/doc/refman/8.0/en/bug-reports.html).
Please remember to also include a full description of your
system, the version of the <b>mysqld</b> binary and how you
compiled it.
</li>
<li>
Run @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" with the
<b>`--force`</b> option to see whether any other tests fail.
</li>
<li>
If you have compiled MySQL yourself, check the MySQL Reference
Manual to see whether there are any platform-specific issues for
your system. There might be configuration workarounds to deal
with the problems that you observe. Also, consider using one of
the binaries we have compiled for you at
https://dev.mysql.com/downloads/. All our standard binaries
should pass the test suite!
</li>
<li>
If you get an error such as <b>Result length mismatch</b> or
<b>Result content mismatch</b> it means that the output of the
test was not an exact match for the expected output. This could
be a bug in MySQL or it could be that your version of
<b>mysqld</b> produces slightly different results under some
circumstances.
This output from @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl"
should include a diff of the expected and actual result. If
unable to produce a diff, it will instead print out both in
full. In addition, the actual result is put in a file in the
<b>r</b> directory with a <b>.result</b> extension.
</li>
<li>
If a test fails completely, you should check the logs file in
the <b>mysql-test/var/log</b> directory for hints of what went
wrong.
</li>
<li>
If you have compiled MySQL with debugging, you can try to debug
test failures by running @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" with either or both of the <b>`--gdb`</b>
and <b>`--debug`</b> options.
If you have not compiled MySQL for debugging you should probably
do so by specifying the [-DWITH_DEBUG]
(https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html#option_cmake_with_debug)
option when you invoke <b>CMake</b>.
</li>
</ul>
*/
###############################################################################
## Running Test Cases
/**
@page PAGE_RUNNING_TESTCASES Running Test Cases
Typically, you run the test suite either from within a source tree
(after MySQL has been built), or on a host where the MySQL server
distribution has been installed. (If you find that the test suite is
not included in your distribution, look for a similar distribution
with <b>-test</b> in the name and install that as well.)
To run tests, your current working directory should be the
<b>mysql-test</b> directory of your source tree or installed
distribution. In a source distribution, <b> mysql-test</b> is
under the root of the source tree. In a binary distribution, the
location of <b>mysql-test</b> depends on the distribution layout.
The program that runs the test suite, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl", will figure out whether you are in a source
tree or an installed directory tree.
To run the test suite, change location into your <b>mysql-test</b>
directory and invoke the @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" script:
@verbatim
shell> cd mysql-test
shell> ./mysql-test-run.pl
@endverbatim
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" accepts options on
the command line. For example:
@verbatim
shell> ./mysql-test-run.pl --force --suite=binlog
@endverbatim
By default, @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" exits if
a test case fails. <b>`--force`</b> causes execution to continue
regardless of test case failure.
For a full list of the supported options, see @ref
PAGE_MYSQL_TEST_RUN_PL.
To run one or more specific test cases, name them on the @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" command line. Test case
files have names like <b>t/<em>test_name</em>.test</b>, where
<b><em>test_name</em></b> is the name of the test case, but each name
given on the command line should be the test case name, not the full
test case file name. The following command runs the test case named
<b>rpl_abcd</b>, which has a test file of
<b>t/rpl_abcd.test</b>:
@verbatim
shell> ./mysql-test-run.pl rpl_abcd
@endverbatim
To run a family of test cases for which the names share a common
prefix, use the <b>`--do-test`</b> option:
@verbatim
shell> ./mysql-test-run.pl --do-test=prefix
@endverbatim
For example, the following command runs the events tests (test
cases that have names beginning with <b>events</b>):
@verbatim
shell> ./mysql-test-run.pl --do-test=events
@endverbatim
To run a specific named testsuite with all the test cases in it,
use the <b>`--suite`</b> option:
@verbatim
shell> ./mysql-test-run.pl --suite=suite_name
@endverbatim
For example, the following command runs the replication tests
located in the <b>rpl</b> suite:
@verbatim
shell> ./mysql-test-run.pl --suite=rpl
@endverbatim
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" starts the MySQL
server, sets up the environment for calling the @ref PAGE_MYSQLTEST
"mysqltest" program, and invokes @ref PAGE_MYSQLTEST "mysqltest" to
run the test case. For each test case to be run, @ref PAGE_MYSQLTEST
"mysqltest" handles operations such as reading input from the test
case file, creating server connections, and sending SQL statements
to servers.
The language used in test case files is a mix of commands that the
@ref PAGE_MYSQLTEST "mysqltest" program understands and SQL
statements. Input that @ref PAGE_MYSQLTEST "mysqltest" doesn't
understand is assumed to consist of SQL statements to be sent to the
database server. This makes the test case language familiar to those
that know how to write SQL and powerful enough to add the control
needed to write test cases.
You need not start a MySQL server first before running tests.
Instead, the @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" program
will start the server or servers as needed. Any servers started for
the test run use ports in the range from 13000 by default.
@section SECTION_RUNNING_TESTS_IN_PARALLEL Running Tests in Parallel
It is possible to run more than one instance of @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" simultaneously on the
same machine. Both will by default use server ports from 13000 but
will coordinate used port numbers as well as check for availibility,
to avoid conflicts.
Running several instances from the same <b>mysql-test</b>
directory is possible but problematic. You must the use the
<b>`--vardir`</b> to set different log directories for each
instance. Even so, you can get into trouble becuse they will write
<b>.reject</b> files to the same directories.
It is also possible to have a single @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" run tests in several threads in parallel.
Execution of the tests will be distributed among the threads. This
is achieved using the <b>`--parallel`</b> option, with the number
of threads as argument. The special value <b>auto</b> will ask
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" to pick a value
automatically, based on system information. The parallel option may
also be given using the environment variable <b>MTR_PARALLEL</b>.
@note
Test cases which use <b>not_parallel.inc</b> are run at the end with
a parallel value of <b>1</b> overriding the <b>`--parallel`</b>
option value. Such test cases will be executed at the end of the test
run one at a time.
*/
###############################################################################
## Writing Test Cases
/**
@page PAGE_WRITING_TESTCASES Writing Test Cases
<h3>Table of Contents</h3>
- @subpage PAGE_QUICK_START
- @subpage PAGE_TESTCASE_CODING_GUIDELINES
- @subpage PAGE_SAMPLE_TESTCASES
- @subpage PAGE_CLEANUP_PREVIOUS_TEST_RUN
- @subpage PAGE_GENERATE_TESTCASE_RESULT_FILE
- @subpage PAGE_CHECK_EXPECTED_ERRORS
- @subpage PAGE_CONTROL_INFORMATION_PRODUCED_TESTCASE
- @subpage PAGE_DEALING_OUTPUT
- @subpage PAGE_PASSING_OPTIONS
- @subpage PAGE_TESTCASE_SPECIFIC_SERVER_OPTIONS
- @subpage PAGE_TESTCASE_SPECIFIC_BOOTSTRAP_OPTIONS
- @subpage PAGE_TESTCASE_SPECIFIC_CLIENT_OPTIONS
- @subpage PAGE_INCLUDE_FILES
- @subpage PAGE_BINARY_LOG_FORMAT
- @subpage PAGE_WRITING_REPLICATION_TESTS
- @subpage PAGE_THREAD_SYNCHRONIZATION
- @subpage PAGE_SUPPRESSING_ERRORS_WARNINGS
- @subpage PAGE_STOPPING_AND_RESTARTING_SERVER_DURING_TEST
- @subpage PAGE_TIPS_WRITING_TESTCASES
Normally, you run the test suite during the development process to
ensure that your changes do not cause existing test cases to break.
You can also write new test cases or add tests to existing cases.
This happens when you fix a bug (so that the bug cannot reappear
later without being detected) or when you add new capabilities to
the server or other MySQL programs.
This chapter provides guidelines for developing new test cases for
the MySQL test framework.
Some definitions:
- One “test file” is one “test case”.
- One “test case” might contain a “test sequence” (that is, a
number of individual tests that are grouped together in the same
test file).
- A “command” is an input test that @ref PAGE_MYSQLTEST "mysqltest"
recognizes and executes itself. A “statement” is an SQL statement
or query that @ref PAGE_MYSQLTEST "mysqltest" sends to the MySQL
server to be executed.
*/
###############################################################################
## Writing a Test Case: Quick Start
/**
@page PAGE_QUICK_START Writing a Test Case: Quick Start
The basic principle of test case evaluation is that output resulting
from running a test case is compared to the expected result. This is
just a <b>diff</b> comparison between the output and an expected-result
file that the test writer provides. This simplistic method of
comparison does not by itself provide any way to handle variation in
the output that may occur when a test is run at different times.
However, the test language provides commands for postprocessing
result output before the comparison occurs. This enables you to
manage certain forms of expected variation.
Use the following procedure to write a new test case. In the
examples, <b><em>test_name</em></b> represents the name of the test
case. It is assumed here that you'll be using a development source
tree, so that when you create a new test case, you can commit the
files associated with it to the source repository for others to use.
<ol>
<li>
Change location to the test directory
<b>mysql-<em>version</em>/mysql-test</b>:
@verbatim
shell> cd mysql-version/mysql-test
@endverbatim
<b>mysql-<em>version</em></b> represents the root directory of
your source tree.
</li>
<li>
Create the test case in a file
<b>t/<em>test_name</em>.test</b>. You can do this with
any text editor. For details of the language used for writing
@ref PAGE_MYSQLTEST "mysqltest" test cases, see @ref
PAGE_MYSQLTEST_LANGUAGE_REFERENCE.
</li>
<li>
Create an empty result file:
@verbatim
shell> touch r/test_name.result
@endverbatim
</li>
<li>
Run the test:
@verbatim
shell> ./mysql-test-run.pl test_name
@endverbatim
</li>
<li>
Assuming that the test case produces output, it should fail
because the output does not match the result file (which is
empty at this point). The failure results in creation of a
reject file named
<b>mysql-test/var/log/<em>test_name</em>.reject</b>.
Examine this file. If the reject file appears to contain the
output that you expect the test case to produce, copy its
content to the result file:
@verbatim
shell> cp mysql-test/var/log/test_name.reject r/test_name.result
@endverbatim
Another way to create the result file is by invoking @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" with the
<b>`--record`</b> option to record the test output in the
result file:
@verbatim
shell> ./mysql-test-run.pl --record test_name
@endverbatim
</li>
<li>
Run the test again. This time it should succeed:
@verbatim
shell> ./mysql-test-run.pl test_name
@endverbatim
You can also run the newly created test case as part of
the entire suite:
@verbatim
shell> ./mysql-test-run.pl
@endverbatim
</li>
</ol>
It is also possible to invoke the @ref PAGE_MYSQLTEST "mysqltest"
program directly. If the test case file refers to environment
variables, you will need to define those variables in your
environment first. For more information about the @ref
PAGE_MYSQLTEST "mysqltest" program, see @ref PAGE_MYSQLTEST.
*/
###############################################################################
## Test Case Coding Guidelines
/**
@page PAGE_TESTCASE_CODING_GUIDELINES Test Case Coding Guidelines
<h3>Table of Contents</h3>
- @subpage PAGE_NAMING_ORGANIZATION_GUIDELINES
- @subpage PAGE_CONTENT_FORMATTING_GUIDELINES
- @subpage PAGE_NAMING_CONVENTIONS
*/
###############################################################################
## File Naming and Organization Guidelines
/**
@page PAGE_NAMING_ORGANIZATION_GUIDELINES File Naming and Organization Guidelines
Test case file names may use alphanumeric characters (<b>A-Z</b>,
<b>a-z</b>, <b>0-9</b>), underscore (<b>'_'</b>) or dash
(<b>'-'</b>), but should not start with underscore or dash. No other
special characters are allowed, if used, then an error is thrown and
the test run is aborted.
Test names have traditionally used lowercase only, and we recommend
continuing this for tests added to the common repository, though
uppercase letters are also supported.
Test cases are located in the <b>mysql-test/t</b> directory. Test
case file names consist of the test name with a <b>.test</b>
suffix. For example, a test named <b>foo</b> should be written in
the file <b>mysql-test/t/foo.test</b>.
In addition to this directory, tests are organized in test suites,
located in subdirectories under the <b>suite</b> directory. For
example, a test named <b>bar</b> under the replication suite
<b>rpl</b> may be stored in the file <b>mysql-
test/suite/rpl/t/bar.test</b>.
In practice, the file would likely be called <b>rpl_bar.test</b>
as tests in a suite usually also have the suite name as a prefix.
This is just a convention from the time when suites were not
supported, and not a requirement for test naming.
One test case file can be a collection of individual tests that
belong together. If one of the tests fails, the entire test case
fails. Although it may be tempting to write each small test into a
single file, that will be too inefficient and makes test runs
unbearably slow. So make the test case files not too big, not too
small.
Each test case (that is, each test file) must be self contained and
independent of other test cases. Do not create or populate a table
in one test case and depend on the table in a later test case. If
you have some common initialization that needs to be done for
multiple test cases, create an include file. That is, create a file
containing the initialization code in the <b>mysql-test/include</b>
directory, and then put a <b>source</b> command in each test case
that requires the code. For example, if several test cases need to
have a given table created and filled with data, put the statements
to do that in a file named <b>mysql-test/include/create_my_table.inc</b>.
The <b>.inc</b> is a convention, not a requirement. Then put the
following command in each test case file that needs the
initialization code:
@verbatim
--source include/create_my_table.inc
@endverbatim
The file name in the <b>source</b> command is relative to the
<b>mysql-test</b> directory. Remember to drop the table at the
end of each test that creates it.
*/
###############################################################################
## Test Case Content-Formatting Guidelines
/**
@page PAGE_CONTENT_FORMATTING_GUIDELINES Test Case Content-Formatting Guidelines
When you write a test case, please keep in mind the following
general guidelines.
There are C/C++ coding guidelines in the MySQL Internals manual;
please apply them when it makes sense to do so: @ref
PAGE_CODING_GUIDELINES.
Other guidelines may be found in this page, which discusses general
principles of test-case writing: MySQL Internals:
[How to Create Good Test Cases]
(https://dev.mysql.com/doc/internals/en/good-tests.html)
The following guidelines are particularly applicable to writing test
cases:
<ul>
<li>
To write a test case file, use any text editor that uses
linefeed (newline) as the end-of-line character.
</li>
<li>
Avoid lines longer than 80 characters unless there is no
other choice.
</li>
<li>
A comment in a test case is started with the "#" character.
@ref PAGE_MYSQL_TEST_INPUT_CONVENTIONS discusses the details
of input syntax for mysqltest test cases.
</li>
<li>
Use spaces, not tabs.
</li>
<li>
Write SQL statements using the same style as our manual:
<ul>
<li>
Use uppercase for SQL keywords.
</li>
<li>
Use lowercase for identifiers (names of objects such as
databases, tables, columns, and so forth).
</li>
</ul>
Ignore this guideline if your intent is to test lettercase
processing for SQL statements, of course.
Use lowercase for @ref PAGE_MYSQLTEST "mysqltest" commands
(<b>echo</b>, <b>sleep</b>, <b>let,</b> and so forth).
You may notice that many existing test cases currently do not
follow the lettercase guideline and contain SQL statements
written entirely in lowercase. Nevertheless, <b><em>please use
the guideline for new tests</em></b>. Lettercase for older tests
can be left as is, unless perhaps you need to revise them
significantly.
</li>
<li>
Break a long SQL statement into multiple lines to make it more
readable. This means that you will need to write it using a
<b>";"</b> delimiter at the end of the statement rather than
using <b>"--"</b> at the beginning because the latter style
works only for single-line statements.
</li>
<li>
Include comments. They save the time of others. In particular:
<ul>
<li>
Please include a header in test files that indicates the
purpose of the test and references the corresponding worklog
task, if any.
</li>
<li>
Comments for a test that is related to a bug report should
include the bug number and title.
</li>
</ul>
Worklog and bug numbers are useful because they enable people
who are interested in additional background related to the test
case to know which worklog entries or bug reports to read.
</li>
</ul>
Example SQL statement, formatted onto multiple lines for readability:
@verbatim
SELECT f1 AS "my_column", f10 ....
FROM mysqltest1.t5
WHERE (f2 BETWEEN 17 AND 25 OR f2 = 61)
AND f3 IN (SELECT ....
FROM mysqltest1.t4
WHERE .....)
ORDER BY ... ;
@endverbatim
Example test file header:
@verbatim
########### suite/funcs_1/t/a_processlist_val_no_prot.test #############
# #
# Testing of values within INFORMATION_SCHEMA.PROCESSLIST #
# #
# The prepared statement variant of this test is #
# suite/funcs_1/t/b_processlist_val_ps.test. #
# #
# There is important documentation within #
# suite/funcs_1/datadict/processlist_val.inc #
# #
# Note(mleich): #
# The name "a_process..." with the unusual prefix "a_" is #
# caused by the fact that this test should run as second test, that #
# means direct after server startup and a_processlist_priv_no_prot. #
# Otherwise the connection IDs within the processlist would differ. #
# #
# Creation: #
# 2007-08-09 mleich Implement this test as part of #
# WL#3982 Test information_schema.processlist #
# #
########################################################################
@endverbatim
Example test reference to bug report:
@verbatim
# Bug #3671 Stored procedure crash if function has "set @variable=param"
@endverbatim
*/
###############################################################################
## Naming Conventions for Database Objects
/**
@page PAGE_NAMING_CONVENTIONS Naming Conventions for Database Objects
It is possible to run test cases against a production server. This
is very unlikely to happen by accident, as @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will start its own server
unless you use the <b>`--extern`</b> Even so, try to write test
cases in a way that reduces the risk that running tests will alter
or destroy important tables, views, or other objects. (<b>DROP
DATABASE</b> statements are particularly dangerous if written using
names that could exist on a customer's machine.) To avoid such
problems, we recommend the following naming conventions:
<ul>
<li>
User names: User names should begin with “mysql” (for example,
<b>mysqluser1</b>, <b>mysqluser2</b>)
</li>
<li>
Database names: Unless you have a special reason not to, use
the default database named <b>test</b> that is already created
for you. For tests that need to operate outside the <b>test</b>
database, database names should contain “test” or begin with
“mysql” (for example, <b>mysqltest1</b>, <b>mysqltest2</b>)
</li>
<li>
Table names: <b>t1</b>, <b>t2</b>, <b>t3</b>, ...
</li>
<li>
View names: <b>v1</b>, <b>v2</b>, <b>v3</b>, ...
</li>
</ul>
For examples of how to name objects, examine the existing test
cases. Of course, you can name columns and other objects inside
tables as you wish.
*/
###############################################################################
## Sample Test Case
/**
@page PAGE_SAMPLE_TESTCASES Sample Test Case
Here is a small sample test case:
@verbatim
--disable_warnings
DROP TABLE IF EXISTS t1;
SET @@sql_mode='NO_ENGINE_SUBSTITUTION';
--enable_warnings
SET SQL_WARNINGS=1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES ("hej");
DROP TABLE t1;
@endverbatim
The first few lines try to clean up from possible earlier runs of
the test case by dropping the <b>t1</b> table. The test case uses
<b>disable_warnings</b> to prevent warnings from being written to
the output because it is not of any interest at this point during
the test to know whether the table <b>t1</b> was there. The value of
<b>sql_mode</b> is changed to <b>NO_ENGINE_SUBSTITUTION</b> to avoid
the error thrown by the second insert statement. After this, the
test case uses <b>enable_warnings</b> so that subsequent warnings
will be written to the output. The test case also enables verbose
warnings in MySQL using the <b>SET SQL_WARNINGS=1;</b> statement.
Next, the test case creates the table <b>t1</b> and tries some
operations. Creating the table and inserting the first row are
operations that should not generate any warnings. The second insert
should generate a warning because it inserts a nonnumeric string
into a numeric column. At the end, it drops the table <b>t1</b>. The
output that results from running the test looks like this:
@verbatim
DROP TABLE IF EXISTS t1;
SET @@sql_mode='NO_ENGINE_SUBSTITUTION';
SET SQL_WARNINGS=1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES ("hej");
Warnings:
Warning 1366 Incorrect integer value: 'hej' for column 'a' at row 1
DROP TABLE t1;
@endverbatim
Note that the result includes not only the output from SQL
statements, but the statements themselves. Statement logging can be
disabled with the <b>disable_query_log</b> test language command.
There are several options for controlling the amount of output from
running the tests.
If there was a test failure, it will be reported to the screen. You
can see the actual output from the last unsuccessful run of the test
case in the reject file
<b>mysql-test/var/log/<em>test_name</em>.reject</b>.
*/
###############################################################################
## Cleaning Up from a Previous Test Run
/**
@page PAGE_CLEANUP_PREVIOUS_TEST_RUN Cleaning Up from a Previous Test Run
For efficiency, the @ref PAGE_MYSQLTEST "mysqltest" test engine does
not start with a clean new database for running each test case, so a
test case generally starts with a “cleaning up section”. Assume that
a test case will use two tables named <b>t1</b> and <b>t2</b>.
The test case should begin by making sure that any old tables with
those names do not exist:
@verbatim
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
@endverbatim
The <b>disable_warnings</b> command instructs the test engine not
to log any warnings until an <b>enable_warnings</b> command occurs
or the test case is ended. (MySQL generates a warning if the table
<b>t1</b> or <b>t2</b> does not exist.) Surrounding this part of
the test case with commands to disable and enable warnings makes its
output the same regardless of whether the tables exist before the
test is started. After ensuring that the tables do not exist, we are
free to put in any SQL statements that create and use the tables
<b>t1</b> and <b>t2</b>. The test case should also clean up at
the end of the test by dropping any tables that it creates.
Let's put in some SQL code into this test case:
@verbatim
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
CREATE TABLE t1 (
Period SMALLINT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
Varor_period SMALLINT(4) UNSIGNED DEFAULT '0' NOT NULL
);
CREATE TABLE t2 (Period SMALLINT);
INSERT INTO t1 VALUES (9410,9412);
INSERT INTO t2 VALUES (9410),(9411),(9412),(9413);
SELECT PERIOD FROM t1;
SELECT * FROM t1;
SELECT t1.* FROM t1;
SELECT * FROM t1 INNER JOIN t2 USING (Period);
DROP TABLE t1, t2;
@endverbatim
If a test case creates other objects such as stored programs or
user accounts, it should take care to also clean those up at the
beginning and end of the test. Temporary files should also be
removed, either at the end or just after they have been used.
*/
###############################################################################
## Generating a Test Case Result File
/**
@page PAGE_GENERATE_TESTCASE_RESULT_FILE Generating a Test Case Result File
The test code we just wrote contains no checks of the result. The
test will report a failure for one of two reasons:
- An individual SQL statement fails with an error
- The overall test case result does not match what was expected
Note that these are the reasons why @ref PAGE_MYSQLTEST "mysqltest"
would fail; if the test is run from @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" the test may fail for additional reasons.
In the first case, @ref PAGE_MYSQLTEST "mysqltest" aborts with an
error. The second case requires that we have a record of the
expected result so that it can be compared with the actual result.
To generate a file that contains the test result, run the test with
the <b>`--record`</b> option, like this:
@verbatim
shell> cd mysql-test
shell> ./mysql-test-run.pl --record foo
@endverbatim
Running the test as shown creates a result file named
<b>mysql-test/r/foo.result</b> that has this content:
@verbatim
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
Period SMALLINT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
Varor_period SMALLINT(4) UNSIGNED DEFAULT '0' NOT NULL
);
CREATE TABLE t2 (Period SMALLINT);
INSERT INTO t1 VALUES (9410,9412);
INSERT INTO t2 VALUES (9410),(9411),(9412),(9413);
SELECT period FROM t1;
period
9410
SELECT * FROM t1;
Period Varor_period
9410 9412
SELECT t1.* FROM t1;
Period Varor_period
9410 9412
SELECT * FROM t1 INNER JOIN t2 USING (Period);
Period Varor_period
9410 9412
DROP TABLE t1, t2;
ok
@endverbatim
If we look at this result file, it contains the statements in the
<b>foo.test</b> file together with the output from the
<b>SELECT</b> statements. The output for each statement includes a
row of column headings followed by data rows. Rows have columns
separated by Tab characters.
At this point, you should inspect the result file and determine
whether its contents are as expected. If so, let it be part of your
test case. If the result is not as expected, you have found a
problem, either with the server or the test. Determine the cause of
the problem and fix it. For example, the test might produce output
that varies from run to run. To deal with this, you can postprocess
the output before the comparison occurs. See @ref
PAGE_DEALING_OUTPUT.
*/
###############################################################################
## Checking for Expected Errors
/**
@page PAGE_CHECK_EXPECTED_ERRORS Checking for Expected Errors
A good test suite checks not only that operations succeed as they
ought, but also that they fail as they ought. For example, if a
statement is illegal, the server should reject it with an error
message. The test suite should verify that the statement fails and
that it fails with the proper error message.
The test engine enables you to specify “expected failures.” Let's
say that after we create <b>t1</b>, we try to create it again
without dropping it first:
@verbatim
--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings
CREATE TABLE t1 (
Period SMALLINT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
Varor_period SMALLINT(4) UNSIGNED DEFAULT '0' NOT NULL
);
CREATE TABLE t2 (Period SMALLINT);
INSERT INTO t1 VALUES (9410,9412);
INSERT INTO t2 VALUES (9410),(9411),(9412),(9413);
SELECT period FROM t1;
SELECT * FROM t1;
SELECT t1.* FROM t1;
SELECT * FROM t1 INNER JOIN t2 USING (Period);
CREATE TABLE t1 (something SMALLINT(4));
@endverbatim
The result is failure and an error:
@verbatim
At line 21: query 'CREATE TABLE t1 (something SMALLINT(4))'
failed: 1050: Table 't1' already exists
@endverbatim
To handle this error and indicate that indeed we do expect it to
occur, we can put an <b>error</b> command before the second
<b>create table</b> statement. Either of the following commands
test for this particular MySQL error:
@verbatim
--error 1050
--error ER_TABLE_EXISTS_ERROR
@endverbatim
<b>1050</b> is the numeric error code and
<b>ER_TABLE_EXISTS_ERROR</b> is the symbolic name. Symbolic names
are more stable than error numbers because the numbers sometimes
change, particularly for those created during recent development.
For such errors, use of numbers rather than the names in a test case
will require test to be revised should the numbers change.
After we make a change to add an <b>error</b> command before the
<b>CREATE TABLE</b> statement and run the test again, the end of
the result will look like this:
@verbatim
CREATE TABLE t1 (something SMALLINT(4));
ERROR 42S01: Table 't1' already exists
@endverbatim
In this case, the result shows the statement that causes the error,
together with the resulting error message. The fact that @ref
PAGE_MYSQLTEST "mysqltest" does not terminate and that the error
message becomes part of the result indicates that the error was
expected.
You can also test for errors by specifying an SQLSTATE value. For
MySQL error number <b>1050</b>, the corresponding SQLSTATE value
is <b>42S01</b>. To specify an SQLSTATE value in an <b>error</b>
command, use an <b>S</b> prefix:
@verbatim
--error S42S01
@endverbatim
A disadvantage of SQLSTATE values is that sometimes they correspond
to more than one MySQL error code. Using the SQLSTATE value in this
case might not be specific enough (it could let through an error
that you do not actually expect).
If you want to test for multiple errors, the <b>error</b> command
allows multiple arguments, separated by commas. For example:
@verbatim
--error ER_NO_SUCH_TABLE,ER_KEY_NOT_FOUND
@endverbatim
For a list of MySQL error codes, symbolic names, and SQLSTATE values,
see https://dev.mysql.com/doc/refman/8.0/en/error-messages-server.html.
You can also examine the <b>mysqld_error.h</b> and
<b>sql_state.h</b> files in the <b>include</b> directory of a MySQL
source distribution.
It is also possible to use symbolic error names to refer to client
errors:
@verbatim
--error CR_SERVER_GONE_ERROR
@endverbatim
For a list of MySQL client error codes, see
https://dev.mysql.com/doc/refman/8.0/en/error-messages-client.html.
You can also examine the <b>errmsg.h</b> file in the <b>include</b>
directory of a MySQL source distribution.
The built-in variable <b>$mysql_errno</b> contains the numeric
error returned by the most recent SQL statement sent to the server,
or 0 if the statement executed successfully. This may be useful
after statements that may or may not fail, or fail in more than one
way (more than one argument to the <b>error</b> command), in case
you need to perform different actions. Note that this applies to SQL
statements, not to other commands.
There is also a variable <b>$mysql_errname</b> which contains the
symbolic name of the last error. In some cases the symbolic name is
not available; in those cases the variable will contain the string
<b>"<Unknown>"</b>. For new test development we recommend testing
against the name rather than the number, since the number may change
in future versions. If the last statement succeeded
(<b>$mysql_errno</b> is 0), this variable is an empty string.
*/
###############################################################################
## Controlling the Information Produced by a Test Case
/**
@page PAGE_CONTROL_INFORMATION_PRODUCED_TESTCASE Controlling the Information Produced by a Test Case
By default, the @ref PAGE_MYSQLTEST "mysqltest" test engine produces
output only from <b>select</b>, <b>show</b>, and other SQL
statements that you expect to produce output (that is, statements
that create a result set). It also produces output from certain
commands such as <b>echo</b> and <b>exec</b>. @ref
PAGE_MYSQLTEST "mysqltest" can be instructed to be more or less
verbose.
Suppose that we want to include in the result the number of rows
affected by or returned by SQL statements. To do this, add the
following line to the test case file preceding the first
table-creation statement:
@verbatim
--enable_info
@endverbatim
After rerunning the test by invoking @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" with the <b>`--record`</b> option to record
the new result, the result file will contain more information:
@verbatim
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
Period SMALLINT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
Varor_period SMALLINT(4) UNSIGNED DEFAULT '0' NOT NULL
);
affected rows: 0
CREATE TABLE t2 (Period SMALLINT);
affected rows: 0
INSERT INTO t1 VALUES (9410,9412);
affected rows: 1
INSERT INTO t2 VALUES (9410),(9411),(9412),(9413);
affected rows: 4
info: Records: 4 Duplicates: 0 Warnings: 0
SELECT period FROM t1;
period
9410
affected rows: 1
SELECT * FROM t1;
Period Varor_period
9410 9412
affected rows: 1
SELECT t1.* FROM t1;
Period Varor_period
9410 9412
affected rows: 1
SELECT * FROM t1 INNER JOIN t2 USING (Period);
Period Varor_period
9410 9412
affected rows: 1
DROP TABLE t1, t2;
affected rows: 0
ok
@endverbatim
To turn off the affected-rows reporting, add this command to the
test case file:
@verbatim
--disable_info
@endverbatim
In general, options can be enabled and disabled for different parts
of the test file. Suppose that we are interested in the internals of
the database as well. We could enable the display of query metadata
using <b>enable_metadata</b>. With this option enabled, the test
output is a bit verbose. However, as mentioned earlier, the option
can be enabled and disabled selectively so that it is enabled only
for those parts of the test case where it interests you to know
more.
If you perform an operation for which you have no interest in seeing
the statements logged to the result, you can disable statement
logging. For example, you might be initializing a table where you
don't really expect a failure, and you are not interested in seeing
the initialization statements in the test result. You can use the
<b>disable_query_log</b> command to temporarily disable recording
of input SQL statements, and enable recording again with
<b>enable_query_log</b>. You can disable the recording of the
output from executing commands using <b>disable_result_log</b> and
enable recording again with <b>enable_result_log</b>.
*/
###############################################################################
## Dealing with Output That Varies Per Test Run
/**
@page PAGE_DEALING_OUTPUT Dealing with Output That Varies Per Test Run
It is best to write each test case so that the result it produces
does not vary for each test run, or according to factors such as the
time of day, differences in how program binaries are compiled, the
operating system, and so forth. For example, if the result contains
the current date and time, the test engine has no way to verify that
the result is correct.
However, sometimes a test result is inherently variable according to
external factors, or perhaps there is a part of a result that you
simply do not care about. @ref PAGE_MYSQLTEST "mysqltest" provides
commands that enable you to postprocess test output into a more
standard format so that output variation across test runs will not
trigger a result mismatch.
One such command is <b>replace_column</b>, which specifies that
you want to replace whatever is in a given column with a string.
This makes the output for that column the same for each test run.
To see how this command works, add the following row after the first
insert in the test case:
@verbatim
INSERT INTO t1 VALUES (DATE_FORMAT(NOW(), '%s'),9999);
@endverbatim
Then record the test result and run the test again:
@verbatim
shell> ./mysql-test-run.pl --record foo
shell> ./mysql-test-run.pl foo
@endverbatim
Most likely, a failure will occur and @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" will display the difference between the expected
result and what we actually got, like this (the header has been
simplified):
@verbatim
CURRENT_TEST: main.foo
--- r/foo.result 2009-11-17 16:22:38
+++ var/log/foo.reject 2009-11-17 16:22:47
@@ -10,15 +10,15 @@
SELECT period FROM t1;
period
9410
-0038
+0047
SELECT * FROM t1;
Period Varor_period
9410 9412
-0038 9999
+0047 9999
SELECT t1.* FROM t1;
Period Varor_period
9410 9412
-0038 9999
+0047 9999
SELECT * FROM t1 INNER JOIN t2 USING (Period);
Period Varor_period
9410 9412
mysqltest: Result content mismatch
@endverbatim
The actual numbers will likely be different for your case, and the
format of the diff may also vary.
If we are not really interested in the first column, one way to
eliminate this mismatch is by using the <b>replace_column</b>
command. The duration of the effect of this command is the next SQL
statement, so we need one before each <b>select</b> statement:
@verbatim
--replace_column 1 SECONDS
SELECT period FROM t1;
--replace_column 1 SECONDS
SELECT * FROM t1;
--replace_column 1 SECONDS
SELECT t1.* FROM t1;
@endverbatim
In the <b>replace_column</b> commands, <b>SECONDS</b> could be
any string. Its only purpose is to map variable output onto a
constant value. If we record the test result again, we will succeed
each time we run the test after that. The result file will look like
this:
@verbatim
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
Period SMALLINT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
Varor_period SMALLINT(4) UNSIGNED DEFAULT '0' NOT NULL
);
affected rows: 0
CREATE TABLE t2 (Period SMALLINT);
affected rows: 0
INSERT INTO t1 VALUES (9410,9412);
affected rows: 1
INSERT INTO t1 VALUES (DATE_FORMAT(NOW(), '%s'),9999);
affected rows: 1
INSERT INTO t2 VALUES (9410),(9411),(9412),(9413);
affected rows: 4
info: Records: 4 Duplicates: 0 Warnings: 0
SELECT period FROM t1;
period
SECONDS
SECONDS
affected rows: 2
SELECT * FROM t1;
Period Varor_period
SECONDS 9412
SECONDS 9999
affected rows: 2
SELECT t1.* FROM t1;
Period Varor_period
SECONDS 9412
SECONDS 9999
affected rows: 2
SELECT * FROM t1 INNER JOIN t2 USING (Period);
Period Varor_period
9410 9412
affected rows: 1
DROP TABLE t1, t2;
affected rows: 0
ok
@endverbatim
*/
###############################################################################
## Passing Options from mysql-test-run.pl to mysqld or mysqltest
/**
@page PAGE_PASSING_OPTIONS Passing Options from mysql-test-run.pl to mysqld or mysqltest
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" supports several
options that enable you to pass options to other programs. Each of
these options takes a value consisting of one or more comma-separated
options:
<ul>
<li>
The <b>`--mysqld`</b> option tells @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" to start the <b>mysqld</b> server with the
named option added. More than one such extra option may be
provided. The following command causes <b>`--big-tables`</b>
and <b>`--key_buffer_size`=16384</b> to be passed to
<b>mysqld</b>:
@verbatim
shell> ./mysql-test-run.pl
--mysqld=--big-tables
--mysqld=--key_buffer_size=16384
@endverbatim
Note how <b>`--mysqld`</b> needs to be repeated for each
server option to add. It does not work to add several server
options with one <b>`--mysqld`</b> even if enclosed in
quotation marks, as that will be interpreted as a single server
option (including spaces).
</li>
<li>
The <b>`--combination`</b> option is similar to
<b>`--mysqld`</b>, but behaves differently. @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" executes multiple
test runs, using the options for each instance of
<b>`--combination`</b> in successive runs. The following
command passes <b>`--big-tables`</b> to <b>mysqld</b> for the
first test run, <b>`--innodb`</b> for the second run and
<b>`--innodb-file-per-table`</b> for the last run:
@verbatim
shell> ./mysql-test-run.pl
--combination=--big-tables
--combination=--innodb
--combination=--innodb-file-per-table
@endverbatim
If <b>`--combination`</b> is given only once, it behaves similar
to <b>`--mysqld`</b> option.
For test runs specific to a given test suite, an alternative to
the use of the <b>`--combination`</b> option is to create a
<b>combinations</b> file in the suite directory. The file should
contain a section of options for each test run. For an example,
see @ref PAGE_BINARY_LOG_FORMAT.
<b>combinations</b> file can support <b>bootstrap</b> variables
too. The <b>bootstrap</b> variable has to be passed as a value
to the <b>`initialize`</b> keyword.
For a test specific combinations, an alternative to the use of
the <b>`--combination`</b> option is to create a
<b><em>test_name</em>.combinations</b> file in the test
directory.
</li>
<li>
The <b>`--mysqltest`</b> option is used to pass extra options
to @ref PAGE_MYSQLTEST "mysqltest".
@verbatim
shell> ./mysql-test-run.pl --mysqltest=options
@endverbatim
For an example, see @ref PAGE_MYSQL_TEST_RUN_PL.
</li>
</ul>
*/
###############################################################################
## Specifying Test Case-Specific Server Options
/**
@page PAGE_TESTCASE_SPECIFIC_SERVER_OPTIONS Specifying Test Case-Specific Server Options
Within a test case, many system variables can be set by using
statements such as these:
@verbatim
SET sql_warnings= 1;
SET sql_mode= 'NO_AUTO_VALUE_ON_ZERO';
@endverbatim
But sometimes you need to restart the server to use command-line
options that are specific to a given test case. You can specify
these options in a file named
<b>mysql-test/t/<em>test_name-master</em>.opt</b>. When a
file named <b>t/<em>test_name-master</em>.opt</b> exists,
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" examines it for
extra options that the server needs to be run with when executing
the <em>test_name</em> test case. If no server has yet been
started or the current server is running with different options,
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" restarts the server
with the new options.
You may refer to environment variables in the option file, using the
usual <b><em>$VAR_NAME</em></b> syntax. It is also possible to refer
to optional variables using the syntax <b><em>$?VAR_NAME</em></b>.
This will be replaced with an empty string if the variable is not
set.
As a special case, the option <b>`--skip-core-file`</b> will be
interpreted by @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl",
which will then block the server from producing any core files or
crash dumps during this test. This may be useful for tests that
intentionally crash the server.
Another special case is <b>`--testcase-timeout`=minutes</b> which
can be used to set a different, longer timeout for a particular test
case. The given timeout in minutes will be used for this test if
it's longer than the default.
Files in the <b>mysql-test/t</b> directory with names ending in
<b>-slave.opt</b> are similar, but they are used for slave servers
in replication tests.
Sometimes it's also necessary to execute some external commands
before starting the server, such as creating a directory. If you add
a file named <b>t/<em>test_name-master</em>.sh</b>, it will
be executed by @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl"
before it starts the server; a similar file may be created for the
slave in replication tests.
Because the <b>.sh</b> file is executed through <b>/bin/sh</b>, it
cannot be used on Windows, and any tests using such a file will
automatically be skipped if you run on Windows. For this reason,
this mechanism may be replaced with a more portable one in some
future release of MySQL.
*/
###############################################################################
## Specifying Test Case-Specific Bootstrap Options
/**
@page PAGE_TESTCASE_SPECIFIC_BOOTSTRAP_OPTIONS Specifying Test Case-Specific Bootstrap Options
If a test has to run with a particular value of a bootstrap variable
such as <b>`--innodb-page-size`</b> or
<b>`--innodb-data-file-path`</b>, the option can be passed on the
command line while running @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl". For example, consider a test that can only run
with <b>`--innodb-page-size`=8k</b>. The test can be run like this:
@verbatim
shell> ./mysql-test-run.pl test_name_8k --initialize=--innodb-page-size=8k
@endverbatim
This will initialize the data directory with 8k page size, and start the
server with that value.
It is also possible to pass bootstrap options in the
<b>master.opt</b> file of the test, so that the test can run with
the specified value of the bootstrap options without using any
command line arguments. The usage is:
@verbatim
--initialize --innodb-page-size=8k
@endverbatim
or
@verbatim
--initialize=--innodb-page-size=8k
@endverbatim
Specifying bootstrap variables in the opt file is the preferred
method.
Each bootstrap variable must be specified as the value of a
<b>`--initialize`</b> option in the opt file to ensure @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" recognizes that the
variable must be used during server initialization. If there are
bootstrap options in the file, the current data directory is
deleted, and initialized again with the options set in the file. The
server is also started with the bootstrap options passed along with
the other options in the opt file.
Similarly, bootstrap options passed in the <b>slave.opt</b> will be
used to reinitialize the slave server in replication scenarios.
Bootstrap options set in the opt file are passed to the server
first, followed by the server options. So, server start up options
have precedence over bootstrap options, regardless of the order in
which they are set in the opt file.
Note that since the bootstrap options are passed in the opt files,
they have precedence over the command line bootstrap options. So,
if a test has a master.opt file containing <b>`--innodb-page-size`=8k</b>,
and while it is being run, <b>`--innodb-page-size`=4k</b> is passed on
the command line, the test will run with <b>8k</b> page size.
Some tests require the server to be restarted multiple times with
different server options, as well different bootstrap options. In
such cases, the existing data directory is deleted inside the test
and a new data directory is initialized with the bootstrap options.
When the server is started with the bootstrap options after this,
the SQL queries will run with the specified options.
@verbatim
--exec $MYSQLD --no-defaults --initialize-insecure
--lc_messages_dir=$MYSQL_SHAREDIR --innodb_page_size=8K
--basedir=$MYSQLD_BASEDIR --datadir=$MYSQL_TMP_DIR/datadir1/data
--init-file=$BOOTSTRAP_SQL --secure-file-priv=""
@endverbatim
*/
###############################################################################
## Specifying Test Case-Specific Client Options
/**
@page PAGE_TESTCASE_SPECIFIC_CLIENT_OPTIONS Specifying Test Case-Specific Client Options
If a test case needs a specific client option, you can specify such
options in a file named <b><em>testname</em>-client.opt</b>. When a
test case has its own <b>-client.opt</b> file, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" examines it for any
additional options that the @ref PAGE_MYSQLTEST "mysqltest" should
run with while executing the test case.
For example, consider a test case <b>example.test</b> needs
<tt>latin1</tt> as default character set for client and connection,
then that option can be specified in
<b><em>example</em>-client.opt</b> file.
@verbatim
--default-character-set=latin1
@endverbatim
You may refer to environment variables in the option file, using the
usual <b><em>$VAR_NAME</em></b> syntax. It is also possible to refer
to optional variables using the syntax <b><em>$?VAR_NAME</em></b>.
This will be replaced with an empty string if the variable is not
set.
*/
###############################################################################
## Using Include Files to Simplify Test Cases
/**
@page PAGE_INCLUDE_FILES Using Include Files to Simplify Test Cases
The <b>include</b> directory contains many files intended for
inclusion into test case files.
These include files serve many purposes, but in general, they
encapsulate operations of varying complexity into single files so
that you can perform each operation in a single step. Include files
are available for operations such as these:
<ul>
<li>
Ensure that a given feature is available. The file checks to
make sure that the feature is available and exits if not.
</li>
<ul>
<li>
Storage engine tests: These files have names of the form
<b>have_<em>engine_name.inc</em></b>, such as
<b>have_archive.inc</b> or <b>have_blackhole.inc</b>. The
<b>MyISAM</b>, <b>MERGE</b>, and <b>MEMORY</b> storage
engines are always supported and need not be checked.
</li>
<li>
Windows specific tests: Include <b>have_windows.inc</b> file
if a test runs only on windows machines.
</li>
<li>
Debugging capabilities: Include the <b>have_debug.inc</b>
file if a test requires that the server was built for
debugging (that is, that the MySQL distribution was configured
with the <b>`--with-debug`</b> option).
</li>
</ul>
<li>
Wait for a condition to become true. Set the
<b>$wait_condition</b> variable to an SQL statement that
selects a value and then include the <b>wait_condition.inc</b>
file. The include file executes the statement in a loop with a
0.1 second sleep between executions until the select value is
nonzero. For example:
@verbatim
--let $wait_condition= SELECT c = 3 FROM t
--source include/wait_condition.inc
@endverbatim
</li>
<li>
Control the binary log format. See @ref PAGE_BINARY_LOG_FORMAT.
</li>
<li>
Control replication slave servers. See @ref
PAGE_WRITING_REPLICATION_TESTS.
</li>
</ul>
You can think of an include file as a rudimentary form of subroutine
that is “called” at the point of inclusion. You can “pass
parameters” by setting variables before including the file and
referring to them within the file. You can “return” values by
setting variables within the file and referring them following
inclusion of the file.
*/
###############################################################################
## Controlling the Binary Log Format Used for Tests
/**
@page PAGE_BINARY_LOG_FORMAT Controlling the Binary Log Format Used for Tests
<h3>Table of Contents</h3>
- @subpage PAGE_CONTROLLING_BINARY_LOG_FORMAT
- @subpage PAGE_SPECIFY_BINARY_LOG_FORMAT
The server can do binary logging using statement-based logging
(SBL), which logs events as statements that produce data changes, or
row-based logging (RBL), which logs events as changes to individual
rows. It also supports mixed logging, which switches between SBL and
RBL automatically as necessary.
The server's global <b>binlog_format</b> system variable indicates
which log format is in effect. It has possible values of
<b>STATEMENT</b>, <b>ROW</b>, and <b>MIXED</b> (not case
sensitive). This system variable can be set at server startup by
specifying <b>`--binlog_format`=<em>value</em></b> on the
command line or in an option file. A user who has the <b>SUPER</b>
privilege can change the log format at runtime. For example:
@verbatim
SET GLOBAL binlog_format = STATEMENT;
@endverbatim
Some tests require a particular binary log format. You can exercise
control over the binary log format in two ways:
- To control the log format that the server uses for an entire
test run, you can pass options to @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" that tell it which format <b>mysqld</b>
should use.
- To verify that a particular log format is in effect for a specific
test case, you can use an appropriate include file that checks
the current format and exits if the format is other than what
is required.
The following sections describe how to use these techniques.
*/
###############################################################################
## Controlling the Binary Log Format Used for an Entire Test Run
/**
@page PAGE_CONTROLLING_BINARY_LOG_FORMAT Controlling the Binary Log Format Used for an Entire Test Run
To specify the binary log format for a test run, you can use the
<b>`--mysqld`</b> or <b>`--combination`</b> option to tell @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" to pass a logging option
to <b>mysqld</b>. For example, the following command runs the tests
from the <b>rpl</b> suite that have names that begin with
<b>rpl_row</b>. The tests are run once with the binary log format
set to <b>STATEMENT</b>:
@verbatim
shell> ./mysql-test-run.pl --suite=rpl --do-test=rpl_row
--mysqld=--binlog_format=statement
@endverbatim
To run tests under multiple log formats, use two or more instances
of the <b>`--combination`</b> option. The following command runs
the same tests as the preceding command, but runs them once with the
binary log format set to <b>ROW</b> and a second time with the
format set to <b>MIXED</b>:
@verbatim
shell> ./mysql-test-run.pl --suite=rpl --do-test=rpl_row
--combination=--binlog_format=row
--combination=--binlog_format=mixed
@endverbatim
The <b>`--combination`</b> option must be given at least twice or
it has no effect.
As an alternative to using the <b>`--combination`</b> option, you
can create a file named <b>combinations</b> in the test suite
directory and list the options that you would specify using
<b>`--combination`</b>, one line per option. For the preceding
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" command, the suite
name is <b>rpl</b>, so you would create a file named
<b>suite/rpl/combinations</b> with these contents:
@verbatim
[row]
--binlog_format=row
[mixed]
--binlog_format=mixed
@endverbatim
Then invoke @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" like this:
@verbatim
shell> ./mysql-test-run.pl --suite=rpl --do-test=row
@endverbatim
Similar to <b>combinations</b> file in the test suite directory, you
can also create a file named <b><em>test_name</em>.combinations</b>
in the test directory and list the options that you would specify
using <b>`--combination`</b>, one line per option.
If there exist both suite level <b>combinations</b> file and a
<b><em>test_name</em>.combinations</b> file, then the
<b><em>test_name</em>.combinations</b> file will take the priority
i.e combinations specified in suite level <b>combinations</b> file
will be ignored.
The format of the <b>combinations</b> file is similar to that of
<b>my.cnf</b> files (section names followed by options for each
section). @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" displays
the section name following the test name when it reports the test
result.
Any <b>`--combination`</b> options specified on the command line
override those found in a <b>combinations</b> file.
The <b>`--combination`</b> option and the <b>combinations</b>
file have different scope. The <b>`--combination`</b> option
applies globally to all tests run by a given invocation of @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl". The
<b>combinations</b> file is placed in a test suite directory and
applies only to tests in that suite. The
<b><em>test_name</em>.combinations</b> file is placed in a test
directory and applies only to <b>test_name</b>.
*/
###############################################################################
## Specifying the Required Binary Log Format for Individual Test Cases
/**
@page PAGE_SPECIFY_BINARY_LOG_FORMAT Specifying the Required Binary Log Format for Individual Test Cases
To specify within a test case that a particular binary log format is
required, include one of the following lines to indicate the format:
@verbatim
--source include/have_binlog_format_row.inc
--source include/have_binlog_format_statement.inc
--source include/have_binlog_format_mixed.inc
@endverbatim
The following files can be used for tests that support two binary
log formats:
@verbatim
--source include/have_binlog_format_mixed_or_row.inc
--source include/have_binlog_format_mixed_or_statement.inc
--source include/have_binlog_format_row_or_statement.inc
@endverbatim
Before @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" runs the test
case, it checks whether the value that it is using for the
<b>binlog_format</b> system variable matches what the test
requires, based on whether the test refers to one of the preceding
include files. If <b>binlog_format</b> does not have an
appropriate value, @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl"
skips the test.
If a test supports all binary log formats, none of the
<b>have_binlog_format_*.inc</b> include files should be used in
the test file. A test that includes no such file is assumed to
support all formats.
*/
###############################################################################
## Writing Replication Tests
/**
@page PAGE_WRITING_REPLICATION_TESTS Writing Replication Tests
If you are writing a replication test case, the test case file
should begin with this command:
@verbatim
--source include/master-slave.inc
@endverbatim
To switch between the master and slave, use these commands:
@verbatim
connection master;
connection slave;
@endverbatim
If you need to do something on an alternative connection, you can
use <b>connection master1;</b> for the master and <b>connection
slave1;</b> for the slave.
To run the master with additional options for your test case, put
them in command-line format in
<b>t/<em>test_name-master</em>.opt</b>. When a file named
<b>t/<em>test_name-master</em>.opt</b> exists, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" examines it for extra
options that the server needs to be run with when executing the
<em>test_name</em> test case. If no server has yet been started
or the current server is running with different options, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" restarts the server with
the new options.
For the slave, similar principles apply, but you should list
additional options in <b>t/<em>test_name-slave</em>.opt</b>.
Several include files are available for use in tests that enable
better control over the behavior of slave server I/O and SQL
threads. The files are located in the <b>include</b> directory and
have names of the form <b>wait_for_slave_*.inc</b>. By using these
files, you can help make replication tests more stable because it
will be more likely that test failures are due to replication
failures, not due to problems with the tests themselves.
The slave-control include files address the issue that it is not
always sufficient to use a <b>START SLAVE</b> or <b>STOP
SLAVE</b> statement by itself: When the statement returns, the
slave may not have reached the desired operational state. For
example, with <b>START SLAVE</b>, the following considerations
apply:
<ul>
<li>
It is not necessary to wait for the SQL thread after <b>START
SLAVE</b> or <b>START SLAVE SQL_THREAD</b> because the thread
will have started by the time statement returns.
</li>
<li>
By contrast, it is necessary to wait for the I/O thread after
<b>START SLAVE</b> or <b>START SLAVE IO_THREAD</b> because
although the thread will have started when the statement returns,
it may not yet have established the connection to the master.
</li>
</ul>
To verify that a slave has reached the desired state, combine the
use of <b>START SLAVE</b> or <b>STOP SLAVE</b> with an
appropriate “wait” include file. The file contains code that waits
until the state has been reached or a timeout occurs. For example,
to verify that both slave threads have started, do this:
@verbatim
START SLAVE
--source include/wait_for_slave_to_start.inc
@endverbatim
Similarly, to stop both slave threads, do this:
@verbatim
STOP SLAVE;
--source include/wait_for_slave_to_stop.inc
@endverbatim
The following list describes the include files that are available
for slave control:
<ul>
<li>
<tt>wait_for_slave_to_start.inc</tt>
Waits for both slave threads (I/O and SQL) to start. Should be
preceded by a <b>START SLAVE</b> statement.
</li>
<li>
<tt>wait_for_slave_to_stop.inc</tt>
Waits for both slave threads (I/O and SQL) to stop. Should be
preceded by a <b>STOP SLAVE</b> statement.
</li>
<li>
<tt>wait_for_slave_sql_to_stop.inc</tt>
Waits for the slave SQL thread to stop. Should be preceded by
a <b>STOP SLAVE SQL_THREAD</b> statement.
</li>
<li>
<tt>wait_for_slave_io_to_stop.inc</tt>
Waits for the slave I/O thread to stop. Should be preceded by
a <b>STOP SLAVE IO_THREAD</b> statement.
</li>
<li>
<tt>wait_for_slave_param.inc</tt>
Waits until <b>SHOW SLAVE STATUS</b> output contains a given
value or a timeout occurs. Before including the file, you should
set the <b>$slave_param</b> variable to the column name to
look for in <b>SHOW SLAVE STATUS</b> output, and
<b>$slave_param_value</b> to the value that you are waiting
for the column to have.
Example:
@verbatim
--let $slave_param= Slave_SQL_Running
--let $slave_param_value= No
--source include/slave_wait_slave_param.inc
@endverbatim
</li>
<li>
<tt>wait_for_slave_sql_error.inc</tt>
Waits until the SQL thread for the current connection has gotten
an error or a timeout occurs. Occurrence of an error is
determined by waiting for the <b>Last_SQL_Errno</b> column of
<b>SHOW SLAVE STATUS</b> output to have a nonzero value.
</li>
</ul>
*/
###############################################################################
## Thread Synchronization in Test Cases
/**
@page PAGE_THREAD_SYNCHRONIZATION Thread Synchronization in Test Cases
The Debug Sync facility allows placement of synchronization points
in the code. They can be activated by statements that set the
<b>debug_sync</b> system variable. An active synchronization point
can emit a signal or wait for a signal to be emitted by another
thread. This waiting times out after 300 seconds by default. The
<b>`--debug-sync-timeout`=<em>N</em></b> option for
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" changes that
timeout to <b><em>N</em></b> seconds. A timeout of zero disables
the facility altogether, so that synchronization points will not
emit or wait for signals, even if activated.
The purpose of the timeout is to avoid a complete lockup in test
cases. If for some reason the expected signal is not emitted by
any thread, the execution of the affected statement will not block
forever. A warning shows up when the timeout happens. That makes a
difference in the test result so that it will not go undetected.
For test cases that require the Debug Sync facility, include the
following line in the test case file:
@verbatim
--source include/have_debug_sync.inc
@endverbatim
For a description of the Debug Sync facility and how to use
synchronization points,
see [MySQL Internals: Test Synchronization]
(https://dev.mysql.com/doc/internals/en/test-synchronization.html).
*/
###############################################################################
## Suppressing Errors and Warning
/**
@page PAGE_SUPPRESSING_ERRORS_WARNINGS Suppressing Errors and Warning
After a test is finished, and if it didn't fail for some other
reason, @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will check
the log written by the server(s) during the test for any warnings or
errors. If it finds any, it will print them out and the test will be
reported as failed.
However, many warnings and also a few errors may occur normally
without signifying a real problem. Also, many tests purposefully
perform actions that will provoke warnings. For these not to result
in a test failure, it is possible to specify that certain messages
are to be suppressed.
There is a list of global suppressions; warnings that will always be
suppressed. These are listed in the file
<b>include/mtr_warnings.sql</b>. Any error or warning that
contains one of the listed strings will be ignored. It is not
necessary to include the whole text, and regular expressions can be
used, such as <b>.*</b> to match any substring or <b>[0-9]*</b>
to match any number.
You will rarely need to change or add to this global list, but you
may need to suppress a particular error or warning for a new test
case. A typical case is a test that performs some illegal action on
purpose to test the respone; if this also results in a warning in
the server log, this should not cause this particular test to fail.
To add a suppresion for a warning text like for example <b>The
table 't23456' is full</b> where the number in the table name can
vary, add this line anywhere in the test case file:
@verbatim
call mtr.add_suppression("The table 't[0-9]*' is full");
@endverbatim
This may be put anythere in the test, but we recommend putting it
either near the top, or just after the action that may result in the
warning. If you're adding this line to an existing test, keep in
mind that it will be echoed in the output, so the exact same line
also needs to be added to the corresponding place in the result
file. Alternatively, you may turn off logging like this, and will
then not have to edit the result file:
@verbatim
--disable_query_log
call mtr.add_suppression("The table 't[0-9]*' is full")
--enable_query_log
@endverbatim
It is also possible to intruct @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" to skip the check for errors and warnings
completely, by use of the <b>`--nowarnings`</b> command line
option.
*/
###############################################################################
## Stopping and restarting a Server During a Test
/**
@page PAGE_STOPPING_AND_RESTARTING_SERVER_DURING_TEST Stopping and Restarting a Server During a Test
If a server dies during execution of a test case, this will be
interpreted as a failure. However, there may be cases where you
actually want to stop and possibly restart a server intentionally.
It is possible to let the system know you expect a server to
terminate, and to either wait or have it restarted immediately:
Before you initiate the action that will stop the server, the test
case should write either <b>restart</b> or <b>wait</b> to the
file <b>$MYSQLTEST_VARDIR/tmp/mysqld.1.expect</b>. The easiest way
to do this is using the <b>exec echo</b> construct like in the
following example.
If you write <b>restart</b> into this file, the server will be
immediately restarted. If you write <b>wait</b> instead, the
server will remain down, but can be restarted at a later time by
writing <b>restart</b> to the file.
If you write <b>restart:</b> or <b>restart_abort:</b> (please note
the colon) followed by some command line parameters, those will
be appended to the command line arguments of the server on restart.
The former should be used when the server is expected to restart
successfully while the latter comes with an implicit follow up wait
and can be used when the server is expected to exit due to the
provided arguments.
@verbatim
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server 10
--source include/wait_until_disconnected.inc
# Do something while server is down
--enable_reconnect
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/wait_until_connected_again.inc
@endverbatim
The file name to write the command to will be
<b>mysqld.2.expect</b> for the slave server in replication tests.
Note that you have to use <b>$MYSQLTEST_VARDIR/tmp</b> for the
directory here; if you use <b>$MYSQL_TMP_DIR</b> instead, it will
not work when running tests in parallel.
For your convenience, there are files which can be used to do
what's shown in the example.
<ul>
<li>
<tt>restart_mysqld.inc</tt>
<b>include/restart_mysqld.inc</b> can be sourced in your
own test case, to shutdown and start the server but
the server is immediately started up again.
@verbatim
# Restart the server
--source include/restart_mysqld.inc
@endverbatim
It is also possible to provide additional command line options
to the restarted server, by writing a line with <b>restart:</b>
(with a colon) followed by one or more options into the expect
file. These extra options will be dropped if the same server
is restarted again, unless they are repeated. A value for
shutdown timeout can also be set with
<b>$shutdown_server_timeout</b>, when this file is used.
@verbatim
# Restart server with extra parameters
--let $shutdown_server_timeout= 10
--let $restart_parameters= "restart: --innodb_autoinc_lock_mode=1"
--source include/restart_mysqld.inc
@endverbatim
</li>
<li>
<tt>kill_and_restart_mysqld.inc</tt>
Similar to <b>include/restart_mysqld.inc</b>,
<b>include/kill_and_restart_mysqld.inc</b> can be used to
restart the server, but setting <b>$shutdown_server_timeout</b>
will have no effect.
@verbatim
# Restart server with extra parameters
--let $restart_paramters= "restart: --innodb_autoinc_lock_mode=0"
--source include/kill_and_restart_mysqld.inc
@endverbatim
</li>
<li>
<tt>shutdown_mysqld.inc and start_mysqld.inc</tt>
If there is something to be done between the server shutdown
and startup, there is a file
<b>include/shutdown_mysqld.inc</b>
which can be used to shutdown the server. A shutdown timeout
value can be set and passed to
<b>include/shutdown_mysqld.inc</b>.
<b>include/start_mysqld.inc</b> can be used to start the
server again after it has been shutdown.
@verbatim
# Timeout of 10 seconds
--let $shutdown_server_timeout= 10
--source include/shutdown_mysqld.inc
# Do something while the server is down
--source include/start_mysqld.inc
@endverbatim
</li>
<li>
<tt>kill_mysqld.inc</tt>
To the kill the server,
<b>include/kill_mysqld.inc</b> can be sourced, which
internally calls <b>--shutdown_server 0</b>. Therefore,
setting a value for shutdown timeout will have no effect.
@verbatim
--source include/kill_mysqld.inc
# Do something while the server is down
--source include/start_mysqld.inc
@endverbatim
</li>
<li>
<tt>wait_until_disconnected.inc</tt>
It is recommended to use <b>include/wait_until_disconnected</b>
in tandem with <b>--shutdown_server</b>. It ensures that all
connections to the server are dropped before proceeding with
the test. This file is sourced internally in
<b>include/shutdown_mysqld.inc</b>,
<b>include/kill_mysqld.inc</b>,
<b>include/kill_and_restart_mysqld.inc</b>,
and <b>include/restart_mysqld.inc</b>.
</li>
<li>
<tt>wait_until_connected_again.inc</tt>
<b>include/wait_until_connected_again.inc</b> is used after
the server is started again, to ensure that the client
connection is restored. It tries to establish the connection
till a timeout occurs. This file is sourced internally in
<b>include/start_mysqld.inc</b>,
<b>include/restart_mysqld.inc</b>,
and <b>include/kill_and_restart_mysqld.inc</b>.
</li>
</ul>
*/
###############################################################################
## Other Tips for Writing Test Cases
/**
@page PAGE_TIPS_WRITING_TESTCASES Other Tips for Writing Test Cases
<ul>
<li>
Writing loops
If you need to do something in a loop, you can use something like this:
@verbatim
let $1= 10;
while ($1)
{
# execute your statements here
dec $1;
}
@endverbatim
</li>
<li>
Pausing between statements
To sleep between statements, use the <b>sleep</b> command. It
supports fractions of a second. For example, <b>sleep 0.2</b>;
sleeps 0.2 seconds.
Try not to use the <b>sleep</b> command more than necessary.
The more of them there are, the slower the test suite becomes.
In some cases, heavy reliance on sleep operations is an indicator
that the logic of a test should be reconsidered.
</li>
<li>
Commenting the test result
When the output in a result file is not understandable by
inspection, it can be helpful to have the test case write
comments to the result file that provide context. You can use
the <b>echo</b> command for this:
@verbatim
--echo # Comment to explain the following output
@endverbatim
Of course, the same line (without <b>`--echo`</b>) will need
to be put in the corresponding place in the result file, if you
are adding this to an existing test.
</li>
<li>
Sorting result sets
If a test case depends on <b>SELECT</b> output being in a
particular row order, use an <b>ORDER BY</b> clause. Do not
assume that rows will be selected in the same order they are
inserted, particularly for tests that might be run multiple
times under conditions that can change the order, such as with
different storage engines, or with and without indexing.
If you do not want to add <b>ORDER BY</b> to the query, an
alternative is to use the test command <b>sorted_result</b>
which will sort the result of the following statement before
putting it into the result file.
</li>
<li>
Performing file system operations
Avoid using <b>exec</b> or <b>system</b> to execute
operating system commands for file system operations. This used
to be very common, but OS commands tend to be platform specific,
which reduces test portability. @ref PAGE_MYSQLTEST "mysqltest"
now has several commands to perform these operations portably,
so these commands should be used instead: <b>remove_file</b>,
<b>chmod</b>, <b>mkdir</b>, and so forth.
</li>
<li>
Local versus remote storage
Some test cases depend on being run on local storage, and may
fail when run on remote storage such as a network share. For
example, if the test result can be affected by differences
between local and remote file system times, the expected result
might not be obtained. Failure of these test cases under such
circumstances does not indicate an actual malfunction. It is not
generally possible to determine whether tests are being run on
local storage.
</li>
<li>
Skipping consistency check or forcing restart after test
As mentioned before, a test case should leave the server in a
"clean" state for the next test. In cases where this is not
possible or too costly, the test may in stead ask for the
consistency check to be skipped, and the server(s) to be
restarted. This is done by this executing this command at any
time during the test:
@verbatim
call mtr.force_restart();
@endverbatim
This signals to @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl"
that it should restart the server before the next test, and also
skip the consistency check.
</li>
</ul>
*/
###############################################################################
## MySQL Test Programs
/**
@page PAGE_MYSQLTEST_PROGRAMS MySQL Test Programs
<h3>Table of Contents</h3>
- @subpage PAGE_MYSQLTEST
- @subpage PAGE_MYSQL_CLIENT_TEST
- @subpage PAGE_MYSQL_TEST_RUN_PL
- @subpage PAGE_MYSQL_STRESS_TEST_PL
This chapter describes the test programs that run test cases. For
information about the language used for writing test cases, see @ref
PAGE_MYSQLTEST_LANGUAGE_REFERENCE.
The test suite uses the following programs:
<ul>
<li>
The @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" Perl script
is the main application used to run the MySQL test suite. It
invokes @ref PAGE_MYSQLTEST "mysqltest" to run individual test
cases. (Prior to MySQL 4.1, a similar shell script,
<b>mysql-test-run</b>, can be used instead).
</li>
<li>
@ref PAGE_MYSQLTEST "mysqltest" runs test cases.
</li>
<li>
The @ref PAGE_MYSQL_CLIENT_TEST "mysql_client_test" program is
used for testing aspects of the MySQL client API that cannot be
tested using @ref PAGE_MYSQLTEST "mysqltest" and its test
language.
</li>
<li>
The @ref PAGE_MYSQL_STRESS_TEST_PL "mysql-stress-test.pl" Perl
script performs stress-testing of the MySQL server.
</li>
</ul>
*/
###############################################################################
## mysqltest — Program to Run Test Cases
/**
@page PAGE_MYSQLTEST mysqltest — Program to Run Test Cases
The @ref PAGE_MYSQLTEST "mysqltest" program runs a test case against
a MySQL server and optionally compares the output with a result
file. This program reads input written in a special test language.
Typically, you invoke @ref PAGE_MYSQLTEST "mysqltest" using @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" rather than invoking it
directly.
Features of @ref PAGE_MYSQLTEST "mysqltest":
- Can send SQL statements to MySQL servers for execution
- Can execute external shell commands
- Can test whether the result from an SQL statement or shell
command is as expected
- Can connect to one or more standalone <b>mysqld</b> servers
and switch between connections
By default, @ref PAGE_MYSQLTEST "mysqltest" reads the test case on
the standard input. To run @ref PAGE_MYSQLTEST "mysqltest" this way,
you normally invoke it like this:
@verbatim
shell> mysqltest [options] [db_name] < test_file
@endverbatim
You can also name the test case file with a <b>`--test-
file`=<em>file_name</em></b> option.
The exit value from @ref PAGE_MYSQLTEST "mysqltest" is 0 for
success, 1 for failure, and 62 if it skips the test case (for
example, if after checking some preconditions it decides not to
run the test).
@ref PAGE_MYSQLTEST "mysqltest" supports the following options:
<ul>
<li>
<tt>`--help`, -?</tt>
Display a help message and exit.
</li>
<li>
<tt>`--async-client`</tt>
Enable asynchronous communication support in mysql protocol.
</li>
<li>
<tt>`--basedir`=<b>dir_name</b>, -b <b>dir_name</b></tt>
The base directory for tests.
</li>
<li>
<tt>`--character-sets-dir`=<b>path</b></tt>
The directory where character sets are installed.
</li>
<li>
<tt>`--colored-diff`</tt>
Colorize the diff part of the output.
If enabled, @ref PAGE_MYSQLTEST "mysqltest" uses <b>diff</b>
command with <b>`--color`='always'</b> option to print the
colored diff. If the command fails or is not supported, @ref
PAGE_MYSQLTEST "mysqltest" will report an error and abort the
test run.
@note
<b>`--color`</b> option for <b>diff</b> command is available
from <b>GNU diffutils</b> version <b>3.4</b>.
</li>
<li>
<tt>`--compress`, -C</tt>
Compress all information sent between the client and the server
if both support compression.
</li>
<li>
<tt>`--cursor-protocol`</tt>
Use cursors for prepared statements.
</li>
<li>
<tt>`--database`=<b>db_name</b>, -D <b>db_name</b></tt>
The default database to use.
</li>
<li>
<tt>`--debug`[=<b>debug_options</b>], -#[<b>debug_options</b>]</tt>
Write a debugging log if MySQL is built with debugging support.
The default <b><em>debug_options</em></b> value is
<b>'d:t:S:i:O,/tmp/mysqltest.trace'</b>.
</li>
<li>
<tt>`--debug-check`</tt>
Print some debugging information when the program exits.
</li>
<li>
<tt>`--debug-info`</tt>
Print debugging information and memory and CPU usage statistics
when the program exits.
</li>
<li>
<tt>`--default-character-set`=<b>charset_name</b></tt>
Use <b>charset_name</b> as the default character set for the
client and connection. For more information, see [Connection
Character Sets and Collations]
(https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html).
</li>
<li>
<tt>`--explain-protocol`</tt>
Run <b>EXPLAIN EXTENDED</b> on all <b>SELECT</b>,
<b>INSERT</b>, <b>REPLACE</b>, <b>UPDATE</b> and
<b>DELETE</b> queries.
</li>
<li>
<tt>`--host`=<b>host_name</b>, -h <b>host_name</b></tt>
Connect to the MySQL server on the given host.
</li>
<li>
<tt>`--include`=<b>file_name</b>, -i <b>file_name</b></tt>
Include the contents of the given file before processing the
contents of the test file. The included file should have the
same format as other @ref PAGE_MYSQLTEST "mysqltest" test files.
This option has the same effect as putting a <b>`--source`
<em>file_name</em></b> command as the first line of the test
file.
</li>
<li>
<tt>`--init-command`=<b>str</b></tt>
SQL statement passed as an argument, to execute after connecting
to the MYSQL server. If auto-reconnect is enabled, the statement
is executed again after reconnection occurs.
</li>
<li>
<tt>`--json-explain-protocol`</tt>
Run <b>EXPLAIN EXTENDED</b> on all <b>SELECT</b>,
<b>INSERT</b>, <b>REPLACE</b>, <b>UPDATE</b> and
<b>DELETE</b> queries. The <b>json-explain-protocol</b>
</li>
<li>
<tt>`--logdir`=<b>dir_name</b></tt>
The directory to use for log files.
</li>
<li>
<tt>`--mark-progress`</tt>
Write the line number and elapsed time to
<b><em>test_file</em>.progress.</b>
</li>
<li>
<tt>`--max-connect-retries`=<b>num</b></tt>
The maximum number of connection attempts when connecting to
server.
</li>
<li>
<tt>`--max-connections`=<b>num</b></tt>
The maximum number of simultaneous server connections per client
(that is, per test). If not set, the maximum is 128. Minimum
allowed limit is 8, maximum is 5120.
</li>
<li>
<tt>`--no-defaults`</tt>
Do not read default options from any option files. If used, this
must be the first option.
</li>
<li>
<tt>`--plugin-dir`=<b>path</b></tt>
The directory in which to look for plugins. It may be necessary
to specify this option if the <b><em>default_auth</em></b>
argument is used for the <b>connect()</b> command to specify
an authentication plugin but @ref PAGE_MYSQLTEST "mysqltest"
does not find it.
</li>
<li>
<tt>`--password`[=<b>password</b>], -p[<b>password</b>]</tt>
The password to use when connecting to the server. If you use
the short option form (<b>-p</b>), you <b><em>cannot</em></b>
have a space between the option and the password. If you omit
the <b><em>password</em></b> value following the
<b>`--password`</b> or <b>-p</b> option on the command line,
you are prompted for one.
</li>
<li>
<tt>`--port`=<b>port_num</b>, -P <b>port_num</b></tt>
The TCP/IP port number to use for the connection.
</li>
<li>
<tt>`--protocol`={TCP|SOCKET|PIPE|MEMORY}</tt>
Choose the protocol for communication with the server.
<b>SOCKET</b> is default.
</li>
<li>
<tt>`--ps-protocol`</tt>
Use the prepared-statement protocol for communication.
</li>
<li>
<tt>`--quiet`</tt>
Suppress all normal output. This is a synonym for
<b>`--silent`</b>.
</li>
<li>
<tt>`--record`, -r</tt>
Record the output that results from running the test file into
the file named by the <b>`--result-file`</b> option, if that
option is given. It is an error to use this option without also
using <b>`--result-file`</b>.
</li>
<li>
<tt>`--result-file`=<b>file_name</b>, -R <b>file_name</b></tt>
This option specifies the file for test case expected results.
<b>`--result-file`</b>, together with <b>`--record`</b>,
determines how @ref PAGE_MYSQLTEST "mysqltest" treats the test
actual and expected results for a test case:
<ul>
<li>
If the test produces no results, @ref PAGE_MYSQLTEST
"mysqltest" exits with an error message to that effect,
unless <b>`--result-file`</b> is given and the named file
is an empty file.
</li>
<li>
Otherwise, if <b>`--result-file`</b> is not given, @ref
PAGE_MYSQLTEST "mysqltest" sends test results to the
standard output.
</li>
<li>
With <b>`--result-file`</b> but not <b>`--record`</b>,
@ref PAGE_MYSQLTEST "mysqltest" reads the expected results
from the given file and compares them with the actual
results. If the results do not match, @ref PAGE_MYSQLTEST
"mysqltest" writes a <b>.reject</b> file in the log
directory, outputs a diff of the two files, and exits with
an error.
</li>
<li>
With both <b>`--result-file`</b> and <b>`--record`</b>,
@ref PAGE_MYSQLTEST "mysqltest" updates the given file by
writing the actual test results to it.
</li>
</ul>
</li>
<li>
<tt>`--server-public-key-path`=<b>file_name</b></tt>
The path name to a file containing the server RSA public key.
The file must be in PEM format. The public key is used for RSA
encryption of the client password for connections to the server
made using accounts that authenticate with the
<b>sha256_password</b> plugin. This option is ignored for
client accounts that do not authenticate with that plugin. It is
also ignored if password encryption is not needed, as is the
case when the client connects to the server using an SSL
connection.
The server sends the public key to the client as needed, so it
is not necessary to use this option for RSA password encryption
to occur. It is more efficient to do so because then the server
need not send the key.
For additional discussion regarding use of the
<b>sha256_password plugin</b>, including how to get the RSA
public key, see [The SHA-256 Authentication Plugin]
(https://dev.mysql.com/doc/refman/8.0/en/sha256-authentication-plugin.html).
</li>
<li>
<tt>`--silent`, -s</tt>
Suppress all normal output.
</li>
<li>
<tt>`--skip-safemalloc`</tt>
Do not use memory allocation checking.
</li>
<li>
<tt>`--socket`=<b>path</b>, -S <b>path</b></tt>
The socket file to use when connecting to <b>localhost</b>
(which is the default host).
</li>
<li>
<tt>`--sp-protocol`</tt>
Execute DML statements within a stored procedure. For every DML
statement, @ref PAGE_MYSQLTEST "mysqltest" creates and invokes a
stored procedure that executes the statement rather than
executing the statement directly.
</li>
<li>
<tt>`--tail-lines`=<b>n</b></tt>
Specify how many lines of the result to include in the output if
the test fails because an SQL statement fails. The default is 0,
meaning no lines of result printed.
</li>
<li>
<tt>`--test-file`=<b>file_name</b>, -x <b>file_name</b></tt>
Read test input from this file. The default is to read from the
standard input.
</li>
<li>
<tt>`--timer-file`=<b>file_name</b>, -m <b>file_name</b></tt>
If given, the number of millisecond spent running the test will
be written to this file. This is used by @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" for its reporting.
</li>
<li>
<tt>`--tls-version`=<b>protocol_list</b></tt>
The protocols permitted by the client for encrypted connections.
The value is a comma-separated list containing one or more of
these protocols: TLSv1, TLSv1.1, TLSv1.2.
</li>
<li>
<tt>`--tmpdir`=<b>dir_name</b>, -t <b>dir_name</b></tt>
The temporary directory where socket files are created.
</li>
<li>
<tt>`--trace-exec`</tt>
If enabled, this option causes @ref PAGE_MYSQLTEST "mysqltest"
to immediately display the output from executed programs to
stdout.
</li>
<li>
<tt>`--user`=<b>user_name</b>, -u <b>user_name</b></tt>
The MySQL user name to use when connecting to the server.
</li>
<li>
<tt>`--verbose, -v`</tt>
Verbose mode. Print out more information about what the program
does.
</li>
<li>
<tt>`--version, -V`</tt>
Display version information and exit.
</li>
<li>
<tt>`--view-protocol`</tt>
Every <b>SELECT</b> statement is wrapped inside a view.
</li>
</ul>
*/
###############################################################################
## mysql_client_test — Test Client API
/**
@page PAGE_MYSQL_CLIENT_TEST mysql_client_test — Test Client API
The @ref PAGE_MYSQL_CLIENT_TEST "mysql_client_test" program is used
for testing aspects of the MySQL client API that cannot be tested
using @ref PAGE_MYSQLTEST "mysqltest" and its test language. @ref
PAGE_MYSQL_CLIENT_TEST "mysql_client_test" is run as part of the
test suite.
The source code for the programs can be found in in
<b>tests/mysql_client_test.c</b> in a source distribution. The
program serves as a good source of examples illustrating how to use
various features of the client API.
@ref PAGE_MYSQL_CLIENT_TEST "mysql_client_test" is used in a test by
the same name in the main tests suite of @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" but may also be run directly. Unlike the other
programs listed here, it does not read an external description of
what tests to run. Instead, all tests are coded into the program,
which is written to cover all aspects of the C language API.
@ref PAGE_MYSQL_CLIENT_TEST "mysql_client_test" supports the
following options:
<ul>
<li>
<tt>`--help`, -?</tt>
Display a help message and exit.
</li>
<li>
<tt>`--basedir`=<b>dir_name</b>, -b <b>dir_name</b></tt>
The base directory for the tests.
</li>
<li>
<tt>`--count`=<b>count</b>, -t <b>count</b></tt>
The number of times to execute the tests.
</li>
<li>
<tt>`--database`=<b>db_name</b>, -D <b>db_name</b></tt>
The database to use.
</li>
<li>
<tt>`--debug`[=<b>debug_options</b>], -#[<b>debug_options</b>]</tt>
Write a debugging log if MySQL is built with debugging support.
The default <b>debug_options</b> value is
<tt>'d:t:o,/tmp/mysql_client_test.trace'</tt>.
</li>
<li>
<tt>`--getopt-ll-test`=<b>option</b>,
-g <b>option</b></tt>
Option to use for testing bugs in the <tt>getopt</tt> library.
</li>
<li>
<tt>`--host`=<b>host_name</b>, -h <b>host_name</b></tt>
Connect to the MySQL server on the given host.
</li>
<li>
<tt>`--password`[=<b>password</b>], -p[<b>password]</b></tt>
The password to use when connecting to the server. If you use
the short option form (<b>-p</b>), you <tt><em>cannot</em></tt>
have a space between the option and the password. If you omit
the <b>password</b> value following the
<b>`--password`</b> or <b>-p</b> option on the command line,
you are prompted for one.
</li>
<li>
<tt>`--port`=<b>port_num</b>, -P <b>port_num</b></tt>
The TCP/IP port number to use for the connection.
</li>
<li>
<tt>`--show-tests`, -T</tt>
Show all test names.
</li>
<li>
<tt>`--silent`, -s</tt>
Be more silent.
</li>
<li>
<tt>`--socket`=<b>path</b>, -S <b>path</b></tt>
The socket file to use when connecting to <b>localhost</b>
(which is the default host).
</li>
<li>
<tt>`--testcase`, -c</tt>
The option is used when called from @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl", so that @ref PAGE_MYSQL_CLIENT_TEST
"mysql_client_test" may optionally behave in a different way
than if called manually, for example by skipping some tests.
Currently, there is no difference in behavior but the option is
included to make this possible.
</li>
<li>
<tt>`--user`=<b>user_name</b>, -u <b>user_name</b></tt>
The MySQL user name to use when connecting to the server.
</li>
<li>
<tt>`--vardir`=<b>dir_name</b>, -v <b>dir_name</b></tt>
The data directory for tests. The default is
<b>mysql-test/var</b>.
</li>
</ul>
*/
###############################################################################
## mysql-test-run.pl — Run MySQL Test Suite
/**
@page PAGE_MYSQL_TEST_RUN_PL mysql-test-run.pl — Run MySQL Test Suite
The @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" Perl script is
the main application used to run the MySQL test suite. It invokes
@ref PAGE_MYSQLTEST "mysqltest" to run individual test cases.
Invoke @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" in the
<b>mysql-test</b> directory like this:
@verbatim
shell> mysql-test-run.pl [options] [test_name] ...
@endverbatim
Each <b>test_name</b> argument names a test case. The test
case file that corresponds to the test name is
<b>t/<em>test_name</em>.test</b>.
For each <b>test_name</b> argument, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" runs the named test case.
With no <b>test_name</b> arguments, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" runs all <b>.test</b>
files in the <b>t</b> subdirectory.
If no suffix is given for the test name, a suffix of <b>.test</b>
is assumed. Any leading path name is ignored. These commands are
equivalent:
@verbatim
shell> mysql-test-run.pl mytest
shell> mysql-test-run.pl mytest.test
shell> mysql-test-run.pl t/mytest.test
@endverbatim
A suite name can be given as part of the test name. That is, the
syntax for naming a test is:
@verbatim
[suite_name.]test_name[.suffix]
@endverbatim
If a suite name is given, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" looks in that suite for the test. The test file
corresponding to a test named <b>suite_name.test_name</b> is
found in
<b>suite/<em>suite_name</em>/t/<em>test_name</em>.test</b>.
There is also an implicit suite name <b>main</b> for the tests in
the top <b>t</b> directory. With no suite name, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" looks in the default list
of suites for a match and runs the test in any suites where it finds
the test. Suppose that the default suite list is <b>main</b>,
<b>binlog</b>, <b>rpl</b>, and that a test <b>mytest.test</b>
exists in the <b>main</b> and <b>rpl</b> suites. With an
argument of <b>mytest</b> or <b>mytest.test</b>, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will run
<b>mytest.test</b> from the <b>main</b> and <b>rpl</b> suites.
To run a family of test cases for which the names share a common
prefix, use the <b>`--do-test`=<em>prefix</em></b> option.
For example, <b>`--do-test`=rpl</b> runs the replication tests
(test cases that have names beginning with <b>rpl</b>).
<b>`--skip-test`</b> has the opposite effect of skipping test
cases for which the names share a common prefix.
The argument for the <b>`--do-test`</b> and <b>`--skip-test`</b>
options also allows more flexible specification of which tests to
perform or skip. If the argument contains a pattern metacharacter
other than a lone period, it is interpreted as a Perl regular
expression and applies to test names that match the pattern. If the
argument contains a lone period or does not contain any pattern
metacharacters, it is interpreted the same way as previously and
matches test names that begin with the argument value. For example,
<b>`--do-test`=testa</b> matches tests that begin with testa,
<b>`--do-test`=main.testa</b> matches tests in the <b>main</b>
test suite that begin with <b>testa</b>, and
<b>`--do-test`=main.*testa</b> matches test names that contain
<b>main</b> followed by <b>testa</b> with anything in between.
In the latter case, the pattern match is not anchored to the
beginning of the test name, so it also matches names such as
<b>xmainytesta</b>.
It is also possible to put a list of test names in a file and have
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" run those tests,
using the option <b>`--do-test-list`=file</b>. The tests should be
listed one per line in the file. A line beginning with <b>#</b>
indicates a comment and is ignored. Similary an empty line in the
file is also ignored.
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" also supports a
<b>`--do-suite`</b> option, which is similar to <b>`--do-test`</b>
but permits specifying entire suites of tests to run.
To perform setup prior to running tests, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" needs to invoke <b>mysqld</b> with the
<b>`--initialize`</b> and <b>`--skip-grant-tables`</b> options.
If MySQL was built with the compiler flag
<b>-DDISABLE_GRANT_OPTIONS</b>, then <b>`--initialize`</b>,
<b>`--skip-grant-tables`</b>, and <b>`--init-file`</b> will be
disabled. To handle this, set the <b>MYSQLD_BOOTSTRAP</b>
environment variable to the full path name of a server that has all
options enabled. @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl"
will use that server to perform setup; it is not used to run the
tests.
The <b>init_file</b> test will fail if <b>`--init-file`</b> is
disabled. This is an expected failure in this case.
To run @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" on Windows,
you'll need either Cygwin or ActiveState Perl to run it. You may
also need to install the modules required by the script. To run the
test script, change location into the <b>mysql-test</b> directory,
set the <b>MTR_VS_CONFIG</b> environment variable to the
configuration you selected earlier (or use the <b>`--vs-config`</b>
option), and invoke @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl".
For example (using <b>Cygwin</b> and the <b>bash</b> shell):
@verbatim
shell> cd mysql-test
shell> export MTR_VS_CONFIG=debug
shell> ./mysqltest-run.pl --force --timer
shell> ./mysqltest-run.pl --force --timer --ps-protocol
@endverbatim
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" uses several
environment variables. Some of them are listed in the following
table. Some of these are set from the outside and used by @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl", others are set by @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" instead, and may be
referred to in tests.
<table>
<tr>
<th>Variable</th>
<th>Description</th>
</tr>
<tr>
<td><tt>EXE_MYSQL</tt></td>
<td>
Path to the mysql client executable
</td>
</tr>
<tr>
<td><tt>MTR_BUILD_THREAD</tt></td>
<td>
If set, defines which port number range is used for the server
</td>
</tr>
<tr>
<td><tt>MTR_MAX_PARALLEL</tt></td>
<td>
If set, defines maximum number of parallel threads if
<b>`--parallel`=auto</b> is given
</td>
</tr>
<tr>
<td><tt>MTR_MEM</tt></td>
<td>
If set to anything, will run tests with files in "memory"
using tmpfs or ramdisk. Not available on Windows. Same as
<b>`--mem`</b> option
</td>
</tr>
<tr>
<td><tt>MTR_<b>NAME</b>_TIMEOUT</tt></td>
<td>
Setting of a timeout in minutes or seconds, corresponding to
command line option <b>`--name-timeout`</b>. Avaliable timeout
names are <b>TESTCASE</b>, <b>SUITE</b> (both in minutes) and
<b>START</b>, <b>SHUTDOWN</b>, <b>CTEST</b> (all in seconds).
<b>MTR_CTEST_TIMEOUT</b> is for <b>ctest</b> unit tests.
</td>
</tr>
<tr>
<td><tt>MTR_PARALLEL</tt></td>
<td>
If set, defines number of parallel threads executing tests. Same
as <tt>`--parallel`</tt> option
</td>
</tr>
<tr>
<td><tt>MTR_PORT_BASE</tt></td>
<td>
If set, defines which port number range is used for the server
</td>
</tr>
<tr>
<td><tt>MTR_RECORD</tt></td>
<td>
Set to 1 if a MTR run is started with <b>`--record`</b>
option, 0 otherwise.
</td>
</tr>
<tr>
<td><tt>MTR_UNIQUE_IDS_DIR</tt></td>
<td>
The method in which the free ports are allocated is by maintaining
a list under the unique ids directory. In case there are multiple
chroot environments on the same host, then the same set of ports may
get allocated for all environments, because there will be
multiple unique ids directories in different physical locations,
but MTR assumes it is the same directory.
This will lead to a conflict while reserving ports for the
different MTR runs. To avoid this problem, when using chroot
environments, <b>MTR_UNIQUE_IDS_DIR</b> environment variable can
be set to a common location, so that all the MTR processes will
use the same unique ids directory.
Users have to make sure this variable is set to the same path
on all environments, and that this common path is mounted on
all the environments.
</td>
</tr>
<tr>
<td><tt>MYSQL</tt></td>
<td>
Full path to <b>mysql</b> client executable ,along with options passed to server.
</td>
</tr>
<tr>
<td><tt>MYSQL_BIN_PATH</tt></td>
<td>
Path to the directory having mysql binaries.
</td>
</tr>
<tr>
<td><tt>MYSQL_CLIENT_BIN_PATH</tt></td>
<td>
Path to the directory having client binaries.
</td>
</tr>
<tr>
<td><tt>MYSQL_CONFIG_EDITOR</tt></td>
<td>
Path name to <b>mysql_config_editor</b> binary.
</td>
</tr>
<tr>
<td><tt>MYSQL_OPTIONS</tt></td>
<td>
Options passed to server when connecting from mysql client.
</td>
</tr>
<tr>
<td><tt>MYSQL_TEST</tt></td>
<td>
Path name to @ref PAGE_MYSQLTEST "mysqltest" binary
</td>
</tr>
<tr>
<td><tt>MYSQL_TEST_DIR</tt></td>
<td>
Full path to the <tt>mysql-test</tt> directory where tests
are being run from
</td>
</tr>
<tr>
<td><tt>MYSQL_TEST_LOGIN_FILE</tt></td>
<td>
Path name to login file used by <b>mysql_config_editor</b>.
If not set, the default is <b>$HOME/.mylogin.cnf</b>, or
<b>\%APPDATA%\\MySQL\\\.mylogin.cnf</b> on Windows.
</td>
</tr>
<tr>
<td><tt>MYSQL_TMP_DIR</tt></td>
<td>
Path to temp directory used for temporary files during tests
</td>
</tr>
<tr>
<td><tt>MYSQLD</tt></td>
<td>
Full path to server executable used in tests.
</td>
</tr>
<tr>
<td><tt>MYSQLD_BOOTSTRAP</tt></td>
<td>
Full path name to <b>mysqld</b> that has all options enabled
</td>
</tr>
<tr>
<td><tt>MYSQLD_BOOTSTRAP_CMD</tt></td>
<td>
Full command line used for initial database setup for this
test batch
</td>
</tr>
<tr>
<td><tt>MYSQLD_CMD</tt></td>
<td>
Command line for starting server as used in tests, with the
minimum set of required arguments.
</td>
</tr>
<tr>
<td><tt>MYSQLTEST_VARDIR</tt></td>
<td>
Path name to the <b>var</b> directory that is used for logs,
temporary files, and so forth
</td>
</tr>
<tr>
<td><tt>NUMBER_OF_CPUS</tt></td>
<td>
Defines number of processors.
</td>
</tr>
<tr>
<td><tt>TSAN_OPTIONS</tt></td>
<td>
Path name to a file containing ThreadSanitizer suppressions.
</td>
</tr>
</table>
The variable <b>MTR_PORT_BASE</b> is a more logical replacement
for the original variable <b>MTR_BUILD_THREAD</b>. It gives the
actual port number directly (will be rounded down to a multiple of
10). If you use <b>MTR_BUILD_THREAD</b>, the port number is found
by multiplying this by 10 and adding 10000.
The variable <b>$MYSQL_OPTIONS</b> contains only the options used while
connecting to server from mysql client . whereas variable <b>$MYSQL</b>
contains path to mysql client executable along with options .
Tests sometimes rely on certain environment variables being defined.
For example, certain tests assume that <b>MYSQL_TEST</b> is
defined so that @ref PAGE_MYSQLTEST "mysqltest" can invoke itself
with <b>exec $MYSQL_TEST</b>.
Other tests may refer to the last three variables listed in the
preceding table, to locate files to read or write. For example,
tests that need to create files will typically put them in
<b>$MYSQL_TMP_DIR/file_name</b>.
The variable <b>$MYSQLD_CMD</b> will include any server options
added with the <b>`--mysqld`</b> option to @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl", but will not include
server options added specifically for the currently running test.
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" supports the
options in the following list. An argument of -- tells @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" not to process any
following arguments as options.
<ul>
<li>
<tt>`--help, -h`</tt>
Display a help message and exit.
</li>
<li>
<tt>`--accept-test-fail`</tt>
Do not print an error and do not give exit 1 if some tests failed,
but test run was completed. This also enables --force.
</li>
<li>
<tt>`--big-test`</tt>
Allow tests marked as "big" to run. Tests can be thus marked by
including the line <b>`--source` include/big_test.inc</b>, and
they will only be run if this option is given, or if the
environment variable <b>BIG_TEST</b> is set to 1.
This is typically done for tests that take very long to run, or
that use very much resources, so that they are not suitable for
running as part of a normal test suite run.
If both <b>`--big-test`</b> and <b>`--only-big-tests`</b>
are given, <b>`--only-big-tests`</b> is ignored.
@note
This option is enabled by default when test cases are specified
on command line.
</li>
<li>
<tt>`--boot-dbx`</tt>
Run the <b>mysqld</b> server used for bootstrapping the database
through the <b>dbx</b> debugger.
</li>
<li>
<tt>`--boot-ddd`</tt>
Run the <b>mysqld</b> server used for bootstrapping the database
through the <b>ddd</b> debugger.
</li>
<li>
<tt>`--boot-gdb`</tt>
Run the <b>mysqld</b> server used for bootstrapping the database
through the <b>gdb</b> debugger.
See also the <b>`--manual-boot-gdb`</b> option.
</li>
<li>
<tt>`--build-thread`=<b>number</b></tt>
Specify a number to calculate port numbers from. The formula is
<b>10 * build_thread + 10000</b>. Instead of a number, it can
be set to <b>auto</b>, which is also the default value, in
which case @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will
allocate a number unique to this host.
The value (number or <b>auto</b>) can also be set with the
<b>MTR_BUILD_THREAD</b> environment variable.
This option is kept for backward compatibility. The more logical
<b>`--port-base`</b> is recommended instead.
</li>
<li>
<tt>`--callgrind`</tt>
Instructs <b>valgrind</b> to use <b>callgrind</b>.
</li>
<li>
<tt>`--charset-for-testdb`=<b>charset_name</b></tt>
Specify the default character set for the test database. The
default value is latin1.
</li>
<li>
<tt>`--check-testcases`</tt>
Check test cases for side effects. This is done by checking the
system state before and after each test case. If there is any
difference, the test case is marked as failed because of it.
Similarly, when <b>`--check-testcases`</b> option is enabled,
MTR does additional check for missing <b>.result</b> file and a
test case not having its corresponding <b>.result</b> file is
marked as failed.
This check is enabled by default. To disable it, use the
<b>`--nocheck-testcases`</b> option.
</li>
<li>
<tt>`--clean-vardir`</tt>
Clean up the <b>var</b> directory with logs and test results
etc. after the test run, but only if there were no test
failures. This option only has effect if also running with
option <b>`--mem`</b>. The intent is to alleviate the problem
of using up memory for test results, in cases where many
different test runs are being done on the same host.
</li>
<li>
<tt>`--client-bindir`=<b>path</b></tt>
The path to the directory where client binaries are located.
</li>
<li>
<tt>`--client-dbx`</tt>
Start @ref PAGE_MYSQLTEST "mysqltest" in the <b>dbx</b>
debugger.
</li>
<li>
<tt>`--client-ddd`</tt>
Start @ref PAGE_MYSQLTEST "mysqltest" in the <b>ddd</b>
debugger.
</li>
<li>
<tt>`--client-debugger`=<b>debugger</b></tt>
Start @ref PAGE_MYSQLTEST "mysqltest" in the named debugger.
</li>
<li>
<tt>`--client-gdb`</tt>
Start @ref PAGE_MYSQLTEST "mysqltest" in the <b>gdb</b> debugger.
</li>
<li>
<tt>`--client-libdir`=<b>path</b></tt>
The path to the directory where client libraries are located.
</li>
<li>
<tt>`--colored-diff`</tt>
Colorize the diff part of the output.
When this option is enabled, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" passes <b>`--colored-diff`</b> option to
@ref PAGE_MYSQLTEST "mysqltest". If colored diff is enabled,
@ref PAGE_MYSQLTEST "mysqltest" uses <b>diff</b> command with
<b>`--color`='always'</b> option to print the colored diff.
@note
<b>`--color`</b> option for <b>diff</b> command is available
from <b>GNU diffutils</b> version <b>3.4</b>.
</li>
<li>
<tt>`--combination`=<b>value</b></tt>
Extra option to pass to <b>mysqld</b>. The value should consist
of a single <b>mysqld</b> option including dashes. This option
is similar to <b>`--mysqld`</b> but has a different effect.
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" executes
multiple test runs, using the options for each instance of
<b>`--combination`</b> in successive runs. If
<b>`--combination`</b> is given only once, it has no effect and
behaves similar to <b>`--mysqld`</b> option.
If a test being run, passes the same <b>`--mysqld`</b> option from an
opt file which is also passed from <b>`--combination`</b>, then that
<b>`--combination`</b> run is skipped because opt file always takes
higher precedence over command line options. The test will just run
once using the options provided in the opt file.
For test runs specific to a given test suite, an alternative to
the use of <b>`--combination`</b> is to create a
<b>combinations</b> file in the suite directory. The file
should contain a section of options for each test run. See @ref
PAGE_PASSING_OPTIONS.
For test specific combinations, onc can use
<b><em>test_name</em>.combinations</b> file in the test
directory.
</li>
<li>
<tt>`--comment`=<b>str</b></tt>
Write <b><em>str</em></b> to the output within lines filled
with #, as a form of banner.
</li>
<li>
<tt>`--compress`</tt>
Compress all information sent between the client and the server
if both support compression.
</li>
<li>
<tt>`--cursor-protocol`</tt>
Pass the <b>`--cursor-protocol`</b> option to @ref
PAGE_MYSQLTEST "mysqltest" (implies <b>`--ps-protocol`</b>).
</li>
<li>
<tt>`--dbx`</tt>
Start <b>mysqld</b> in the <b>dbx</b> debugger.
</li>
<li>
<tt>`--ddd`</tt>
Start <b>mysqld</b> in the <b>ddd</b> debugger.
</li>
<li>
<tt>`--debug`</tt>
Dump trace output for all clients and servers.
</li>
<li>
<tt>`--debugger`=<b>debugger</b></tt>
Start <b>mysqld</b> using the named debugger.
</li>
<li>
<tt>`--debug-common`</tt>
This option works similar to <b>`--debug`</b> but turns on
debug only for the debug macro keywords <b>query</b>,
<b>info</b>, <b>error</b>, <b>enter</b>, <b>exit</b>
which are considered the most commonly used.
</li>
<li>
<tt>`--debug-server`</tt>
Runs <b>mysqld.debug</b> (if available) instead of
<b>mysqld</b> as server. If it does find <b>mysqld.debug</b>,
it will search for plugin libraries in a subdirectory
<b>debug</b> under the directory where it's normally located.
This option does not turn on trace output and is independent of
the <b>debug</b> option.
</li>
<li>
<tt>`--debug-sync-timeout`=<b>seconds</b></tt>
Controls whether the Debug Sync facility for testing and
debugging is enabled. The option value is a timeout in seconds.
The default value is 300. A value of 0 disables Debug Sync. The
value of this option also becomes the default timeout for
individual synchronization points.
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" passes
<b>`--loose-debug-sync-timeout`=<em>seconds</em></b> to
<b>mysqld</b>. The <b>`--loose`</b> prefix is used so that
<b>mysqld</b> does not fail if Debug Sync is not compiled in.
For information about using the Debug Sync facility for testing,
see @ref PAGE_THREAD_SYNCHRONIZATION.
</li>
<li>
<tt>`--default-myisam`</tt>
Use <b>MyISAM</b> as the default storage engine for all except
<b>InnoDB</b>-specific tests. This option is off by default.
</li>
<li>
<tt>`--defaults-file`=<b>file_name</b></tt>
Use the named file as fixed config file template for all tests.
</li>
<li>
<tt>`--defaults_extra_file`=<b>file_name</b></tt>
Add setting from the named file to all generated configs.
</li>
<li>
<tt>`--do-suite`=<b>prefix or regex</b></tt>
Run all test cases from suites having a name that begins with
the given <b><em>prefix</em></b> value or matches the regular
expression. If the argument matches no existing suite, @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" aborts.
The argument for the <b>`--do-suite`</b> option allows more
flexible specification of which tests to perform. See the
description of the <b>`--do-test`</b> option for details.
In case a suite or a list of suites is specified using the
<b>`--suite`</b> option along with a pattern or regular
expression given through <b>`--do-suite`</b>, only suite(s)
from the list which match the prefix or regular expression
are picked up.
When the <b>`--do-suite`</b> option is specified more than once
on the command line, only the last occurrence is considered.
</li>
<li>
<tt>`--do-test`=<b>prefix or regex</b></tt>
Run all test cases having a name that begins with the given
<b><em>prefix</em></b> value or matches the regular expression.
This option provides a convenient way to run a family of
similarly named tests.
The argument for the <b>`--do-test`</b> option allows more
flexible specification of which tests to perform. If the
argument contains a pattern metacharacter other than a lone
period, it is interpreted as a Perl regular expression and
applies to test names that match the pattern. If the argument
contains a lone period or does not contain any pattern
metacharacters, it is interpreted the same way as previously and
matches test names that begin with the argument value. For
example, <b>`--do-test`=testa</b> matches tests that begin with
<b>testa</b>, <b>`--do-test`=main.testa</b> matches tests in the
<b>main</b> test suite that begin with <b>testa</b>, and
<b>`--do-test`=main.*testa</b> matches test names that contain
<b>main</b> followed by <b>testa</b> with anything in between.
In the latter case, the pattern match is not anchored to the
beginning of the test name, so it also matches names such as
<b>xmainytestz</b>.
</li>
<li>
<tt>`--do-test-list`=<b>file</b></tt>
Run all tests listed in the file <b><em>file</em></b>. In this
file, tests should be listed one per line in any of the
following forms.
@verbatim
<test_name>
<test_name>.test
<suite_name>.<test_name>
<suite_name>.<test_name>.test
path_to_the_test_file
@endverbatim
Path to the test file should either be an absolute path or a
relative path from base directory.
To run a test present in a non-default test suite, either the
test name qualified with the suite name i.e
<b>suite_name.test_name[.test]</b> or a <b>path</b> to the
test file should be mentioned.
A line beginning with <b>#</b> will be ignored and is considered
as a comment. Similarly an empty line in the file is also
ignored.
For example, consider a test list file <b>test_list</b>
containing following tests.
@verbatim
# Main suite test '1st.test'
1st
1st.test
main.1st
main.1st.test
mysql-test/t/1st.test
# GIS suite test 'geohash_functions.test'
gis.geohash_functions
mysql-test/suite/gis/t/geohash_functions.test
# Non-default suite 'test_services'
test_services.test_services
mysql-test/suite/test_services/t/test_services.test
# Internal suite test 'i_main.user_var'
i_main.user_var
internal/mysql-test/suite/i_main/t/user_var.test
@endverbatim
Following command runs the list of tests mentioned in the file.
@verbatim
./mysql-test-run.pl --do-test-list=test_list
@endverbatim
If both <b>`--suite`</b> and <b>`--do-test-list`</b> are given,
and if suite name is <em>not</em> part of the test names listed
in the file, then those tests are searched only in the suites
mentioned in <b>`--suite`</b> option.
</li>
<li>
<tt>`--enable-disabled`</tt>
Ignore any <b>disabled.def</b> file, and run also tests marked
as disbaled. Success or failure of those tests will be reported
the same way as other tests.
@note
This option is enabled by default when test cases are specified
on command line.
</li>
<li>
<tt>`--explain-protocol`</tt>
Run <b>EXPLAIN EXTENDED</b> on all <b>SELECT</b>, <b>INSERT</b>,
<b>REPLACE</b>, <b>UPDATE</b> and <b>DELETE</b> queries.
</li>
<li>
<tt>`--extern` <b>option=value</b></tt>
Use an already running server. The option/value pair is what is
needed by the <b>mysql</b> client to connect to the server. Each
<b>`--extern`</b> can only take one option/value pair as
argument, so it you need more you need to repeat
<b>`--extern`</b> for each of them.
@verbatim
./mysql-test-run.pl --extern socket=var/tmp/mysqld.1.sock main.1st
@endverbatim
During server initialization, @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" creates a default database <b>test</b> which
is used while establishing an initial connection with the
server. When running a test case with <b>--extern</b> option, if
<b>test</b> database doesn't exist on an already running server,
then the test case will fail with following error.
@verbatim
mysqltest: Could not open connection 'default': 1049 Unknown database 'test'
@endverbatim
So if you're running a test case on an already running server
using <b>--extern</b> option, it is necessary to create
<b>test</b> database on the server before running the test case
if it doesn't exist.
Similarly, @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl"
creates <b>mtr</b> database during server initialization which
contains tables and procedures used to suppress global or test
specific warnings. If a test case refers to this database and
the database doesn't exist on running server, then the test case
will fail.
@note
If a test case has an <b>.opt</b> file that requires the server
to be restarted with specific options, the file will not be
used. The test case likely will fail as a result.
</li>
<li>
<tt>`--fast`</tt>
Do not perform controlled shutdown when servers need to be
restarted or at the end of the test run. This is equivalent to
using <b>`--shutdown-timeout`=0</b>.
</li>
<li>
<tt>`--force`</tt>
Normally, @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" exits
if a test case fails. <b>`--force`</b> causes execution to
continue regardless of test case failure.
</li>
<li>
<tt>`--force-restart`</tt>
Always restart the server(s) between each tast case, whether
it's needed or not. Will also restart between repeated runs of
the same test case. This may be useful e.g. when looking for the
source of a memory leak, as there will only have been one test
run before the server exits.
Enabling this option will cause @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" to restart the server(s) on a newly
intialized data directory.
This option can also be mentioned in
<b><em>test-name</em>-master.opt</b> file for a test case to
restart the server(s) before it runs.
</li>
<li>
<tt>`--gcov`</tt>
Run tests with the <b>gcov</b> test coverage tool.
</li>
<li>
<tt>`--gdb`</tt>
Start <b>mysqld</b> in the <b>gdb</b> debugger.
</li>
<li>
<tt>`--gprof`</tt>
Run tests with the <b>gprof</b> profiling tool.
</li>
<li>
<tt>`--include-ndbcluster`, `--include-ndb`</tt>
Run also tests that need Cluster.
</li>
<li>
<tt>`--initialize`=<b>value</b></tt>
Extra bootstrap options that need be to be passed during
the server initialization process can be passed as a value
to <b>`--initialize`</b>. The server is then started with
the specified value. Only one option may be specified in
<b>value</b>; to specify more than one, use additional
<b>`--initialize`</b> options.
Options passed as a value to <b>`--mysqld`</b> will have
precedence over the options passed to <b>`--initialize`</b>,
regardless of the order in which they passed on the command
line.
</li>
<li>
<tt>`--json-explain-protocol`</tt>
Run <b>EXPLAIN FORMAT=JSON</b> on all <b>SELECT</b>,
<b>INSERT</b>, <b>REPLACE</b>, <b>UPDATE</b> and <b>DELETE</b>
queries.
</li>
<li>
<tt>`--manual-boot-gdb`</tt>
This option is similar to <b>`--boot-gdb`</b> but attaches the
debugger to the server during the bootstrapping process,
permitting the use of a remote debugger.
</li>
<li>
<tt>`--manual-dbx`</tt>
Use a server that has already been started by the user in the
<b>dbx</b> debugger.
</li>
<li>
<tt>`--manual-ddd`</tt>
Use a server that has already been started by the user in the
<b>ddd</b> debugger.
</li>
<li>
<tt>`--manual-debug`</tt>
Use a server that has already been started by the user in a
debugger.
</li>
<li>
<tt>`--manual-gdb`</tt>
Use a server that has already been started by the user in the
<b>gdb</b> debugger.
</li>
<li>
<tt>`--mark-progress`</tt>
Marks progress with timing (in milliseconds) and line number in
<b>var/log/<em>testname</em>.progress</b>.
</li>
<li>
<tt>`--max-connections`=<b>num</b></tt>
The maximum number of simultaneous server connections that may
be used per test. If not set, the maximum is 128. Minimum
allowed limit is 8, maximum is 5120. Corresponds to the same
option for @ref PAGE_MYSQLTEST "mysqltest".
</li>
<li>
<tt>`--max-save-core`=<b>N</b></tt>
Limit the number of core files saved, to avoid filling up disks
in case of a frequently crashing server. Defaults to 5, set to 0
for no limit. May also be set with the environment variable
<tt>MTR_MAX_SAVE_CORE</tt>.
</li>
<li>
<tt>`--max-save-datadir`=<b>N</b></tt>
Limit the number of data directories saved after failed tests,
to avoid filling up disks in case of frequent failures. Defaults
to 20, set to 0 for no limit. May also be set with the
environment variable <b>MTR_MAX_SAVE_DATADIR</b>.
</li>
<li>
<tt>`--max-test-fail`=<b>N</b></tt>
Stop execution after the specified number of tests have failed,
to avoid using up resources (and time) in case of massive
failures. retries are noe counted. Defaults to 10, set to 0 for
no limit. May also be set with the environment variable
<b>MTR_MAX_TEST_FAIL</b>.
</li>
<li>
<tt>`--mem`</tt>
This option is not supported on Windows and on MacOS.
Run the test suite in memory, using tmpfs or ramdisk. This can
decrease test times significantly, in particular if you would
otherwise be running over a remote file system. @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" attempts to find a
suitable location using a built-in list of standard locations
for tmpfs and puts the <b>var</b> directory there. This option
also affects placement of temporary files, which are created in
<b>var/tmp</b>.
The default list includes <b>/dev/shm</b>, <b>/run/shm</b> and
<b>/tmp</b>. You can also enable this option by setting the
environment variable <b>MTR_MEM[=<em>dir_name</em>]</b>. If
<b><em>dir_name</em></b> is given, it is added to the beginning
of the list of locations to search, so it takes precedence over
any built-in locations.
Once you have run tests with <b>`--mem`</b> within a
<b>mysql-test</b> directory, a soflink <b>var</b> will have been
set up to the temporary directory, and this will be re-used the
next time, until the soflink is deleted. Thus, you do not have
to repeat the <b>`--mem`</b> option next time.
</li>
<li>
<tt>`--mysqld`=<b>value</b></tt>
Extra option to pass to <b>mysqld</b>. Only one option may be
specified in <b>value</b>; to specify more than one, use
additional <b>--mysqld</b> options. See @ref PAGE_PASSING_OPTIONS.
</li>
<li>
<tt>`--mysqld-env`=<b>variable</b>=<b>value</b></tt>
Sets (or changes) an environment variable before starting
<b>mysqld</b>. Varibles set in the environment from which you
run @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will
normally also be propagated to <b>mysqld</b>, but there may be
cases where you want a setting just for a single run, or you may
not want the setting to affect other programs. You may use
additional <b>`--mysqld-env`</b> options to set more than one
variable.
</li>
<li>
<tt>`--mysqltest`=<b>options</b></tt>
Extra options to pass to @ref PAGE_MYSQLTEST "mysqltest".
</li>
<li>
<tt>`--ndb-connectstring`=<b>str</b></tt>
Pass <b>`--ndb-connectstring`=<em>str</em></b> to the master
MySQL server. This option also prevents @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" from starting a
cluster. It is assumed that there is already a cluster running
to which the server can connect with the given connectstring.
</li>
<li>
<tt>`--no-skip`</tt>
This option forces all tests to run, ignoring any
<b>`--skip`</b> commands used in the test. This ensures that all
tests are run. An excluded list (<b>excludenoskip.list</b>) is
maintained to track which tests should continue to be skipped.
The <b>`--no-skip`</b> option continues to skip the tests that
are named in the excluded list. In case the test or file invoking
the <b>`--skip`</b> command is not present in the excluded list, the
outcome of the test will be identified as <b>[ noskip-pass ]</b> or
<b>[ noskip-fail ]</b> .The default value of <b>--no-skip</b>
introduced variable is OFF, which implies users are not forced to
run all tests unless the <b>--no-skip</b> is explicitly used.
@verbatim
shell> mysql-test-run.pl --suite=innodb --no-skip
@endverbatim
</li>
<li>
<tt>`--nocheck-testcases`</tt>
Disable the check for test case side effects. For additional
information, see the description of the
<b>`--check-testcases`</b> option.
</li>
<li>
<tt>`--noreorder`</tt>
Do not reorder tests to reduce number of restarts, but run them
in exactly the order given. If a whole suite is to be run, the
tests are run in alphabetic order, though similiar combinations
will be grouped together. If more than one suite is listed, the
tests are run one suite at a time, in the order listed.
</li>
<li>
<tt>`--notimer`</tt>
Cause @ref PAGE_MYSQLTEST "mysqltest" not to generate a timing
file. The effect of this is that the report from each test case
does not include the timing in milliseconds as it normally does.
</li>
<li>
<tt>`--nounit-tests`</tt>
Do not run unit tests, overriding default behavior or setting of
the <b>MTR_UNIT_TESTS</b> variable.
</li>
<li>
<tt>`--nowarnings`</tt>
Do not look for and report errors and warning in the server logs.
@note
In addition to being passed as a command-line option,
<b>`--nowarnings`</b> can also be passed in the <b>.opt</b> file of
a test case.
</li>
<li>
<tt>`--only-big-tests`</tt>
This option causes only big tests to run. Normal (non-big) tests
are skipped. If both <b>`--big-test`</b> and
<b>`--only-big-tests`</b> are given, <b>`--only-big-tests`</b>
is ignored.
</li>
<li>
<tt>`--opt-trace-protocol`</tt>
Prints the @ref PAGE_OPT_TRACE "optimizer trace" of SQL statements in a test.
Running any MTR test with this option executes the following SQL
statement after every <b>DML statement</b> that it encounters:
@verbatim
SELECT trace FROM information_schema.optimizer_trace /* injected by --opt-trace-protocol */;
@endverbatim
</li>
<li>
<tt>`--parallel`={<b>N</b>|auto}</tt>
Run tests using <b><em>N</em></b> parallel threads. By default,
1 thread is used. Use <b>`--parallel`=auto</b> to set
<b><em>N</em></b> automatically.
Setting the <b>MTR_PARALLEL</b> environment variable to
<b><em>N</em></b> has the same effect as specifying
<b>`--parallel`=<em>N</em></b>.
The <b>MTR_MAX_PARALLEL</b> environment variable, if set,
specifies the maximum number of parallel workers that can be
spawned when the <b>`--parallel`=auto</b> option is specified.
If <b>`--parallel`=auto</b> is not specified,
<b>MTR_MAX_PARALLEL</b> variable has no effect.
</li>
<li>
<tt>`--port-base`=<b>P</b></tt>
Specify base of port numbers to be used; a block of 10 will be
allocated. <b><em>P</em></b> should be divisible by 10; if it is
not, it will be rounded down. If running with more than one
parallel test thread, thread 2 will use the next block of 10 and
so on.
If the port number is given as <b>auto</b>, which is also the
default, @ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will
allocate a number unique to this host. The value may also be
given with the environment variable <b>MTR_PORT_BASE</b>.
<b>`--port-base`</b> was added as a more logical alternative to
<b>`--build-thread`</b>. If both are used, <b>`--port-base`</b>
takes precedence.
</li>
<li>
<tt>`--print-testcases`</tt>
Do not run any tests, but print details about all tests, in the
order they would have been run.
</li>
<li>
<tt>`--ps-protocol`</tt>
Pass the <b>`--ps-protocol`</b> option to @ref PAGE_MYSQLTEST
"mysqltest".
</li>
<li>
<tt>`--quiet`</tt>
Reuse the output buffer and maintain a single line for reporting
successful tests, skipped tests and disabled tests. Failed tests
and the necessary information about the failure will be printed
on a separate line.
When <b>`--quiet`</b> option is enabled, MTR prints only the
test name and result of the test run.
</li>
<li>
<tt>`--record`</tt>
Pass the <b>`--record`</b> option to @ref PAGE_MYSQLTEST
"mysqltest". This option requires a specific test case to be
named on the command line.
</li>
<li>
<tt>`--reorder`</tt>
Reorder tests to minimize the number of server restarts needed.
This is the default behavior. There is no guarantee that a
particular set of tests will always end up in the same order.
</li>
<li>
<tt>`--repeat`=<b>N</b></tt>
Run each test <b><em>N</em></b> number of times, in parallel if
<b>`--parallel`</b> option value is greater than 1.
</li>
<li>
<tt>`--report-features`</tt>
Display the output of <b>SHOW ENGINES</b> and <b>SHOW
VARIABLES</b>. This can be used to verify that binaries are
built with all required features.
</li>
<li>
<tt>`--report-times`</tt>
At the end of the test run, write a summary of how much time was
spent in various phases of execution. If you run with
<b>`--parallel`</b>, the total will exceed the wall clock time
passed, since it will be summed over all threads.
The times reported should only be treated as approximations, and
the exact points where the time is taken may also change between
releases. If the test run is aborted, including if a test fails
and <b>`--force`</b> is not in use, the time report will not
be produced.
</li>
<li>
<tt>`--report-unstable-tests`</tt>
The option can be used to distinguish unstable tests which pass
on at least one retry attempt from hard failing ones. Unstable
tests are reported separately in the end summary in the format:
<b>test_name(num_of_failures/num_of_attempts)</b>.
In case all failures encountered are due to unstable tests, MTR
will print the below warning and exit with a zero status code.
@verbatim
mysql-test-run: WARNING: There are failures due to unstable test cases.
However, the tests are not hard-failing.
@endverbatim
This option has no effect unless <b>`--force`</b> is used and
both <b>`--retry`</b> and <b>`--retry-failure`</b> are set to
values greater than 1.
</li>
<li>
<tt>`--retry`=<b>N</b></tt>
If a test fails, it is retried up to a maximum of
<b><em>N</em></b> runs, but will terminate after 2 failures.
Default is 3, set to 1 or 0 for no retries. This option has no
effect unless <b>`--force`</b> is also used; without it, test
execution will terminate after the first failure.
The <b>`--retry`</b> and <b>`--retry-failure`</b> options do not
affect how many times a test repeated with <b>`--repeat`</b> may
fail in total, as each repetition is considered a new test case,
which may in turn be retried if it fails.
</li>
<li>
<tt>`--retry-failure`=<b>N</b></tt>
Allow a failed and retried test to fail more than the default 2
times before giving it up. Setting it to 0 or 1 effectively
turns off retries
</li>
<li>
<tt>`--sanitize`</tt>
Scan the server log files for warnings from various sanitizers.
Use of this option assumes that MySQL was configured with
[-DWITH_ASAN]
(https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html#option_cmake_with_asan)
or [-DWITH_UBSAN]
(https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html#option_cmake_with_ubsan).
The <b>TSAN_OPTIONS</b> environment variable can be set to
specify the path name of a file containing ThreadSanitizer
suppressions.
</li>
<li>
<tt>`--shutdown-timeout`=<b>seconds</b></tt>
Max number of seconds to wait for servers to do controlled
shutdown before killing them. Default is 10.
</li>
<li>
<tt>`--skip-combinations`</tt>
Do not apply combinations; ignore combinations file or option.
</li>
<li>
<tt>`--skip-ndbcluster`, `--skip-ndb`</tt>
Do not start NDB Cluster; skip Cluster test cases. This option
only has effect if you do have NDB, if not it will have no
effect as it cannot run those tests anyway.
</li>
<li>
<tt>`--skip-ndbcluster-slave`, `--skip-ndb-slave`</tt>
Do not start an NDB Cluster slave.
</li>
<li>
<tt>`--skip-rpl`</tt>
Skip replication test cases.
</li>
<li>
<tt>`--skip-test`=<b>regex</b></tt>
Specify a regular expression to be applied to test case names.
Cases with names that match the expression are skipped. tests to
skip.
The argument for the <b>`--skip-test`</b> option allows more
flexible specification of which tests to skip. If the argument
contains a pattern metacharacter other than a lone period, it is
interpreted as a Perl regular expression and applies to test
names that match the pattern. See the description of the
<b>`--do-test`</b> option for details.
</li>
<li>
<tt>`--skip-test-list`=<b>file</b></tt>
Specify a file listing tests that should be skipped (disabled).
The file has the same format as the <b>disabled.def</b> file
listing disabled tests. With this option, disabling can be done
on a case by case basis.
</li>
<li>
<tt>`--skip-*`</tt>
<b>`--skip-*`</b> options not otherwise recognized by @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" are passed to the
master server.
</li>
<li>
<tt>`--sp-protocol`</tt>
Pass the <b>`--sp-protocol`</b> option to @ref PAGE_MYSQLTEST
"mysqltest".
</li>
<li>
<tt>`--start`</tt>
Initialize and start servers with the startup settings for the
specified test case. You can use this option to start a server
to which you can connect later. For example, after building a
source distribution you can start a server and connect to it
with the <b>mysql</b> client like this:
@verbatim
shell> cd mysql-test
shell> ./mysql-test-run.pl --start alias &
shell> ../mysql -S ./var/tmp/master.sock -h localhost -u root
@endverbatim
If no tests are named on the command line, the server(s) will be
started with settings for the first test that would have been
run without the <b>`--start`</b> option.
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will stop once
the server has been started, but will terminate if the server
dies. If killed, it will also shut down the server.
</li>
<li>
<tt>`--start-and-exit`</tt>
This is similar to <b>`--start`</b>, but @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" terminates once the
server has been started, leaving just the server process
running.
</li>
<li>
<tt>`--start-dirty`</tt>
This is similar to <b>`--start`</b>, but will skip the
database initialization phase and assume that database files are
already available. Usually this means you must have run another
test first.
</li>
<li>
<tt>`--start-from`=<b>test_name</b></tt>
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" sorts the list
of names of the test cases to be run, and then begins with
<b><em>test_name</em></b>.
</li>
<li>
<tt>`--strace-client`</tt>
Create <b>strace</b> output for @ref PAGE_MYSQLTEST "mysqltest".
Will produce default <b>strace</b> output as
<b>mysqltest.strace</b>. Note that this will be overwritten
for each new test case, so it's most useful for running only one
test.
The <b>strace-client</b> option is only supported on Linux.
</li>
<li>
<tt>`--strace-server`</tt>
Create <b>strace</b> output for the server. Will produce default
<b>strace</b> output as <b>mysqld.1.strace</b>. Note that this
will be overwritten each time the server is restarted, so it's
most useful for running a single test, or if you want trace from
the first test that fails.
The <b>strace-server</b> option is available on Linux only.
</li>
<li>
<tt>`--stress`=<b>stress options</b></tt>
Start a server, but instead of running a test, run @ref
PAGE_MYSQLTEST "mysql-stress-test.pl" with the supplied
arguments. Arguments needed to communicate with the server will
be automatically provided, the rest should be given as arguments
to this option. Command line options for @ref PAGE_MYSQLTEST
"mysql-stress-test.pl" should be separeted by a comma.
</li>
<li>
<tt>`--suite(s)`=<b>{suite_name|suite_list|suite_set}</b></tt>
Run a suite or a comma separated list of suites or those suites
which fall under the specified suite set. If the option is not
specified explicitly, MTR assumes that it needs to use the
default suite set for the test run.
The suite set's MTR can use are case insensitive and take the
below values:
@verbatim
default - To run the default list of suites.
all - To scan the mysql directory and run all available suites.
non-default - To scan the mysql directory for available suites and
collect only the non-default suites.
@endverbatim
The suite set 'all' is used implicitly if neither a suite nor a
suite list is specified and\n
(i) There are tests given on the MTR command line <b>or</b>\n
(ii) Any of the following options are used: <b>--do-suite</b>,
<b>--do-test</b>, <b>--do-test-list</b>.
Note that suite sets 'all' and 'non-default' do not include ndb test
suites in case ndb cluster is not enabled.
If a suite set is specified in the suite list, MTR does not treat it
as a suite set and considers it as the name of a suite to be run.
</li>
<li>
<tt>`--suite-timeout`=<b>minutes</b></tt>
Specify the maximum test suite runtime in minutes.
</li>
<li>
<tt>`--summary-report`=<b>file_name</b></tt>
Generate a plain text version of the test summary only and write
it to the file named as the option argument. The file is
suitable for sending by email.
</li>
<li>
<tt>`--test-progress`[={0|1}]</tt>
Print the percentage of tests completed. This option is enabled
by default. The argument to <b>`--test-progress`</b> is
optional. To disable it, set the value to <b>0</b>.
For example, consider a test suite <b>sample_test_suite</b>
containing 3 tests.
@verbatim
./mysql-test-run.pl --suite=sample_test_suite [--test-progress]
@endverbatim
Running the suite with <b>`--test-progress`</b> option enabled
will print the percentage of tests completed.
@verbatim
[ 33%] sample_test_suite.1st [ pass ] 1
[ 66%] sample_test_suite.2nd [ pass ] 1
[100%] sample_test_suite.3rd [ pass ] 1
@endverbatim
</li>
<li>
<tt>`--testcase-timeout`=<b>minutes</b></tt>
Specify the maximum test case runtime in minutes.
@note
When a test case is run with <b>valgrind</b> option enabled, the
test case timeout value becomes 10 times the specified value.
For example, running a test case with timeout value
<b>1 minute</b> and <b>valgrind</b> enabled will increase the
timeout value to <b>10 minutes</b>.
</li>
<li>
<tt>`--timediff`</tt>
Adds to each test report for a test case, the total time in
seconds and milliseconds passed since the preceding test ended.
This option can only be used together with
<b>`--timestamp`</b>, and has no effect without it.
</li>
<li>
<tt>`--timer`</tt>
Cause @ref PAGE_MYSQLTEST "mysqltest" to generate a timing file.
The default file is named <b>./var/log/timer</b>.
</li>
<li>
<tt>`--timestamp`</tt>
Prints a timestamp before the test case name in each test report
line, showing when the test ended.
</li>
<li>
<tt>`--tmpdir`=<b>path</b></tt>
The directory where temporary file are stored. The default
location is <b>./var/tmp</b>. The environment variable
<b>MYSQL_TMP_DIR</b> will be set to the path for this directory,
whether it has the default value or has been set explicitly.
This may be referred to in tests.
</li>
<li>
<tt>`--unit-tests`</tt>
Force running of unit tests, overriding default behavior or
setting of the <b>MTR_UNIT_TESTS</b> variable.
</li>
<li>
<tt>`--unit-tests-report`</tt>
Extend the unit test run by also outputting the log from the
test run, independently of whether it succeeded or not. This
option implies <b>`--unit-tests`</b> so it is not necessary to
specify both.
</li>
<li>
<tt>`--user`=<b>user_name</b></tt>
The MySQL user name to use when connecting to the server.
</li>
<li>
<tt>`--user-args`</tt>
Drops all non-essential command line arguments to the
<b>mysqld</b> server, except those supplied with
<b>`--mysqld`</b> arguemnts, if any. Only works in combination
with <b>`--start`</b>, <b>`--start-and-exit`</b> or
<b>`--start-dirty`</b>, and only if no test name is given.
</li>
<li>
<tt>`--valgrind`</tt>
Run @ref PAGE_MYSQLTEST "mysqltest" and <b>mysqld</b> with
<b>valgrind</b>. This and the following <b>`--valgrind`</b>
options require that the executables have been build with
<b>valgrind</b> support.
When the server is run with valgrind, an extra pass over the
server log file(s) will be performed after all tests are run,
and any report with problems that have been reported at server
shutdown will be extracted and printed. The most common warnings
are memory leaks. With each report will also be listed all tests
that were run since previous server restart; one of these is
likely to have caused the problem.
A final "pseudo" test named <b>valgrind_report</b> is added to
the list of tests when the server is run in valgrind. This test
is reported as failed if any such shutdown warnings were
produced by valgrind. Pass or failure of this test is also added
to the total test count reported.
@note
When a test case is run with <b>valgrind</b> option enabled, the
test case timeout value becomes 10 times the specified value.
For example, running a test case with timeout value
<b>1 minute</b> and <b>valgrind</b> enabled will increase the
timeout value to <b>10 minutes</b>.
</li>
<li>
<tt>`--valgrind-clients`</tt>
Run all clients started by <b>.test</b> files with
<b>valgrind</b>. This option requires <b>valgrind 3.9</b> or
later.
</li>
<li>
<tt>`--valgrind-mysqld`</tt>
Run the <b>mysqld</b> server with <b>valgrind</b>.
</li>
<li>
<tt>`--valgrind-mysqltest`</tt>
Run @ref PAGE_MYSQLTEST "mysqltest" with <b>valgrind</b>.
</li>
<li>
<tt>`--valgrind-option`=<b>str</b></tt>
Extra options to pass to <b>valgrind</b>.
</li>
<li>
<tt>`--valgrind-path`=<b>path</b></tt>
Specify the path name to the valgrind executable.
</li>
<li>
<tt>`--vardir`=<b>path</b></tt>
Specify the path where files generated during the test run are
stored. The default location is <b>./var</b>. The environment
variable <b>MYSQLTEST_VARDIR</b> will be set to the path for
this directory, whether it has the default value or has been set
explicitly. This may be referred to in tests.
</li>
<li>
<tt>`--verbose`</tt>
Give more verbose output regarding test execution. Note that the
output generated within each test case is not affected.
</li>
<li>
<tt>`--verbose-restart`</tt>
Write when and why servers are restarted between test cases.
</li>
<li>
<tt>`--view-protocol`</tt>
Pass the <b>`--view-protocol`</b> option to @ref
PAGE_MYSQLTEST "mysqltest".
</li>
<li>
<tt>`--vs-config`=<b>config_val</b></tt>
Specify the configuration used to build MySQL (for example,
<b>--vs-config=debug --vs-config=release</b>). This option
is for Windows only.
</li>
<li>
<tt>`--wait-all`</tt>
If <b>`--start`</b> or <b>`--start-dirty`</b> is used, wait
for all servers to exit before termination. Otherise, it will
terminate if one (of several) servers is restarted.
</li>
<li>
<tt>`--warnings`</tt>
Search the server log for errors or warning after each test and
report any suspicious ones; if any are found, the test will be
marked as failed. This is the default behavior, it may be turned
off with <b>`--nowarnings`</b>.
</li>
<li>
<tt>`--with-ndbcluster-only`, `--with-ndb-only`</tt>
Run only <b>ndb</b> tests. If no suites are explicitly given, this
option also skip all non <b>ndb</b> suites without checking
individual test names.
</li>
<li>
<tt>`--xml-report`=<b>file_name</b></tt>
Generate an xml file containing result of the test run and write
it to the file named as the option argument. It includes
suite-wise and overall statistics like the number of tests run,
number of failures, number of disabled and skipped tests along
with information about each individual test according to its
outcome.
The xml report's structure can be found below :
@verbatim
<testsuites ... >
<testsuite ... >
<testcase ... />
<testcase ... >
<failure ... > ... </failure>
</testcase>
</testsuite>
</testsuites>
@endverbatim
</li>
</ul>
@note
The hostname resolves to 127.0.0.1 and not to the actual IP address.
*/
###############################################################################
## mysql-stress-test.pl — Server Stress Test Program
/**
@page PAGE_MYSQL_STRESS_TEST_PL mysql-stress-test.pl — Server Stress Test Program
The @ref PAGE_MYSQL_STRESS_TEST_PL "mysql-stress-test.pl" Perl
script performs stress-testing of the MySQL server.
@ref PAGE_MYSQL_STRESS_TEST_PL "mysql-stress-test.pl" requires
version of Perl that has been built with threads support.
Invoke @ref PAGE_MYSQL_STRESS_TEST_PL "mysql-stress-test.pl" like
this:
@verbatim
shell> mysql-stress-test.pl [options]
@endverbatim
@ref PAGE_MYSQL_STRESS_TEST_PL "mysql-stress-test.pl" supports the
following options:
<ul>
<li>
<tt>`--help`</tt>
Display a help message and exit.
</li>
<li>
<tt>`--abort-on-erro`r=<b>N</b></tt>
Causes the program to abort if an error with severity less than
or equal to N was encountered. Set to 1 to abort on any error.
</li>
<li>
<tt>`--check-tests-file`</tt>
Periodically check the file that lists the tests to be run. If
it has been modified, reread the file. This can be useful if you
update the list of tests to be run during a stress test.
</li>
<li>
<tt>`--cleanup`</tt>
Force cleanup of the working directory.
</li>
<li>
<tt>`--log-error-details`</tt>
Log error details in the global error log file.
</li>
<li>
<tt>`--loop-count`=<b>N</b></tt>
In sequential test mode, the number of loops to execute before
exiting.
</li>
<li>
<tt>`--mysqltest`=<b>path</b></tt>
The path name to the @ref PAGE_MYSQLTEST "mysqltest" program.
</li>
<li>
<tt>`--server-database`=<b>db_name</b></tt>
The database to use for the tests. The default is <b>test</b>.
</li>
<li>
<tt>`--server-host`=<b>host_name</b></tt>
The host name of the local host to use for making a TCP/IP
connection to the local server. By default, the connection is
made to <b>localhost</b> using a Unix socket file.
</li>
<li>
<tt>`--server-logs-dir`=<b>path</b></tt>
This option is required. path is the directory where all client
session logs will be stored. Usually this is the shared
directory that is associated with the server used for testing.
</li>
<li>
<tt>`--server-password`=<b>password</b></tt>
The password to use when connecting to the server.
</li>
<li>
<tt>`--server-port`=<b>port_num</b></tt>
The TCP/IP port number to use for connecting to the server.
The default is <b>3306</b>.
</li>
<li>
<tt>`--server-socket`=<b>file_name</b></tt>
For connections to <b>localhost</b>, the Unix socket file to
use, or, on Windows, the name of the named pipe to use. The
default if <b>/tmp/mysql.sock</b>.
</li>
<li>
<tt>`--server-user`=<b>user_name</b></tt>
The MySQL user name to use when connecting to the server. The
default is <b>root</b>.
</li>
<li>
<tt>`--sleep-time`=<b>N</b></tt>
The delay in seconds between test executions.
</li>
<li>
<tt>`--stress-basedir`=<b>path</b></tt>
This option is required. <b>path</b> is the working
directory for the test run. It is used as the temporary location
for result tracking during testing.
</li>
<li>
<tt>`--stress-datadir`=<b>path</b></tt>
The directory of data files to be used during testing. The
default location is the <b>data</b> directory under the
location given by the <b>`--stress-suite-basedir`</b> option.
</li>
<li>
<tt>`--stress-init-file`[=<b>path</b>]</tt>
<b>file_name</b> is the location of the file that
contains the list of tests to be run once to initialize the
database for the testing. If missing, the default file is
<b>stress_init.txt</b> in the test suite directory.
</li>
<li>
<tt>`--stress-mode`=<b>mode</b></tt>
This option indicates the test order in stress-test mode. The
<b>mode</b> value is either <b>random</b> to select tests in
random order or <b>seq</b> to run tests in each thread in the
order specified in the test list file. The default mode is
<b>random</b>.
</li>
<li>
<tt>`--stress-suite-basedir`=<b>path</b></tt>
This option is required. <b>path</b> is the directory
that has the <b>t</b> and <b>r</b> subdirectories containing
the test case and result files. This directory is also the
default location of the <b>stress-test.txt</b> file that
contains the list of tests. (A different location can be
specified with the <b>`--stress-tests-file`</b> option).
</li>
<li>
<tt>`--stress-tests-file`[=<b>file_name</b>]</tt>
Use this option to run the stress tests. <b>file_name</b>
is the location of the file that contains the list of tests. If
<b>file_name</b> is omitted, the default file is
<b>stress-test.txt</b> in the stress suite directory. (See
<b>`--stress-suite-basedir`</b>).
</li>
<li>
<tt>`--suite`=<b>suite_name</b></tt>
Run the named test suite. The default name is <b>main</b> (the
regular test suite located in the mysql-test directory).
</li>
<li>
<tt>`--test-count`=<b>N</b></tt>
The number of tests to execute before exiting.
</li>
<li>
<tt>`--test-duration`=<b>N</b></tt>
The duration of stress testing in seconds.
</li>
<li>
<tt>`--threads`=<b>N</b></tt>
The number of threads. The default is 1.
</li>
<li>
<tt>`--verbose`</tt>
Verbose mode. Print more information about what the program does.
</li>
</ul>
*/
###############################################################################
## mysqltest Language Reference
/**
@page PAGE_MYSQLTEST_LANGUAGE_REFERENCE mysqltest Language Reference
<h3>Table of Contents</h3>
- @subpage PAGE_MYSQL_TEST_INPUT_CONVENTIONS
- @subpage PAGE_MYSQL_TEST_COMMANDS
- @subpage PAGE_MYSQL_TEST_VARIABLES
- @subpage PAGE_MYSQL_TEST_FLOW_CONTROL
- @subpage PAGE_ERROR_HANDLING
This chapter describes the test language implemented by @ref
PAGE_MYSQLTEST "mysqltest". The language allows input to contain a
mix of comments, commands executed by @ref PAGE_MYSQLTEST
"mysqltest" itself, and SQL statements that @ref PAGE_MYSQLTEST
"mysqltest" sends to a MySQL server for execution.
Terminology notes:
------------------
<ul>
<li>
A “command” is an input test that @ref PAGE_MYSQLTEST
"mysqltest" recognizes and executes itself. A “statement” is
an SQL statement or query that @ref PAGE_MYSQLTEST "mysqltest"
sends to the MySQL server to be executed.
</li>
<li>
When @ref PAGE_MYSQLTEST "mysqltest" starts, it opens a
connection it calls <b>default</b> to the MySQL server, using
any connection parameters specified by the command options. (For
a local server, the default user name is <b>root</b>. For an
external server, the default user name is <b>test</b> or the
user specified with the <b>`--user`</b> option.) You can use
the <b>connect</b> command to open other connections, the
<b>connection</b> command to switch between connections, and
the <b>disconnect</b> command to close connections. However,
the capability for switching connections means that the
connection named <b>default</b> need not be the connection in
use at a given time. To avoid ambiguity, this document avoids
the term “default connection”. It uses the term “current
connection” to mean “the connection currently in use”, which
might be different from “the connection named <b>default</b>”.
</li>
</ul>
*/
###############################################################################
## mysqltest Input Conventions
/**
@page PAGE_MYSQL_TEST_INPUT_CONVENTIONS mysqltest Input Conventions
@ref PAGE_MYSQLTEST "mysqltest" reads input lines and processes
them as follows:
<ul>
<li>
“End of line” means a newline (linefeed) character. A carriage
return/linefeed (CRLF) pair also is allowable as as a line
terminator (the carriage return is ignored). Carriage return by
itself is not allowed as a line terminator.
</li>
<li>
A line that begins with "#" as the first nonwhitespace content
is treated as a comment that extends to the end of the line and
is ignored. Example:
@verbatim
# this is a comment
@endverbatim
</li>
<li>
Earlier versions would also allow comments beginning with “`--`”
unless the first word was a valid @ref PAGE_MYSQLTEST
"mysqltest" command, but this has been deprecated and is longer
allowed.
</li>
<li>
Other input is taken as normal command input. The command
extends to the next occurrence of the command delimiter, which
is semicolon (“<b>;</b>”) by default. The delimiter can be
changed with the <b>delimiter</b> command.
If @ref PAGE_MYSQLTEST "mysqltest" recognizes the first word of
the delimiter-terminated command, @ref PAGE_MYSQLTEST
"mysqltest" executes the command itself. Otherwise, @ref
PAGE_MYSQLTEST "mysqltest" assumes that the command is an SQL
statement and sends it to the MySQL server to be executed.
Because the command extends to the delimiter, a given input line
can contain multiple commands, and a given command can span
multiple lines. The ability to write multiple-line statements is
useful for making long statements more readable, such as a
<b>create table</b> statement for a table that has many
columns.
</li>
</ul>
After @ref PAGE_MYSQLTEST "mysqltest" reads a command up to a
delimiter and executes it, input reading restarts following the
delimiter and any remaining input on the line that contains the
delimiter is treated as though it begins on a new line. Consider the
following two input lines:
@verbatim
echo issue a select statement; select 1; echo done
issuing the select statement;
@endverbatim
That input contains two commands and one SQL statement:
@verbatim
echo issue a SELECT statement
SELECT 1;
echo done issuing the SELECT statement
@endverbatim
Similarly, "#" comments can begin on a command line following
a delimiter:
@verbatim
SELECT 'hello'; # select a string value
@endverbatim
On a multiple-line command, "#" or “`--`” at the beginning of the
second or following lines is not special. Thus, the second and third
lines of the following variable-assignment command are not taken as
comments. Instead, the variable <b>$a</b> is set to a value that
contains two linefeed characters:
@verbatim
let $a= This is a variable
# assignment that sets a variable
-- to a multiple-line value;
@endverbatim
`--` commands and normal commands have complementary properties with
regard to how @ref PAGE_MYSQLTEST "mysqltest" reads them:
- A “`--`” command is terminated by a newline, regardless of how
many delimiters it contains.
- A normal command (without “`--`”) is terminated by the delimiter
(semicolon), no matter how many newlines it contains.
@ref PAGE_MYSQLTEST "mysqltest" commands can be written either with
a leading “`--`”) or as normal command input (no leading “`--`”).
Use the command delimiter only in the latter case. Thus, these two
lines are equivalent:
@verbatim
--sleep 2
sleep 2;
@endverbatim
The equivalence is true even for the <b>delimiter</b> command. For
example, to set the delimiter to “<b>//</b>”, either of these
commands work:
@verbatim
--delimiter //
delimiter //;
@endverbatim
To set the delimiter back to “;”, use either of these commands:
@verbatim
--delimiter ;
delimiter ;//
@endverbatim
A potential ambiguity occurs because a command line can contain
either a @ref PAGE_MYSQLTEST "mysqltest" command or an SQL
statement. This has a couple of implications:
- No @ref PAGE_MYSQLTEST "mysqltest" command should be the same
as any keyword that can begin an SQL statement.
- Should extensions to SQL be implemented in the future, it is
possible that a new SQL keyword could be impossible for @ref
PAGE_MYSQLTEST "mysqltest" to recognize as such if that keyword
is already used as a @ref PAGE_MYSQLTEST "mysqltest" command.
Any ambiguity can be resolved by using the “`--`” syntax to force
interpetation as a @ref PAGE_MYSQLTEST "mysqltest" command, or the
<b>query</b> command to force interpretation as SQL.
All file paths used in test commands should use forward slash
\"<b>/</b>\" as the directory separator as in Unix. They will be
automatically converted when needed if the test is run on Windows.
We also recommend putting all temporary or auxiliary files made
during the test under the directory referred to by
<b>$MYSQL_TMP_DIR</b>. Do not put them under fixed full paths like
<b>/tmp</b>. This will help ensuring portability of the test, and
avoiding conflicts with other programs.
<b>$MYSQL_TMP_DIR</b> is equivalent to
<b>$MYSQLTEST_VARDIR/tmp</b> if you are not running with parallel
test threads, but if you run @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl" with <b>`--parallel`</b>, they will be different.
It is therefore best to be consistent and use <b>$MYSQL_TMP_DIR</b>.
Commands named <b>disable_X</b> or <b>enable_X</b>, except
<b>parsing</b>, <b>reconnect</b> and <b>rpl_parse</b>, can take an
optional modifier <b>ONCE</b>. If this is added, the relevant
setting is enabled or disabled only for the next command or
statement, after which it is reverted to whatever it was before.
Note that the word <b>ONCE</b> must be in upper case; this was
chosen in order to make it more visible when reading the test
script.
For example, <b>`--disable_query_log`</b> <b>ONCE</b> will
ensure query log is disabled for the next statement, but will not
affect whether or not query log is enabled for statements following
the next. It is possible to enable/disable more that one property
(e.g. both query log and result log) for a single statement using
the <b>ONCE</b> modifier.
*/
###############################################################################
## mysqltest Commands
/**
@page PAGE_MYSQL_TEST_COMMANDS mysqltest Commands
@ref PAGE_MYSQLTEST "mysqltest" supports the commands described in
this section. Command names are not case sensitive.
Some examples of command use are given, but you can find many more
by searching the test case files in the <b>mysql-test/t</b>
directory.
<ul>
<li>
<tt>append_file <b>file_name</b> [<b>terminator</b>]</tt>
<b>append_file</b> is like <b>write_file</b> except that the
lines up to the terminator are added to the end of the file.
The file is created if it does not exist. The file name argument
is subject to variable substitution.
@verbatim
write_file $MYSQL_TMP_DIR/data01;
line one for the file
line two for the file
EOF
append_file $MYSQL_TMP_DIR/data01;
line three for the file
EOF
@endverbatim
@verbatim
write_file $MYSQL_TMP_DIR/data02 END_OF_FILE;
line one for the file
line two for the file
END_OF_FILE
append_file $MYSQL_TMP_DIR/data02 END_OF_FILE;
line three for the file
END_OF_FILE
@endverbatim
</li>
<li>
<tt>assert (<b>expr</b>)</tt>
Assert that <b>expr</b> is true; otherwise terminate the test program
with an error message indicating that <b>expr</b> failed.
<b>expr</b> is parsed as it is for <tt>if()</tt> and <tt>while()</tt>,
as described at @ref PAGE_MYSQL_TEST_FLOW_CONTROL.
@verbatim
assert(1);
assert($x);
assert(!$x);
assert(`select count(*) from t1`);
@endverbatim
</li>
<li>
<tt>cat_file <b>file_name</b></tt>
<b>cat_file</b> writes the contents of the file to the output.
The file name argument is subject to variable substitution.
@verbatim
cat_file $MYSQL_TMP_DIR/data01;
@endverbatim
</li>
<li>
<tt>change_user [<b>user_name</b>], [<b>password</b>],
[<b>db_name</b>]</tt>
Changes the current user and causes the database specified by
<b><em>db_name</em></b> to become the default database for the
current connection.
@verbatim
change_user root;
--change_user root,,test
@endverbatim
</li>
<li>
<tt>character_set <b>charset_name</b></tt>
Set the default character set to <b><em>charset_name</em></b>.
Initially, the character set is latin1.
@verbatim
character_set utf8;
--character_set sjis
@endverbatim
</li>
<li>
<tt>chmod <b>octal_mode file_name</b></tt>
Change the mode of the given file. The file mode must be given as
a four-digit octal number. The file name argument is subject to
variable substitution, but must evaluate to a literal file name,
not a file name pattern.
@verbatim
chmod 0644 $MYSQL_TMP_DIR/data_xxx01;
@endverbatim
</li>
<li>
<tt>connect (<b>name</b>, <b>host_name</b>,
<b>user_name</b>, <b>password</b>, <b>db_name</b>
[,<b>port_num</b> [,<b>socket</b> [,<b>options</b>
[,<b>default_auth</b> [,<b>compression algorithm</b>,
[,<b>compression level</b>]]]]]])</tt>
Open a connection to the server and make the connection the
current connection.
The arguments to <b>connect</b> are:
<ul>
<li>
<b><em>name</em></b> is the name for the connection (for use
with the <b>connection</b>, <b>disconnect</b>, and
<b>dirty_close</b> commands). This name must not already be
in use by an open connection.
</li>
<li>
<b><em>host_name</em></b> indicates the host where the
server is running.
</li>
<li>
<b><em>user_name</em></b> and <b><em>password</em></b> are
the user name and password of the MySQL account to use.
</li>
<li>
<b><em>db_name</em></b> is the default database to use. As a
special case, *<b>NO-ONE</b>* means that no default database
should be selected. You can also leave
<b><em>db_name</em></b> blank to select no database.
</li>
<li>
<b><em>port_num</em></b>, if given, is the TCP/IP port
number to use for the connection. This parameter can be
given by using a variable.
</li>
<li>
<b><em>socket</em></b>, if given, is the socket file to use
for connections to <b>localhost</b>. This parameter can be
given by using a variable.
</li>
<li>
<b><em>options</em></b> can be one or more of the following
words, separated by spaces:
<ul>
<li>
<tt>CLEARTEXT</tt>: Enable use of the cleartext authentication
plugin.
</li>
<li>
<tt>COMPRESS</tt>: Use the compressed client/server protocol,
if available.
</li>
<li>
<tt>PIPE</tt>: Use the named-pipe connection protocol, if
available.
</li>
<li>
<tt>SHM</tt>: Use the shared-memory connection protocol, if
available.
</li>
<li>
<tt>SOCKET</tt>: Use the socket-file connection protocol.
</li>
<li>
<tt>SSL</tt>:Use SSL network protocol to have encrypted connection.
</li>
<li>
<tt>TCP</tt>: Use the TCP/IP connection protocol.
</li>
</ul>
Passing <b>PIPE</b> or <b>SHM</b> on non-Windows systems
causes an error, and, similarly, passing <b>SOCKET</b> on
Windows systems causes an error.
</li>
<li>
<b><em>default_auth</em></b> is the name of an
authentication plugin. It is passed to the
<b>mysql_options()</b> C API function using the
<b>MYSQL_DEFAULT_AUTH</b> option. If @ref PAGE_MYSQLTEST
"mysqltest" does not find the plugin, use the
<b>--plugin-dir</b> option to specify the directory where
the plugin is located.
</li>
<li>
<b><em>compression algorithm</em></b> is the name of compression
algorithm to be used to compress data transferred between client
server. It is passed to the <b>mysql_options()</b> C API function
using the <b>MYSQL_OPT_COMPRESSION_ALGORITHMS</b> option.
</li>
<li>
<b><em>zstd compression level</em></b> is the extent of compression
to be applied when zstd compression algorithm is used. It is passed to
the <b>mysql_options()</b> C API function using the
<b>MYSQL_OPT_COMPRESSION_ALGORITHMS</b> option.
</li>
<li>
<b><em>compression level</em></b> is the extent of compression to
be applied based on the compression algorithm used. It is passed to
the <b>mysql_options()</b> C API function using the
<b>MYSQL_OPT_COMPRESSION_ALGORITHMS</b> option.
</li>
</ul>
To omit an argument, just leave it blank. For an omitted
argument, @ref PAGE_MYSQLTEST "mysqltest" uses an empty string
for the first five arguments and the <b><em>options</em></b>
argument. For omitted port or socket options, @ref
PAGE_MYSQLTEST "mysqltest" uses the default port or socket.
@verbatim
connect (conn1,localhost,root,,);
connect (conn2,localhost,root,mypass,test);
connect (conn1,127.0.0.1,root,,test,$MASTER_MYPORT);
@endverbatim
The last example assumes that the <b>$MASTER_MYPORT</b> variable
has already been set (perhaps as an environment variable).
If a connection attempt fails initially, @ref PAGE_MYSQLTEST
"mysqltest" retries five times if the abort-on-error setting is
enabled.
</li>
<li>
<tt>connection <b>connection_name</b></tt>
Select <b><em>connection_name</em></b> as the current
connection. To select the connection that @ref PAGE_MYSQLTEST
"mysqltest" opens when it starts, use the name default.
@verbatim
connection master;
connection conn2;
connection default;
@endverbatim
A variable can be used to specify the
<b><em>connection_name</em></b> value.
</li>
<li>
<tt>let $var= convert_error(<b>error</b>)</tt>
This is not a command as such but rather a function that can be
used in <b>let</b> statements. If the argument is a number, it
returns the name of the corresponding error, or <b>\<Unknown\></b>
if no such error exists. If the argument is an error name, it
returns the corresponding number, or fails if the error name is
unknown. If the argument is 0 or an empty string, it returns 0.
The function can also take a variable as argument.
@verbatim
let $errvar1=convert_error(ER_UNKNOWN_ERROR);
let $errvar2=convert_error(1450);
let $errvar3=convert_error($errvar1);
@endverbatim
</li>
<li>
<tt>copy_file <b>from_file to_file</b> [<b>retry</b>]</tt>
Copy the file <b><em>from_file</em></b> to the file
<b><em>to_file</em></b>. The command fails if
<b><em>to_file</em></b> already exists. The file name arguments
are subject to variable substitution.
<b>copy_file</b> can also take an optional argument <b>retry</b>.
If the command fails due to an environmental issue, the command
can be retried for a <b>retry</b> number of times. Each retry
happens after an interval of one second.
@verbatim
copy_file $MYSQL_TMP_DIR/copy1.txt $MYSQL_TMP_DIR/copy2.txt;
copy_file $MYSQL_TMP_DIR/foo.txt $MYSQL_TMP_DIR/foo2.txt 5;
@endverbatim
</li>
<li>
<tt>copy_files_wildcard <b>src_dir_name dst_dir_name</b>
<b>pattern</b> [<b>retry</b>]</tt>
Copy all files that match the pattern in the source directory to
the destination directory. Patterns can use <b>?</b> to
represent any single character, or <b>*</b> for any sequence of
0 or more characters. The <b>.</b> character is treated like any
other. The pattern may not include <b>/</b>. If all the files
need to be copied, the <b>*</b> wildcard can be used.
<b>copy_files_wildcard</b> can also take an optional argument
<b>retry</b>. If the command fails due to an environmental
issue, the command can be retried for a <b>retry</b> number
of times. Each retry happens after an interval of one second.
The command works like this:
<ul>
<li>
Files that match the pattern are copied from the source
directory to the destination directory. Overwriting of files
is permitted.
</li>
<li>
Copying does not apply to directories matching the pattern
or matching files in subdirectories.
</li>
<li>
If the source or destination directory is not present, an
error occurs.
</li>
<li>
If no files match the specified pattern, an error occurs.
</li>
<li>
If the source directory has no files, an error occurs.
</li>
</ul>
@verbatim
copy_files_wildcard $MYSQLTEST_VARDIR/std_data/ $MYSQLTEST_VARDIR/copy1/ *.txt;
copy_files_wildcard $MYSQLTEST_VARDIR/std_data/ $MYSQLTEST_VARDIR/copy1/ *.txt 5;
@endverbatim
</li>
<li>
<tt>dec <b>$var_name</b></tt>
Decrement a numeric variable. If the variable does not have a
numeric value, the result is undefined.
@verbatim
dec $count;
dec $2;
@endverbatim
</li>
<li>
<tt>delimiter <b>str</b></tt>
Set the command delimiter to <b><em>str</em></b>, which may consist
of 1 to 15 characters. The default delimiter is the semicolon
character (“<b>;</b>”).
@verbatim
delimiter /;
--delimiter stop
@endverbatim
This is useful or needed when you want to include long SQL
statements like <b>CREATE PROCEDURE</b> which include semicolon
delimited statements but need to be interpreted as a single
statement by @ref PAGE_MYSQLTEST "mysqltest". If you have set
the delimiter to “<b>/</b>” as in the previous example, you can
set it back to the default like this:
@verbatim
delimiter ;|
@endverbatim
</li>
<li>
<tt>die [<b>message</b>]</tt>
Aborts the test with an error code after printing the given
message as the reason. Suppose that a test file contains the
following line:
@verbatim
die Cannot continue;
@endverbatim
When @ref PAGE_MYSQLTEST "mysqltest" encounters that line, it
produces the following result and exits:
@verbatim
mysqltest: At line 1: Cannot continue
not ok
@endverbatim
</li>
<li>
<tt>diff_files <b>file_name1 file_name2</b></tt>
Compare the two files. The command succeeds if the files are the
same, and fails if they are different or either file does not
exist. The file name arguments are subject to variable
substitution.
</li>
<li>
<tt>dirty_close <b>connection_name</b></tt>
Close the named connection. This is like <b>disconnect</b>
except that it calls <b>vio_delete()</b> before it closes the
connection. If the connection is the current connection, you
should use the <b>connection</b> command to switch to a
different connection before executing further SQL statements.
A variable can be used to specify the
<b><em>connection_name</em></b> value.
</li>
<li>
<tt>disable_abort_on_error</tt>, <tt>enable_abort_on_error</tt>
Disable or enable abort-on-error behavior. This setting is
enabled by default. With this setting enabled, @ref
PAGE_MYSQLTEST "mysqltest" aborts the test when a statement sent
to the server results in an unexpected error, and does not
generate the <b>.reject</b> file. For discussion of reasons why
it can be useful to disable this behavior, see @ref
PAGE_ERROR_HANDLING.
@verbatim
--disable_abort_on_error
--enable_abort_on_error
@endverbatim
</li>
<li>
<tt>disable_async_client</tt>, <tt>enable_async_client</tt>
Disable or enable asynchronous communication between the client and
the server. With this setting enabled, @ref PAGE_MYSQLTEST "mysqltest"
uses non-blocking C API's to communicate with the server.<br> Please
note that <b>disable_async_client</b> disables asynchronous
communication if it had been enabled either by the
<b>--enable_async_client</b> command or the <b>--async-client</b>
command line option.
@verbatim
--disable_async_client
--enable_async_client
@endverbatim
</li>
<li>
<tt>disable_connect_log</tt>, <tt>enable_connect_log</tt>
Disable or enable logging of creation or switch of connections.
Connection logging is disabled by default. With this setting
enabled, @ref PAGE_MYSQLTEST "mysqltest" enters lines in the
test results to show when connections are created, switched or
disconnected.
If query logging is turned off using <b>disable_query_log</b>,
connection logging is also turned off, until query log is re-
enabled.
@verbatim
--disable_connect_log
--enable_connect_log
@endverbatim
</li>
<li>
<tt>disable_info</tt>, <tt>enable_info</tt>
Disable or enable additional information about SQL statement
results. Information display is disabled by default. With this
setting enabled, @ref PAGE_MYSQLTEST "mysqltest" displays the
affected-rows count and the output from the <b>mysql_info()</b>
C API function. The “affected-rows” value is “rows selected” for
statements such as <b>SELECT</b> and “rows modified” for
statements that change data.
@verbatim
--disable_info
--enable_info
@endverbatim
</li>
<li>
<tt>disable_metadata</tt>, <tt>enable_metadata</tt>
Disable or enable query metadata display. Metadata display is
disabled by default. With this setting enabled, @ref
PAGE_MYSQLTEST "mysqltest" adds query metadata to the result.
This information consists of the values corresponding to the
members of the <b>MYSQL_FIELD</b> C API data structure, for each
column of the result.
@verbatim
--disable_metadata
--enable_metadata
@endverbatim
</li>
<li>
<tt>disable_ps_protocol</tt>, <tt>enable_ps_protocol</tt>
Disable or enable prepared-statement protocol. This setting is
disabled by default unless the <b>`--ps-protocol`</b> option is
given.
@verbatim
--disable_ps_protocol
--enable_ps_protocol
@endverbatim
</li>
<li>
<tt>disable_query_log</tt>, <tt>enable_query_log</tt>
Disable or enable query logging. This setting is enabled by
default. With this setting enabled, @ref PAGE_MYSQLTEST
"mysqltest" echoes input SQL statements to the test result.
One reason to disable query logging is to reduce the amount of
test output produced, which also makes comparison of actual and
expected results more efficient.
@verbatim
--disable_query_log
--enable_query_log
@endverbatim
</li>
<li>
<tt>disable_reconnect</tt>, <tt>enable_reconnect</tt>
Disable or enable automatic reconnect for dropped connections.
(The default depends on the client library version.) This
command only applies to the current connection.
@verbatim
--disable_reconnect
--enable_reconnect
@endverbatim
</li>
<li>
<tt>disable_result_log</tt>, <tt>enable_result_log</tt>
Disable or enable the result log. This setting is enabled by
default. With this setting enabled, @ref PAGE_MYSQLTEST
"mysqltest" displays query results (and results from commands
such as <b>echo</b> and <b>exec</b>).
@verbatim
--disable_result_log
--enable_result_log
@endverbatim
</li>
<li>
<tt>disable_rpl_parse</tt>, <tt>enable_rpl_parse</tt>
Disable or enable parsing of statements to determine whether
they go to the master or slave. The default is whatever the
default is for the C API library.
@verbatim
--disable_rpl_parse
--enable_rpl_parse
@endverbatim
</li>
<li>
<tt>disable_session_track_info</tt>, <tt>enable_session_track_info</tt>
Disable or enable display of session tracking information.
Session-tracking display disabled by default.
@verbatim
--disable_session_track_info
--enable_session_track_info
@endverbatim
</li>
<li>
<tt>disable_testcase bug_number</tt>, <tt>enable_testcase</tt>
Disable or enable a section from a test case. This setting is
enabled by default. When disabled, @ref PAGE_MYSQLTEST
"mysqltest" ignores everything until <b>enable_testcase</b>.
These commands are useful for disabling a section inside a
<b>.test</b> file that fails due to a known bug, without having
to disable the entire test case.
Bug number is a mandatory argument to <b>disable_testcase</b>
command and it should be in <b>BUG\#XXXX</b> format where keyword
<b>BUG</b> is case-insensitive and <b>XXXX</b> should contain
only digits.
@verbatim
--disable_testcase BUG#XXXX
--enable_testcase
@endverbatim
</li>
<li>
<tt>disable_warnings</tt>, <tt>enable_warnings</tt>
Disable or enable warnings. This setting is enabled by default.
With this setting enabled, @ref PAGE_MYSQLTEST "mysqltest" uses
<b>SHOW WARNINGS</b> to display any warnings produced by SQL
statements.
@verbatim
--disable_warnings
--enable_warnings
@endverbatim
<b>disable_warnings</b> and <b>enable_warnings</b> commands can
take an optional argument specifying one or more comma-separated
list of warnings to be disabled or enabled. Each warning
specified should be in symbolic error name format.
@verbatim
--disable_warnings ER_BAD_TABLE_ERROR,ER_YES
DROP TABLE IF EXISTS t1;
--enable_warnings ER_BAD_TABLE_ERROR,ER_YES
@endverbatim
Or
@verbatim
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings ER_BAD_TABLE_ERROR,ER_YES
DROP TABLE IF EXISTS t1;
--disable_warnings ER_BAD_TABLE_ERROR,ER_YES
--enable_warnings
@endverbatim
<b>disable_warnings</b> and <b>enable_warnings</b> commands can
also take a second optional argument, <b>"ONCE"</b>, which when
specified will disable or enable the warnings for next
statement only.
@verbatim
--disable_warnings ER_BAD_TABLE_ERROR ONCE
DROP TABLE IF EXISTS t1;
@endverbatim
Or
@verbatim
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings ER_BAD_TABLE_ERROR ONCE
DROP TABLE IF EXISTS t1;
--enable_warnings
@endverbatim
</li>
@note
At the end of a test, all the disabled warnings must be enabled,
else @ref PAGE_MYSQLTEST "mysqltest" will throw an error and
abort the test run.
<li>
<tt>disconnect <b>connection_name</b></tt>
Close the named connection. If the connection is the current
connection, you should use the <b>connection</b> command to
switch to a different connection before executing further SQL
statements.
@verbatim
disconnect conn2;
disconnect slave;
@endverbatim
</li>
<li>
<tt>echo <b>text</b></tt>
Echo the text to the test result. References to variables within
the text are replaced with the corresponding values. The text
does not need to be enclosed in quotation marks; if it is, the
quotation marks will be included in the output.
@verbatim
--echo Another sql_mode test
echo should return only 1 row;
@endverbatim
</li>
<li>
<tt>end</tt>
End an <b>if</b> or <b>while</b> block. If there is no such
block open, @ref PAGE_MYSQLTEST "mysqltest" exits with an error.
See @ref PAGE_MYSQL_TEST_FLOW_CONTROL, for information on
flow-control constructs.
@ref PAGE_MYSQLTEST "mysqltest" considers <b>}</b> and end the
same: Both end the current block.
</li>
<li>
<tt>end_timer</tt>
Stop the timer. By default, the timer does not stop until just
before @ref PAGE_MYSQLTEST "mysqltest" exits.
</li>
<li>
<tt>error <b>error_code</b> [, <b>error_code</b>] ...</tt>
Specify one or more comma-separated error values that the next
command is expected to return. Each <b><em>error_code</em></b>
value is a MySQL-specific error number or an <b>SQLSTATE</b>
value. (These are the kinds of values returned by the
<b>mysql_errno()</b> and <b>mysql_sqlstate()</b> C API
functions, respectively.)
If you specify an <b>SQLSTATE</b> value, it should begin with an
<b>S</b> to enable @ref PAGE_MYSQLTEST "mysqltest" to
distinguish it from a MySQL error number. For example, the error
number 1050 and the SQLSTATE value <b>42S01</b> are equivalent,
so the following commands specify the same expected error:
@verbatim
--error 1050
--error S42S01
@endverbatim
<b>SQLSTATE</b> values should be five characters long and may
contain only digits and uppercase letters.
It is also possible to use the symbolic error name from
<b>mysqld_error.h</b>:
@verbatim
--error ER_TABLE_EXISTS_ERROR
@endverbatim
It is also possible to use symbolic error names from
<b>errmsg.h</b> to refer to client errors:
@verbatim
--error CR_SERVER_GONE_ERROR
@endverbatim
Finally, you can assign either a numerical code or a symbolic
error name to a variable and refer to that in the <b>error</b>
command. Numbers, symbolic names and variables may be freely
mixed.
If a statement fails with an error that has not been specified
as expected by means of a <b>error</b> command, @ref
PAGE_MYSQLTEST "mysqltest" aborts and reports the error message
returned by the MySQL server.
If a statement fails with an error that has been specified as
expected by means of a <b>error</b> command, @ref PAGE_MYSQLTEST
"mysqltest" does not abort. Instead, it continues and writes a
message to the result output.
<ul>
<li>
If an <b>error</b> command is given with a single error
value and the statement fails with that error, @ref
PAGE_MYSQLTEST "mysqltest" reports the error message
returned by the MySQL server.
Input:
@verbatim
--error S42S02
DROP TABLE t;
@endverbatim
@ref PAGE_MYSQLTEST "mysqltest" reports:
@verbatim
ERROR 42S02: Unknown table 't'
@endverbatim
</li>
<li>
If an <b>error</b> command is given with multiple error
values and the statement fails with any of those errors,
@ref PAGE_MYSQLTEST "mysqltest" reports a generic message.
(This is true even if the error values are all the same, a
fact that can be used if you want a message that does not
contain varying information such as table names.)
Input:
@verbatim
--error S41S01,S42S02
DROP TABLE t;
@endverbatim
@ref PAGE_MYSQLTEST "mysqltest" reports:
@verbatim
Got one of the listed errors
@endverbatim
</li>
</ul>
An error value of <b>0</b> or <b>S00000</b> means “no error,”
so using either for an <b>error</b> command is the same as saying
explicitly, “no error is expected, the statement must succeed.”.
To indicate that you expect success or a given error or errors,
specify <b>0</b> or <b>S00000</b> first in the error list. If
you put the no-error value later in the list, the test will abort
if the statement is successful. That is, the following two commands
have different effects: The second form literally means the next
command may fail with error code 0, (rather than succeed) which
in practice never happens:
@verbatim
--error 0,1051
--error 1051,0
@endverbatim
You can use <b>error</b> to specify shell status values for
testing the value of shell commands executed using the
<b>exec</b> command. This does not apply to <b>system</b>, for
which the command status is ignored.
If you use <b>error</b> in combination with <b>send</b> and
<b>reap</b>, the <b>error</b> should be used just before the
<b>reap</b>, as this is the command that actually gives the
result and the potential error.
Variables may also be used as arguments to the <b>error</b>
command; these may contain a number (including 0), an SQLSTATE
or a symbolic error name. Variables and constant values may be
freely combined.
</li>
<li>
<tt>eval <b>statement</b></tt>
Evaluate the statement by replacing references to variables
within the text with the corresponding values. Then send the
resulting statement to the server to be executed. Use
“<b>\$</b>” to specify a literal “<b>$</b>” character.
The advantage of using <b>eval <em>statement</em></b> versus just
<b><em>statement</em></b> is that <b>eval</b> provides variable
expansion.
@verbatim
eval USE $DB;
eval CHANGE MASTER TO MASTER_PORT=$SLAVE_MYPORT;
eval PREPARE STMT1 FROM "$my_stmt";
@endverbatim
</li>
<li>
<tt>exec <b>command</b> [<b>arg</b>] ...</tt>
Execute the shell command using the <b>popen()</b> library call.
References to variables within the command are replaced with the
corresponding values. Use “<b>\\$</b>” to specify a literal
“<b>$</b>” character.
On Cygwin, the command is executed from <b>cmd.exe</b>, so
commands such as <b>rm</b> cannot be executed with <b>exec</b>.
Use <b>system</b> instead.
@verbatim
--exec $MYSQL_DUMP --xml --skip-create test
--exec rm $MYSQLTEST_VARDIR/tmp/t1
exec $MYSQL_SHOW test -v -v;
@endverbatim
@note
<b>exec</b> or <b>system</b> are sometimes used to perform
file system operations, but the command for doing so tend to be
operating system specific, which reduces test portability. @ref
PAGE_MYSQLTEST "mysqltest" now has several commands to perform
these operations portably, so they should be used instead:
<b>remove_file</b>, <b>chmod</b>, <b>mkdir</b>, and so forth.
</li>
<li>
<tt>exec_in_background <b>command</b> [<b>arg</b>] ...</tt>
Execute a shell command using the <b>popen()</b> library call in
the background. When a command is executed using
<b>exec_in_background</b>, @ref PAGE_MYSQLTEST "mysqltest" does
not wait for it to finish, nor attempt to read the output of it.
@verbatim
--exec_in_background $MYSQL_DUMP --xml --skip-create test
--exec_in_background rm $MYSQLTEST_VARDIR/tmp/t1
@endverbatim
</li>
<li>
<tt>execw <b>command</b> [<b>arg</b>] ...</tt>
This is a variant of the <b>exec</b> command which is needed on
Windows if the command line contains non-ASCII characters.
Otherwise it works exactly the same. On platforms other than
Windows there is no difference, but on Windows it uses a
different version of the <b>popen()</b> library call. So if your
command line contains non-ASCII characters, it is recommended to
use <b>execw</b> instead of <b>exec</b>.
</li>
<li>
<tt>exit</tt>
Terminate the test case. This is considered a “normal
termination.” That is, using <b>exit</b> does not result in
evaluation of the test case as having failed. It is not
necessary to use <b>exit</b> at the end of a test case, as the
test case will terminate normally when reaching the end without
failure.
</li>
<li>
<tt>expr <b>$var_name</b>= <b>operand1 operator operand2</b></tt>
Evaluate an expression and assign the result to a variable. The
result is also the return value of the expr command itself.
@verbatim
--let $val1= 10
--let $var2= 20
--expr $res= $var1 + $var2
--echo $res
@endverbatim
<b>operand1</b> and <b>operand2</b> must be valid variables.
expr supports these mathematical operators:
@verbatim
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo
@endverbatim
expr supports these logical operators:
@verbatim
&& Logical AND
|| Logical OR
@endverbatim
expr supports these bitwise operators:
@verbatim
& Binary AND
| Binary OR
^ Binary XOR
<< Binary left shift
>> Binary right shift
@endverbatim
Operations are subject to these conditions:
- Operations that do not support noninteger operands truncate
such operands to integer values.
- If the result is an infinite value, expr returns the inf
keyword.
- Division by 0 results in an infinite value.
</li>
<li>
<tt>file_exists <b>file_name</b> [<b>retry</b>]</tt>
<b>file_exists</b> succeeds if the named file exists and fails
otherwise. The file name argument is subject to variable
substitution.
<b>file_exists</b> can also take an optional argument
<b>retry</b>. If the command fails due to an environmental
issue, the command can be retried for a <b>retry</b> number
of times. Each retry happens after an interval of one second.
@verbatim
file_exists /etc/passwd;
file_exists /etc/passwd 5;
@endverbatim
</li>
<li>
<tt>force-cpdir <b>src_dir_name dst_dir_name</b></tt>
Copies the source directory, <b><em>src_dir_name</em></b>, to
the destination directory, <b><em>dst_dir_name</em></b>. The
copy operation is recursive, so it copies subdirectories.
Returns 0 for success and 1 for failure.
@verbatim
--force-cpdir testdir testdir2
@endverbatim
If the source directory does not exist, an error occurs.
If the destination directory does not exist, @ref PAGE_MYSQLTEST
"mysqltest" creates it before copying the source directory.
</li>
<li>
<tt>force-rmdir <b>dir_name</b></tt>
Remove a directory named <b><em>dir_name</em></b>. Returns 0 for
success and 1 for failure.
@verbatim
--force-rmdir testdir
@endverbatim
<b>force-rmdir</b> removes the directory as well as its
contents, if any, unlike <b>rmdir</b>, which fails if the
directory to be removed contains any files or directories.
</li>
<li>
<tt>horizontal_results</tt>
Set the default query result display format to horizontal.
Initially, the default is to display results horizontally.
@verbatim
--horizontal_results
@endverbatim
</li>
<li>
<tt>if (<b>expr</b>)</tt>
Begin an if block, which continues until an <b>end</b> or
<b>}</b> line. @ref PAGE_MYSQLTEST "mysqltest" executes the
block if the expression is non-zero. There is no provision for
<b>else</b> with <b>if</b>. See @ref
PAGE_MYSQL_TEST_FLOW_CONTROL, for further information about
<b>if</b> statements.
@verbatim
let $counter= 0;
if ($counter)
{
echo Counter is not 0;
}
if (!$counter)
{
echo Counter is 0;
}
@endverbatim
</li>
<li>
<tt>inc <b>$var_name</b></tt>
Increment a numeric variable. If the variable does not have a
numeric value, the result is undefined.
@verbatim
--inc $i;
inc $3;
@endverbatim
</li>
<li>
<tt>let <b>$var_name</b> = <b>value</b></tt>
<tt>let <b>$var_name</b> = query_get_value(<b>query</b>,
<b>col_name</b>,
<b>row_num</b>)</tt>
Assign a value to a variable. The variable name cannot contain
whitespace or the “<b>=</b>” character. Except for the one-digit
<b>$0</b> to <b>$9</b>, it cannot begin with a number. @ref
PAGE_MYSQLTEST "mysqltest" aborts with an error if the value is
erroneous.
References to variables within <b><em>value</em></b> are replaced
with their corresponding values.
If the <b>let</b> command is specified as a normal command (that
is, not beginning with “<b>--</b>”), <b><em>value</em></b>
includes everything up to the command delimiter, and thus can
span multiple lines.
@verbatim
--let $1= 0
let $count= 10;
@endverbatim
When assigning a literal string to a variable, no quoting is
required even if the string contains spaces. If the string does
include quotation marks, they will be trated like any other
characters and be included in the string value. This is
important to be aware of when using the variable in an SQL
statement.
The result from executing a query can be assigned to a variable
by enclosing the query within backtick (“`”) characters:
@verbatim
let $q= `SELECT VERSION()`;
@endverbatim
The <b>let</b> command can set environment variables, not just
@ref PAGE_MYSQLTEST "mysqltest" test language variables. To
assign a value to an environment variable rather than a test
language variable, just omit the dollar sign:
@verbatim
let $mysqltest_variable= foo;
let ENV_VARIABLE= bar;
@endverbatim
This is useful in interaction with external tools. In
particular, when using the <b>perl</b> command, the Perl code
cannot access test language variables, but it can access
environment variables. For example, the following statement can
access the <b>ENV_VARIABLE</b> value:
@verbatim
print $ENV{'ENV_VARIABLE'};
@endverbatim
The <b>let</b> syntax also allows the retrieval of a value from
a query result set produced by a statement such as <b>SELECT</b>
or <b>SHOW</b>. See the description of <b>query_get_value()</b>
for more information.
</li>
<li>
<tt>mkdir <b>dir_name</b></tt>
Create a directory named <b><em>dir_name</em></b>. Returns 0 for
success and 1 for failure.
@verbatim
--mkdir testdir
@endverbatim
</li>
<li>
<tt>list_files <b>dir_name</b> [<b>pattern</b>]</tt>
<b>list_files</b> lists the files in the named directory. If a
pattern is given, lists only file(s) matching the pattern, which
may contain wild cards.
@verbatim
--list_files $MYSQLD_DATADIR/test t1*
@endverbatim
</li>
<li>
<tt>list_files_append_file <b>file_name dir_name</b>
[<b>pattern</b>]</tt>
<b>list_files_append_file</b> works like <b>list_files</b>,
but rather than outputting the file list, it is appended to the
file named in the first argument. If the file does not exist, it
is created.
@verbatim
--list_files_append_file $MYSQL_TMP_DIR/filelist $MYSQL_TMP_DIR/testdir *.txt;
@endverbatim
</li>
<li>
<tt>list_files_write_file <b>file_name dir_name</b>
[<b>pattern</b>]</tt>
<b>list_files_write_file</b> works like
<b>list_files_append_file</b>, but creates a new file to write
the file list to. If the file already exists, it will be
replaced.
@verbatim
--list_files_write_file $MYSQL_TMP_DIR/filelist $MYSQL_TMP_DIR/testdir *.txt;
@endverbatim
</li>
<li>
<tt>lowercase_result</tt>
Output from the following SQL statement will be converted to
lowercase. This is sometimes needed to ensure consistent result
across different platforms. If this is combined with one of the
<b>replace</b> commands or with <b>sorted_result</b>, both will
take effect on the output, with conversion to lowercase being
applied first.
@verbatim
--lowercase_result
@endverbatim
</li>
<li>
<tt>move_file <b>from_name to_name</b> [<b>retry</b>]</tt>
<b>move_file</b> renames <b><em>from_name</em></b> to
<b><em>to_name</em></b>. The file name arguments are subject to
variable substitution, but must evaluate to a literal file name,
not a file name pattern.
<b>move_file</b> can also take an optional argument <b>retry</b>.
If the command fails due to an environmental issue, the command
can be retried for a <b>retry</b> number of times. Each retry
happens after an interval of one second.
@verbatim
move_file $MYSQL_TMP_DIR/data01 $MYSQL_TMP_DIR/test.out;
move_file $MYSQL_TMP_DIR/data01 $MYSQL_TMP_DIR/test.out 5;
@endverbatim
</li>
<li>
<tt>output <b>file_name</b></tt>
Direct output from the next SQL statement to the named file
rather than to the test output. If the file already exists, it
will be overwritten. Only the next SQL statement will have its
output redirected.
@verbatim
output $MYSQL_TMP_DIR/out-file
@endverbatim
</li>
<li>
<tt>perl [<b>terminator</b>]</tt>
Use Perl to execute the following lines of the test file. The
lines end when a line containing the terminator is encountered.
The default terminator is <b>EOF</b>, but a different terminator
can be provided.
@verbatim
perl;
print "This is a test\n";
EOF
@endverbatim
@verbatim
perl END_OF_FILE;
print "This is another test\n";
END_OF_FILE
@endverbatim
</li>
<li>
<tt>ping</tt>
Ping the server. This executes the <b>mysql_ping()</b> C API
function. The function result is discarded. The effect is that
if the connection has dropped and reconnect is enabled, pinging
the server causes a reconnect.
</li>
<li>
<tt>query [<b>statement</b>]</tt>
Send the statement to the server to be executed. The
<b>query</b> command can be used to force @ref PAGE_MYSQLTEST
"mysqltest" to send a statement to the server even if it begins
with a keyword that is a @ref PAGE_MYSQLTEST "mysqltest"
command.
</li>
<li>
<tt>query_get_value(<b>query</b>, <b>col_name</b>, <b>row_num</b>)</tt>
The <b>query_get_value()</b> function can be used only on the
right hand side of a variable assigment in a <b>let</b>
statement.
<b>query_get_value()</b> enables retrieval of a value from a
query result set produced by a statement such as <b>SELECT</b>
or <b>SHOW</b>. The first argument indicates the query to
execute. The second and third arguments indicate the column name
and row number that specify which value to extract from the
result set. The column name is case sensitive. Row numbers begin
with 1. The arguments can be given literally or supplied using
variables.
Suppose that the test file contains this input:
@verbatim
CREATE TABLE t1(a INT, b VARCHAR(255), c DATETIME);
SHOW COLUMNS FROM t1;
let $value= query_get_value(SHOW COLUMNS FROM t1, Type, 1);
echo $value;
@endverbatim
The result will be:
@verbatim
CREATE TABLE t1(a INT, b VARCHAR(255), c DATETIME);
SHOW COLUMNS FROM t1;
Field Type Null Key Default Extra
a int(11) YES NULL
b varchar(255) YES NULL
c datetime YES NULL
int(11)
@endverbatim
If the query fails, an error message occurs and the test fails.
</li>
<li>
<tt>query_horizontal <b>statement</b></tt>
Execute the statement and display its result horizontally.
@verbatim
query_horizontal SELECT PI();
@endverbatim
</li>
<li>
<tt>query_vertical <b>statement</b></tt>
Execute the statement and display its result vertically.
@verbatim
query_vertical SELECT PI();
@endverbatim
</li>
<li>
<tt>--let <b>$var</b> = escape(<b>characters</b>,<b>string</b>)</tt>
Insert a backslash character before every character in
<b>string</b> that occurs in <b>characters</b>, and assign the
result to <b>$var</b>.
<b>characters</b> must not contain newline. If it contains a
comma, it must be the first character. All whitespace is
significant and preserved in both arguments, so you typically
want to omit the space after the comma for this command.
This can be useful when you need to include <b>string</b> in an
SQL string in a query, and <b>string</b> may contain quote
characters.
@verbatim
--let <b>$var</b> = escape(\',The 'path separator' in Windows is \.)
--echo $var
# Prints: The \'path separator\' in Windows is \\.
@endverbatim
</li>
<li>
<tt>reap</tt>
Receive the result of the statement sent with the <b>send</b>
command within the current session. You should not use
<b>reap</b> unless a statement has been sent with <b>send</b>,
and you should not use <b>send</b> again if there is an
outstanding <b>send</b> that has not been processed with
<b>reap</b>.
</li>
<li>
<tt>remove_file <b>file_name</b> [<b>retry</b>]</tt>
<b>remove_file</b> removes the file. It fails with an error if
the file does not exist. The file name argument is subject to
variable substitution, but must evaluate to a literal file name,
not a file name pattern.
<b>remove_file</b> also takes an optional argument <b>retry</b>.
If the command fails due to an environmental issue, the command
can be retried for a <b>retry</b> number of times. Each retry
happens after an interval of one second.
@verbatim
remove_file $MYSQL_TMP_DIR/data01;
remove_file $MYSQL_TMP_DIR/data01 5
@endverbatim
</li>
<li>
<tt>remove_files_wildcard <b>dir_name</b> <b>pattern</b> [<b>retry</b>]</tt>
Remove all files in the named directory that match the pattern.
Removal does not apply to directories matching the pattern or
matching files in subdirectories. Patterns can use <b>?</b> to
represent any single character, or <b>*</b> for any sequence of
0 or more characters. The <b>.</b> character is treated like any
other. The pattern may not include <b>/</b>. If all the files
need to be removed, the <b>*</b> wildcard can be used.
<b>remove_files_wildcard</b> can also take an optional argument
<b>retry</b>. If the command fails due to an environmental
issue, the command can be retried for a <b>retry</b> number of
times. Each retry happens after an interval of one second.
@verbatim
remove_files_wildcard $MYSQL_TMP_DIR file*.txt;
remove_files_wildcard $MYSQL_TMP_DIR file*.txt 5;
@endverbatim
</li>
<li>
<tt>replace_column <b>col_num</b> <b>value</b>
[<b>col_num value</b>] ...</tt>
Replace strings in the output from the next statement. The value
in <b><em>col_num</em></b> is replaced by the corresponding
<b><em>value</em></b>. There can be more than one
<b><em>col_num/value</em></b> pair. Column numbers start with 1.
A replacement value can be double-quoted. (Use “<b>\"</b>” to
specify a double quote within a replacement string.) Variables
can be used in a replacement value if it is not double-quoted.
If mixed <b>replace_<em>xxx</em></b> commands are given, only the
final one applies.
@note
Although <b>replace_regex</b> and <b>replace_result</b> affect
the output from <b>exec</b>, <b>replace_column</b> does not
because <b>exec</b> output is not necessarily columnar.
@verbatim
--replace_column 9 #
replace_column 1 b 2 d;
@endverbatim
</li>
<li>
<tt>replace_numeric_round <b>precision</b></tt>
Rounds off floating point numbers. <b>precision</b> is the
number of digits after the decimal point to which the result will
be rounded off to. It can only be a number between
0 and 16.
If the precision is 0, then the value is rounded off to the
nearest whole number. Trailing zeroes after the decimal point are
removed from the numbers.
Numbers which are <b>greater than <em>1e10</em></b> or <b> lesser
than <em> -1e10 </em></b> are represented using the
exponential notation after they are rounded off.
@verbatim
--replace_numeric_round 6
SELECT 12379.79459775333;
12379.794598
replace_numeric_round 0;
SELECT 876.87302;
877
@endverbatim
</li>
<li>
<tt>replace_regex <b>/pattern/replacement/</b>[i] ...</tt>
In the output from the next statement, find strings within
columns of the result set that match <b><em>pattern</em></b> (a
regular expression) and replace them with
<b><em>replacement</em></b>. Each instance of a string in a
column that matches the pattern is replaced. Matching is case
sensitive by default. Specify the optional <b>i</b> modifier to
cause matching to be case insensitive.
The syntax for allowable patterns is same as the <b>std::ECMAScript</b>
syntax. The pattern can contain parentheses to mark substrings
matched by parts of the pattern. These substrings can be referenced in
the replacement string: An instance of <b><em>N</em></b> in the
replacement string causes insertion of the <b><em>N</em>-th</b> substring
matched by the pattern. For example, the following command matches
<b>strawberry</b> and replaces it with <b>raspberry</b> and
<b>strawberry</b>:
@verbatim
--replace_regex /(strawberry)/raspberry and \1/
@endverbatim
Multiple <b><em>pattern/replacement</em></b> pairs may be given.
The following command replaces instances of <b>A</b> with
<b>C</b> (the first pattern replaces <b>A</b> with <b>B</b>, the
second replaces <b>B</b> with <b>C</b>):
@verbatim
--replace_regex /A/B/ /B/C/
@endverbatim
If a given pattern is not found, no error occurs and the input
is unchanged.
</li>
<li>
<tt>replace_result <b>from_val to_val</b>
[<b>from_val to_val</b>] ...</tt>
Replace strings in the result. Each occurrence of
<b><em>from_val</em></b> is replaced by the corresponding
<b><em>to_val</em></b>. There can be more than
<b><em>from_val/to_val</em></b> pair. Arguments can be quoted
with single quotation marks or double quotation marks. Variable
references within the arguments are expanded before replacement
occurs. Values are matched literally. To use patterns, use the
<b>replace_regex</b> command.
@verbatim
--replace_result 1024 MAX_KEY_LENGTH 3072 MAX_KEY_LENGTH
replace_result $MASTER_MYPORT MASTER_PORT;
@endverbatim
</li>
<li>
<tt>reset_connection</tt>
Reset the connection state by calling [mysql_reset_connection()]
(https://dev.mysql.com/doc/refman/8.0/en/mysql-reset-connection.html).
</li>
<li>
<tt>result_format <b>version</b></tt>
Set the format to the specified version, which is either 1 for
the current, default behavior, or to 2 which is an extended
alternative format. The setting is in effect until it is changed
or until the end of the test.
In format version 2, empty lines and indentation in the test
file are preserveded in the result. Also, comments indicated by
a double \## are copied verbatim to the result. Comments using a
single \# are not copied. Format version 2 makes it easier for
humans to read the result output, but at the cost of somewhat
larger files due to the white space and comments.
@verbatim
--result_format 2
@endverbatim
</li>
<li>
<tt>rmdir <b>dir_name</b></tt>
Remove a directory named <b><em>dir_name</em></b>. Returns 0 for
success and 1 for failure.
@verbatim
--rmdir testdir
@endverbatim
<b>rmdir</b> fails if the directory to be removed contains any
files or directories. To remove the directory as well as its
contents, if any, use <b>force-rmdir</b>.
</li>
<li>
<tt>save_master_pos</tt>
For a master replication server, save the current binary log
file name and position. These values can be used for subsequent
<b>sync_with_master</b> or <b>sync_slave_with_master</b>
commands.
</li>
<li>
<tt>send [<b>statement</b>]</tt>
Send a statement to the server but do not wait for the result.
The result must be received with the <b>reap</b> command. You
cannot execute another SQL statement on the same connection
between <b>send</b> and <b>reap</b>.
If <b><em>statement</em></b> is omitted, the <b>send</b> command
applies to the next statement executed. This means that
<b>send</b> can be used on a line by itself before a statement.
Thus, this command:
@verbatim
send SELECT 1;
@endverbatim
Is equivalent to these commands:
@verbatim
send;
SELECT 1;
@endverbatim
</li>
<li>
<tt>send_eval [<b>statement</b>]</tt>
Evaluate the command, then send it to the server. This is a
combination of the <b>send</b> and <b>eval</b> commands, giving
the functionality of both. After variable replacement has been
done, it behaves like the <b>send</b> command.
If <b><em>statement</em></b> is omitted, the <b>send_eval</b>
command applies to the next statement executed. This means that
<b>send_eval</b> can be used on a line by itself before a
statement. Thus, this command:
@verbatim
--send_eval $my_stmt
@endverbatim
</li>
Is equivalent to these commands:
@verbatim
--send_eval
$my_stmt;
@endverbatim
</li>
<li>
<tt>send_quit <b>connection</b></tt>
Sends a <b>COM_QUIT</b> command to the server on the named
connection.
@verbatim
send_quit con;
@endverbatim
</li>
<li>
<tt>send_shutdown</tt>
Sends a shutdown command to the server but does not wait for it
to complete the shutdown. Test execution proceeds as soon as the
shutdown command is sent.
</li>
<li>
<tt>shutdown_server [<b>timeout</b>]</tt>
Stops the server. This command waits for the server to shut down
by monitoring its process ID (PID) file. If the server's process
ID file is not gone after <b><em>timeout</em></b> seconds, the
process will be killed. If <b><em>timeout</em></b> is omitted,
the default is 60 seconds.
@verbatim
shutdown_server;
shutdown_server 30;
@endverbatim
</li>
<li>
<tt>skip [<b>message</b>]</tt>
Skips the rest of the test file after printing the given message
as the reason. This can be used after checking a condition that
must be satisfied, as a way of performing an exit that displays
a reason. References to variables within the message are
replaced with the corresponding values. Suppose that the test
file <b>mytest.test</b> has these contents:
@verbatim
let $var= 0;
if (!$var)
{
skip value of \$var is '$var', skipping test;
}
echo This command is never reached;
@endverbatim
Executing @ref PAGE_MYSQLTEST "mysqltest" -x mytest.test yields
these results:
@verbatim
The test './mytest' is not supported by this installation
Detected in file ./mytest at line 4
reason: value of $var is '0', skipping test
@endverbatim
If the test is run from @ref PAGE_MYSQL_TEST_RUN_PL
"mysql-test-run.pl", you will instead see the test result as
<b>[ skipped ]</b> followed by the message.
@verbatim
main.mytest [ skipped ] value of $var is '0', skipping test
@endverbatim
</li>
<li>
<tt>sleep <b>num</b></tt>
Sleep <b><em>num</em></b> seconds. <b><em>num</em></b> need not be
a whole number and can have a fractional part as well i.e., the
command supports sleeping for intervals shorter than 1 second.
@verbatim
--sleep 10
sleep 0.5;
@endverbatim
Try not to use <b>sleep</b> command more than necessary. The
more of them there are, the slower the test suite becomes.
</li>
<li>
<tt>sorted_result</tt>
Sort the output from the next statement if it produces a result
set. <b>sorted_result</b> is applied just before displaying the
result, after any other result modifiers that might have been
specified, such as <b>replace_result</b> or
<b>replace_column</b>. If the next statement produces no result
set, <b>sorted_result</b> has no effect because there is nothing
to sort.
@verbatim
sorted_result;
SELECT 2 AS "my_col" UNION SELECT 1;
let $my_stmt=SELECT 2 AS "my_col" UNION SELECT 1;
--sorted_result
eval $my_stmt;
--sorted_result
--replace_column 1 #
SELECT '1' AS "my_col1",2 AS "my_col2"
UNION
SELECT '2',1;
@endverbatim
<b>sorted_result</b> sorts the entire result of the next query.
If this involves constructs such as <b>UNION</b>, stored
procedures, or multi-statements, the output will be in a fixed
order, but all the results will be sorted together and might
appear somewhat strange.
The purpose of the <b>sorted_result</b> command is to produce
output with a deterministic order for a given set of result
rows. It is possible to use <b>ORDER BY</b> to sort query
results, but that can sometimes present its own problems. For
example, if the optimizer is being investigated for some bug,
<b>ORDER BY</b> might order the result but return an incorrect
set of rows. <b>sorted_result</b> can be used to produce sorted
output even in the absence of <b>ORDER BY</b>.
<b>sorted_result</b> is useful for eliminating differences
between test runs that may otherwise be difficult to compensate
for. Results without <b>ORDER BY</b> are not guaranteed to be
returned in any given order, so the result for a given query
might differ between test runs. For example, the order might
vary between different server versions, so a result file created
by one server might fail when compared to the result created by
another server. The same is true for different storage engines.
<b>sorted_result</b> eliminates these order differences by
producing a deterministic row order.
Other ways to eliminate differences from results without use of
<b>sorted_result</b> include:
- Remove columns from the select list to reduce variability in
the output
- Use aggregate functions such as <b>AVG()</b> on all columns
of the select list
- Use <b>ORDER BY</b>
The use of aggregate functions or <b>ORDER BY</b> may also have
the advantage of exposing other bugs by introducing additional
stress on the server. The choice of whether to use
<b>sorted_result</b> or <b>ORDER BY</b> (or perhaps both) may be
dictated by whether you are trying to expose bugs, or avoid
having them affect results. This means that care should be taken
with <b>sorted_result</b> because it has the potential of hiding
server bugs that result in true problems with result order.
</li>
<li>
<tt>partially_sorted_result <b>start_column</b></tt>
Similarly to <b>sorted_result</b>, but assumes that the first
<b>start_column</b> columns are already sorted, sorting only
on the remaining ones. This is useful if you wish to verify
a partial ordering property, e.g. that <b>SELECT a,b,c ORDER BY
a</b>. In this case, you could use <b>partially_sorted_result 1</b>
to sort only on b and c, giving deterministic results without
masking bugs where sorting on a column would not work correctly.
<tt>sorted_result</tt> is functionally equal to
<tt>partially_sorted_result 0</tt>.
</li>
<li>
<tt>source <b>file_name</b></tt>
Read test input from the named file.
If you find that several test case files contain a common
section of commands (for example, statements that create a
standard set of tables), you can put those commands in another
file and those test cases that need the file can include it by
means of a <b>source <em>file_name</em></b> command. This
enables you to write the code just once rather than in multiple
test cases.
Normally, the file name in the <b>source</b> command is relative
to the <b>mysql-test</b> directory because @ref PAGE_MYSQLTEST
"mysqltest" usually is invoked in that directory.
A sourced file can use <b>source</b> to read other files, but
take care to avoid a loop. The maximum nesting level is 16.
@verbatim
--source include/have_csv.inc
source include/varchar.inc;
@endverbatim
The file name can include variable references. Variables are
expanded including any quotation marks in the values, so
normally the values should not include quotation marks. Suppose
that <b>/tmp/junk</b> contains this line:
@verbatim
SELECT 'I am a query';
@endverbatim
The following example shows one way in which variable references
could be used to specify the file name:
@verbatim
let $dir= /tmp;
let $file= junk;
source $dir/$file;
@endverbatim
</li>
<li>
<tt>start_timer</tt>
Restart the timer, overriding any timer start that occurred
earlier. By default, the timer starts when @ref PAGE_MYSQLTEST
"mysqltest" begins execution.
</li>
<li>
<tt>sync_slave_with_master [<b>connection_name</b>]</tt>
Executing this command is equivalent to executing the following
commands:
@verbatim
save_master_pos;
connection connection_name;
sync_with_master 0;
@endverbatim
If <b><em>connection_name</em></b> is not specified, the
connection named <b>slave</b> is used.
The effect is to save the replication coordinates (binary log
file name and position) for the server on the current connection
(which is assumed to be a master replication server), and then
switch to a slave server and wait until it catches up with the
saved coordinates. Note that this command implicitly changes the
current connection.
A variable can be used to specify the
<b><em>connection_name</em></b> value.
</li>
<li>
<tt>sync_with_master <b>offset</b></tt>
For a slave replication server, wait until it has caught up with
the master. The position to synchronize to is the position saved
by the most recent <b>save_master_pos</b> command plus offset.
To use this command, <b>save_master_pos</b> must have been
executed at some point earlier in the test case to cause @ref
PAGE_MYSQLTEST "mysqltest" to save the master's replication
coordinates.
</li>
<li>
<tt>vertical_results</tt>
Set the default query result display format to vertical.
Initially, the default is to display results horizontally.
@verbatim
--vertical_results
@endverbatim
</li>
<li>
<tt>wait_for_slave_to_stop</tt>
Poll the current connection, which is assumed to be a connection
to a slave replication server, by executing <b>SHOW STATUS LIKE
'Slave_running'</b> statements until the result is <b>OFF</b>.
For information about alternative means of slave server control,
see @ref PAGE_WRITING_REPLICATION_TESTS.
</li>
<li>
<tt>while (<b>expr</b>)</tt>
Begin a <b>while</b> loop block, which continues until an
<b>end</b> line. @ref PAGE_MYSQLTEST "mysqltest" executes the
block repeatedly as long as the expression is true (non-zero).
See @ref PAGE_MYSQL_TEST_FLOW_CONTROL, for further information
about while statements.
Make sure that the loop includes some exit condition that
eventually occurs. This can be done by writing
<b><em>expr</em></b> so that it becomes false at some point.
@verbatim
let $i=5;
while ($i)
{
echo $i;
dec $i;
}
@endverbatim
</li>
<li>
<tt>write_file <b>file_name</b> [<b>terminator</b>]</tt>
Write the following lines of the test file to the given file,
until a line containing the terminator is encountered. The
default terminator is <tt>EOF</tt>, but a different terminator
can be provided. The file name argument is subject to variable
substitution. An error occurs if the file already exists.
@verbatim
write_file $MYSQL_TMP_DIR/data01;
line one for the file
line two for the file
EOF
@endverbatim
@verbatim
write_file $MYSQL_TMP_DIR/data02 END_OF_FILE;
line one for the file
line two for the file
END_OF_FILE
@endverbatim
</li>
</ul>
*/
###############################################################################
## mysqltest Variables
/**
@page PAGE_MYSQL_TEST_VARIABLES mysqltest Variables
You can define variables and refer to their values. You can also
refer to environment variables, and there is a built-in variable
that contains the result of the most recent SQL statement.
To define a variable, use the <b>let</b> command. Examples:
@verbatim
let $a= 14;
let $b= this is a string;
--let $a= 14
--let $b= this is a string
@endverbatim
The variable name cannot contain whitespace or the “=” character.
If a variable has a numeric value, you can increment or decrement
the value:
@verbatim
inc $a;
dec $a;
--inc $a
--dec $a
@endverbatim
<b>inc</b> and <b>dec</b> are commonly used in <b>while</b>
loops to modify the value of a counter variable that controls loop
execution.
The result from executing a query can be assigned to a variable by
enclosing the query within backtick (“`”) characters:
@verbatim
let $q= `select version()`;
@endverbatim
References to variables can occur in the <b>echo</b>,
<b>eval</b>, <b>exec</b>, and <b>system</b> commands. Variable
references are replaced by their values. A nonquery value assigned
to a variable in a <b>let</b> command can also refer to variables.
Variable references that occur within
\`<b><em>query</em></b>\` are expanded before the query is
sent to the server for execution.
You can refer to environment variables. For example, this command
displays the value of the <b>$PATH</b> variable from the
environment:
@verbatim
--echo $PATH
@endverbatim
<b>$mysql_errno</b> is a built-in variable that contains the
numeric error returned by the most recent SQL statement sent to the
server, or 0 if the statement executed successfully.
<b>$mysql_errno</b> has a value of −1 if no statement has yet been
sent.
<b>$mysql_errname</b> similarly contains the symbolic name of the
last error, or an empty string if there was no error.
@ref PAGE_MYSQLTEST "mysqltest" first checks @ref PAGE_MYSQLTEST
"mysqltest" variables and then environment variables. @ref
PAGE_MYSQLTEST "mysqltest" variable names are not case sensitive.
Environment variable names are case sensitive.
*/
###############################################################################
## mysqltest Flow Control Constructs
/**
@page PAGE_MYSQL_TEST_FLOW_CONTROL mysqltest Flow Control Constructs
The syntax for <b>if</b> block looks like this:
@verbatim
if (expr)
{
command list
}
@endverbatim
The syntax for <b>while</b> block looks like this:
@verbatim
while (expr)
{
command list
}
@endverbatim
An expression result is true if nonzero, false if zero. If the
expression begins with <b>!</b>, the sense of the test is reversed.
If the expression is a string that does not begin with a numeric
digit (possibly preceeded by a plus or minus sign), it evaluates as
true if non-empty. Any white space is ignored in this case, so a
string consisting of only white space is false.
There is no provision for <b>else</b> with <b>if</b>.
For a <b>while</b> loop, make sure that the loop includes some
exit condition that eventually occurs. This can be done by writing
<b><em>expr</em></b> so that it becomes false at some point.
The allowable syntax for <b><em>expr</em></b> is
<b>$<em>var_name</em></b>, <b>!$<em>var_name</em></b>,
<b><em>integer</em></b>, or \`<b><em>query</em></b>\`.
The expression can also be a simple comparison, where the left hand
side must be a variable, and the right hand side can be string or any type
valid for the single expression except the negated variable. The
supported operators are ==, !=, <, <=, > and >=. Only the first two
may be used if the right hand side does not evaluate to an integer.
With ==, strings must match exactly.
If you use a string on the right hand side of the comparison, it
does not have to be quoted even if it contains spaces. It may
optionally be enclosed in single or double quotation marks which
will then be stripped off before comparison. This is in contrast to
<b>let</b> statements, where quoting is not stripped.
Examples of the expression syntax with and without comparisons (only the header
shown):
@verbatim
while ($counter<5) ...
if ($value == 'No such row') ...
if ($slave_count != $master_count) ...
if ($counter < `SELECT 10`) ...
if (-1) ...
if (20) ...
if (`SELECT 1`) ...
if(! $cnt) ...
@endverbatim
The opening <b>{</b> (curly brace) must be separated from the
preceding <b>)</b> (right parenthesis) by whitespace, such as a
space or a line break.
Variable references that occur within
\`<b><em>query</em></b>\` are expanded before the query is
sent to the server for execution.
*/
###############################################################################
## Error Handling
/**
@page PAGE_ERROR_HANDLING Error Handling
If an expected error is specified and that error occurs, @ref
PAGE_MYSQLTEST "mysqltest" continues reading input. If the command
is successful or a different error occurs, @ref PAGE_MYSQLTEST
"mysqltest" aborts.
If no expected error is specified, @ref PAGE_MYSQLTEST "mysqltest"
aborts unless the command is successful. (It is implicit that you
expect <b>$mysql_errno</b> to be 0.)
By default, @ref PAGE_MYSQLTEST "mysqltest" aborts for certain
conditions:
<ul>
<li>
A statement that fails when it should have succeeded. The
following statement should succeed if table <b>t</b> exists;
@verbatim
SELECT * FROM t;
@endverbatim
</li>
<li>
A statement that fails with an error different from that
specified:
@verbatim
--error 1
SELECT * FROM no_such_table;
@endverbatim
</li>
<li>
A statement that succeeds when an error was expected:
@verbatim
--error 1
SELECT 'a string';
@endverbatim
</li>
</ul>
You can disable the abort for errors of the first type by using the
<b>disable_abort_on_error</b> command. In this case, when errors
occur for statements that should succeed, @ref PAGE_MYSQLTEST
"mysqltest" continues processing intput.
<b>disable_abort_on_error</b> does <b>not</b> cause @ref
PAGE_MYSQLTEST "mysqltest" to ignore errors for the other two types,
where you explicitly state which error you expect. This behavior is
intentional. The rationale is that if you use the <b>error</b>
command to specify an expected error, it is assumed that the test is
sufficiently well characterized that only the specified error is
accceptable.
If you do not use the <b>error</b> command, it is assumed that you
might not know which error to expect or that it might be difficult
to characterize all possible errors that could occur. In this case,
<b>disable_abort_on_error</b> is useful for causing @ref
PAGE_MYSQLTEST mysqltest to continue processing input. This can be
helpful in the following circumstances:
<ul>
<li>
During test case development, it is useful to process all input
even if errors occur so that you can see all errors at once, such
as those that occur due to typographical or syntax errors.
Otherwise, you can see and fix only one scripting problem at a
time.
</li>
<li>
Within a file that is included with a <b>source</b> command by
several different test cases, errors might vary depending on the
processing environment that is set up prior to the <b>source</b>
command.
</li>
<li>
Tests that follow a given statement that can fail are independent
of that statement and do not depend on its result.
</li>
</ul>
*/
###############################################################################
## Creating and Executing Unit Tests
/**
@page PAGE_UNIT_TESTS Creating and Executing Unit Tests
<h3>Table of Contents</h3>
- @subpage PAGE_UNIT_TESTS_TAP
- @subpage PAGE_UNIT_TESTS_GOOGLE
- @subpage PAGE_UNIT_TESTS_MAIN_TEST_RUNS
Storage engines and plugins can have unit tests to test their
components. The top-level <b>Makefile</b> target
<b>test-unit</b> runs all unit tests: It scans the storage engine
and plugin directories, recursively, and executes all executable
files having a name that ends with <b>-t</b>.
The following sections describe MySQL unit testing using TAP and
the Google Test framework.
*/
###############################################################################
## Unit Testing Using TAP
/**
@page PAGE_UNIT_TESTS_TAP Unit Testing Using TAP
The unit-testing facility based on the Test Anything Protocol (TAP)
is mainly used when developing Perl and PHP modules. To write unit
tests for C/C++ code, MySQL has developed a library for generating
TAP output from C/C++ files. Each unit test is written as a separate
source file that is compiled to produce an executable. For the unit
test to be recognized as a unit test, the executable file has to be
of the format <b>mytext-t</b>. For example, you can create a
source file named <b>mytest-t.c</b> that compiles to produce an
executable <b>mytest-t</b>. The executable will be found and run
when you execute <b>make test</b> or <b>make test-unit</b> in the
distribution top-level directory.
Example unit tests can be found in the <b>unittest/examples</b>
directory of a MySQL source distribution. The code for the MyTAP
protocol is located in the <b>unittest/mytap</b> directory.
Each unit test file should be stored in a storage engine or plugin
directory (<b>storage/<em>engine_name</em></b> or
<b>plugin/<em>plugin_name</em></b>), or one of its
subdirectories. A reasonable convention is to create a
<b>unittest</b> subdirectory under the storage engine or plugin
directory and create unit test files in <b>unittest</b>.
*/
###############################################################################
## Unit Testing Using the Google Test Framework
/**
@page PAGE_UNIT_TESTS_GOOGLE Unit Testing Using the Google Test Framework
The Google Test unit-testing framework is available in MySQL source
trees and distributions. Google Test, like MyTAP, provides a unit-
testing framework, but Google Test provides richer functionality,
such as:
- A rich set of predicates
- User-defined predicates and assertions
- Automatic test registration
- Nice error reporting when a predicate fails (with line number, expected
and actual values, and additional comments)
- Test fixtures, and setup/teardown logic
- Death tests
- Disabled tests
- Test filtering and shuffling
Google Test runs on many platforms. Some functionality is missing on
some platforms (such as death tests and parameterized tests), so
those features should not be used.
This section provides notes about using Google Test within the
context of MySQL development. For general-purpose information about
Google Test, see these resources:
- Main Google Test page: http://code.google.com/p/googletest
- Primer: http://code.google.com/p/googletest/wiki/GoogleTestPrimer
- Advanced guide:
http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide
- Google presentation:
http://docs.google.com/present/view?id=dfsbxvm5_0f5s4pvf9
@section SECTION_WRITING_UNIT_TESTS Writing Unit Tests for Google Test
Most of The Google Test unit test files are located in the
<b>unittest/gunit</b> directory. You can look at these files to
see how tests are written. Here are some examples:
- <tt>sql_list-t.cc</tt>: A simple test of some list classes
- <tt>mdl-t.cc</tt>: Some tests of metadata locking (MDL),
including testing of lock acquisition from multiple threads
- <tt>mdl_mytap-t.cc</tt>: The same tests as <b>mdl-t.cc</b>, but
written for MyTAP, to illustrate some features of Google Test
Most MyTAP-based tests are likely easily converted to Google Test.
However, there might be low-level tests that absolutely must be run
on every platform, and thus require MyTAP.
To see what options are available, run a test executable with the
<b>`--help`</b> option.
*/
###############################################################################
## Unit Tests Added to Main Test Runs
/**
@page PAGE_UNIT_TESTS_MAIN_TEST_RUNS Unit Tests Added to Main Test Runs
@ref PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl" will also run unit
tests at the end of full test runs, when being run from within a
build directory. It depends on the unit tests having been built and
defined in a file <b>CTestTestfile.cmake</b> in the top level build
directory. Those will normally be there after a build using
<b>CMake</b>, but will not be in a binary package.
The unit tests are run simply by executing <b>ctest</b> with no
arguments from the top level build directory. The result will be
shown as a single test at the end, named <b>unit_tests</b> which
passes if and only if all unit tests pass. A summary of the result
will be printed, including the name of any failed unit tests. The
set of unit tests will be counted as one test (either passed or
failed) in the overall test summary.
Unit tests will by default be run only if you have not specified any
specific tests or suites on the command line for @ref
PAGE_MYSQL_TEST_RUN_PL "mysql-test-run.pl". This can be overridden
by setting the environment variable <b>MTR_UNIT_TESTS</b> to 0 or 1.
This in turn can be overriden by a command line argument
<b>`--unit-tests`</b> or <b>`--nounit-tests`</b>.
If the file <b>CTestTestfile.cmake</b> and the <b>ctest</b>
command are not both available, unit tests will be silently skipped,
unless you have used the command line option <b>`--unit-tests`</b>.
*/
###############################################################################
## Plugins for Testing Plugin Services
/**
@page PAGE_PLUGINS Plugins for Testing Plugin Services
MySQL server plugins have access to server “services”, as described in
[MySQL Services for Plugins]
(https://dev.mysql.com/doc/refman/8.0/en/plugin-services.html).
MySQL distributions include plugins that demonstrate how to test
plugin service APIs:
<ul>
<li>
The <b>test_framework</b> plugin is a bare bones plugin that
shows the minimum required framework for service testing.
</li>
<li>
The <b>test_services</b> plugin demonstrates how to test the
<b>my_plugin_log_service</b> service in unthreaded context.
</li>
<li>
The <b>test_services_threaded</b> plugin is like
<b>test_services</b>, but for threaded context.
</li>
</ul>
The source code for the plugins is located in the
<b>plugin/test_services</b> directory of MySQL source
distributions. The <b>README</b> file in that directory contains
instructions for running the test cases available for the
<b>test_services</b> and <b>test_services_threaded</b> plugins.
@note
The test plugins in <b>plugin/test_services</b> are daemon plugins
(see [Daemon Plugins]
(https://dev.mysql.com/doc/refman/8.0/en/plugin-types.html#daemon-plugin-type)).
For an example of a nondaemon service-testing plugin plugin, see the
<b>test_security_context.cc</b> file in the <b>plugin/audit_null</b>
directory. This file creates an audit plugin for testing the
<b>security_context</b> service.
Use the following procedure to create a new service-testing plugin
based on one of those provided in the <b>plugin/test_services</b>
directory. Assume that you want to create a new plugin named
<b>test_myservice</b> (or <b>test_myservice_threaded</b> to test
in threaded context).
<ol>
<li>
Select a source file to use as a basis for the new plugin:
<ul>
<li>
To begin with a bare bones plugin, copy <b>test_framework.cc</b>
to <b>test_myservice.cc</b>.
</li>
<li>
To begin with a plugin that already includes code for running tests
in unthreaded context, copy <b>test_services.cc</b> to
<b>test_myservice.cc</b>.
</li>
<li>
To begin with a plugin that already includes code for running tests
in threaded context, copy <b>test_services_threaded.cc</b> to
<b>test_myservice_threaded.cc</b>.
</li>
</ul>
</li>
<li>
There is a plugin descriptor near the end of the new source file. Modify
this descriptor appropriately for your plugin. Change the <b>name</b>,
<b>author</b>, and <b>descr</b> members that indicate the plugin
name and author and provide a description. For example, if you copied
<b>test_framework.cc</b>, those members look like this:
@verbatim
"test_framework",
"Horst Hunger",
"Test framework",
@endverbatim
Change them to something like this:
@verbatim
"test_myservice",
"Your Name Here",
"Test My Service",
@endverbatim
</li>
<li>
Modify your source file appropriately for the service to be tested:
<ul>
<li>
If you copied <b>test_framework.cc</b>, your file has no
tests initially and is set up for unthreaded context. In
this case, add code to the
<b>test_services_plugin_init()</b> function. This code
should invoke the service to be tested.
</li>
<li>
If you copied <b>test_services.cc</b> or
<b>test_services_threaded.cc</b>, the file contains tests
for the <b>my_plugin_log_service</b> service in unthreaded or
threaded contexts. Replace or modify those tests with code
for your own tests.
those tests with code for your own tests.
</li>
</ul>
</li>
</ol>
Compiling your plugin creates a plugin library file, which you
should install in the directory named by the
[plugin_dir]
https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_plugin_dir)
system variable. The file base name is the same as that of the
source file. The file name suffix differs per platform (for example,
<b>.so</b> for Unix and Unix-like systems, <b>.dll</b> for
Windows).
To install or unintall your plugin at server startup, use the
[`--plugin-load`]
(https://dev.mysql.com/doc/refman/8.0/en/server-options.html#option_mysqld_plugin-load) or
[`--plugin-load-add`]
(https://dev.mysql.com/doc/refman/8.0/en/server-options.html#option_mysqld_plugin-load-add)
option. For example, you can use these lines in an option file
(adjust the file name as necessary):
@verbatim
[mysqld]
plugin-load-add=test_myservice.so
@endverbatim
To install or uninstall the plugin at runtime, use these statements
(adjust the plugin name and file name as necessary):
@verbatim
INSTALL PLUGIN test_myservice SONAME 'test_myservice.so';
UNINSTALL PLUGIN test_myservice;
@endverbatim
For addition information about plugin loading, see
[Installing and Uninstalling Plugins]
(https://dev.mysql.com/doc/refman/8.0/en/server-plugin-loading.html).
For information about creating and running test cases for your new
plugin, adapt the instructions in the <b>README</b> file in the
<b>plugin/test_services</b> directory. Test cases for the
<b>test_services</b> and <b>test_services_threaded</b> plugins
are located in <b>mysql-test/suite/test_services</b>.
*/
###############################################################################
|