diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 46 |
1 files changed, 40 insertions, 6 deletions
| @@ -69,8 +69,8 @@ CFLAGS_libowfat=-I$(LIBOWFAT_HEADERS) | |||
| 69 | LDFLAGS_libowfat=-L$(LIBOWFAT_LIBRARY) -lowfat | 69 | LDFLAGS_libowfat=-L$(LIBOWFAT_LIBRARY) -lowfat |
| 70 | 70 | ||
| 71 | BINARY =opentracker | 71 | BINARY =opentracker |
| 72 | HEADERS=trackerlogic.h ot_urlencoded.h ot_batch.h ot_buf.h ot_event.h ot_fdstate.h ot_hex.h ot_ip.h ot_config.h ot_scan.h ot_socket.h ot_mutex.h ot_random.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h | 72 | HEADERS=trackerlogic.h ot_urlencoded.h ot_batch.h ot_buf.h ot_event.h ot_fdstate.h ot_fmt.h ot_hex.h ot_ip.h ot_config.h ot_scan.h ot_socket.h ot_mutex.h ot_random.h ot_stats.h ot_vector.h ot_clean.h ot_udp.h ot_iovec.h ot_fullscrape.h ot_accesslist.h ot_http.h ot_livesync.h ot_rijndael.h |
| 73 | SOURCES=opentracker.c trackerlogic.c ot_urlencoded.c ot_batch.c ot_buf.c ot_event.c ot_fdstate.c ot_hex.c ot_ip.c ot_config.c ot_scan.c ot_socket.c ot_mutex.c ot_random.c ot_stats.c ot_vector.c ot_clean.c ot_udp.c ot_iovec.c ot_fullscrape.c ot_accesslist.c ot_http.c ot_livesync.c ot_rijndael.c | 73 | SOURCES=opentracker.c trackerlogic.c ot_urlencoded.c ot_batch.c ot_buf.c ot_event.c ot_fdstate.c ot_fmt.c ot_hex.c ot_ip.c ot_config.c ot_scan.c ot_socket.c ot_mutex.c ot_random.c ot_stats.c ot_vector.c ot_clean.c ot_udp.c ot_iovec.c ot_fullscrape.c ot_accesslist.c ot_http.c ot_livesync.c ot_rijndael.c |
| 74 | SOURCES_proxy=proxy.c ot_batch.c ot_fdstate.c ot_vector.c ot_mutex.c ot_random.c ot_scan.c ot_ip.c ot_socket.c | 74 | SOURCES_proxy=proxy.c ot_batch.c ot_fdstate.c ot_vector.c ot_mutex.c ot_random.c ot_scan.c ot_ip.c ot_socket.c |
| 75 | 75 | ||
| 76 | OBJECTS = $(SOURCES:%.c=%.o) | 76 | OBJECTS = $(SOURCES:%.c=%.o) |
| @@ -120,8 +120,8 @@ $(OBJECTS_proxy_debug): $(HEADERS) | |||
| 120 | # has to. tests/stubs.c supplies the few symbols those modules reference but | 120 | # has to. tests/stubs.c supplies the few symbols those modules reference but |
| 121 | # the tests never reach. | 121 | # the tests never reach. |
| 122 | TESTBIN=tests/runner | 122 | TESTBIN=tests/runner |
| 123 | TEST_SOURCES=tests/runner.c tests/test.c tests/stubs.c tests/t_urlencoded.c tests/t_iovec.c tests/t_vector.c tests/t_random.c tests/t_hex.c tests/t_accesslist.c tests/t_scan.c tests/t_buf.c tests/t_ip.c tests/t_socket.c tests/t_mutex.c tests/t_batch.c tests/t_fdstate.c tests/t_event.c | 123 | TEST_SOURCES=tests/runner.c tests/test.c tests/stubs.c tests/t_urlencoded.c tests/t_iovec.c tests/t_vector.c tests/t_random.c tests/t_hex.c tests/t_accesslist.c tests/t_scan.c tests/t_buf.c tests/t_ip.c tests/t_socket.c tests/t_mutex.c tests/t_batch.c tests/t_fdstate.c tests/t_event.c tests/t_fmt.c |
| 124 | TEST_UNITS=ot_urlencoded.c ot_event.c ot_batch.c ot_fdstate.c ot_buf.c ot_ip.c ot_socket.c ot_iovec.c ot_vector.c ot_random.c ot_hex.c ot_scan.c ot_accesslist.c ot_mutex.c | 124 | TEST_UNITS=ot_urlencoded.c ot_fmt.c ot_event.c ot_batch.c ot_fdstate.c ot_buf.c ot_ip.c ot_socket.c ot_iovec.c ot_vector.c ot_random.c ot_hex.c ot_scan.c ot_accesslist.c ot_mutex.c |
| 125 | TEST_HEADERS=tests/test.h $(HEADERS) | 125 | TEST_HEADERS=tests/test.h $(HEADERS) |
| 126 | # Tests reach code that sits behind feature flags, so the units under test are | 126 | # Tests reach code that sits behind feature flags, so the units under test are |
| 127 | # built with those features enabled. A test binary is not a production binary. | 127 | # built with those features enabled. A test binary is not a production binary. |
| @@ -134,10 +134,44 @@ $(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) | |||
| 134 | check: $(TESTBIN) $(BINARY) | 134 | check: $(TESTBIN) $(BINARY) |
| 135 | ./$(TESTBIN) | 135 | ./$(TESTBIN) |
| 136 | 136 | ||
| 137 | .PHONY: all check clean install | 137 | # The same unit tests under the sanitizers. Use clang over $(CC) because the |
| 138 | # two toolchains do not check the same things | ||
| 139 | # Override CC_sanitize to use another compiler. | ||
| 140 | CC_sanitize?=clang | ||
| 141 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 142 | LDFLAGS_sanitize=$(LDFLAGS) -fsanitize=address,undefined | ||
| 143 | |||
| 144 | $(TESTBIN).sanitize: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) | ||
| 145 | $(CC_sanitize) -o $@ $(CFLAGS_sanitize) $(TEST_SOURCES) $(TEST_UNITS) $(LDFLAGS_sanitize) | ||
| 146 | |||
| 147 | check-sanitize: $(TESTBIN).sanitize | ||
| 148 | ./$(TESTBIN).sanitize | ||
| 149 | |||
| 150 | # Black box tests: these drive the real binary over the wire, so they cover | ||
| 151 | # the event loop and the parsers working together, which the unit tests | ||
| 152 | # cannot reach. Built with the sanitizers on, so the tracker reports its own | ||
| 153 | # memory errors and the harness turns those into failures. | ||
| 154 | PYTHON?=python3 | ||
| 155 | FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_BLACK | ||
| 156 | CFLAGS_integration=$(CFLAGS) $(OPTS_debug) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 157 | LDFLAGS_integration=$(LDFLAGS) -fsanitize=address,undefined | ||
| 158 | |||
| 159 | opentracker.integration: $(SOURCES) $(HEADERS) | ||
| 160 | $(CC) -o $@ $(CFLAGS_integration) $(SOURCES) $(LDFLAGS_integration) | ||
| 161 | |||
| 162 | check-integration: opentracker.integration | ||
| 163 | OPENTRACKER=./opentracker.integration $(PYTHON) -m unittest discover -s tests/integration | ||
| 164 | |||
| 165 | # Everything, cheapest first, so a quick failure comes back quickly. | ||
| 166 | check-all: | ||
| 167 | $(MAKE) check | ||
| 168 | $(MAKE) check-sanitize | ||
| 169 | $(MAKE) check-integration | ||
| 170 | |||
| 171 | .PHONY: all check check-sanitize check-integration check-all clean install | ||
| 138 | 172 | ||
| 139 | clean: | 173 | clean: |
| 140 | rm -rf opentracker opentracker.debug proxy proxy.debug $(TESTBIN) *.o *~ | 174 | rm -rf opentracker opentracker.debug opentracker.integration proxy proxy.debug $(TESTBIN) $(TESTBIN).sanitize *.o *~ |
| 141 | 175 | ||
| 142 | install: | 176 | install: |
| 143 | install -m 755 opentracker $(DESTDIR)$(BINDIR) | 177 | install -m 755 opentracker $(DESTDIR)$(BINDIR) |
