]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-cpu-set-util: fix check for CPUSet.allocated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 21 Jun 2025 14:06:16 +0000 (23:06 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 23 Jun 2025 21:28:22 +0000 (22:28 +0100)
The check was simply wrong and meaningless, as it always checked
CPUSet.allocated is greater than or equals to 1, as sizeof(__cpu_mask) is 8.

Let's make the test more strict.

src/test/test-cpu-set-util.c

index c7bc63406236105afec2328bd6015abe94b191f0..e37ddc4cad4be75c177c3b00123d590c57d21085 100644 (file)
@@ -8,13 +8,10 @@
         ASSERT_NULL(c.set);                     \
         ASSERT_EQ(c.allocated, 0u)
 
-#define ASSERT_CPUSET_ALLOCATED(c)                                      \
-        ASSERT_GE(c.allocated, DIV_ROUND_UP(sizeof(__cpu_mask), 8))
-
 #define ASSERT_CPUSET_COUNT(c, n)                                       \
         ASSERT_NOT_NULL(c.set);                                         \
-        ASSERT_CPUSET_ALLOCATED(c);                                     \
-        ASSERT_EQ(CPU_COUNT_S(c.allocated, c.set), n)
+        ASSERT_GE(c.allocated, CPU_ALLOC_SIZE(n));                      \
+        ASSERT_EQ(CPU_COUNT_S(c.allocated, c.set), (n))
 
 #define ASSERT_CPUSET_ISSET(c, i)                               \
         ASSERT_TRUE(CPU_ISSET_S(i, c.allocated, c.set));