15ae59decSJulio Merino 25ae59decSJulio MerinoThis directory contains regression tests for make(1). 35ae59decSJulio Merino 45ae59decSJulio MerinoTo invoke the tests, please refer to tests(7). 55ae59decSJulio Merino 65ae59decSJulio Merino---------------------------------------------------------------------------- 75ae59decSJulio Merino 85ae59decSJulio MerinoThe rest of this file is intended for developers. 95ae59decSJulio Merino 105ae59decSJulio MerinoThe tests are invoked via the test.sh script or prove(1) from p5-Test-Harness. 115ae59decSJulio MerinoTests are normally executed in a special test directory that is built under 125ae59decSJulio Merino/tmp. The reason for this is, that make tests are generally influenced by 135ae59decSJulio Merinoall file in a directory, by files in one of make's obscure object directories 145ae59decSJulio Merinoas well as in other directories make happens to look into. Therefor the 155ae59decSJulio Merinotest scripts build a clean environment in the temp directory and the 165ae59decSJulio Merinotests are executed by cd-ing into that directory and invoking make. The 175ae59decSJulio Merinooutput of the make run (standard output, standard error and the exit status) 185ae59decSJulio Merinoare written into files that are created in another directory. So the layout 195ae59decSJulio Merinofor the shell/builtin test looks like: 205ae59decSJulio Merino 215ae59decSJulio Merino ./shell/builtin/ - directory with test stuff 225ae59decSJulio Merino /tmp/make.${USER}/shell/builtin - actual test directory 235ae59decSJulio Merino /tmp/make.${USER}/shell/builtin.OUTPUT - output files 245ae59decSJulio Merino 255ae59decSJulio MerinoSo a full test consists of the following steps: 265ae59decSJulio Merino 275ae59decSJulio Merino setup - Set up the test environment by creating the test directory 285ae59decSJulio Merino and populating it with the needed files. If the test 295ae59decSJulio Merino directory already exists an error is printed. 305ae59decSJulio Merino 315ae59decSJulio Merino run - Run the test and produce the output into the output 325ae59decSJulio Merino directory. 335ae59decSJulio Merino 345ae59decSJulio Merino show - Show the result files on the screen. 355ae59decSJulio Merino 365ae59decSJulio Merino compare - Compare the results in the output directory with those 375ae59decSJulio Merino in the test source directory. This just prints whether 385ae59decSJulio Merino the test was ok or not in the format used by prove(1). 395ae59decSJulio Merino 405ae59decSJulio Merino diff - Diff the output files and the expected output files. 415ae59decSJulio Merino 425ae59decSJulio Merino reset - Reset the test to its initial state. 435ae59decSJulio Merino 445ae59decSJulio Merino clean - Remove both the test directory and the output directory. 455ae59decSJulio Merino 465ae59decSJulio MerinoEach of these steps can independently be invoked with the test script 475ae59decSJulio Merinocontained in each directory. These test scripts are called test.t. 485ae59decSJulio MerinoAdditionally the scripts understand the following commands: 495ae59decSJulio Merino 505ae59decSJulio Merino test - Run setup, run and compare. 515ae59decSJulio Merino 525ae59decSJulio Merino prove - Run setup, run, compare and clean. This is identically 535ae59decSJulio Merino to invoking the script without an argument. 545ae59decSJulio Merino 555ae59decSJulio Merino desc - Print a short test description. 565ae59decSJulio Merino 575ae59decSJulio Merino update - Update the expected results from the actual results. 585ae59decSJulio Merino 595ae59decSJulio MerinoThe test script has the following syntax: 605ae59decSJulio Merino 615ae59decSJulio Merino % test.t [-v] [-m path_to_make_binary] command 625ae59decSJulio Merino 635ae59decSJulio MerinoTo invoke it via prove(1) use: 645ae59decSJulio Merino 655ae59decSJulio Merino % [MAKE_PROG=path_to_make_binary] prove [options] [files/directories] 665ae59decSJulio Merino 675ae59decSJulio MerinoExample: 685ae59decSJulio Merino % sh test.t -m `pwd`/../obj/make run 695ae59decSJulio Merino % MAKE_PROG=/usr/obj/usr/src/usr.bin/make/make prove -r 705ae59decSJulio Merino 715ae59decSJulio MerinoThe test scripts use the following environment variables that can be set 725ae59decSJulio Merinoby the user in the test script's environment: 735ae59decSJulio Merino 745ae59decSJulio Merino WORK_BASE 755ae59decSJulio Merino - Base directory for working files. If not set 765ae59decSJulio Merino /tmp/make.${USER} is used. 775ae59decSJulio Merino 785ae59decSJulio Merino MAKE_PROG 795ae59decSJulio Merino - Path to the make program to test. If not set 805ae59decSJulio Merino /usr/bin/make is used. 815ae59decSJulio Merino 825ae59decSJulio MerinoThe following variables are available to test scripts: 835ae59decSJulio Merino 845ae59decSJulio Merino SRC_BASE 855ae59decSJulio Merino - test source base directory. This is determined by 865ae59decSJulio Merino repeatedly doing cd .. and checking for common.sh. 875ae59decSJulio Merino Therefor this can fail if a test source directory is 885ae59decSJulio Merino actually a symbolic link and is physically not located 895ae59decSJulio Merino below the directory containing common.sh. 905ae59decSJulio Merino 915ae59decSJulio Merino SUBDIR 925ae59decSJulio Merino - subdirectory below WORK_BASE and SRC_BASE for current test 935ae59decSJulio Merino 945ae59decSJulio Merino WORK_DIR 955ae59decSJulio Merino - ${WORK_BASE}/${SUBDIR} 965ae59decSJulio Merino 975ae59decSJulio Merino SRC_DIR 985ae59decSJulio Merino - ${SRC_BASE}/${SUBDIR} 995ae59decSJulio Merino 1005ae59decSJulio MerinoThe following variables and functions may be defined by the test script. 1015ae59decSJulio MerinoThis also lists special filenames. 1025ae59decSJulio Merino 1035ae59decSJulio Merino DESC 1045ae59decSJulio Merino A one-line description of the test. 1055ae59decSJulio Merino 1065ae59decSJulio Merino TEST_MAKE_DIRS 1075ae59decSJulio Merino A list of pairs of directory names and modes. These 1085ae59decSJulio Merino directories are created during setup and reset. When 1095ae59decSJulio Merino the directory already exists (during reset) only the 1105ae59decSJulio Merino mode change is applied. 1115ae59decSJulio Merino 1125ae59decSJulio Merino TEST_MAKE_DIRS="subdir 775 subdir/sub 555" 1135ae59decSJulio Merino 1145ae59decSJulio Merino TEST_COPY_FILES 1155ae59decSJulio Merino A list of pairs of file names and modes. These files 1165ae59decSJulio Merino are copied from the source to the working directory 1175ae59decSJulio Merino during setup and reset. When the file already exists 1185ae59decSJulio Merino (during reset) only the mode change is applied. Files 1195ae59decSJulio Merino may be copied from/to sub-directories. The sub-directory 1205ae59decSJulio Merino in the working directory must already exists (see 1215ae59decSJulio Merino TEST_MAKE_DIRS). 1225ae59decSJulio Merino 1235ae59decSJulio Merino TEST_COPY_FILES="libtest.a 444 subdir/libfoo.a 444" 1245ae59decSJulio Merino 1255ae59decSJulio Merino TEST_TOUCH 1265ae59decSJulio Merino List of pairs of file names and arguments to touch(1). 1275ae59decSJulio Merino During setup and reset for each list element touch(1) 1285ae59decSJulio Merino is executed. 1295ae59decSJulio Merino 1305ae59decSJulio Merino TEST_TOUCH="file1 '-t 200501011257'" 1315ae59decSJulio Merino 1325ae59decSJulio Merino TEST_LINK 1335ae59decSJulio Merino List of pairs of filenames. Each pair is passed to ln(1). 1345ae59decSJulio Merino All names are prefixed with the working directory. 1355ae59decSJulio Merino 1365ae59decSJulio Merino Makefile 1375ae59decSJulio Merino If a file with this name exists in the source directory 1385ae59decSJulio Merino it is automatically copied to the working directory. 1395ae59decSJulio Merino 1405ae59decSJulio Merino setup_test() 1415ae59decSJulio Merino If this function exists it is executed at the end of the 1425ae59decSJulio Merino setup. 1435ae59decSJulio Merino 1445ae59decSJulio Merino reset_test() 1455ae59decSJulio Merino If this function exists it is executed at the end of the 1465ae59decSJulio Merino reset. 1475ae59decSJulio Merino 1485ae59decSJulio Merino TEST_CLEAN_FILES 1495ae59decSJulio Merino A list of file to be deleted when resetting. 1505ae59decSJulio Merino 1515ae59decSJulio Merino TEST_N 1525ae59decSJulio Merino Number of tests in this script. If not set this is assumed 1535ae59decSJulio Merino to be 1. 1545ae59decSJulio Merino 1555ae59decSJulio Merino TEST_<number> 1565ae59decSJulio Merino Arguments to make for test number <number>. If not set 1575ae59decSJulio Merino the default argument of test<number> is used. To run a test 1585ae59decSJulio Merino without argument to make, set TEST_<number> to the empty string. 1595ae59decSJulio Merino 1605ae59decSJulio Merino TEST_<number>_SKIP 1615ae59decSJulio Merino To skip a test (for whatever reason) this should be set 1625ae59decSJulio Merino to a string explaining the reason for skipping the test. 1635ae59decSJulio Merino 1645ae59decSJulio Merino TEST_<number>_TODO 1655ae59decSJulio Merino For a test that should fail this is a short string describing 1665ae59decSJulio Merino what the problem in make(1) is that should be fixed. 1675ae59decSJulio Merino 1685ae59decSJulio Merino run_test() 1695ae59decSJulio Merino Function to run a test. This function gets a single argument 1705ae59decSJulio Merino which is the number of the test to executed. The default 1715ae59decSJulio Merino function evaluates the variable TEST_<number> and calls 1725ae59decSJulio Merino make with the arguments in this variable. 1735ae59decSJulio Merino 174