summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/arp/Makefile
blob: e3555a9df98cd1131a4768ae3da084982e9e389e (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
# $OpenBSD: Makefile,v 1.4 2023/10/19 18:36:41 anton Exp $

RDOMAIN?=	5
VETHER_MAC=	fe:e1:ba:d2:a3:18
PRIV_MAC=	00:90:27:bb:cc:dd
PUB_MAC=	fe:88:33:11:bb:aa
OTHER_MAC=	cc:77:55:22:aa:66

.MAIN: all

.ifmake !obj && !clean && !cleandir && !regress
.if (${.TARGET} != all && ! make(all)) || (${.TARGET} == all)

.SILENT: .BEGIN .END .INTERRUPT

.BEGIN:
	-${SUDO} ifconfig vether10001 up lladdr ${VETHER_MAC} \
		rdomain ${RDOMAIN} 192.0.2.1/24

.END:
	-${SUDO} ifconfig vether10001 destroy
	-${SUDO} ifconfig lo${RDOMAIN} destroy

.INTERRUPT:
	-${SUDO} ifconfig vether10001 destroy
	-${SUDO} ifconfig lo${RDOMAIN} destroy

.endif
.endif

ARP=		${SUDO} arp -n -V ${RDOMAIN}

# Two entries to the same destination are ok if one is "pub"
n=	1
RTTEST_TARGETS+:=arptest${n}
arptest${n}:
	${ARP} -s 192.0.2.42 ${PRIV_MAC}
	${ARP} -s 192.0.2.42 ${PUB_MAC} pub
	${ARP} -a 2>&1| \
		diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin

# Insert the "pub" entry first, it should not matter
n=	2
RTTEST_TARGETS+:=arptest${n}
arptest${n}:
	${ARP} -s 192.0.2.42 ${PUB_MAC} pub
	${ARP} -s 192.0.2.42 ${PRIV_MAC}
	${ARP} -a 2>&1| \
		diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin

# Not specifying "pub" should generate an error
n=	3
RTTEST_TARGETS+:=arptest${n}
arptest${n}:
	${ARP} -s 192.0.2.42 ${PRIV_MAC}
	${ARP} -s 192.0.2.42 ${PUB_MAC} && exit 1 || exit 0
	${ARP} -a 2>&1| \
		diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin

# Not specifying "pub" works only if "-F" is specified
n=	4
RTTEST_TARGETS+:=arptest${n}
arptest${n}:
	${ARP} -s 192.0.2.42 ${PRIV_MAC}
	${ARP} -Fs 192.0.2.42 ${PUB_MAC}
	${ARP} -a 2>&1 | \
		diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin

# Test that "permanent" entries are correctly created
n=	5
RTTEST_TARGETS+:=arptest${n}
arptest${n}:
	${ARP} -s 192.0.2.42 ${PRIV_MAC} "permanent"
	${ARP} -a 2>&1 | \
		diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin

# Tryin to add two "pub" entries should generate and error
n=	6
RTTEST_TARGETS+:=arptest${n}
arptest${n}:
	${ARP} -s 192.0.2.42 ${PRIV_MAC}
	${ARP} -s 192.0.2.42 ${PUB_MAC} pub
	${ARP} -s 192.0.2.42 ${OTHER_MAC} pub && exit 1 || exit 0
	${ARP} -a 2>&1| \
		diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin

REGRESS_TARGETS=${RTTEST_TARGETS}
REGRESS_ROOT_TARGETS=${REGRESS_TARGETS}
.PHONY: ${REGRESS_TARGETS}

.include <bsd.regress.mk>