-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (67 loc) · 4.29 KB
/
Copy pathMakefile
File metadata and controls
81 lines (67 loc) · 4.29 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
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
.PHONY: all clean run build test test-unit test-smoke coverage-build test-coverage profile-build profile-tests system-tests system-tests-parallel
NPROC := $(shell command -v nproc >/dev/null 2>&1 && nproc || sysctl -n hw.ncpu 2>/dev/null || echo 2)
JOBS := $(shell expr $(NPROC) / 4)
COVERAGE_BUILD_DIR := build/coverage
PROFILE_BUILD_DIR := build/profile
PROFILE_TEST_BINARIES := core_unit_tests exec_rules_unit_tests core_integration_tests
PROFILE_GPROF_RUNS := 5
PYTHON := python3
LOCAL_BUILD_CMAKE_ARGS := -DREQPACK_LINK_STATIC_LUA:BOOL=OFF -DCMAKE_EXE_LINKER_FLAGS:STRING=
LOCAL_SYSTEM_TEST_JOBS ?= $(JOBS)
LOCAL_SYSTEM_TEST_BUILD_JOBS ?=
all: build
cmake --build build -j$(JOBS)
build:
cmake -S . -B build $(LOCAL_BUILD_CMAKE_ARGS)
run: all
@echo
@echo "---------------------- Running ReqPack ----------------------"
@echo
@echo
@./build/ReqPack ${ARGS}
test: all
@ctest --test-dir build --output-on-failure
test-unit: all
@ctest --test-dir build --output-on-failure -R "^unit::"
test-smoke: all
@ctest --test-dir build --output-on-failure -R "^integration::"
system-tests:
@LOCAL_SYSTEM_TEST_BUILD_JOBS="$(LOCAL_SYSTEM_TEST_BUILD_JOBS)" bash scripts/run-all-local-system-tests.sh $(LOCAL_SYSTEM_TEST_SCENARIOS)
system-tests-parallel:
@JOBS="$(LOCAL_SYSTEM_TEST_JOBS)" LOCAL_SYSTEM_TEST_BUILD_JOBS="$(LOCAL_SYSTEM_TEST_BUILD_JOBS)" bash scripts/run-all-local-system-tests-parallel.sh $(LOCAL_SYSTEM_TEST_SCENARIOS)
coverage-build:
cmake -S . -B $(COVERAGE_BUILD_DIR) -DCMAKE_BUILD_TYPE=Debug -DREQPACK_ENABLE_COVERAGE=ON
cmake --build $(COVERAGE_BUILD_DIR) -j$(JOBS)
test-coverage: coverage-build
@ctest --test-dir $(COVERAGE_BUILD_DIR) --output-on-failure
@ctest --test-dir $(COVERAGE_BUILD_DIR) -T Coverage
@$(PYTHON) tests/coverage_summary.py $(COVERAGE_BUILD_DIR) .
profile-build:
cmake -S . -B $(PROFILE_BUILD_DIR) -DCMAKE_BUILD_TYPE=RelWithDebInfo -DREQPACK_ENABLE_PROFILING=ON
cmake --build $(PROFILE_BUILD_DIR) -j$(JOBS)
profile-tests: profile-build
@cmake -E make_directory $(PROFILE_BUILD_DIR)/profile-data
@if command -v perf >/dev/null 2>&1; then \
for binary in $(PROFILE_TEST_BINARIES); do \
echo "Profiling $$binary with perf"; \
"$(CURDIR)/$(PROFILE_BUILD_DIR)/$$binary" > "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/$$binary.log" 2>&1 || { cat "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/$$binary.log"; exit 1; }; \
perf record --no-inherit --call-graph dwarf --output "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/$$binary.perf.data" -- "$(CURDIR)/$(PROFILE_BUILD_DIR)/$$binary" > "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/$$binary.perf.log" 2>&1 || { cat "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/$$binary.perf.log"; exit 1; }; \
perf report --stdio --no-children --sort comm,dso,symbol --percent-limit 0.5 --dsos "$$binary" -i "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/$$binary.perf.data" > "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/$$binary.perf-report.txt"; \
$(PYTHON) tests/profile_summary.py perf "$(PROFILE_BUILD_DIR)/profile-data/$$binary.perf-report.txt"; \
echo "Full perf report: $(PROFILE_BUILD_DIR)/profile-data/$$binary.perf-report.txt"; \
done; \
elif command -v gprof >/dev/null 2>&1; then \
for run in $$(seq 1 $(PROFILE_GPROF_RUNS)); do \
cmake -E env GMON_OUT_PREFIX="$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/core_unit_tests" "$(CURDIR)/$(PROFILE_BUILD_DIR)/core_unit_tests" > /dev/null || exit 1; \
cmake -E env GMON_OUT_PREFIX="$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/exec_rules_unit_tests" "$(CURDIR)/$(PROFILE_BUILD_DIR)/exec_rules_unit_tests" > /dev/null || exit 1; \
done; \
gprof "$(CURDIR)/$(PROFILE_BUILD_DIR)/core_unit_tests" "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/core_unit_tests."* > "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/core_unit_tests.gprof.txt"; \
gprof "$(CURDIR)/$(PROFILE_BUILD_DIR)/exec_rules_unit_tests" "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/exec_rules_unit_tests."* > "$(CURDIR)/$(PROFILE_BUILD_DIR)/profile-data/exec_rules_unit_tests.gprof.txt"; \
$(PYTHON) tests/profile_summary.py gprof "$(PROFILE_BUILD_DIR)/profile-data/core_unit_tests.gprof.txt"; \
echo "Full gprof reports: $(PROFILE_BUILD_DIR)/profile-data/core_unit_tests.gprof.txt, $(PROFILE_BUILD_DIR)/profile-data/exec_rules_unit_tests.gprof.txt"; \
else \
echo "Neither perf nor gprof is available" >&2; \
exit 1; \
fi
clean:
rm -rf build