Makefile revision 270190
195158Sjmallett# $FreeBSD: head/tools/build/make_check/Makefile 270190 2014-08-20 00:33:37Z ian $ 295158Sjmallett 3222295Sobrien.MAKE.MODE= normal 4222295Sobrien 5270190Sian# Failure is handled by the invoker, don't kill other legs of a parallel build. 6270190SianMAKE_JOB_ERROR_TOKEN=no 7270190Sian 898442Sjmallett# Test for broken LHS expansion. 9107374Sru# This *must* cause make(1) to detect a recursive variable, and fail as such. 1098442Sjmallett.if make(lhs_expn) 1198442SjmallettFOO= ${BAR} 1298442SjmallettBAR${NIL}= ${FOO} 1398442SjmallettFOO${BAR}= ${FOO} 1498442Sjmallett.endif 1598442Sjmallett 1695158SjmallettDATA1= helllo 1795158SjmallettDATA2:= ${DATA1} 1895158SjmallettDATA3= ${DATA2:S/ll/rr/g} 1995158SjmallettDATA4:= ${DATA2:S/ll/rr/g} 2095158SjmallettDATA2?= allo 2195158SjmallettDATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g} 2295158SjmallettDATA2= yello 2395158SjmallettDATA1:= ${DATA5:S/l/r/g} 2496070SjmallettNIL= 2595158Sjmallett 26138432SruSMAKE= MAKEFLAGS= ${MAKE} -C ${.CURDIR} 27138317Sharti 2895158Sjmallettall: 29238143Sobrien @echo '1..16' 30245171Sobrien @${SMAKE} C_check || { ${MAKE} -C ${.CURDIR} failure ; } 31138317Sharti @echo "ok 1 - C_check # Test of -C flag existence detected no regression." 3295158Sjmallett @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \ 33138317Sharti diff -u ${.CURDIR}/regress.variables.out - || \ 34138317Sharti ${SMAKE} failure 35138317Sharti @echo "ok 2 - test_variables # Test variables detected no regression, output matches." 36138317Sharti @${SMAKE} double 2>/dev/null || ${SMAKE} failure 37138317Sharti @echo "ok 3 - test_targets # Test targets detected no regression." 38138317Sharti @${SMAKE} sysvmatch || ${SMAKE} failure 39138317Sharti @echo "ok 4 - sysvmatch # Test sysvmatch detected no regression." 40138317Sharti @! ${SMAKE} lhs_expn && true || ${SMAKE} failure 41138317Sharti @echo "ok 5 lhs_expn # Test lhs_expn detected no regression." 42138317Sharti @${SMAKE} notdef || ${SMAKE} failure 43138317Sharti @echo "ok 6 - notdef # Test notdef detected no regression." 44138317Sharti @${SMAKE} modifiers || ${SMAKE} failure 45138317Sharti @echo "ok 7 - modifiers # Test modifiers detected no regression." 46138317Sharti @${SMAKE} arith_expr || ${SMAKE} failure 47238143Sobrien @echo "ok 8 arith_expr # Test arith_expr detected no regression." 48138317Sharti @${SMAKE} PATH_exists || ${SMAKE} failure 49238143Sobrien @echo "ok 9 PATH_exists # Test PATH_exists detected no regression." 50138317Sharti @${SMAKE} double_quotes || ${SMAKE} failure 51238143Sobrien @echo "ok 10 double_quotes # Test double_quotes detected no regression." 52138317Sharti @! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure 53238143Sobrien @echo "ok 11 double_quotes2 # Test double_quotes2 detected no regression." 54138317Sharti @${SMAKE} pass_cmd_vars || ${SMAKE} failure 55238143Sobrien @echo "ok 12 pass_cmd_vars # Test pass_cmd_vars detected no regression." 56138317Sharti @${SMAKE} plus_flag || ${SMAKE} failure 57238143Sobrien @echo "ok 13 plus_flag # Test plus_flag detected no regression." 58138317Sharti @! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure 59238143Sobrien @echo "ok 14 shell # Test shell detected no regression." 60138317Sharti @${SMAKE} shell_1 || ${SMAKE} failure 61238143Sobrien @echo "ok 15 shell_1 # Test shell_1 detected no regression." 62241298Smarcel.if !defined(.PARSEDIR) 63138317Sharti @${SMAKE} shell_2 || ${SMAKE} failure 64238143Sobrien @echo "ok 16 shell_2 # Test shell_2 detected no regression." 65241298Smarcel.endif 6695158Sjmallett 67138317Sharti.if make(C_check) 68138317ShartiC_check: 69138317Sharti.endif 70138317Sharti 71105907Sjmallett.if make(double) 72100794Sjmallett# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 73100794Sjmallett# switches to using the "non-right" one, it breaks things worse than a little 74100794Sjmallett# regression test. 7595167Sjmallettdouble: 7695167Sjmallett @true 7795167Sjmallett 7895167Sjmallettdouble: 7995167Sjmallett @false 80105907Sjmallett.endif 8195167Sjmallett 82105907Sjmallett.if make(sysvmatch) 8396070Sjmallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 8496070Sjmallettsysvmatch: 8596070Sjmallett @echo EMPTY ${NIL:=foo} LHS | \ 8696070Sjmallett diff -u ${.CURDIR}/regress.sysvmatch.out - || false 87105907Sjmallett.endif 8896070Sjmallett 8998442Sjmallett# A bogus target for the lhs_expn test; If this is reached, then the make(1) 9098442Sjmallett# program has not errored out because of the recursion caused by not expanding 9198442Sjmallett# the left-hand-side's embedded variables above. 9298442Sjmallettlhs_expn: 9398461Sjmallett @true 9498442Sjmallett 95107374Sru.if make(notdef) 96107374Sru# make(1) claims to only evaluate a conditional as far as is necessary 97107374Sru# to determine its value; that was not always the case. 98107374Sru.undef notdef 99107374Srunotdef: 100241298Smarcel.if defined(notdef) && ${notdef:M/} 101107374Sru.endif 102107374Sru.endif 103107374Sru 104107374Sru.if make(modifiers) 105241298Smarcel.if defined(.PARSEDIR) 106241298Smarcel# check if bmake can expand plain variables 107241298Smarcel.MAKE.EXPAND_VARIABLES= yes 108241298Smarcelx!= ${SMAKE} -V .CURDIR:H 109241298Smarcelmodifiers: 110241298Smarcel.if ${.CURDIR:H} != "$x" 111241298Smarcel @false 112241298Smarcel.endif 113241298Smarcel.else 114107374Sru# See if make(1) supports the C modifier. 115241298Smarcelmodifiers: dollarV 116138317Sharti @if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 117107374Sru grep -q "Unknown modifier 'C'"; then \ 118107374Sru false; \ 119107374Sru fi 120241298Smarcel 121241298Smarcel# check that make -V '${VAR}' works 122241298SmarcelV_expn != V_OK=ok ${SMAKE} -r -f /dev/null -V '$${V_OK}' 123241298SmarceldollarV: 124241298Smarcel.if ${V_expn} == "" 125241298Smarcel @false 126107374Sru.endif 127241298Smarcel.endif 128241298Smarcel.endif 129107374Sru 130117226Sru.if make(arith_expr) 131117226Sruarith_expr: 132117226Sru# See if arithmetic expression parsing is broken. 133117226Sru# The different spacing below is intentional. 134117226SruVALUE= 0 135117226Sru.if (${VALUE} < 0)||(${VALUE}>0) 136117226Sru.endif 137117226Sru.endif 138117226Sru 139120676Sru.if make(PATH_exists) 140120676SruPATH_exists: 141120676Sru.PATH: ${.CURDIR} 142120676Sru.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..) 143120676Sru.error exists() failed 144120676Sru.endif 145120676Sru.endif 146120676Sru 147125219Sru.if make(double_quotes) 148125219SruVALUE= foo "" 149125219Srudouble_quotes: 150125219Sru.if ${VALUE:S/$//} != ${VALUE} 151125219Sru.error "" reduced to " 152125219Sru.endif 153125219Sru.endif 154125219Sru 155125227Sru.if make(double_quotes2) 156125227Srudouble_quotes2: 157125227Sru @cat /dev/null "" 158125227Sru.endif 159125227Sru 160133109Sharti# 161133109Sharti# Check passing of variable via MAKEFLAGS 162133109Sharti# 163133109Sharti.if make(pass_cmd_vars) 164133109Shartipass_cmd_vars: 165138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1 166138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2 167138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3 168138317Sharti @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4 169133109Sharti.endif 170133109Sharti 171222295Sobrien# 172222295Sobrien# Check that the variable definition arrived from the calling make 173222295Sobrien# 174133109Sharti.if make(pass_cmd_vars_1) 175222295Sobrien# These values should get overridden by the commandline 176222295SobrienCMD1=oops1 177222295SobrienCMD2=oops2 178133109Shartipass_cmd_vars_1: 179133109Sharti @: 180133109Sharti 181133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 182133164Sharti.error variables not passed through MAKEFLAGS 183133109Sharti.endif 184133109Sharti.endif 185133109Sharti 186133109Sharti.if make(pass_cmd_vars_2) 187133109Sharti# Check that we cannot override the passed variables 188133109ShartiCMD1=foo1 189133109ShartiCMD2=foo2 190133109Sharti 191133109Sharti.if ${CMD1} != cmd1 || ${CMD2} != cmd2 192133164Sharti.error MAKEFLAGS-passed variables overridden 193133109Sharti.endif 194133109Sharti 195133109Shartipass_cmd_vars_2: 196133109Sharti @: 197133109Sharti.endif 198133109Sharti 199133109Sharti.if make(pass_cmd_vars_3) 200133109Sharti# Check that we can override the passed variables on the next sub-make's 201133109Sharti# command line 202133109Sharti 203133109Shartipass_cmd_vars_3: 204138317Sharti @${SMAKE} CMD1=foo1 pass_cmd_vars_3_1 205133109Sharti.endif 206133109Sharti 207133109Sharti.if make(pass_cmd_vars_3_1) 208133109Sharti.if ${CMD1} != foo1 || ${CMD2} != cmd2 209133164Sharti.error MAKEFLAGS-passed variables not overridden on command line 210133109Sharti.endif 211133109Shartipass_cmd_vars_3_1: 212133109Sharti @: 213133109Sharti.endif 214133109Sharti 215133109Sharti.if make(pass_cmd_vars_4) 216133109Sharti# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten 217133109Sharti# by evaluating the .MAKEFLAGS target. 218133109Sharti 219133109Sharti.MAKEFLAGS: CMD1=baz1 220133109Sharti 221133109Shartipass_cmd_vars_4: 222138317Sharti @${SMAKE} pass_cmd_vars_4_1 223133109Sharti 224133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 225133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target 226133109Sharti.endif 227133109Sharti 228133109Sharti.endif 229133109Sharti.if make(pass_cmd_vars_4_1) 230133109Sharti.if ${CMD1} != baz1 || ${CMD2} != cmd2 231133164Sharti.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2) 232133109Sharti.endif 233133109Shartipass_cmd_vars_4_1: 234133109Sharti @: 235133109Sharti.endif 236133109Sharti 237133161Sharti# 238133161Sharti# Test whether make supports the '+' flag (meaning: execute even with -n) 239133161Sharti# 240133161Sharti.if make(plus_flag) 241138317ShartiOUT != ${SMAKE} -n plus_flag_1 242222295Sobrien.if ${OUT:M/tmp} != "/tmp" 243133164Sharti.error make doesn't handle + flag 244133161Sharti.endif 245133161Shartiplus_flag: 246133161Sharti @: 247133161Sharti.endif 248133161Sharti.if make(plus_flag_1) 249133161Shartiplus_flag_1: 250133161Sharti +@cd /tmp; pwd 251133161Sharti.endif 252133161Sharti 253136842Sru.if make(shell) 254136842Sru# Test if make fully supports the .SHELL specification. 255136842Sru.SHELL: path=/nonexistent 256136842SruA!= echo ok 257136842Srushell: 258136842Sru.endif 259136842Sru 260138080Sharti.if make(shell_1) 261138080Sharti# Test if setting the shell by name only works. Because we have no ksh 262138080Sharti# in the base system we test that we can set sh and csh. We try only exact 263138080Sharti# matching names and do not exercise the rather strange matching algorithm. 264138080Shartishell_1: 265138317Sharti @${SMAKE} shell_1_csh 266138317Sharti @${SMAKE} shell_1_sh 267138080Sharti.endif 268138080Sharti.if make(shell_1_csh) 269138080Sharti.SHELL: name="csh" 270138080Shartishell_1_csh: 271138317Sharti @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$' 272138080Sharti.endif 273138080Sharti.if make(shell_1_sh) 274138080Sharti.SHELL: name="sh" 275138080Shartishell_1_sh: 276172399Sru @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?sh$$' 277138080Sharti.endif 278138080Sharti 279138080Sharti.if make(shell_2) 280138080Sharti# Test if we can replace the shell specification. We do this by using 281138080Sharti# a shell scripts that prints us its arguments and standard input as the shell 282138515Shartishell_2: shell_test 283138317Sharti @${SMAKE} -B shell_2B | \ 284138080Sharti diff -u ${.CURDIR}/regress.shell_2B.out - || false 285138317Sharti @${SMAKE} -j1 shell_2j | \ 286138080Sharti diff -u ${.CURDIR}/regress.shell_2j.out - || false 287138080Sharti.endif 288138080Sharti 289138080Sharti.if make(shell_2B) 290138317Sharti.SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors" 291138080Sharti 292138080Shartishell_2B: 293138080Sharti -@funny $$ 294138080Sharti funnier $$ 295138080Sharti.endif 296138080Sharti 297138080Sharti.if make(shell_2j) 298138317Sharti.SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors" 299138080Sharti 300138080Shartishell_2j: 301138080Sharti -@funny $$ 302138080Sharti funnier $$ 303138080Sharti.endif 304138080Sharti 30595158Sjmallettfailure: 306137587Snik @echo "not ok # Test failed: regression detected. See above." 30795158Sjmallett @false 308138317Sharti 309138515ShartiCLEANFILES= shell_test 310138515Sharti 311138515Sharti.include <bsd.obj.mk> 312