]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/cond1.mk
zfs: merge openzfs/zfs@afa7b3484 (master) into main
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / cond1.mk
1 # $NetBSD: cond1.mk,v 1.3 2020/11/15 14:58:14 rillig Exp $
2
3 # TODO: Convert these tests into tutorial form.
4 # TODO: Split these tests by topic.
5 # TODO: Use better variable names and expression values that actually express
6 # the intended behavior.  uname(1) has nothing to do with conditions.
7
8 # hard code these!
9 TEST_UNAME_S= NetBSD
10 TEST_UNAME_M= sparc
11 TEST_MACHINE= i386
12
13 .if ${TEST_UNAME_S}
14 Ok=var,
15 .endif
16 .if ("${TEST_UNAME_S}")
17 Ok+=(\"var\"),
18 .endif
19 .if (${TEST_UNAME_M} != ${TEST_MACHINE})
20 Ok+=(var != var),
21 .endif
22 .if ${TEST_UNAME_M} != ${TEST_MACHINE}
23 Ok+= var != var,
24 .endif
25 .if !((${TEST_UNAME_M} != ${TEST_MACHINE}) && defined(X))
26 Ok+= !((var != var) && defined(name)),
27 .endif
28 # from bsd.obj.mk
29 MKOBJ?=no
30 .if ${MKOBJ} == "no"
31 o= no
32 Ok+= var == "quoted",
33 .else
34 .if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
35 .if defined(notMAKEOBJDIRPREFIX)
36 o=${MAKEOBJDIRPREFIX}${__curdir}
37 .else
38 o= ${MAKEOBJDIR}
39 .endif
40 .endif
41 o= o
42 .endif
43
44 # repeat the above to check we get the same result
45 .if ${MKOBJ} == "no"
46 o2= no
47 .else
48 .if defined(notMAKEOBJDIRPREFIX) || defined(norMAKEOBJDIR)
49 .if defined(notMAKEOBJDIRPREFIX)
50 o2=${MAKEOBJDIRPREFIX}${__curdir}
51 .else
52 o2= ${MAKEOBJDIR}
53 .endif
54 .endif
55 o2= o
56 .endif
57
58 PRIMES=2 3 5 7 11
59 NUMBERS=1 2 3 4 5
60
61 n=2
62 .if ${PRIMES:M$n} == ""
63 X=not
64 .else
65 X=
66 .endif
67
68 .if ${MACHINE_ARCH} == no-such
69 A=one
70 .else
71 .if ${MACHINE_ARCH} == not-this
72 .if ${MACHINE_ARCH} == something-else
73 A=unlikely
74 .else
75 A=no
76 .endif
77 .endif
78 A=other
79 # We expect an extra else warning - we're not skipping here
80 .else
81 A=this should be an error
82 .endif
83
84 .if $X != ""
85 .if $X == not
86 B=one
87 .else
88 B=other
89 # We expect an extra else warning - we are skipping here
90 .else
91 B=this should be an error
92 .endif
93 .else
94 B=unknown
95 .endif
96
97 .if "quoted" == quoted
98 C=clever
99 .else
100 C=dim
101 .endif
102
103 .if defined(nosuch) && ${nosuch:Mx} != ""
104 # this should not happen
105 .info nosuch is x
106 .endif
107
108 all:
109         @echo "$n is $X prime"
110         @echo "A='$A' B='$B' C='$C' o='$o,${o2}'"
111         @echo "Passed:${.newline} ${Ok:S/,/${.newline}/}"
112         @echo "${NUMBERS:@n@$n is ${("${PRIMES:M$n}" == ""):?not:} prime${.newline}@}"
113         @echo "${"${DoNotQuoteHere:U0}" > 0:?OK:No}"
114         @echo "${${NoSuchNumber:U42} > 0:?OK:No}"