1145620Sharti$FreeBSD$ 2145620Sharti 3145620ShartiThis directory contains regression tests for make(1). 4145620Sharti 5263346SjmmvTo invoke the tests, please refer to tests(7). 6145620Sharti 7146822Sharti---------------------------------------------------------------------------- 8145620Sharti 9228975SuqsThe rest of this file is intended for developers. 10145620Sharti 11146822ShartiThe tests are invoked via the test.sh script or prove(1) from p5-Test-Harness. 12146822ShartiTests are normally executed in a special test directory that is built under 13146822Sharti/tmp. The reason for this is, that make tests are generally influenced by 14146822Shartiall file in a directory, by files in one of make's obscure object directories 15146822Shartias well as in other directories make happens to look into. Therefor the 16146822Shartitest scripts build a clean environment in the temp directory and the 17146822Shartitests are executed by cd-ing into that directory and invoking make. The 18146822Shartioutput of the make run (standard output, standard error and the exit status) 19146822Shartiare written into files that are created in another directory. So the layout 20146822Shartifor the shell/builtin test looks like: 21145620Sharti 22146822Sharti ./shell/builtin/ - directory with test stuff 23146822Sharti /tmp/make.${USER}/shell/builtin - actual test directory 24146822Sharti /tmp/make.${USER}/shell/builtin.OUTPUT - output files 25145620Sharti 26146822ShartiSo a full test consists of the following steps: 27145620Sharti 28146822Sharti setup - Set up the test environment by creating the test directory 29146822Sharti and populating it with the needed files. If the test 30146822Sharti directory already exists an error is printed. 31145620Sharti 32146822Sharti run - Run the test and produce the output into the output 33146822Sharti directory. 34145620Sharti 35146822Sharti show - Show the result files on the screen. 36145620Sharti 37146822Sharti compare - Compare the results in the output directory with those 38146822Sharti in the test source directory. This just prints whether 39146822Sharti the test was ok or not in the format used by prove(1). 40146822Sharti 41146822Sharti diff - Diff the output files and the expected output files. 42146822Sharti 43146822Sharti reset - Reset the test to its initial state. 44146822Sharti 45146822Sharti clean - Remove both the test directory and the output directory. 46146822Sharti 47146822ShartiEach of these steps can independently be invoked with the test script 48146822Sharticontained in each directory. These test scripts are called test.t. 49146822ShartiAdditionally the scripts understand the following commands: 50146822Sharti 51146822Sharti test - Run setup, run and compare. 52146822Sharti 53146822Sharti prove - Run setup, run, compare and clean. This is identically 54146822Sharti to invoking the script without an argument. 55146822Sharti 56146822Sharti desc - Print a short test description. 57146822Sharti 58146822Sharti update - Update the expected results from the actual results. 59146822Sharti 60146822ShartiThe test script has the following syntax: 61146822Sharti 62146822Sharti % test.t [-v] [-m path_to_make_binary] command 63146822Sharti 64146822ShartiTo invoke it via prove(1) use: 65146822Sharti 66145620Sharti % [MAKE_PROG=path_to_make_binary] prove [options] [files/directories] 67145620Sharti 68145620ShartiExample: 69145620Sharti % sh test.t -m `pwd`/../obj/make run 70145620Sharti % MAKE_PROG=/usr/obj/usr/src/usr.bin/make/make prove -r 71145620Sharti 72146822ShartiThe test scripts use the following environment variables that can be set 73146822Shartiby the user in the test script's environment: 74145620Sharti 75146822Sharti WORK_BASE 76146822Sharti - Base directory for working files. If not set 77146822Sharti /tmp/make.${USER} is used. 78145620Sharti 79146822Sharti MAKE_PROG 80146822Sharti - Path to the make program to test. If not set 81146822Sharti /usr/bin/make is used. 82145620Sharti 83146822ShartiThe following variables are available to test scripts: 84145620Sharti 85146822Sharti SRC_BASE 86146822Sharti - test source base directory. This is determined by 87146822Sharti repeatedly doing cd .. and checking for common.sh. 88146822Sharti Therefor this can fail if a test source directory is 89146822Sharti actually a symbolic link and is physically not located 90146822Sharti below the directory containing common.sh. 91146822Sharti 92146822Sharti SUBDIR 93146822Sharti - subdirectory below WORK_BASE and SRC_BASE for current test 94146822Sharti 95146822Sharti WORK_DIR 96146822Sharti - ${WORK_BASE}/${SUBDIR} 97146822Sharti 98146822Sharti SRC_DIR 99146822Sharti - ${SRC_BASE}/${SUBDIR} 100146822Sharti 101146822ShartiThe following variables and functions may be defined by the test script. 102146822ShartiThis also lists special filenames. 103146822Sharti 104146822Sharti DESC 105146822Sharti A one-line description of the test. 106146822Sharti 107146822Sharti TEST_MAKE_DIRS 108146822Sharti A list of pairs of directory names and modes. These 109146822Sharti directories are created during setup and reset. When 110146822Sharti the directory already exists (during reset) only the 111146822Sharti mode change is applied. 112146822Sharti 113146822Sharti TEST_MAKE_DIRS="subdir 775 subdir/sub 555" 114146822Sharti 115146822Sharti TEST_COPY_FILES 116146822Sharti A list of pairs of file names and modes. These files 117146822Sharti are copied from the source to the working directory 118146822Sharti during setup and reset. When the file already exists 119146822Sharti (during reset) only the mode change is applied. Files 120146822Sharti may be copied from/to sub-directories. The sub-directory 121146822Sharti in the working directory must already exists (see 122146822Sharti TEST_MAKE_DIRS). 123146822Sharti 124146822Sharti TEST_COPY_FILES="libtest.a 444 subdir/libfoo.a 444" 125146822Sharti 126146822Sharti TEST_TOUCH 127146822Sharti List of pairs of file names and arguments to touch(1). 128146822Sharti During setup and reset for each list element touch(1) 129146822Sharti is executed. 130146822Sharti 131146822Sharti TEST_TOUCH="file1 '-t 200501011257'" 132146822Sharti 133146822Sharti TEST_LINK 134146822Sharti List of pairs of filenames. Each pair is passed to ln(1). 135146822Sharti All names are prefixed with the working directory. 136146822Sharti 137146822Sharti Makefile 138146822Sharti If a file with this name exists in the source directory 139146822Sharti it is automatically copied to the working directory. 140146822Sharti 141146822Sharti setup_test() 142146822Sharti If this function exists it is executed at the end of the 143146822Sharti setup. 144146822Sharti 145146822Sharti reset_test() 146146822Sharti If this function exists it is executed at the end of the 147146822Sharti reset. 148146822Sharti 149146822Sharti TEST_CLEAN_FILES 150146822Sharti A list of file to be deleted when resetting. 151146822Sharti 152146822Sharti TEST_N 153146822Sharti Number of tests in this script. If not set this is assumed 154146822Sharti to be 1. 155146822Sharti 156146822Sharti TEST_<number> 157146822Sharti Arguments to make for test number <number>. If not set 158146822Sharti the default argument of test<number> is used. To run a test 159146822Sharti without argument to make, set TEST_<number> to the empty string. 160146822Sharti 161146822Sharti TEST_<number>_SKIP 162146822Sharti To skip a test (for whatever reason) this should be set 163146822Sharti to a string explaining the reason for skipping the test. 164146822Sharti 165146855Sharti TEST_<number>_TODO 166146855Sharti For a test that should fail this is a short string describing 167146855Sharti what the problem in make(1) is that should be fixed. 168146855Sharti 169146822Sharti run_test() 170146822Sharti Function to run a test. This function gets a single argument 171146822Sharti which is the number of the test to executed. The default 172146822Sharti function evaluates the variable TEST_<number> and calls 173146822Sharti make with the arguments in this variable. 174146822Sharti 175