-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (40 loc) · 1.38 KB
/
Makefile
File metadata and controls
48 lines (40 loc) · 1.38 KB
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
# sema — Makefile
# ============================================================
# Usage:
# make test Run unit tests (alias for test-unit)
# make test-unit Run unit tests with race detector
# make test-bench Run benchmarks
# make test-fuzz Run all fuzz targets (30s each by default)
# make test-all Run unit + bench + fuzz
# ============================================================
PACKAGE := ./...
FUZZTIME ?= 30s
BENCHTARGET ?= .
GO ?= go
# Fuzz targets discovered from the test file
FUZZ_TARGETS := FuzzNew \
FuzzAcquireN \
FuzzReleaseN \
FuzzSetCap \
FuzzTryAcquireN \
FuzzUtilization \
FuzzConcurrentAcquireRelease \
FuzzConcurrentMixedOps
.PHONY: test test-all test-unit test-bench test-fuzz
# Default: unit tests
test: test-unit
# Everything
test-all: test-unit test-bench test-fuzz
# Unit tests with race detector
test-unit:
$(GO) test -race -count=1 -v $(PACKAGE)
# Benchmarks with memory stats
test-bench:
$(GO) test -bench=$(BENCHTARGET) -benchmem -run='^$$' $(PACKAGE)
# All fuzz targets, each for FUZZTIME duration
test-fuzz:
@for target in $(FUZZ_TARGETS); do \
echo ""; \
echo "=== FUZZ $$target ($(FUZZTIME)) ==="; \
$(GO) test -fuzz=$$target -fuzztime=$(FUZZTIME) -run='^$$' $(PACKAGE) || exit 1; \
done