xref: /openbsd/regress/sbin/slaacd/Makefile (revision 4cfece93)
1#	$OpenBSD: Makefile,v 1.5 2019/05/10 02:22:34 bluhm Exp $
2
3# The following ports must be installed:
4#
5# python-2.7          interpreted object-oriented programming language
6# scapy               powerful interactive packet manipulation in python
7
8RTABLE		?=	1
9PAIR1		?=	pair1
10PAIR2		?=	pair2
11CTR_SOCK	?=	${.OBJDIR}/slaacd.sock
12
13CLEANFILES +=		slaacd.sock
14
15.if ! (make(clean) || make(cleandir) || make(obj))
16# Check whether all required python packages are installed.  If some
17# are missing print a warning and skip the tests, but do not fail.
18AUTOCONF6 != sh -c "ifconfig | fgrep AUTOCONF6 2>&1" || true
19INTERFACES != sh -c "ifconfig ${PAIR1} 2>/dev/null; \
20    ifconfig ${PAIR2} 2>/dev/null" || true
21.endif
22
23.if ! exists(/usr/local/bin/python2) || ! exists(/usr/local/bin/scapy)
24regress:
25	@echo install python and the scapy module for additional tests
26	@echo SKIPPED
27.endif
28
29.if ! empty(AUTOCONF6)
30regress:
31	@echo 'AUTOCONF6 interface(s) already present'
32	@echo SKIPPED
33.endif
34.if ! empty(INTERFACES)
35regress:
36	@echo 'pair(4) interfaces already present'
37	@echo SKIPPED
38.endif
39
40# Set variables so that make runs with and without obj directory.
41# Only do that if necessary to keep visible output short.
42.if ${.CURDIR} == ${.OBJDIR}
43PYTHON =	python2.7 -B -u ./
44.else
45PYTHON =	python2.7 -B -u ${.CURDIR}/
46.endif
47
48REGRESS_SETUP +=	setup
49setup: cleanup
50	@echo '\n======== $@ ========'
51	${SUDO} ifconfig ${PAIR1} rdomain ${RTABLE} 10.11.12.1/24 up
52	${SUDO} ifconfig ${PAIR2} rdomain ${RTABLE} 10.11.12.2/24 up
53	${SUDO} ifconfig ${PAIR1} rdomain ${RTABLE} patch ${PAIR2}
54	${SUDO} ifconfig ${PAIR1} inet6 rdomain ${RTABLE} eui64
55	${SUDO} ifconfig ${PAIR2} inet6 rdomain ${RTABLE} eui64
56	${SUDO} ifconfig ${PAIR2} inet6 rdomain ${RTABLE} autoconf
57	${SUDO} route -nq -T ${RTABLE} add -host default 10.11.12.1 -reject
58	${SUDO} route -T ${RTABLE} exec slaacd -s ${CTR_SOCK}
59
60REGRESS_CLEANUP +=	cleanup
61cleanup:
62	@echo '\n======== $@ ========'
63	${SUDO} pkill -T ${RTABLE} -xf "slaacd -s ${CTR_SOCK}" || true
64.for iface in ${PAIR1} ${PAIR2}
65	${SUDO} ifconfig ${iface} destroy 2>/dev/null || true
66.endfor
67
68REGRESS_TARGETS +=	run-send-solicitation
69run-send-solicitation:
70	@echo '\n======== $@ ========'
71	${SUDO} route -T${RTABLE} exec ${PYTHON}sniff_sol.py ${CTR_SOCK}
72
73
74REGRESS_TARGETS +=	run-parse-ra
75run-parse-ra:
76	@echo '\n======== $@ ========'
77	${SUDO} route -T${RTABLE} exec ${PYTHON}process_ra.py \
78	    ${PAIR1} ${PAIR2} ${CTR_SOCK}
79
80.include <bsd.regress.mk>
81