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
|
base_tests() {
# -------------------------------------------------------------------------
TEST "Base case"
$COMPILER -c -o reference_test1.o test1.c
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat direct_cache_miss 0
expect_stat preprocessed_cache_miss 1
expect_stat local_storage_hit 0
expect_stat local_storage_miss 1
expect_stat local_storage_read_hit 0
expect_stat local_storage_read_miss 1
expect_stat local_storage_write 1
expect_stat remote_storage_hit 0
expect_stat remote_storage_miss 0
expect_stat remote_storage_read_hit 0
expect_stat remote_storage_read_miss 0
expect_stat remote_storage_write 0
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat direct_cache_miss 0
expect_stat preprocessed_cache_miss 1
expect_stat local_storage_hit 1
expect_stat local_storage_miss 1
expect_stat local_storage_read_hit 1
expect_stat local_storage_read_miss 1
expect_stat local_storage_write 1
expect_stat remote_storage_hit 0
expect_stat remote_storage_miss 0
expect_stat remote_storage_read_hit 0
expect_stat remote_storage_read_miss 0
expect_stat remote_storage_write 0
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
# -------------------------------------------------------------------------
TEST "ccache ccache gcc"
# E.g. due to some suboptimal setup, scripts etc. Source:
# https://github.com/ccache/ccache/issues/686
$COMPILER -c -o reference_test1.o test1.c
$CCACHE $COMPILER -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
$CCACHE $CCACHE $COMPILER -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
$CCACHE $CCACHE $CCACHE $COMPILER -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
# -------------------------------------------------------------------------
TEST "Version output readable"
# The exact output is not tested, but at least it's something human readable
# and not random memory.
local version_pattern=$'^ccache version [a-zA-Z0-9_./+-]*\r?$'
if [ $($CCACHE --version | grep -E -c "$version_pattern") -ne 1 ]; then
test_failed "Unexpected output of --version. Output is '$($CCACHE --version)'"
fi
# -------------------------------------------------------------------------
TEST "Debug option"
$CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
$CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
$COMPILER -c -o reference_test1.o test1.c -g
expect_equal_object_files reference_test1.o test1.o
# -------------------------------------------------------------------------
TEST "Output option"
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -o foo.o
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
$COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o foo.o
# -------------------------------------------------------------------------
TEST "Output option without space"
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -odir
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -optf
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
$COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o dir
expect_equal_object_files reference_test1.o ptf
# -------------------------------------------------------------------------
TEST "Called for link"
$CCACHE_COMPILE test1.c -o test 2>/dev/null
expect_stat called_for_link 1
$CCACHE_COMPILE -c test1.c
$CCACHE_COMPILE test1.o -o test 2>/dev/null
expect_stat called_for_link 2
# -------------------------------------------------------------------------
TEST "No existing input file"
$CCACHE_COMPILE -c foo.c 2>/dev/null
expect_stat no_input_file 1
# -------------------------------------------------------------------------
TEST "No input file on command line"
$CCACHE_COMPILE -c -O2 2>/dev/null
expect_stat no_input_file 1
# -------------------------------------------------------------------------
TEST "Called for preprocessing"
$CCACHE_COMPILE -E -c test1.c >/dev/null 2>&1
expect_stat called_for_preprocessing 1
# -------------------------------------------------------------------------
TEST "Multiple source files"
touch test2.c
$CCACHE_COMPILE -c test1.c test2.c
expect_stat multiple_source_files 1
# -------------------------------------------------------------------------
TEST "Couldn't find the compiler"
$CCACHE blahblah -c test1.c 2>/dev/null
exit_code=$?
if [ $exit_code -ne 1 ]; then
test_failed "Expected exit code to be 1, actual value $exit_code"
fi
# -------------------------------------------------------------------------
TEST "Bad compiler arguments"
$CCACHE_COMPILE -c test1.c -I 2>/dev/null
expect_stat bad_compiler_arguments 1
# -------------------------------------------------------------------------
TEST "Unsupported source language"
ln -f test1.c test1.ccc
$CCACHE_COMPILE -c test1.ccc 2>/dev/null
expect_stat unsupported_source_language 1
# -------------------------------------------------------------------------
TEST "Unsupported compiler option"
$CCACHE_COMPILE -M foo -c test1.c >/dev/null 2>&1
expect_stat unsupported_compiler_option 1
# -------------------------------------------------------------------------
for variable in DEPENDENCIES_OUTPUT SUNPRO_DEPENDENCIES; do
TEST "Unsupported environment variable ${variable}"
eval "export ${variable}=1"
$CCACHE_COMPILE -c test1.c
expect_stat unsupported_environment_variable 1
done
# -------------------------------------------------------------------------
TEST "Output to directory"
mkdir testd
$CCACHE_COMPILE -o testd -c test1.c >/dev/null 2>&1
rmdir testd >/dev/null 2>&1
expect_stat bad_output_file 1
# -------------------------------------------------------------------------
TEST "Output to file in nonexistent directory"
mkdir out
$CCACHE_COMPILE -c test1.c -o out/foo.o
expect_stat bad_output_file 0
expect_stat cache_miss 1
rm -rf out
$CCACHE_COMPILE -c test1.c -o out/foo.o 2>/dev/null
expect_stat bad_output_file 1
expect_stat cache_miss 1
expect_missing out/foo.o
# -------------------------------------------------------------------------
TEST "No file extension"
mkdir src
touch src/foo
$CCACHE_COMPILE -x c -c src/foo
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_exists foo.o
rm foo.o
$CCACHE_COMPILE -x c -c src/foo
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_exists foo.o
rm foo.o
rm -rf src
# -------------------------------------------------------------------------
if ! $HOST_OS_WINDOWS; then
TEST "Source file ending with dot"
mkdir src
touch src/foo.
$CCACHE_COMPILE -x c -c src/foo.
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_exists foo.o
rm foo.o
$CCACHE_COMPILE -x c -c src/foo.
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_exists foo.o
rm foo.o
rm -rf src
fi
# -------------------------------------------------------------------------
TEST "Multiple file extensions"
mkdir src
touch src/foo.c.c
$CCACHE_COMPILE -c src/foo.c.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_exists foo.c.o
rm foo.c.o
$CCACHE_COMPILE -c src/foo.c.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_exists foo.c.o
rm foo.c.o
rm -rf src
# -------------------------------------------------------------------------
TEST "Too new source file"
postdate new.c
$CCACHE_COMPILE -c new.c
expect_stat modified_input_file 1
expect_stat cache_miss 0
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS include_file_mtime" $CCACHE_COMPILE -c new.c
expect_stat modified_input_file 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "Too new include file"
cat <<EOF >new.c
#include "new.h"
EOF
cat <<EOF >new.h
int test;
EOF
postdate new.h
$CCACHE_COMPILE -c new.c
expect_stat modified_input_file 1
expect_stat cache_miss 0
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS include_file_mtime" $CCACHE_COMPILE -c new.c
expect_stat modified_input_file 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "Too new source file ignored if sloppy"
postdate new.c
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS include_file_mtime" $CCACHE_COMPILE -c new.c
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "LANG"
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
LANG=foo $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
expect_stat files_in_cache 2
LANG=foo $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
expect_stat files_in_cache 2
# -------------------------------------------------------------------------
TEST "LANG with sloppiness"
CCACHE_SLOPPINESS=locale LANG=foo $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
CCACHE_SLOPPINESS=locale LANG=foo $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
CCACHE_SLOPPINESS=locale LANG=bar $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
expect_stat files_in_cache 1
# -------------------------------------------------------------------------
TEST "Result file is compressed"
$CCACHE_COMPILE -c test1.c
result_file=$(find $CCACHE_DIR -name '*R')
if ! $CCACHE --inspect $result_file | grep 'Compression type: zstd' >/dev/null 2>&1; then
test_failed "Result file not uncompressed according to metadata"
fi
if [ $(file_size $result_file) -ge $(file_size test1.o) ]; then
test_failed "Result file seems to be uncompressed"
fi
# -------------------------------------------------------------------------
TEST "Corrupt result file"
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
result_file=$(find $CCACHE_DIR -name '*R')
printf foo | dd of=$result_file bs=3 count=1 seek=20 conv=notrunc >&/dev/null
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
expect_stat files_in_cache 1
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
expect_stat files_in_cache 1
# -------------------------------------------------------------------------
TEST "CCACHE_DEBUG"
unset CCACHE_LOGFILE
unset CCACHE_NODIRECT
CCACHE_DEBUG=1 $CCACHE_COMPILE -c test1.c
if ! grep -q Result: test1.o.*.ccache-log; then
test_failed "Unexpected data in <obj>.ccache-log"
fi
if ! grep -q "PREPROCESSOR MODE" test1.o.*.ccache-input-text; then
test_failed "Unexpected data in <obj>.<timestamp>.ccache-input-text"
fi
for ext in c p d; do
if ! [ -f test1.o.*.ccache-input-$ext ]; then
test_failed "<obj>.ccache-input-$ext missing"
fi
done
# -------------------------------------------------------------------------
TEST "CCACHE_DEBUG with too hard option"
CCACHE_DEBUG=1 $CCACHE_COMPILE -c test1.c -save-temps
expect_stat unsupported_compiler_option 1
expect_exists test1.o.*.ccache-log
# -------------------------------------------------------------------------
if $RUN_WIN_XFAIL;then
# TODO: Leading slash is missing. (debugdirC/... instead of debugdir/C/... )
TEST "CCACHE_DEBUGDIR"
CCACHE_DEBUG=1 CCACHE_DEBUGDIR=debugdir $CCACHE_COMPILE -c test1.c
expect_contains debugdir"$(pwd -P)"/test1.o.*.ccache-log "Result: cache_miss"
fi
# -------------------------------------------------------------------------
TEST "CCACHE_DISABLE"
CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2>/dev/null
if [ -d $CCACHE_DIR ]; then
test_failed "$CCACHE_DIR created despite CCACHE_DISABLE being set"
fi
# -------------------------------------------------------------------------
TEST "ccache:disable"
echo '// ccache:disable' >>test1.c
$CCACHE_COMPILE -c test1.c 2>/dev/null
expect_stat disabled 1
# -------------------------------------------------------------------------
TEST "CCACHE_COMMENTS"
$COMPILER -c -o reference_test1.o test1.c
mv test1.c test1-saved.c
echo '// initial comment' >test1.c
cat test1-saved.c >>test1.c
CCACHE_COMMENTS=1 $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
echo '// different comment' >test1.c
cat test1-saved.c >>test1.c
CCACHE_COMMENTS=1 $CCACHE_COMPILE -c test1.c
mv test1-saved.c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 2
$COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o test1.o
# -------------------------------------------------------------------------
TEST "CCACHE_NOSTATS"
CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
# -------------------------------------------------------------------------
TEST "stats file forward compatibility"
mkdir -p "$CCACHE_DIR/4/"
stats_file="$CCACHE_DIR/4/stats"
touch "$CCACHE_DIR/timestamp_reference"
for i in `seq 101`; do
echo $i
done > "$stats_file"
expect_stat cache_miss 5
$CCACHE_COMPILE -c test1.c
expect_stat cache_miss 6
expect_contains "$stats_file" 101
expect_newer_than "$stats_file" "$CCACHE_DIR/timestamp_reference"
# -------------------------------------------------------------------------
TEST "stats file with large counter values"
mkdir -p "$CCACHE_DIR/4/"
stats_file="$CCACHE_DIR/4/stats"
echo "0 0 0 0 1234567890123456789" >"$stats_file"
expect_stat cache_miss 1234567890123456789
$CCACHE_COMPILE -c test1.c
expect_stat cache_miss 1234567890123456790
# -------------------------------------------------------------------------
TEST "CCACHE_RECACHE"
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat preprocessed_cache_miss 1
expect_stat cache_miss 1
expect_stat recache 0
CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat preprocessed_cache_miss 1
expect_stat cache_miss 1
expect_stat recache 1
$COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o test1.o
expect_stat files_in_cache 1
# -------------------------------------------------------------------------
TEST "Directory is hashed if using -g"
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
$CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
cd ../dir2
$CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
$CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
# -------------------------------------------------------------------------
TEST "Directory is not hashed if not using -g"
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
cd ../dir2
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "Directory is not hashed if using -g -g0"
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
$CCACHE_COMPILE -c test1.c -g -g0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -g -g0
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
cd ../dir2
$CCACHE_COMPILE -c test1.c -g -g0
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "Directory is not hashed if using -gz"
if $COMPILER -c test1.c -gz 2>/dev/null \
&& $COMPILER -E test1.c -gz >preprocessed.i 2>/dev/null \
&& [ -s preprocessed.i ] \
&& ! grep -Fq $PWD preprocessed.i; then
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
$CCACHE_COMPILE -c test1.c -gz
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -gz
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
cd ../dir2
$CCACHE_COMPILE -c test1.c -gz
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
fi
# -------------------------------------------------------------------------
TEST "Directory is not hashed if using -gz=zlib"
$COMPILER test1.c -gz=zlib -o /dev/null 2>/dev/null
if [ $? -eq 0 ]; then
# run test only if -gz=zlib is supported
$COMPILER -E test1.c -gz=zlib >preprocessed.i 2>/dev/null
if [ "$exit_code" == "0" ] && [ -s preprocessed.i ] && ! grep -Fq $PWD preprocessed.i; then
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
$CCACHE_COMPILE -c test1.c -gz=zlib
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -gz=zlib
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
cd ../dir2
$CCACHE_COMPILE -c test1.c -gz=zlib
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
fi
fi
# -------------------------------------------------------------------------
if $RUN_WIN_XFAIL; then
TEST "CCACHE_NOHASHDIR"
mkdir dir1 dir2
cp test1.c dir1
cp test1.c dir2
cd dir1
CCACHE_NOHASHDIR=1 $CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
CCACHE_NOHASHDIR=1 $CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
cd ../dir2
CCACHE_NOHASHDIR=1 $CCACHE_COMPILE -c test1.c -g
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
fi
# -------------------------------------------------------------------------
TEST "CCACHE_EXTRAFILES"
echo "a" >a
echo "b" >b
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
CCACHE_EXTRAFILES="a${PATH_DELIM}b" $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
CCACHE_EXTRAFILES="a${PATH_DELIM}b" $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
echo b2 >b
CCACHE_EXTRAFILES="a${PATH_DELIM}b" $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 3
CCACHE_EXTRAFILES="a${PATH_DELIM}b" $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 3
expect_stat cache_miss 3
CCACHE_EXTRAFILES="doesntexist" $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 3
expect_stat cache_miss 3
expect_stat error_hashing_extra_file 1
# -------------------------------------------------------------------------
TEST "CCACHE_PREFIX"
mkdir bin1 bin2
cat <<'EOF' >bin1/prefix-a.sh
#!/bin/sh
PATH=bin2:$PATH
echo a >prefix.result
exec "$@"
EOF
chmod +x bin1/prefix-a.sh
cat <<'EOF' >bin2/prefix-b.sh
#!/bin/sh
echo b >>prefix.result
exec "$@"
EOF
chmod +x bin2/prefix-b.sh
cat <<'EOF' >file.c
int foo;
EOF
PATH=bin1:$PATH CCACHE_PREFIX="prefix-a.sh prefix-b.sh" $CCACHE_COMPILE -c file.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_content prefix.result "a
b"
PATH=bin1:$PATH CCACHE_PREFIX="prefix-a.sh prefix-b.sh" $CCACHE_COMPILE -c file.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_content prefix.result "a
b"
rm -f prefix.result
PATH=bin1:$PATH CCACHE_PREFIX_CPP="prefix-a.sh prefix-b.sh" $CCACHE_COMPILE -c file.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
expect_content prefix.result "a
b"
# -------------------------------------------------------------------------
TEST "Files in cache"
for i in $(seq 32); do
generate_code $i test$i.c
$CCACHE_COMPILE -c test$i.c
done
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 32
expect_stat files_in_cache 32
# -------------------------------------------------------------------------
TEST "Direct .i compile"
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$COMPILER -c test1.c -E >test1.i
$CCACHE_COMPILE -c test1.i
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "-x c"
ln -f test1.c test1.ccc
$CCACHE_COMPILE -x c -c test1.ccc
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -x c -c test1.ccc
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "-xc"
ln -f test1.c test1.ccc
$CCACHE_COMPILE -xc -c test1.ccc
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -xc -c test1.ccc
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "-x none"
$CCACHE_COMPILE -x assembler -x none -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -x assembler -x none -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "-x unknown"
$CCACHE_COMPILE -x unknown -c test1.c 2>/dev/null
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat unsupported_source_language 1
# -------------------------------------------------------------------------
if ! $HOST_OS_WINDOWS; then
TEST "-x c -c /dev/null"
$CCACHE_COMPILE -x c -c /dev/null -o null.o 2>/dev/null
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -x c -c /dev/null -o null.o 2>/dev/null
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
fi
# -------------------------------------------------------------------------
TEST "-D not hashed"
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -DNOT_AFFECTING=1 -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "-S"
$CCACHE_COMPILE -S test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -S test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.s
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
$CCACHE_COMPILE -c test1.s
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
# -------------------------------------------------------------------------
if ! $HOST_OS_WINDOWS; then
TEST "-frecord-gcc-switches"
if $COMPILER -frecord-gcc-switches -c test1.c >&/dev/null; then
$CCACHE_COMPILE -frecord-gcc-switches -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -frecord-gcc-switches -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
$CCACHE_COMPILE -frecord-gcc-switches -Wall -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
$CCACHE_COMPILE -frecord-gcc-switches -Wall -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
fi
fi
# -------------------------------------------------------------------------
TEST "CCACHE_DISABLE set when executing compiler"
cat >compiler.sh <<EOF
#!/bin/sh
printf "%s" "\${CCACHE_DISABLE}" >>CCACHE_DISABLE.value
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
backdate compiler.sh
$CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_content CCACHE_DISABLE.value '11' # preprocessor + compiler
# -------------------------------------------------------------------------
if ! ( $HOST_OS_WINDOWS && $COMPILER_TYPE_CLANG ) && [ -n "$COMPILER_ARGS" ] ; then
TEST "CCACHE_COMPILER"
$COMPILER -c -o reference_test1.o test1.c
export CCACHE_DEBUG=1
export CCACHE_DEBUGDIR=/tmp/a
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
export CCACHE_DEBUGDIR=/tmp/b
CCACHE_COMPILER=$COMPILER $CCACHE \
non_existing_compiler_will_be_overridden_anyway \
$COMPILER_ARGS -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
CCACHE_COMPILER=$COMPILER $CCACHE same/for/relative \
$COMPILER_ARGS -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
CCACHE_COMPILER=$COMPILER $CCACHE /and/even/absolute/compilers \
$COMPILER_ARGS -c test1.c
expect_stat preprocessed_cache_hit 3
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_object_files reference_test1.o test1.o
fi
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILERTYPE"
if $HOST_OS_WINDOWS; then
FAKE_GCC=./gcc.sh
else
FAKE_GCC=./gcc
fi
$CCACHE_COMPILE -c test1.c
cat >$FAKE_GCC <<EOF
#!/bin/sh
EOF
chmod +x $FAKE_GCC
CCACHE_DEBUG=1 $CCACHE $FAKE_GCC -c test1.c
compiler_type=$(sed -En 's/.*Compiler type: (.*)/\1/p' test1.o.*.ccache-log)
if [ "$compiler_type" != gcc ]; then
test_failed "Compiler type $compiler_type != gcc"
fi
rm test1.o.*.ccache-log
CCACHE_COMPILERTYPE=clang CCACHE_DEBUG=1 $CCACHE $FAKE_GCC -c test1.c
compiler_type=$(sed -En 's/.*Compiler type: (.*)/\1/p' test1.o.*.ccache-log)
if [ "$compiler_type" != clang ]; then
test_failed "Compiler type $compiler_type != clang"
fi
# -------------------------------------------------------------------------
TEST "CCACHE_PATH"
if $RUN_WIN_XFAIL; then
override_path=`pwd`/override_path
mkdir $override_path
cat >$override_path/cc <<EOF
#!/bin/sh
touch override_path_compiler_executed
EOF
chmod +x $override_path/cc
CCACHE_PATH=$override_path $CCACHE cc -c test1.c
if [ ! -f override_path_compiler_executed ]; then
test_failed "CCACHE_PATH had no effect"
fi
fi
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILERCHECK=mtime"
cat >compiler.sh <<EOF
#!/bin/sh
exec $COMPILER "\$@"
# A comment
EOF
chmod +x compiler.sh
backdate compiler.sh
CCACHE_COMPILERCHECK=mtime $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
sed_in_place 's/comment/yoghurt/' compiler.sh # Don't change the size
chmod +x compiler.sh
backdate compiler.sh # Don't change the timestamp
CCACHE_COMPILERCHECK=mtime $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
touch compiler.sh
CCACHE_COMPILERCHECK=mtime $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILERCHECK=content"
cat >compiler.sh <<EOF
#!/bin/sh
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
CCACHE_COMPILERCHECK=content $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
CCACHE_COMPILERCHECK=content $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
echo "# Compiler upgrade" >>compiler.sh
CCACHE_COMPILERCHECK=content $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILERCHECK=none"
cat >compiler.sh <<EOF
#!/bin/sh
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
CCACHE_COMPILERCHECK=none $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
CCACHE_COMPILERCHECK=none $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
echo "# Compiler upgrade" >>compiler.sh
CCACHE_COMPILERCHECK=none $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILERCHECK=string"
cat >compiler.sh <<EOF
#!/bin/sh
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
CCACHE_COMPILERCHECK=string:foo $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
CCACHE_COMPILERCHECK=string:foo $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
CCACHE_COMPILERCHECK=string:bar $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
CCACHE_COMPILERCHECK=string:bar $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILERCHECK=command"
if $RUN_WIN_XFAIL; then
cat >compiler.sh <<EOF
#!/bin/sh
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
CCACHE_COMPILERCHECK='echo %compiler%' $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
echo "# Compiler upgrade" >>compiler.sh
CCACHE_COMPILERCHECK="echo ./compiler.sh" $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
cat <<EOF >foobar.sh
#!/bin/sh
echo foo
echo bar
EOF
chmod +x foobar.sh
CCACHE_COMPILERCHECK='./foobar.sh' $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
CCACHE_COMPILERCHECK='echo foo; echo bar' $CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
fi
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILERCHECK=unknown_command"
cat >compiler.sh <<EOF
#!/bin/sh
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
CCACHE_COMPILERCHECK="unknown_command" $CCACHE ./compiler.sh -c test1.c 2>/dev/null
expect_stat compiler_check_failed 1
# -------------------------------------------------------------------------
if ! $HOST_OS_WINDOWS; then
TEST "CCACHE_UMASK"
saved_umask=$(umask)
umask 022
export CCACHE_UMASK=002
export CCACHE_TEMPDIR=$CCACHE_DIR/tmp
$CCACHE -C >/dev/null
expect_perm "$CCACHE_DIR" drwxrwxr-x
expect_perm "$CCACHE_DIR/0" drwxrwxr-x
expect_perm "$CCACHE_DIR/0/stats" -rw-rw-r--
rm -rf $CCACHE_DIR
$CCACHE -c >/dev/null
expect_perm "$CCACHE_DIR" drwxrwxr-x
expect_perm "$CCACHE_DIR/0" drwxrwxr-x
expect_perm "$CCACHE_DIR/0/stats" -rw-rw-r--
rm -rf $CCACHE_DIR
$CCACHE -z >/dev/null
expect_perm "$CCACHE_DIR" drwxrwxr-x
expect_perm "$CCACHE_DIR/0" drwxrwxr-x
expect_perm "$CCACHE_DIR/0/stats" -rw-rw-r--
rm -rf $CCACHE_DIR
cat <<EOF >test.c
int main() {}
EOF
# A cache-miss case which affects the stats file on level 1:
$CCACHE -M 5 >/dev/null
$CCACHE_COMPILE -MMD -c test.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
result_file=$(find "$CCACHE_DIR" -name '*R')
level_2_dir=$(dirname "$result_file")
level_1_dir=$(dirname $(dirname "$result_file"))
expect_perm test.o -rw-r--r--
expect_perm test.d -rw-r--r--
expect_perm "$CCACHE_CONFIGPATH" -rw-rw-r--
expect_perm "$CCACHE_DIR" drwxrwxr-x
expect_perm "$CCACHE_DIR/tmp" drwxrwxr-x
expect_perm "$level_1_dir" drwxrwxr-x
expect_perm "$level_1_dir/stats" -rw-rw-r--
expect_perm "$level_2_dir" drwxrwxr-x
expect_perm "$result_file" -rw-rw-r--
rm test.o test.d
$CCACHE_COMPILE -MMD -c test.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_perm test.o -rw-r--r--
expect_perm test.d -rw-r--r--
$CCACHE_COMPILE -o test test.o
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat called_for_link 1
expect_perm test -rwxr-xr-x
# A non-cache-miss case which affects the stats file on level 2:
rm -rf "$CCACHE_DIR"
$CCACHE_COMPILE --version >/dev/null
expect_stat no_input_file 1
stats_file=$(find "$CCACHE_DIR" -name stats)
level_2_dir=$(dirname "$stats_file")
level_1_dir=$(dirname $(dirname "$stats_file"))
expect_perm "$CCACHE_DIR" drwxrwxr-x
expect_perm "$level_1_dir" drwxrwxr-x
expect_perm "$level_2_dir" drwxrwxr-x
expect_perm "$stats_file" -rw-rw-r--
umask $saved_umask
fi
# -------------------------------------------------------------------------
TEST "No object file due to bad prefix"
cat <<'EOF' >test_no_obj.c
int test_no_obj;
EOF
cat <<'EOF' >no-object-prefix.sh
#!/bin/sh
# Emulate no object file from the compiler.
EOF
chmod +x no-object-prefix.sh
CCACHE_PREFIX=$(pwd)/no-object-prefix.sh $CCACHE_COMPILE -c test_no_obj.c
expect_stat compiler_produced_no_output 1
CCACHE_PREFIX=$(pwd)/no-object-prefix.sh $CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat files_in_cache 0
expect_stat compiler_produced_no_output 2
# -------------------------------------------------------------------------
TEST "-fsyntax-only"
echo existing >test1.o
$CCACHE_COMPILE -fsyntax-only test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_content test1.o existing
rm test1.o
$CCACHE_COMPILE -fsyntax-only test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_missing test1.o
# -------------------------------------------------------------------------
if $RUN_WIN_XFAIL; then
TEST "-fsyntax-only /dev/null"
echo existing >null.o
$CCACHE_COMPILE -fsyntax-only -x c /dev/null
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_content null.o existing
rm null.o
$CCACHE_COMPILE -fsyntax-only -x c /dev/null
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_missing null.o
# -------------------------------------------------------------------------
TEST "No object file due to -fsyntax-only"
echo '#warning This triggers a compiler warning' >stderr.c
$COMPILER -Wall stderr.c -fsyntax-only 2>reference_stderr.txt
expect_contains reference_stderr.txt "This triggers a compiler warning"
$CCACHE_COMPILE -Wall stderr.c -fsyntax-only 2>stderr.txt
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_text_content reference_stderr.txt stderr.txt
# Intentionally compiling with "-c" here but not above.
$CCACHE_COMPILE -Wall -c stderr.c -fsyntax-only 2>stderr.txt
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_equal_text_content reference_stderr.txt stderr.txt
fi
# -------------------------------------------------------------------------
TEST "Empty object file"
cat <<'EOF' >test_empty_obj.c
int test_empty_obj;
EOF
cat <<'EOF' >empty-object-prefix.sh
#!/bin/sh
# Emulate empty object file from the compiler.
touch test_empty_obj.o
EOF
chmod +x empty-object-prefix.sh
CCACHE_PREFIX=`pwd`/empty-object-prefix.sh $CCACHE_COMPILE -c test_empty_obj.c
expect_stat compiler_produced_empty_output 1
# -------------------------------------------------------------------------
TEST "Output to /dev/null"
if ! $HOST_OS_WINDOWS; then
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c test1.c -o /dev/null
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
fi
# -------------------------------------------------------------------------
mkdir dir
chmod a-w dir
if ! touch dir/test 2>/dev/null; then
TEST "Failure to write output file"
mkdir dir
$CCACHE_COMPILE -c test1.c -o dir/test1.o
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat bad_output_file 0
rm dir/test1.o
chmod a-w dir
if $RUN_WIN_XFAIL; then
$CCACHE_COMPILE -c test1.c -o dir/test1.o 2>/dev/null
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat bad_output_file 1
fi
fi
# -------------------------------------------------------------------------
TEST "Caching stderr"
cat <<EOF >stderr.c
int stderr(void)
{
// Trigger warning by having no return statement.
}
EOF
$COMPILER -c -Wall -W -c stderr.c 2>reference_stderr.txt
$CCACHE_COMPILE -Wall -W -c stderr.c 2>stderr.txt
expect_equal_text_content reference_stderr.txt stderr.txt
# -------------------------------------------------------------------------
TEST "Line number in compiler warning"
cat <<'EOF' >hello.h
#define A a
// comment
#define B \
x \
y \
z
int hello(void) {
// trigger warning by having no return statement
}
EOF
cat <<'EOF' >hello.c
#include "hello.h"
EOF
export CCACHE_DEBUG=1
$COMPILER -c -Wall -c hello.c 2>stderr_1_ref.txt
$CCACHE_COMPILE -Wall -c hello.c 2>stderr_1.txt
expect_equal_text_content stderr_1_ref.txt stderr_1.txt
sed -i 's/comment/comment\n/' hello.h
$COMPILER -c -Wall -c hello.c 2>stderr_2_ref.txt
$CCACHE_COMPILE -Wall -c hello.c 2>stderr_2.txt
expect_equal_text_content stderr_2_ref.txt stderr_2.txt
# -------------------------------------------------------------------------
TEST "Stderr from cpp not emitted"
cat >compiler.sh <<EOF
#!/bin/sh
if [ \$1 = -E ]; then
echo preprocessed
printf "[%s]" cpp_stderr >&2
else
echo object >test1.o
printf "[%s]" cc_stderr >&2
fi
EOF
chmod +x compiler.sh
stderr=$($CCACHE ./compiler.sh -c test1.c 2>stderr)
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_content stderr "[cc_stderr]"
# -------------------------------------------------------------------------
TEST "Stderr and dependency file"
cat <<EOF >test.c
#warning Foo
EOF
$COMPILER -c test.c -MMD 2>reference.stderr
mv test.d reference.d
$CCACHE_COMPILE -c test.c -MMD 2>test.stderr
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_equal_text_content reference.stderr test.stderr
expect_equal_content reference.d test.d
$CCACHE_COMPILE -c test.c -MMD 2>test.stderr
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_equal_text_content reference.stderr test.stderr
expect_equal_content reference.d test.d
# -------------------------------------------------------------------------
TEST "Caching stdout and stderr"
cat >compiler.sh <<EOF
#!/bin/sh
if [ \$1 = -E ] || ! echo "\$*" | grep -q '\.i\$'; then
printf "cpp_err|" >&2
fi
if [ \$1 != -E ]; then
printf "cc_err|" >&2
printf "cc_out|"
fi
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
$CCACHE ./compiler.sh -c test1.c >stdout 2>stderr
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_content stdout "cc_out|"
expect_content stderr "cpp_err|cc_err|"
$CCACHE ./compiler.sh -c test1.c >stdout 2>stderr
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_content stdout "cc_out|"
expect_content stderr "cpp_err|cc_err|"
# -------------------------------------------------------------------------
TEST "--zero-stats"
$CCACHE_COMPILE -c test1.c
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
$CCACHE -z >/dev/null
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat files_in_cache 1
# -------------------------------------------------------------------------
TEST "--clear"
$CCACHE_COMPILE -c test1.c
$CCACHE_COMPILE -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
$CCACHE -C >/dev/null
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 0
# -------------------------------------------------------------------------
TEST "-P -c"
$CCACHE_COMPILE -P -c test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -P -c test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "-P -E"
$CCACHE_COMPILE -P -E test1.c >/dev/null
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat called_for_preprocessing 1
# -------------------------------------------------------------------------
if $COMPILER -c -Wa,-a test1.c >&/dev/null; then
TEST "-Wa,-a"
$CCACHE_COMPILE -c -Wa,-a test1.c >first.lst
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c -Wa,-a test1.c >second.lst
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_equal_content first.lst second.lst
fi
# -------------------------------------------------------------------------
if $COMPILER -c -Wa,-a=test1.lst,-L test1.c >&/dev/null && [ -e test1.lst ]; then
TEST "-Wa,-a=file"
# Check that -Wa options after -a are handled.
$CCACHE_COMPILE -c -Wa,-a=test1.lst,-L test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
rm test1.lst
$CCACHE_COMPILE -c -Wa,-a=test1.lst,-L test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
rm test1.lst
# Check that the filename can be changed without changing the hash.
$CCACHE_COMPILE -c -Wa,-a=test2.lst,-L test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
rm test2.lst
# Check that -Wa options before -a are handled.
$CCACHE_COMPILE -c -Wa,-L,-a=test1.lst test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
rm test1.lst
$CCACHE_COMPILE -c -Wa,-L,-a=test1.lst test1.c
expect_stat preprocessed_cache_hit 3
expect_stat cache_miss 2
rm test1.lst
# Check that -Wa,-aOPTIONS=file is different than -Wa,-a=file.
$CCACHE_COMPILE -c -Wa,-as=test1.lst test1.c
expect_stat preprocessed_cache_hit 3
expect_stat cache_miss 3
rm test1.lst
$CCACHE_COMPILE -c -Wa,-as=test1.lst test1.c
expect_stat preprocessed_cache_hit 4
expect_stat cache_miss 3
rm test1.lst
# Multiple -Wa,-a options are not supported.
$CCACHE_COMPILE -c -Wa,-a=test1.lst -Wa,-as=test1.lst test1.c
expect_stat preprocessed_cache_hit 4
expect_stat cache_miss 3
expect_stat unsupported_compiler_option 1
rm test1.lst
fi
# -------------------------------------------------------------------------
TEST "-Wp,-P"
$CCACHE_COMPILE -c -Wp,-P test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c -Wp,-P test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
# -------------------------------------------------------------------------
TEST "-Wp,-P,-DFOO"
# Check that -P disables ccache when used in combination with other -Wp,
# options. (-P removes preprocessor information in such a way that the
# object file from compiling the preprocessed file will not be equal to the
# object file produced when compiling without ccache.)
$CCACHE_COMPILE -c -Wp,-P,-DFOO test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat unsupported_compiler_option 1
$CCACHE_COMPILE -c -Wp,-DFOO,-P test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat unsupported_compiler_option 2
# -------------------------------------------------------------------------
TEST "-Wp,-D"
$CCACHE_COMPILE -c -Wp,-DFOO test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c -Wp,-DFOO test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
$CCACHE_COMPILE -c -DFOO test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
$CCACHE_COMPILE -c -DFOO test1.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
# -------------------------------------------------------------------------
if touch empty.c && $COMPILER -c -- empty.c 2>/dev/null; then
TEST "--"
$CCACHE_COMPILE -c -- test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE_COMPILE -c -- test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
fi
# -------------------------------------------------------------------------
TEST "-march=native, GCC"
if $HOST_OS_WINDOWS; then
compiler="$TEST_BASE_DIR/fake-compilers/gcc-march-native-win.sh"
else
compiler="$TEST_BASE_DIR/fake-compilers/gcc-march-native.sh"
fi
CC1_ARGS=one $CCACHE "${compiler}" -march=native -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
CC1_ARGS=one $CCACHE "${compiler}" -march=native -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
CC1_ARGS=two $CCACHE "${compiler}" -march=native -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
CC1_ARGS=two $CCACHE "${compiler}" -march=native -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
# -------------------------------------------------------------------------
TEST "-march=native, Clang"
CC1_ARGS=one $CCACHE "$TEST_BASE_DIR/fake-compilers/clang-march-native.sh" -march=native -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
CC1_ARGS=one $CCACHE "$TEST_BASE_DIR/fake-compilers/clang-march-native.sh" -march=native -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
CC1_ARGS=two $CCACHE "$TEST_BASE_DIR/fake-compilers/clang-march-native.sh" -march=native -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
CC1_ARGS=two $CCACHE "$TEST_BASE_DIR/fake-compilers/clang-march-native.sh" -march=native -c test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
# -------------------------------------------------------------------------
if $COMPILER -march=native -c test1.c 2>/dev/null; then
TEST "-march=native, no CWD in input hash"
mkdir a b
cp test1.c a
cp test1.c b
cd a
$CCACHE_COMPILE -march=native -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
cd ../b
$CCACHE_COMPILE -march=native -c test1.c
cd ..
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
fi
# -------------------------------------------------------------------------
TEST "Handling of compiler-only arguments"
cat >compiler.sh <<EOF
#!/bin/sh
printf "(%s)" "\$*" >>compiler.args
[ \$1 = -E ] && echo test || echo test >test1.o
EOF
chmod +x compiler.sh
backdate compiler.sh
$CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_content_pattern compiler.args "(-E -o * test1.c)(-c -o test1.o test1.c)"
rm compiler.args
$CCACHE ./compiler.sh -c test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
expect_content_pattern compiler.args "(-E -o * test1.c)"
rm compiler.args
# Even though -Werror is not passed to the preprocessor, it should be part
# of the hash, so we expect a cache miss:
$CCACHE ./compiler.sh -c -Werror -rdynamic test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 2
expect_stat files_in_cache 2
expect_content_pattern compiler.args "(-E -o * test1.c)(-Werror -rdynamic -c -o test1.o test1.c)"
rm compiler.args
# -------------------------------------------------------------------------
if $COMPILER -Wdelete-non-virtual-dtor -c test1.c 2>/dev/null && ! $COMPILER -Werror -Wdelete-non-virtual-dtor -c test1.c 2>/dev/null; then
TEST "Ordering of warning options"
if $CCACHE_COMPILE -Werror -Wdelete-non-virtual-dtor -c test1.c 2>stderr.txt; then
test_failed "-Werror -Wdelete-non-virtual-dtor did not result in an error; stderr: [$(<stderr.txt)]"
fi
if ! $CCACHE_COMPILE -Wdelete-non-virtual-dtor -Werror -c test1.c 2>stderr.txt; then
test_failed "-Wdelete-non-virtual-dtor -Werror resulted in an error; stderr: [$(<stderr.txt)]"
fi
fi
# -------------------------------------------------------------------------
if ! $COMPILER_USES_MSVC; then
for src in test1.c build/test1.c; do
for obj in test1.o build/test1.o; do
TEST "Dependency file content, $src -o $obj"
mkdir build
cp test1.c build
$CCACHE_COMPILE -c -MMD $src -o $obj
dep=$(echo $obj | sed 's/\.o$/.d/')
expect_content $dep "$obj: $src"
done
done
fi
# -------------------------------------------------------------------------
if $RUN_WIN_XFAIL; then
TEST "Buggy GCC 6 cpp"
cat >buggy-cpp.sh <<EOF
#!/bin/sh
if echo "\$*" | grep -- -D >/dev/null; then
$COMPILER "\$@"
else
# Mistreat the preprocessor output in the same way as GCC 6 does.
$COMPILER "\$@" |
sed -e '/^# 1 "<command-line>"\$/ a\\
# 31 "<command-line>"' \\
-e 's/^# 1 "<command-line>" 2\$/# 32 "<command-line>" 2/'
fi
exit 0
EOF
cat <<'EOF' >file.c
int foo;
EOF
chmod +x buggy-cpp.sh
$CCACHE ./buggy-cpp.sh -c file.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
$CCACHE ./buggy-cpp.sh -DNOT_AFFECTING=1 -c file.c
expect_stat direct_cache_hit 0
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
fi
# -------------------------------------------------------------------------
TEST ".incbin"
touch empty.bin
cat <<EOF >incbin.c
__asm__(".incbin \"empty.bin\"");
EOF
$CCACHE_COMPILE -c incbin.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat unsupported_code_directive 1
cat <<EOF >incbin.c
__asm__(".incbin" " \"empty.bin\"");
EOF
$CCACHE_COMPILE -c incbin.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat unsupported_code_directive 2
cat <<EOF >incbin.s
.incbin "empty.bin";
EOF
$CCACHE_COMPILE -c incbin.s
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 0
expect_stat unsupported_code_directive 3
cat <<EOF >incbin.cpp
struct A {
void incbin() const {}
};
void f()
{
A a;
a.incbin();
}
EOF
if $CCACHE_COMPILE -x c++ -c incbin.cpp 2>/dev/null; then
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat unsupported_code_directive 3
fi
# -------------------------------------------------------------------------
if ! $HOST_OS_WINDOWS; then
TEST "UNCACHED_ERR_FD set when executing preprocessor and compiler"
cat >compiler.sh <<'EOF'
#!/bin/sh
if [ "$1" = "-E" ]; then
echo preprocessed
printf ${N}Pu >&$UNCACHED_ERR_FD
else
echo compiled >test1.o
printf ${N}Cc >&2
printf ${N}Cu >&$UNCACHED_ERR_FD
fi
EOF
chmod +x compiler.sh
N=1 $CCACHE ./compiler.sh -c test1.c 2>stderr.txt
stderr=$(cat stderr.txt)
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
if [ "$stderr" != "1Pu1Cu1Cc" ]; then
test_failed "Unexpected stderr: $stderr != 1Pu1Cu1Cc"
fi
N=2 $CCACHE ./compiler.sh -c test1.c 2>stderr.txt
stderr=$(cat stderr.txt)
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
if [ "$stderr" != "2Pu1Cc" ]; then
test_failed "Unexpected stderr: $stderr != 2Pu1Cc"
fi
fi
if ! $HOST_OS_WINDOWS; then
TEST "UNCACHED_ERR_FD not set when falling back to the original command"
# -------------------------------------------------------------------------
$CCACHE bash -c 'echo $UNCACHED_ERR_FD' >uncached_err_fd.txt
expect_content uncached_err_fd.txt ""
fi
# -------------------------------------------------------------------------
TEST "Invalid boolean environment configuration options"
for invalid_val in 0 false FALSE disable DISABLE no NO; do
CCACHE_DISABLE=$invalid_val $CCACHE $COMPILER --version >&/dev/null
if [ $? -eq 0 ] ; then
test_failed "boolean env var '$invalid_val' should be rejected"
fi
CCACHE_NODISABLE=$invalid_val $CCACHE $COMPILER --version >&/dev/null
if [ $? -eq 0 ] ; then
test_failed "boolean env var '$invalid_val' should be rejected"
fi
done
# -------------------------------------------------------------------------
TEST "--hash-file"
$CCACHE --hash-file /dev/null > hash.out
printf "a" | $CCACHE --hash-file - >> hash.out
hash_0='af1396svbud1kqg40jfa6reciicrpcisi'
hash_1='17765vetiqd4ae95qpbhfb1ut8gj42r6m'
if grep "$hash_0" hash.out >/dev/null 2>&1 && \
grep "$hash_1" hash.out >/dev/null 2>&1; then
: OK
else
test_failed "Unexpected output of --hash-file"
fi
}
# =============================================================================
SUITE_base_SETUP() {
generate_code 1 test1.c
}
SUITE_base() {
base_tests
}
|