forked from trip-zip/somewm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
261 lines (218 loc) · 8.98 KB
/
Copy pathMakefile
File metadata and controls
261 lines (218 loc) · 8.98 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# Meson build system wrapper
# Run `meson configure build` to see/change build options
#
# Examples:
# make # Build (sets up meson if needed)
# sudo make install # Install to /usr/local
# make clean # Remove build directory
# make reconfigure # Wipe and reconfigure build
-include .local.mk
.PHONY: all install uninstall clean setup reconfigure test test-unit test-lua-compat test-check test-signal test-integration test-orchestrator test-restart test-one-restart test-asan test-one test-visual test-one-visual test-ci test-fast build-test build-bench bench-run bench-run-live bench-json bench-baseline bench-compare bench-check bench-memory bench-flamegraph bench-diff bench-heaptrack profile profile-lua profile-save profile-diff
# Default build: optimized release, no sanitizers
all:
@test -d build || meson setup build -Dbuildtype=release -Db_sanitize=none $(if $(LUA_PKG),-Dlua_pkg=$(LUA_PKG),) $(MESON_OPTS)
ninja -C build
# AddressSanitizer + UBSan build (separate dir, for development)
asan:
@test -d build-asan || meson setup build-asan -Db_sanitize=address,undefined $(if $(LUA_PKG),-Dlua_pkg=$(LUA_PKG),) $(MESON_OPTS)
ninja -C build-asan
# Build for tests: NO ASAN (fast) - explicitly disable sanitizers, enable test PAM stub
build-test:
@test -d build-test || meson setup build-test -Db_sanitize=none -Dtest_pam=true $(if $(LUA_PKG),-Dlua_pkg=$(LUA_PKG),) $(MESON_OPTS)
ninja -C build-test
install:
meson install -C build
uninstall:
ninja -C build uninstall
clean:
rm -rf build build-test build-asan
# Just setup (useful for IDE integration)
setup:
meson setup build
# Wipe and reconfigure
reconfigure:
rm -rf build
meson setup build
# =============================================================================
# Testing
# =============================================================================
# Run all tests (fast, no ASAN)
test: test-unit test-check test-signal test-orchestrator test-restart test-integration
# Parse lua/ with every installed Lua version (no compositor needed)
test-lua-compat:
@./tests/check-lua-compat.sh
# Unit tests only (busted, no compositor needed)
test-unit: test-lua-compat
@./tests/run-unit.sh
# Check mode tests (no compositor needed, tests somewm --check)
test-check: build-test
@./tests/test-check-mode.sh ./build-test/somewm
# SIGTERM regression test (issue 613): a headless somewm must exit on SIGTERM
test-signal: build-test
@./tests/test-signal-term.sh ./build-test/somewm
# Test orchestrator (somewm-client test ...): spawns headless nested compositor
test-orchestrator: build-test
@./tests/test-test-orchestrator.sh ./build-test/somewm ./build-test/somewm-client
# Restart tests: assertions on both sides of a real awesome.restart()
test-restart: build-test
@SOMEWM=./build-test/somewm SOMEWM_CLIENT=./build-test/somewm-client ./tests/run-restart.sh
# Run single restart test, keeping its instance log
# Usage: make test-one-restart TEST=tests/restart/notify-after-restart.sh
test-one-restart: build-test
ifndef TEST
@echo "Usage: make test-one-restart TEST=tests/restart/restart-executes.sh"
@exit 1
endif
@KEEP_LOGS=1 \
SOMEWM=./build-test/somewm \
SOMEWM_CLIENT=./build-test/somewm-client \
./tests/run-restart.sh $(TEST)
# Integration tests (visual mode by default, no ASAN)
test-integration: build-test
@SOMEWM=./build-test/somewm SOMEWM_CLIENT=./build-test/somewm-client ./tests/run-integration.sh
# Integration tests with ASAN (slower, catches memory bugs)
test-asan: asan
@SOMEWM=./build-asan/somewm SOMEWM_CLIENT=./build-asan/somewm-client ./tests/run-integration.sh
# CI mode: headless (for automated testing environments)
test-ci: build-test test-unit test-signal test-restart
@HEADLESS=1 \
SOMEWM=./build-test/somewm \
SOMEWM_CLIENT=./build-test/somewm-client \
./tests/run-integration.sh
# Fast test suite using persistent compositor (10x faster)
test-fast: build-test
@PERSISTENT=1 \
SOMEWM=./build-test/somewm \
SOMEWM_CLIENT=./build-test/somewm-client \
./tests/run-integration.sh
# Run single test (TDD workflow, no ASAN for speed)
# Usage: make test-one TEST=tests/test-focus.lua
test-one: build-test
ifndef TEST
@echo "Usage: make test-one TEST=tests/test-my-feature.lua"
@exit 1
endif
@VERBOSE=1 \
TEST_TIMEOUT=10 \
SOMEWM=./build-test/somewm \
SOMEWM_CLIENT=./build-test/somewm-client \
./tests/run-integration.sh $(TEST)
# Visual test mode - watch tests run in a window (like AwesomeWM's Xephyr)
test-visual: build-test
@HEADLESS=0 \
SOMEWM=./build-test/somewm \
SOMEWM_CLIENT=./build-test/somewm-client \
./tests/run-integration.sh
# Visual single test - for debugging
test-one-visual: build-test
ifndef TEST
@echo "Usage: make test-one-visual TEST=tests/test-my-feature.lua"
@exit 1
endif
@HEADLESS=0 \
VERBOSE=1 \
TEST_TIMEOUT=60 \
SOMEWM=./build-test/somewm \
SOMEWM_CLIENT=./build-test/somewm-client \
./tests/run-integration.sh $(TEST)
# =============================================================================
# Benchmarking
# =============================================================================
# Build with bench instrumentation (no ASAN, debugoptimized)
build-bench:
@test -d build-bench || meson setup build-bench -Db_sanitize=none -Dbuildtype=debugoptimized -Dbench=true
ninja -C build-bench
# Run benchmarks in headless mode
bench-run: build-bench
@HEADLESS=1 \
SOMEWM=./build-bench/somewm \
SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/run-all.sh
# Run benchmarks against the live compositor session
bench-run-live:
@HEADLESS=0 \
SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/run-all.sh
# Record perf profile during benchmarks (30s default, override with PERF_DURATION=N)
bench-flamegraph: build-bench
perf record -g --call-graph dwarf -p $$(pidof somewm) -o perf-bench.data -- sleep $${PERF_DURATION:-30}
perf script -i perf-bench.data | stackcollapse-perf.pl | flamegraph.pl > somewm-bench-flamegraph.svg
@echo "Flamegraph: somewm-bench-flamegraph.svg"
# Generate differential flamegraph between two perf recordings
# Usage: make bench-diff SYNC=perf-sync.data QUEUE=perf-queue.data
bench-diff:
ifndef SYNC
@echo "Usage: make bench-diff SYNC=perf-sync.data QUEUE=perf-queue.data"
@exit 1
endif
ifndef QUEUE
@echo "Usage: make bench-diff SYNC=perf-sync.data QUEUE=perf-queue.data"
@exit 1
endif
perf script -i $(SYNC) | stackcollapse-perf.pl > /tmp/sync.folded
perf script -i $(QUEUE) | stackcollapse-perf.pl > /tmp/queue.folded
difffolded.pl /tmp/sync.folded /tmp/queue.folded | flamegraph.pl > somewm-bench-diff.svg
@echo "Differential flamegraph: somewm-bench-diff.svg"
# Run benchmarks with JSON output capture (against live session)
bench-json: build-bench
@JSON=1 \
SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/run-all.sh
# Save current results as baseline for this branch
bench-baseline: bench-json
./tests/bench/bench-save-baseline.sh
# Compare two result sets: make bench-compare A=results/dir-a B=results/dir-b
bench-compare:
@lua5.1 tests/bench/bench-stats.lua $(A) $(B) 2>/dev/null \
|| luajit tests/bench/bench-stats.lua $(A) $(B) 2>/dev/null \
|| lua tests/bench/bench-stats.lua $(A) $(B)
# Check for regressions against baseline
bench-check: bench-json
@lua5.1 tests/bench/bench-stats.lua \
tests/bench/results/baselines/$$(git branch --show-current) \
$$(ls -td tests/bench/results/20* | head -1) 2>/dev/null \
|| luajit tests/bench/bench-stats.lua \
tests/bench/results/baselines/$$(git branch --show-current) \
$$(ls -td tests/bench/results/20* | head -1) 2>/dev/null \
|| lua tests/bench/bench-stats.lua \
tests/bench/results/baselines/$$(git branch --show-current) \
$$(ls -td tests/bench/results/20* | head -1)
# Run memory trend analysis (uses its own headless compositor)
bench-memory: build-bench
@SOMEWM=./build-bench/somewm \
SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/bench-memory-runner.sh
# --- Profiling (live session) ---
# Profile the running compositor for DURATION seconds (default: 30)
# Usage: make profile
# make profile DURATION=60
profile:
@SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/profile-session.sh $(DURATION)
# Profile with Lua function breakdown via jit.p
# Usage: make profile-lua
# make profile-lua DURATION=60
profile-lua:
@SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/profile-session.sh --lua $(DURATION)
# Save a profile as a named baseline for later comparison
# Usage: make profile-save LABEL=before-refactor
profile-save:
ifndef LABEL
@echo "Usage: make profile-save LABEL=<name>" >&2
@exit 1
endif
@SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/profile-session.sh --save $(LABEL) $(DURATION)
# Compare current profile against a saved baseline
# Usage: make profile-diff LABEL=before-refactor
profile-diff:
ifndef LABEL
@echo "Usage: make profile-diff LABEL=<name>" >&2
@exit 1
endif
@SOMEWM_CLIENT=./build-bench/somewm-client \
./tests/bench/profile-session.sh --diff $(LABEL) $(DURATION)
# Memory profiling with heaptrack
bench-heaptrack: build-bench
heaptrack ./build-bench/somewm