-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
48 lines (37 loc) · 986 Bytes
/
Makefile
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
CFLAGS+=-Wall
TESTPORT=1025
TARGETS = \
connect_gai \
connect_happy \
# end
TEST_TARGETS = $(addprefix test-,$(TARGETS))
all: $(TARGETS)
connect_%: main.o %.o
$(CC) $(CFLAGS) $^ -o $@
connect_happy: rfc6555.o
rfc6555_test: CFLAGS+=-g
rfc6555_test: rfc6555.o
test%: CFLAGS+=-g
test: test-unit test-integration
test-unit: rfc6555_test
./rfc6555_test
test-integration: $(TEST_TARGETS) test-down
test-%: % test-up
./$(*) localhost $(TESTPORT)
test-up:
-sudo iptables -I INPUT -p tcp --dport $(TESTPORT) -j ACCEPT
-sudo ip6tables -I INPUT -p tcp --dport $(TESTPORT) -j DROP
yes | nc -4klp $(TESTPORT) &
test-down:
killall -9 nc # XXX: dodgy
-sudo ip6tables -D INPUT -p tcp --dport $(TESTPORT) -j DROP
-sudo iptables -D INPUT -p tcp --dport $(TESTPORT) -j ACCEPT
clean:
rm -f *.o
rm -f rfc6555_test
rm -f $(TARGETS)
.PHONY: all \
test test-unit \
test-integration test-up test-down \
# $(TEST_TARGETS) \ # For some reason, those don't run if PHONY
# end