smptest: Add a check for active cpus. build-config-kerneltests currently specifies that this test needs 4 CPUs and should only be run on systems that have at least 4 CPUs. The test used to fail if fewer CPUs were online, but when the test was modified to test all active CPUs it lost the ability to detect that CPUs that are meant to be active never activated. Add a new build flag to specify how many CPUs are expected to be online, with a default value of 4 to match build-config-kerneltests, and a test to check that at least this many CPUs are active. Bug: None Change-Id: I2d1e17339d83126c49fd948635aaba6d216b1889
diff --git a/app/smptest/rules.mk b/app/smptest/rules.mk index 166630b..36aadac 100644 --- a/app/smptest/rules.mk +++ b/app/smptest/rules.mk
@@ -10,6 +10,11 @@ MODULE_SRCS += \ $(LOCAL_DIR)/smptest.c \ +SMPTEST_MIN_CPU_COUNT ?= 4 + +MODULE_DEFINES += \ + SMPTEST_MIN_CPU_COUNT=$(SMPTEST_MIN_CPU_COUNT) \ + include make/module.mk endif
diff --git a/app/smptest/smptest.c b/app/smptest/smptest.c index 6551df9..9b44f07 100644 --- a/app/smptest/smptest.c +++ b/app/smptest/smptest.c
@@ -114,6 +114,16 @@ return 0; } +TEST(smptest, check_cpu_active) { + uint active_cpu_count = 0; + for (uint i = 0; i < SMP_MAX_CPUS; i++) { + if (mp_is_cpu_active(i)) { + active_cpu_count++; + } + } + EXPECT_GE(active_cpu_count, SMPTEST_MIN_CPU_COUNT); +} + TEST(smptest, run) { bool wait_for_cpus = false;