summaryrefslogtreecommitdiff
path: root/regress/usr.bin/mandoc/db/run/Makefile
blob: fac8fd3c6f9af2006659ec67918dd831e107d40b (plain)
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
# $OpenBSD: Makefile,v 1.3 2016/08/30 22:20:03 schwarze Exp $
#
# Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

DO_MO_TESTS =	onepage twopages threepages threemacros
DO_MO_TESTS +=	sortpages sortpages_rev so so_rev sortnames
DO_MO_TESTS +=	twosect twoarch threearch fn in va sh xr
DO_MOE_TESTS =	empty
DOE_M_TESTS =	padipage padfpage padmpage 
DOE_M_TESTS +=	padmacros padimacro padmmacro
DOE_M_TESTS +=	padientry padfentry padmentry padfmagic
DOE_MOE_TESTS =	badname0 badname badsect0 badsect badarch0 badarch
DOE_MOE_TESTS += baddesc0 baddesc badfile0 badfile
DE_M_TESTS =	nonexistent short badimagic badversion badmacrosp badendp
DE_M_TESTS +=	badnpages badnmacros badmacrop badfmagic

DO_TESTS =	${DO_MO_TESTS} ${DO_MOE_TESTS}
DOE_TESTS =	${DOE_M_TESTS} ${DOE_MOE_TESTS}
DE_TESTS =	${DE_M_TESTS}
DOB_TESTS =	${DO_TESTS} ${DOE_TESTS}
DEB_TESTS =	${DOE_TESTS} ${DE_TESTS}
MOB_TESTS =	${DO_MO_TESTS} ${DO_MOE_TESTS} ${DOE_MOE_TESTS}
MEB_TESTS =	${DO_MOE_TESTS} ${DOE_MOE_TESTS}
ALL_TESTS =	${DO_TESTS} ${DOE_TESTS} ${DE_TESTS}

REGRESS_TARGETS = ${ALL_TESTS} diff.derr diff.mout diff.merr

CLEANFILES =	${ALL_TESTS:C/$/.db/}
CLEANFILES +=	${ALL_TESTS:C/$/.dout/} ${ALL_TESTS:C/$/.derr/} all.derr
CLEANFILES +=	${MOB_TESTS:C/$/.mout/} all.mout
CLEANFILES +=	${MEB_TESTS:C/$/.merr/} all.merr

# === MAIN REGRESSION TARGETS ==========================================

.for NAME in ${DO_TESTS}
${NAME}: ${NAME}.dout ${NAME}.derr
	@test \! -s ${NAME}.derr
	@diff -u ${.CURDIR}/../out/${NAME}.dout ${NAME}.dout
.endfor

.for NAME in ${DOE_TESTS}
${NAME}: ${NAME}.dout ${NAME}.derr
	@test -s ${NAME}.derr
	@diff -u ${.CURDIR}/../out/${NAME}.dout ${NAME}.dout
.endfor

.for NAME in ${DE_TESTS}
${NAME}: ${NAME}.dout ${NAME}.derr
	@test -s ${NAME}.derr
	@test \! -s ${NAME}.dout
.endfor

diff.derr: all.derr
	@diff -u ${.CURDIR}/../out/all.derr all.derr

diff.mout: all.mout
	@diff -u ${.CURDIR}/../out/all.mout all.mout

diff.merr: all.merr
	@diff -u ${.CURDIR}/../out/all.merr all.merr

.PHONY: ${REGRESS_TARGETS}

cleandir: cleandir_local

cleandir_local:
	rm -rf man binedit dbm_dump makeinodes


# === RUNNING DBM_DUMP =================================================

.for NAME in ${DOB_TESTS}
${NAME}.dout ${NAME}.derr: dbm_dump ${NAME}.db
	@./dbm_dump ${NAME}.db > ${NAME}.dout 2> ${NAME}.derr
.endfor

.for NAME in ${DE_TESTS}
${NAME}.dout ${NAME}.derr: dbm_dump ${NAME}.db
	@if ./dbm_dump ${NAME}.db > ${NAME}.dout 2> ${NAME}.derr; \
		then false; else true; fi
.endfor

all.derr: ${DEB_TESTS:C/$/.derr/}
	@for f in ${DEB_TESTS}; \
		do printf "\n>>> $$f\n"; cat $$f.derr; done > $@


