xref: /openbsd/regress/usr.bin/lastcomm/Makefile (revision 6f40fd34)
1# $OpenBSD: Makefile,v 1.2 2017/06/11 19:43:16 bluhm Exp $
2
3# Start with a clean /var/account/acct accounting file and turn on
4# process accounting with accton(8).  Each test executes a command
5# with a unique name and checks the flags in the lastcomm(1) output.
6# Run tests with fork, su, core, xsig, pledge, trap accounting.
7
8PROG=		crash
9CLEANFILES=	regress-* stamp-*
10
11.if make (regress) || make (all)
12.BEGIN:
13	@echo
14	rm -f stamp-rotate
15.endif
16
17# Rotate accouting files and keep statistics, from /etc/daily.
18stamp-rotate:
19	@echo '\n======== $@ ========'
20	${SUDO} touch /var/account/acct
21	-${SUDO} mv -f /var/account/acct.2 /var/account/acct.3
22	-${SUDO} mv -f /var/account/acct.1 /var/account/acct.2
23	-${SUDO} mv -f /var/account/acct.0 /var/account/acct.1
24	${SUDO} cp -f /var/account/acct /var/account/acct.0
25	${SUDO} sa -sq
26	${SUDO} accton /var/account/acct
27	date >$@
28
29TARGETS+=	fork
30run-regress-fork:
31	@echo '\n======== $@ ========'
32	# Create shell program, fork a sub shell, and check the -F flag.
33	cp -f /bin/sh regress-fork
34	./regress-fork -c '( : ) &'
35	lastcomm regress-fork | grep -q ' -F '
36
37TARGETS+=	su
38run-regress-su:
39	@echo '\n======== $@ ========'
40	# Create shell program, run as super user, and check the -S flag.
41	cp -f /bin/sh regress-su
42	${SUDO} ./regress-su -c ':'
43	lastcomm regress-su | grep -q ' -S '
44
45TARGETS+=	core
46run-regress-core:
47	@echo '\n======== $@ ========'
48	# Create shell program, abort sub shell, and check the -DX flag.
49	cp -f /bin/sh regress-core
50	rm -f regress-core.core
51	ulimit -c 100000; ./regress-core -c '( : ) & kill -SEGV $$!; wait'
52	lastcomm regress-core | grep -q ' -FDX '
53
54TARGETS+=	xsig
55run-regress-xsig:
56	@echo '\n======== $@ ========'
57	# Create shell program, kill sub shell, and check the -X flag.
58	cp -f /bin/sh regress-xsig
59	./regress-xsig -c '( : ) & kill -KILL $$!; wait'
60	lastcomm regress-xsig | grep -q ' -FX '
61
62TARGETS+=	pledge
63run-regress-pledge:
64	@echo '\n======== $@ ========'
65	# Create perl program, violate pledge, and check the -P flag.
66	cp -f /usr/bin/perl regress-pledge
67	ulimit -c 0; ! ./regress-pledge -MOpenBSD::Pledge -e\
68	    'pledge("stdio") or die $$!; chdir("/")'
69	lastcomm regress-pledge | grep -q ' -S*XP '
70
71TARGETS+=	trap
72run-regress-trap: ${PROG}
73	@echo '\n======== $@ ========'
74	# Build crashing program, run SIGSEGV handler, and check the -T flag.
75	cp -f ${PROG} regress-trap
76	./regress-trap
77	lastcomm regress-trap | grep -q ' -S*T '
78
79REGRESS_TARGETS=	${TARGETS:S/^/run-regress-/}
80${REGRESS_TARGETS}:	stamp-rotate
81
82.include <bsd.regress.mk>
83