summaryrefslogtreecommitdiffstats
path: root/regress/lib/libagentx/Makefile
blob: 6ff7c6dc79fd888c574de4ec2298ec3fd2d12e38 (plain) (blame)
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
# $OpenBSD: Makefile,v 1.5 2021/01/17 20:53:51 bluhm Exp $

.if ! exists(/usr/local/sbin/snmpd)
regress:
	@printf "Install net-snmp package to run this regress.\n"
	@printf "SKIPPED\n"
.endif

PROG=			agentx
SRCS=			main.c log.c
CFLAGS=			-Wall
NOMAN=			yes
LDADD=			-lagentx -levent

REGRESS_SETUP_ONCE=	start
REGRESS_TARGETS=	run-regress-walk
REGRESS_CLEANUP=	stop
CLEANFILES=

SNMPD_CMD=		/usr/local/sbin/snmpd -r -C -c snmpd.conf -Le
UID!!=		id -u
.if ${UID} == 0
SNMPD_CMD+=		-u _netsnmp
.endif

CLEANFILES+=	snmpd.conf
snmpd.conf: Makefile
	@printf "agentaddress udp:127.0.0.1:6161\n" > snmpd.conf
	@printf "rwcommunity public\n" >> snmpd.conf
	@printf "master agentx\n" >> snmpd.conf
	@printf "agentXSocket agentx.sock\n" >> snmpd.conf

CLEANFILES+=	agentx.sock
start: stop snmpd.conf agentx
	${SNMPD_CMD}
	# XXX Race in net-snmpd, socket exists before data is available.
	sleep 1
	./agentx agentx.sock

stop:
	-pkill -xf "${SNMPD_CMD}"

CLEANFILES+=	walk.run.out walk.run.err
run-regress-walk:
	snmp walk 127.0.0.1:6161 openbsd > walk.run.out 2> walk.run.err || true
	diff -up ${.CURDIR}/walk.err walk.run.err
	diff -up ${.CURDIR}/walk.out walk.run.out

.include <bsd.regress.mk>