# === RUNNING MAKEWHATIS AND MAN =======================================

empty.db empty.mout empty.merr:
	@rm -rf man
	@mkdir man
	@makewhatis man
	@if man -kM man something > empty.mout 2> empty.merr; \
		then false; else test $$? -eq 5; fi
	@mv man/mandoc.db empty.db
	@rmdir man

onepage.db onepage.mout: ${.CURDIR}/../man/empty.1
	@rm -rf man
	@mkdir -p man/man1
	@cp ${.CURDIR}/../man/empty.1 man/man1/
	@makewhatis man
	@man -kM man title > onepage.mout
	@mv man/mandoc.db onepage.db
	@rm -rf man

twopages.db twopages.mout: ${.CURDIR}/../man/empty.1
	@rm -rf man
	@mkdir -p man/man1
	@cp ${.CURDIR}/../man/empty.1 man/man1/
	@cp ${.CURDIR}/../man/empty.1 man/man1/second.1
	@makewhatis man
	@(echo "> second"; man -wM man second | sed 's#.*/man/##'; \
	  echo "> empty"; man -wM man empty | sed 's#.*/man/##') \
	  > twopages.mout
	@mv man/mandoc.db twopages.db
	@rm -rf man

threepages.db threepages.mout: ${.CURDIR}/../man/empty.1
	@rm -rf man
	@mkdir -p man/man1
	@cp ${.CURDIR}/../man/empty.1 man/man1/
	@cp ${.CURDIR}/../man/empty.1 man/man1/second.1
	@cp ${.CURDIR}/../man/empty.1 man/man1/third.1
	@makewhatis man
	@(echo "> second"; man -wM man second | sed 's#.*/man/##'; \
	  echo "> third"; man -wM man third | sed 's#.*/man/##'; \
	  echo "> empty"; man -wM man empty | sed 's#.*/man/##') \
	  > threepages.mout
	@mv man/mandoc.db threepages.db
	@rm -rf man

threemacros.db threemacros.mout: ${.CURDIR}/../man/empty.1
	@rm -rf man
	@mkdir -p man/man1
	@cp ${.CURDIR}/../man/empty.1 man/man1/
	@printf ".Sh SEE ALSO\n.Xr one 1\n.Xr two 2\n.Xr three 3" \
		>> man/man1/empty.1
	@makewhatis man
	@(echo "> Xr=one"; man -kwM man Xr=one | sed 's#.*/man/##'; \
	  echo "> Xr~^t"; man -kM man -O Xr Xr~^t;) > threemacros.mout
	@mv man/mandoc.db threemacros.db
	@rm -rf man

sortpages.db sortpages.mout: makeinodes ${.CURDIR}/../man/empty.1
	@rm -rf man
	@./makeinodes
	@cat ${.CURDIR}/../man/empty.1 >> man/man1/1
	@cat ${.CURDIR}/../man/empty.1 >> man/man1/2
	@mv man/man1/1 man/man1/one.1
	@mv man/man1/2 man/man1/two.1
	@makewhatis man
	@man -kM man Nm=empty > sortpages.mout
	@mv man/mandoc.db sortpages.db
	@rm -rf man

sortpages_rev.db sortpages_rev.mout: makeinodes ${.CURDIR}/../man/empty.1
	@rm -rf man
	@./makeinodes
	@cat ${.CURDIR}/../man/empty.1 >> man/man1/1
	@cat ${.CURDIR}/../man/empty.1 >> man/man1/2
	@mv man/man1/2 man/man1/one.1
	@mv man/man1/1 man/man1/two.1
	@makewhatis man
	@man -kM man Nm=empty > sortpages_rev.mout
	@mv man/mandoc.db sortpages_rev.db
	@rm -rf man

so.db so.mout: makeinodes ${.CURDIR}/../man/empty.1
	@rm -rf man
	@./makeinodes
	@cat ${.CURDIR}/../man/empty.1 >> man/man1/1
	@echo ".so man1/one.1" >> man/man1/2
	@mv man/man1/1 man/man1/one.1
	@mv man/man1/2 man/man1/two.1
	@makewhatis man
	@man -wM man two | sed 's#.*/man/##' > so.mout
	@mv man/mandoc.db so.db
	@rm -rf man

