Skip to content

Commit 4058d50

Browse files
committed
Makefile: T9014: unify test target CPU count and memory size
Test targets had inconsistent --cpu (2/4) and --memory (7/8) values hardcoded inline. Standardize on TEST_CPUS and TEST_MEM variables: TEST_CPUS is min(nproc, 4) so hosts with fewer than 4 CPUs don't request more vCPUs than exist; TEST_MEM is 8GB when the host has at least 10GB of RAM, otherwise 4GB.
1 parent fa68ae4 commit 4058d50

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

Makefile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ ISO_PATH := $(build_dir)/live-image-$(ARCH).hybrid.iso
88
# amd64 it stays optional.
99
UEFI_FLAG := $(if $(filter arm64 aarch64,$(ARCH)),--uefi,)
1010

11+
# Common vCPU count for QEMU test targets, capped at the host's available CPUs
12+
TEST_CPUS := $(shell printf '%s\n' "$$(nproc)" 4 | sort -n | head -n1)
13+
14+
# Common memory size (GB) for QEMU test targets: 8GB if the host has at
15+
# least 10GB of RAM, otherwise 4GB
16+
TEST_MEM := $(shell awk '/MemTotal/{if ($$2/1024/1024 >= 10) print 8; else print 4}' /proc/meminfo)
17+
1118
# Test targets forward extra CLI arguments (e.g. `make test -- --match foo`)
1219
# to their scripts via $(MAKECMDGOALS). Those extra words are also goals as
1320
# far as make is concerned, so without this they'd fall through to the `%:`
@@ -28,37 +35,37 @@ all:
2835
.PHONY: test
2936
.ONESHELL:
3037
test:
31-
scripts/check-qemu-install --debug --match="$(MATCH)" --smoketest --uefi --cpu 4 --memory 8 --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
38+
scripts/check-qemu-install --debug --match="$(MATCH)" --smoketest --uefi --cpu $(TEST_CPUS) --memory $(TEST_MEM) --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
3239

3340
.PHONY: test-no-interfaces
3441
.ONESHELL:
3542
test-no-interfaces:
36-
scripts/check-qemu-install --debug --smoketest --uefi --no-interfaces --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 --isolate-cpus 2-3 --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
43+
scripts/check-qemu-install --debug --smoketest --uefi --no-interfaces --cpu $(TEST_CPUS) --memory $(TEST_MEM) --huge-page-size 2M --huge-page-count 1800 --isolate-cpus 2-3 --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
3744

3845
.PHONY: test-no-interfaces-no-vpp
3946
.ONESHELL:
4047
test-no-interfaces-no-vpp:
41-
scripts/check-qemu-install --debug --smoketest --uefi --no-interfaces --no-vpp --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
48+
scripts/check-qemu-install --debug --smoketest --uefi --no-interfaces --no-vpp --cpu $(TEST_CPUS) --memory $(TEST_MEM) --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
4249

4350
.PHONY: test-interfaces
4451
.ONESHELL:
4552
test-interfaces:
46-
scripts/check-qemu-install --debug --match="interfaces_" --smoketest --uefi --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
53+
scripts/check-qemu-install --debug --match="interfaces_" --smoketest --uefi --cpu $(TEST_CPUS) --memory $(TEST_MEM) --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
4754

4855
.PHONY: test-vpp
4956
.ONESHELL:
5057
test-vpp:
51-
scripts/check-qemu-install --debug --match="vpp" --smoketest --uefi --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 --isolate-cpus 2-3 --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
58+
scripts/check-qemu-install --debug --match="vpp" --smoketest --uefi --cpu $(TEST_CPUS) --memory $(TEST_MEM) --huge-page-size 2M --huge-page-count 1800 --isolate-cpus 2-3 --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
5259

5360
.PHONY: testc
5461
.ONESHELL:
5562
testc:
56-
scripts/check-qemu-install --debug --match="!vpp" $(UEFI_FLAG) --cpu 2 --memory 7 --configtest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
63+
scripts/check-qemu-install --debug --match="!vpp" $(UEFI_FLAG) --cpu $(TEST_CPUS) --memory $(TEST_MEM) --configtest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
5764

5865
.PHONY: testcvpp
5966
.ONESHELL:
6067
testcvpp:
61-
scripts/check-qemu-install --debug --match="vpp" $(UEFI_FLAG) --cpu 4 --memory 8 --huge-page-size 2M --huge-page-count 1800 --isolate-cpus 2-3 --configtest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
68+
scripts/check-qemu-install --debug --match="vpp" $(UEFI_FLAG) --cpu $(TEST_CPUS) --memory $(TEST_MEM) --huge-page-size 2M --huge-page-count 1800 --isolate-cpus 2-3 --configtest --iso $(ISO_PATH) $(filter-out $@,$(MAKECMDGOALS))
6269

6370
.PHONY: testraid
6471
.ONESHELL:

0 commit comments

Comments
 (0)