This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.contiki
146 lines (128 loc) · 4.3 KB
/
Makefile.contiki
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Source directories
TWO ?= .
# Contiki sources
CONTIKI ?= ../contiki-ng
# Directories and sources for contiki
TWO_SRC = $(TWO)/src
PROJECTDIRS += $(TWO_SRC) $(TWO_SRC)/hpack
PROJECT_SOURCEFILES=two.c \
content_type.c \
cbuf.c \
event.c \
header_list.c \
buffer.c \
frames.c \
hpack.c \
decoder.c \
encoder.c \
huffman.c \
tables.c \
utils.c \
http2.c
#Default contiki target
TARGET ?= native
# Include src directory first
# to avoid clashes with system include
# files
CFLAGS += -I$(TWO_SRC)
ifneq ($(BORDER_ROUTER),)
MODULES += os/services/rpl-border-router
else
# Include shell module by default if not a BR
ifeq ($(DISABLE_SHELL),)
MODULES += os/services/shell
endif
endif
# Use newlib for ARM based targets
# (save memory)
ifneq ($(filter $(TARGET),zoul openmote iotlab cc2538dk nrf52dk),)
LDFLAGS += -specs=nano.specs
endif
# Add connect-router target if PORT is defined
ifneq ($(PORT),)
connect-router: $(PORT) $(CONTIKI)/tools/serial-io/tunslip6
sudo $(CONTIKI)/tools/serial-io/tunslip6 -s $(PORT) fd00::1/64
endif
# Begin h2spec targets
# `make h2spec` will run all h2spec tests
# against a native target
#
# `make <spec>` will run one of the specs
# in h2spec.conf against a native target
#
# `TARGET=<target != native> H2SPEC_ADDR=<addr> make h2spec`
# will run h2spec against a remote target with IPv6 address H2SPEC_ADDR
# Get specs from configuration file
H2SPEC_ALL = $(filter-out $(H2SPEC_SKIP), $(shell sed -e 's/\#.*$$//' -e "/^\s*$$/d" $(TWO)/h2spec.conf))
H2SPEC_TEST ?= $(H2SPEC_ALL)
# HTTP2 server port and address for h2spec testing
H2SPEC_PORT ?= 8888
H2SPEC_ADDR ?= fd00::302:304:506:708
.PHONY: h2spec-pre h2spec-post
h2spec-pre:
@rm -f summary.txt
@echo "------------------------------"
@echo "Integration tests with h2spec"
@echo "------------------------------"
.PHONY: $(H2SPEC_ALL)
# if we are testing a native target
ifeq ($(TARGET),native)
$(H2SPEC_ALL): server.native /usr/local/bin/h2spec
@if ! test -f summary.txt; then echo "0 0" > summary.txt; fi
@(sudo ./server.native 2>/dev/null > server.log & echo $$! > server.pid) && sleep 0.5 && \
(h2spec $@ -p $(H2SPEC_PORT) -h [$(H2SPEC_ADDR)] > h2spec.log && rm h2spec.log); \
PID=$$(cat server.pid); \
TOTAL=$$(awk '{print $$1 + 1}' summary.txt); \
FAILURES=$$(awk '{print $$2}' summary.txt); \
sed -i 1,20d server.log; \
echo -n "$@: "; \
if test -e /proc/$$PID; then \
sudo pkill server.native && \
if test -f h2spec.log; then \
echo "FAIL"; \
echo " Client output: "; \
FAILURES=$$(($$FAILURES + 1)); \
cat h2spec.log | sed -e/^Failures:/\{ -e:1 -en\;b1 -e\} -ed | grep -a -B 1 -A 4 "×" | sed /^$$/q; \
if test -s server.log; then echo " Server output:"; cat server.log | sed "s/^/ /"; fi; \
rm h2spec.log; \
else \
echo "PASS"; \
fi; \
else \
FAILURES=$$(($$FAILURES + 1)); \
echo "FAIL"; \
echo " Server output:"; cat server.log | sed "s/^/ /" ; \
fi; \
echo "$$TOTAL $$FAILURES" > summary.txt; \
rm server.pid server.log
else
# we are testing a remote target
# Specs to skip on embedded targets (frame size too large)
H2SPEC_SKIP = generic/5/14 generic/5/15 http2/4.2/1 http2/4.2/2 http2/4.2/3 http2/6.5.3/1 http2/6.9.1/1 http2/6.9.2/1 http2/6.9.2/2 http2/6.10/1
$(H2SPEC_ALL): /usr/local/bin/h2spec
@if ! test -f summary.txt; then echo "0 0" > summary.txt; fi
@(h2spec $@ -p $(H2SPEC_PORT) -h [$(H2SPEC_ADDR)] > h2spec.log && rm h2spec.log); \
TOTAL=$$(awk '{print $$1 + 1}' summary.txt); \
FAILURES=$$(awk '{print $$2}' summary.txt); \
/bin/echo -n "$@: "; \
if test -f h2spec.log; then \
echo "FAIL"; \
echo " Client output: "; \
FAILURES=$$(($$FAILURES + 1)); \
cat h2spec.log | sed -e/^Failures:/\{ -e:1 -en\;b1 -e\} -ed | grep -a -B 1 -A 4 "×" | sed /^$$/q; \
if test -s server.log; then echo " Server output:"; cat server.log | sed "s/^/ /"; fi; \
rm h2spec.log; \
else \
echo "PASS"; \
fi; \
echo "$$TOTAL $$FAILURES" > summary.txt && sleep 1
endif
h2spec-post:
@echo "------------------------------"
@awk '{printf "total: %d, passed: %d, failed: %d\n", $$1,$$1 - $$2,$$2}' summary.txt; \
FAILED=$$(awk '{print $$2}' summary.txt); \
rm summary.txt; \
test $$FAILED -eq 0
h2spec: h2spec-pre $(H2SPEC_TEST) h2spec-post
# Include contiki makefile
include $(CONTIKI)/Makefile.include