so_rev.db so_rev.mout: makeinodes ${.CURDIR}/../man/empty.1
	@rm -rf man
	@./makeinodes
	@cat ${.CURDIR}/../man/empty.1 >> man/man1/2
	@echo ".so man1/one.1" >> man/man1/1
	@mv man/man1/2 man/man1/one.1
	@mv man/man1/1 man/man1/two.1
	@makewhatis man
	@man -wM man two | sed 's#.*/man/##' > so_rev.mout
	@mv man/mandoc.db so_rev.db
	@rm -rf man

sortnames.db sortnames.mout: ${.CURDIR}/../man/sortnames.1
	@rm -rf man
	@mkdir -p man/man1
	@cp ${.CURDIR}/../man/sortnames.1 man/man1/
	@ln man/man1/sortnames.1 man/man1/link.1
	@makewhatis man
	@man -kM man Nm=onlysyn > sortnames.mout
	@mv man/mandoc.db sortnames.db
	@rm -rf man

twosect.db twosect.mout: ${.CURDIR}/../man/empty.1
	@rm -rf man
	@mkdir -p man/man1
	@mkdir -p man/man8
	@cp ${.CURDIR}/../man/empty.1 man/man1/
	@ln man/man1/empty.1 man/man8/empty.8
	@makewhatis man
	@man -kM man -s 1 title > twosect.mout
	@mv man/mandoc.db twosect.db
	@rm -rf man

twoarch.db twoarch.mout: ${.CURDIR}/../man/empty.1
	@rm -rf man
	@mkdir -p man/man1/i386
	@mkdir -p man/man1/amd64
	@cp ${.CURDIR}/../man/empty.1 man/man1/i386
	@ln man/man1/i386/empty.1 man/man1/amd64/empty.1
	@makewhatis man
	@man -kM man -S i386 title > twoarch.mout
	@mv man/mandoc.db twoarch.db
	@rm -rf man

threearch.db threearch.mout: ${.CURDIR}/../man/empty.1
	@rm -rf man
	@mkdir -p man/man1/amd64
	@mkdir -p man/man1/i386
	@mkdir -p man/man1/sgi
	@cp ${.CURDIR}/../man/empty.1 man/man1/amd64/
	@cp ${.CURDIR}/../man/empty.1 man/man1/i386/
	@cp ${.CURDIR}/../man/empty.1 man/man1/sgi/
	@makewhatis man
	@(echo "> amd64"; man -wM man -S amd64 empty | sed 's#.*/man/##'; \
	  echo "> i386"; man -wM man -S i386 empty | sed 's#.*/man/##'; \
	  echo "> sgi"; man -wM man -S sgi empty | sed 's#.*/man/##') \
	  > threearch.mout
	@mv man/mandoc.db threearch.db
	@rm -rf man

fn.db fn.mout: ${.CURDIR}/../man/fn.3
	@rm -rf man
	@mkdir -p man/man3
	@cp ${.CURDIR}/../man/fn.3 man/man3/
	@makewhatis man
	@(echo "> fn_type"; man -kwM man Ft=fn_type | sed 's#.*/man/##'; \
	  echo "> fn_func"; man -kwM man Fn=fn_func | sed 's#.*/man/##'; \
	  echo "> fn_arg";  man -kwM man Fa=fn_arg  | sed 's#.*/man/##'; \
	  echo "> fo_type"; man -kwM man Ft=fo_type | sed 's#.*/man/##'; \
	  echo "> fo_func"; man -kwM man Fn=fo_func 2>&1 | sed 's#.*/man/##'; \
	  echo "> fo_arg";  man -kwM man Fa=fo_arg  | sed 's#.*/man/##') \
	  > fn.mout
	@mv man/mandoc.db fn.db
	@rm -rf man

in.db in.mout: ${.CURDIR}/../man/in.3
	@rm -rf man
	@mkdir -p man/man3
	@cp ${.CURDIR}/../man/in.3 man/man3/
	@makewhatis man
	@(echo "> In"; man -kwM man In=in.h | sed 's#.*/man/##'; \
	  echo "> Fd"; man -kwM man In=fd.h | sed 's#.*/man/##') \
	  > in.mout
	@mv man/mandoc.db in.db
	@rm -rf man

