diff options
Diffstat (limited to 'Mk')
| -rw-r--r-- | Mk/gzip.mk | 4 | ||||
| -rw-r--r-- | Mk/proxy.mk | 25 | ||||
| -rw-r--r-- | Mk/release.mk | 27 | ||||
| -rw-r--r-- | Mk/tests.mk | 87 | ||||
| -rw-r--r-- | Mk/zstd.mk | 3 |
5 files changed, 146 insertions, 0 deletions
diff --git a/Mk/gzip.mk b/Mk/gzip.mk new file mode 100644 index 0000000..3ae53b3 --- /dev/null +++ b/Mk/gzip.mk | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_GZIP | ||
| 2 | #FEATURES+=-DWANT_COMPRESSION_GZIP_ALWAYS | ||
| 3 | |||
| 4 | OT_LDLIBS+=-lz | ||
diff --git a/Mk/proxy.mk b/Mk/proxy.mk new file mode 100644 index 0000000..64d18dc --- /dev/null +++ b/Mk/proxy.mk | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | # The proxy relays sync traffic between trackers and between multicast domains | ||
| 2 | # that cannot reach each other. It does not build; see the note at the top of | ||
| 3 | # proxy.c. Scheduled for v1.1.0, when these rules come back. | ||
| 4 | # | ||
| 5 | # LIBOWFAT_HEADERS=$(PREFIX)/libowfat | ||
| 6 | # LIBOWFAT_LIBRARY=$(PREFIX)/libowfat | ||
| 7 | # CFLAGS_libowfat=-I$(LIBOWFAT_HEADERS) | ||
| 8 | # LDFLAGS_libowfat=-L$(LIBOWFAT_LIBRARY) -lowfat | ||
| 9 | # | ||
| 10 | # SOURCES_proxy=src/proxy.c src/ot_batch.c src/ot_fdstate.c src/ot_vector.c src/ot_mutex.c src/ot_random.c src/ot_scan.c src/ot_ip.c src/ot_socket.c | ||
| 11 | # CFLAGS_proxy=$(CFLAGS_production) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | ||
| 12 | # CFLAGS_proxy_debug=$(CFLAGS_debug) $(CFLAGS_libowfat) -DWANT_SYNC_LIVE | ||
| 13 | # | ||
| 14 | # BINARIES+=proxy proxy.debug | ||
| 15 | # | ||
| 16 | # proxy: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 17 | # $(CC) -o $@ $(CFLAGS_proxy) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | ||
| 18 | # proxy.debug: $(SOURCES_proxy) $(HEADERS) $(BUILDDEPS) | ||
| 19 | # $(CC) -o $@ $(CFLAGS_proxy_debug) $(SOURCES_proxy) $(LDFLAGS) $(LDFLAGS_libowfat) | ||
| 20 | |||
| 21 | proxy proxy.debug: | ||
| 22 | @echo "$@ is out of service until v1.1.0, see the note at the top of proxy.c" | ||
| 23 | @false | ||
| 24 | |||
| 25 | .PHONY: proxy proxy.debug | ||
diff --git a/Mk/release.mk b/Mk/release.mk new file mode 100644 index 0000000..5c4afe9 --- /dev/null +++ b/Mk/release.mk | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | # .tarball-version is what dist wrote into the tarball | ||
| 2 | # In a checkout it is absent and git answers instead. A release is always | ||
| 3 | # tagged, so in a tarball both of these are that tag, and the gitweb link | ||
| 4 | # is to it. Between releases there is no tag and the version is the commit. | ||
| 5 | VERSION=1.0.0 | ||
| 6 | |||
| 7 | TARBALL_VERSION=test -r .tarball-version && read v < .tarball-version && echo "$$v" | ||
| 8 | HAVE_GIT=command -v git >/dev/null && test -d .git | ||
| 9 | GIT_VERSION=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --always --dirty 2>/dev/null; }'` | ||
| 10 | OT_TAG=`sh -c '$(TARBALL_VERSION) || { $(HAVE_GIT) && git describe --tags --match "v*" --exact-match 2>/dev/null; }'` | ||
| 11 | |||
| 12 | OT_CFLAGS+=-DOT_VERSION=\"$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" -DOT_TAG=\"$(OT_TAG)\" | ||
| 13 | |||
| 14 | # Roll a release: tag it v$(VERSION), then make dist. The tarball is HEAD by | ||
| 15 | # construction, so the working tree it was rolled from does not enter into it. | ||
| 16 | DISTNAME=opentracker-$(VERSION) | ||
| 17 | |||
| 18 | dist: | ||
| 19 | @test "`git describe --tags --match 'v*' --exact-match 2>/dev/null`" = "v$(VERSION)" || \ | ||
| 20 | { echo "HEAD must carry the tag v$(VERSION). Tag the release, or correct VERSION."; exit 1; } | ||
| 21 | rm -rf $(DISTNAME) $(DISTNAME).tar.gz | ||
| 22 | git archive --format=tar --prefix=$(DISTNAME)/ HEAD | tar -xf - | ||
| 23 | git describe --tags --match "v*" --always > $(DISTNAME)/.tarball-version | ||
| 24 | tar -czf $(DISTNAME).tar.gz $(DISTNAME) | ||
| 25 | rm -rf $(DISTNAME) | ||
| 26 | |||
| 27 | .PHONY: dist | ||
diff --git a/Mk/tests.mk b/Mk/tests.mk new file mode 100644 index 0000000..2efdd72 --- /dev/null +++ b/Mk/tests.mk | |||
| @@ -0,0 +1,87 @@ | |||
| 1 | BUILDDEPS+=Mk/tests.mk | ||
| 2 | |||
| 3 | # The modules under test are compiled straight into the test binary, so a test | ||
| 4 | # may reach a static function by including the source. tests/stubs.c supplies | ||
| 5 | # the few symbols those modules reference but the tests never reach. | ||
| 6 | TESTBIN=tests/runner | ||
| 7 | 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_trackerlogic.c tests/t_workqueue.c tests/t_batch.c tests/t_fdstate.c tests/t_event.c tests/t_fmt.c | ||
| 8 | TEST_UNITS=src/ot_urlencoded.c src/ot_fmt.c src/ot_event.c src/ot_batch.c src/ot_fdstate.c src/ot_buf.c src/ot_ip.c src/ot_socket.c src/ot_iovec.c src/ot_vector.c src/ot_random.c src/ot_hex.c src/ot_scan.c src/ot_accesslist.c src/ot_mutex.c src/ot_workqueue.c src/trackerlogic.c | ||
| 9 | TEST_HEADERS=tests/test.h $(HEADERS) | ||
| 10 | |||
| 11 | # A test binary is not a production binary, so it is built with the features | ||
| 12 | # the tests need to reach. | ||
| 13 | FEATURES_test=$(FEATURES) -DWANT_ACCESSLIST_BLACK -DWANT_SYNC_LIVE | ||
| 14 | CFLAGS_test=-Isrc -g -O1 $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_test) | ||
| 15 | |||
| 16 | # clang over $(CC) because the two toolchains do not check the same things. | ||
| 17 | CC_sanitize?=clang | ||
| 18 | CFLAGS_sanitize=$(CFLAGS_test) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 19 | LDFLAGS_sanitize=$(LINK) -fsanitize=address,undefined | ||
| 20 | |||
| 21 | # Black box tests drive the real binary over the wire, so they cover the event | ||
| 22 | # loop and the parsers working together. The client timeout is cut right down | ||
| 23 | # so a test can reach the expiry sweep; tests/integration/test_expiry.py | ||
| 24 | # mirrors these two numbers. | ||
| 25 | PYTHON?=python3 | ||
| 26 | FEATURES_integration=$(FEATURES) -DWANT_IP_FROM_QUERY_STRING -DWANT_ACCESSLIST_BLACK -DWANT_DYNAMIC_ACCESSLIST -DWANT_KEEPALIVE -DOT_CLIENT_TIMEOUT=5 -DOT_CLIENT_TIMEOUT_CHECKINTERVAL=1 | ||
| 27 | CFLAGS_integration=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 28 | LDFLAGS_integration=$(LINK) -fsanitize=address,undefined | ||
| 29 | CFLAGS_tsan=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_integration) -fsanitize=thread -fno-omit-frame-pointer | ||
| 30 | LDFLAGS_tsan=$(LINK) -fsanitize=thread | ||
| 31 | |||
| 32 | # Live sync is a compile time feature, so reaching it from a black box test | ||
| 33 | # needs a binary of its own. tests/integration/test_livesync.py skips itself | ||
| 34 | # against a build without it, which is what -v is for. | ||
| 35 | FEATURES_livesync=$(FEATURES_integration) -DWANT_SYNC_LIVE | ||
| 36 | CFLAGS_livesync=$(OPTS_debug) $(CPPFLAGS) $(OT_CFLAGS) $(FEATURES_livesync) -fsanitize=address,undefined -fno-omit-frame-pointer | ||
| 37 | |||
| 38 | BINARIES+=$(TESTBIN) $(TESTBIN).poll $(TESTBIN).sanitize opentracker.integration opentracker.tsan opentracker.livesync | ||
| 39 | |||
| 40 | $(TESTBIN): $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 41 | $(CC) -o $@ $(CFLAGS_test) $(TEST_SOURCES) $(TEST_UNITS) | ||
| 42 | |||
| 43 | $(TESTBIN).poll: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 44 | $(CC) -o $@ $(CFLAGS_test) -DOT_EVENT_FORCE_POLL $(TEST_SOURCES) $(TEST_UNITS) | ||
| 45 | |||
| 46 | $(TESTBIN).sanitize: $(TEST_SOURCES) $(TEST_UNITS) $(TEST_HEADERS) $(BUILDDEPS) | ||
| 47 | $(CC_sanitize) -o $@ $(CFLAGS_sanitize) $(TEST_SOURCES) $(TEST_UNITS) $(LDFLAGS_sanitize) | ||
| 48 | |||
| 49 | opentracker.integration: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 50 | $(CC) -o $@ $(CFLAGS_integration) $(SOURCES) $(LDFLAGS_integration) | ||
| 51 | |||
| 52 | opentracker.tsan: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 53 | $(CC) -o $@ $(CFLAGS_tsan) $(SOURCES) $(LDFLAGS_tsan) | ||
| 54 | |||
| 55 | opentracker.livesync: $(SOURCES) $(HEADERS) $(BUILDDEPS) | ||
| 56 | $(CC) -o $@ $(CFLAGS_livesync) $(SOURCES) $(LDFLAGS_integration) | ||
| 57 | |||
| 58 | check: $(TESTBIN) $(BINARY) | ||
| 59 | ./$(TESTBIN) | ||
| 60 | |||
| 61 | check-poll: $(TESTBIN).poll | ||
| 62 | ./$(TESTBIN).poll ot_event | ||
| 63 | |||
| 64 | check-sanitize: $(TESTBIN).sanitize | ||
| 65 | ./$(TESTBIN).sanitize | ||
| 66 | |||
| 67 | check-integration: opentracker.integration | ||
| 68 | OPENTRACKER=./opentracker.integration $(PYTHON) -m unittest discover -s tests/integration | ||
| 69 | |||
| 70 | check-tsan: opentracker.tsan | ||
| 71 | OPENTRACKER=./opentracker.tsan $(PYTHON) -m unittest discover -s tests/integration | ||
| 72 | |||
| 73 | # The whole suite against a build that has live sync, which is also the only | ||
| 74 | # way the live sync tests stop skipping. | ||
| 75 | check-livesync: opentracker.livesync | ||
| 76 | OPENTRACKER=./opentracker.livesync $(PYTHON) -m unittest discover -s tests/integration | ||
| 77 | |||
| 78 | # Cheapest first, so a quick failure comes back quickly. | ||
| 79 | check-all: | ||
| 80 | $(MAKE) check | ||
| 81 | $(MAKE) check-poll | ||
| 82 | $(MAKE) check-sanitize | ||
| 83 | $(MAKE) check-integration | ||
| 84 | $(MAKE) check-livesync | ||
| 85 | $(MAKE) check-tsan | ||
| 86 | |||
| 87 | .PHONY: check check-poll check-sanitize check-integration check-livesync check-tsan check-all | ||
diff --git a/Mk/zstd.mk b/Mk/zstd.mk new file mode 100644 index 0000000..8c1fc40 --- /dev/null +++ b/Mk/zstd.mk | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | FEATURES+=-DWANT_COMPRESSION_ZSTD | ||
| 2 | #FEATURES+=-DWANT_COMPRESSION_ZSTD_ALWAYS | ||
| 3 | OT_LDLIBS+=-lzstd | ||