va.db va.mout: ${.CURDIR}/../man/va.3
	@rm -rf man
	@mkdir -p man/man3
	@cp ${.CURDIR}/../man/va.3 man/man3/
	@makewhatis man
	@(echo "> b2"; man -kwM man Va='block vt_two' | sed 's#.*/man/##'; \
	  echo "> t1"; man -kwM man Vt='vt_one' | sed 's#.*/man/##'; \
	  echo "> a1"; man -kwM man Va='va_one'  | sed 's#.*/man/##'; \
	  echo "> t2"; man -kwM man Vt='struct vt_two' | sed 's#.*/man/##'; \
	  echo "> a2"; man -kwM man Va='int va_two'  | sed 's#.*/man/##') \
	  > va.mout
	@mv man/mandoc.db va.db
	@rm -rf man

sh.db sh.mout: ${.CURDIR}/../man/sh.1
	@rm -rf man
	@mkdir -p man/man1
	@cp ${.CURDIR}/../man/sh.1 man/man1/
	@makewhatis man
	@(echo "> Sh"; man -kwM man Sh=sh_title | sed 's#.*/man/##'; \
	  echo "> Ss"; man -kwM man Ss=ss_title | sed 's#.*/man/##') \
	  > sh.mout
	@mv man/mandoc.db sh.db
	@rm -rf man

xr.db xr.mout: ${.CURDIR}/../man/xr.1
	@rm -rf man
	@mkdir -p man/man1
	@cp ${.CURDIR}/../man/xr.1 man/man1/
	@makewhatis man
	@(echo "> bare"; man -kwM man 'Xr~^bare$$' | sed 's#.*/man/##'; \
	  echo "> page"; man -kwM man 'Xr=page(1)' | sed 's#.*/man/##') \
	  > xr.mout
	@mv man/mandoc.db xr.db
	@rm -rf man

badname0.mout badname0.merr: badname0.db
	@rm -rf man
	@mkdir man
	@cp badname0.db man/mandoc.db
	@if man -wM man empty > badname0.mout 2> badname0.merr; \
		then false; else test $$? -eq 5; fi
	@rm -rf man

badname.mout badname.merr: badname.db
	@rm -rf man
	@mkdir man
	@cp badname.db man/mandoc.db
	@man -wM man empty > badname.mout 2> badname.merr
	@rm -rf man

badsect0.mout badsect0.merr: badsect0.db
	@rm -rf man
	@mkdir man
	@cp badsect0.db man/mandoc.db
	@if man -wM man -s 1 empty > badsect0.mout 2> badsect0.merr; \
		then false; else test $$? -eq 5; fi
	@rm -rf man

badsect.mout badsect.merr: badsect.db
	@rm -rf man
	@mkdir man
	@cp badsect.db man/mandoc.db
	@man -wM man -s 1 empty > badsect.mout 2> badsect.merr
	@rm -rf man

badarch0.mout badarch0.merr: badarch0.db
	@rm -rf man
	@mkdir man
	@cp badarch0.db man/mandoc.db
	@man -wM man -S amd64 empty > badarch0.mout 2> badarch0.merr
	@rm -rf man

badarch.mout badarch.merr: badarch.db
	@rm -rf man
	@mkdir man
	@cp badarch.db man/mandoc.db
	@man -wM man -S i386 empty > badarch.mout 2> badarch.merr
	@rm -rf man

baddesc0.mout baddesc0.merr: baddesc0.db
	@rm -rf man
	@mkdir man
	@cp baddesc0.db man/mandoc.db
	@man -kM man empty > baddesc0.mout 2> baddesc0.merr
	@rm -rf man

baddesc.mout baddesc0.merr: baddesc.db
	@rm -rf man
	@mkdir man
	@cp baddesc.db man/mandoc.db
	@man -kM man empty > baddesc.mout 2> baddesc.merr
	@rm -rf man

badfile0.mout badfile0.merr: badfile0.db
	@rm -rf man
	@mkdir man
	@cp badfile0.db man/mandoc.db
	@man -wM man empty > badfile0.mout 2> badfile0.merr
	@rm -rf man

badfile.mout badfile.merr: badfile.db
	@rm -rf man
	@mkdir man
	@cp badfile.db man/mandoc.db
	@man -wM man empty > badfile.mout 2> badfile.merr
	@rm -rf man

all.mout: ${MOB_TESTS:C/$/.mout/}
	@for f in ${MOB_TESTS}; \
		do printf "\n>>> $$f\n"; cat $$f.mout || true; done > $@

all.merr: ${MEB_TESTS:C/$/.merr/}
	@for f in ${MEB_TESTS}; \
		do printf "\n>>> $$f\n"; cat $$f.merr || true; done > $@


# === RUNNING BINEDIT ==================================================

padipage.db: binedit twopages.db
	@./binedit c16rw1f < twopages.db > $@

padfpage.db: binedit twopages.db
	@./binedit c16rw1s20c20w0w0w0w0w0f < twopages.db > $@

padmpage.db: binedit threepages.db
	@./binedit c16rw2c20s20c20w0w0w0w0w0f < threepages.db > $@

badname0.db: binedit onepage.db
	@./binedit c20rw-1f < onepage.db > $@

badname.db: binedit threepages.db
	@./binedit c40rw-1f < threepages.db > $@

badsect0.db: binedit onepage.db
	@./binedit c24rw-1f < onepage.db > $@

badsect.db: binedit threepages.db
	@./binedit c44rw-1f < threepages.db > $@

badarch0.db: binedit threearch.db
	@./binedit c28rw-1f < threearch.db > $@

badarch.db: binedit threearch.db
	@./binedit c48rw-1f < threearch.db > $@

baddesc0.db: binedit onepage.db
	@./binedit c32rw-1f < onepage.db > $@

baddesc.db: binedit threepages.db
	@./binedit c52rw-1f < threepages.db > $@

badfile0.db: binedit onepage.db
	@./binedit c36rw-1f < onepage.db > $@

badfile.db: binedit threepages.db
	@./binedit c56rw-1f < threepages.db > $@

padmacros.db: binedit onepage.db
	@./binedit c16rw0f < onepage.db > $@

padimacro.db: binedit empty.db
	@./binedit c8rdwri4wac4s4c136rwi4ww0f < empty.db > $@

padmmacro.db: binedit empty.db
	@./binedit c8rdwri4wac8s4c132rwi4ww0f < empty.db > $@

padientry.db: binedit threemacros.db
	@./binedit c8rdwac4rdwarw2f < threemacros.db > $@

padfentry.db: binedit threemacros.db
	@./binedit c8rdwac4rdwarw2s8c16w0w0f < threemacros.db > $@

padmentry.db: binedit threemacros.db
	@./binedit c8rdwac4rdwarw2c8s8c8w0w0f < threemacros.db > $@

padfmagic.db: binedit empty.db
	@./binedit c12rdi4waw0f < empty.db > $@

nonexistent.db:
	@rm -rf nonexistent.db

short.db:
	@echo 'sho' > $@

badimagic.db: binedit empty.db
	@./binedit riwf < empty.db > $@

badversion.db: binedit empty.db
	@./binedit c4riwf < empty.db > $@

badmacrosp.db: binedit empty.db
	@./binedit c8rw1000f < empty.db > $@

badendp.db: binedit empty.db
	@./binedit c12riwf < empty.db > $@

badnpages.db: binedit empty.db
	@./binedit c16rw-1f < empty.db > $@

badnmacros.db: binedit empty.db
	@./binedit c8rdwariwf < empty.db > $@

badmacrop.db: binedit empty.db
	@./binedit c8rdwac4rw1000f < empty.db > $@

badfmagic.db: binedit empty.db
	@./binedit c12rdwariwf < empty.db > $@


# === GETTING ACCESS TO THE UTILITIES ==================================

binedit dbm_dump makeinodes:
	@if [ -x ${.CURDIR}/../$@/obj/$@ ]; \
		then ln -s ${.CURDIR}/../$@/obj/$@; \
		elif [ -x ${.CURDIR}/../$@/$@ ]; \
		then ln -s ${.CURDIR}/../$@/$@; \
		else echo "Cannot find $@ binary; run 'make' in .." 1>&2; \
		exit 1; fi

.include <bsd.regress.mk>