Lines Matching +full:test +full:- +full:cpu

1 // SPDX-License-Identifier: GPL-2.0-only
8 #include <kunit/test.h>
9 #include <linux/cpu.h>
16 #define EXPECT_FOR_EACH_CPU_EQ(test, mask) \ argument
20 int cpu, iter = 0; \
21 for_each_cpu(cpu, m) \
23 KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(mask)); \
26 #define EXPECT_FOR_EACH_CPU_OP_EQ(test, op, mask1, mask2) \ argument
31 int cpu, iter = 0; \
34 for_each_cpu_##op(cpu, mask1, mask2) \
36 KUNIT_EXPECT_EQ((test), weight, iter); \
39 #define EXPECT_FOR_EACH_CPU_WRAP_EQ(test, mask) \ argument
43 int cpu, iter = 0; \
44 for_each_cpu_wrap(cpu, m, nr_cpu_ids / 2) \
46 KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(mask)); \
49 #define EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, name) \ argument
52 int cpu, iter = 0; \
53 for_each_##name##_cpu(cpu) \
55 KUNIT_EXPECT_EQ_MSG((test), mask_weight, iter, MASK_MSG(cpu_##name##_mask)); \
62 static void test_cpumask_weight(struct kunit *test) in test_cpumask_weight() argument
64 KUNIT_EXPECT_TRUE_MSG(test, cpumask_empty(&mask_empty), MASK_MSG(&mask_empty)); in test_cpumask_weight()
65 KUNIT_EXPECT_TRUE_MSG(test, cpumask_full(&mask_all), MASK_MSG(&mask_all)); in test_cpumask_weight()
67 KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_weight(&mask_empty), MASK_MSG(&mask_empty)); in test_cpumask_weight()
68 KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids, cpumask_weight(cpu_possible_mask), in test_cpumask_weight()
70 KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids, cpumask_weight(&mask_all), MASK_MSG(&mask_all)); in test_cpumask_weight()
73 static void test_cpumask_first(struct kunit *test) in test_cpumask_first() argument
75 KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_first(&mask_empty), MASK_MSG(&mask_empty)); in test_cpumask_first()
76 KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_first(cpu_possible_mask), MASK_MSG(cpu_possible_mask)); in test_cpumask_first()
78 KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_first_zero(&mask_empty), MASK_MSG(&mask_empty)); in test_cpumask_first()
79 KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_first_zero(cpu_possible_mask), in test_cpumask_first()
83 static void test_cpumask_last(struct kunit *test) in test_cpumask_last() argument
85 KUNIT_EXPECT_LE_MSG(test, nr_cpumask_bits, cpumask_last(&mask_empty), in test_cpumask_last()
87 KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids - 1, cpumask_last(cpu_possible_mask), in test_cpumask_last()
91 static void test_cpumask_next(struct kunit *test) in test_cpumask_next() argument
93 KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_next_zero(-1, &mask_empty), MASK_MSG(&mask_empty)); in test_cpumask_next()
94 KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_next_zero(-1, cpu_possible_mask), in test_cpumask_next()
97 KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids, cpumask_next(-1, &mask_empty), in test_cpumask_next()
99 KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_next(-1, cpu_possible_mask), in test_cpumask_next()
103 static void test_cpumask_iterators(struct kunit *test) in test_cpumask_iterators() argument
105 EXPECT_FOR_EACH_CPU_EQ(test, &mask_empty); in test_cpumask_iterators()
106 EXPECT_FOR_EACH_CPU_WRAP_EQ(test, &mask_empty); in test_cpumask_iterators()
107 EXPECT_FOR_EACH_CPU_OP_EQ(test, and, &mask_empty, &mask_empty); in test_cpumask_iterators()
108 EXPECT_FOR_EACH_CPU_OP_EQ(test, and, cpu_possible_mask, &mask_empty); in test_cpumask_iterators()
109 EXPECT_FOR_EACH_CPU_OP_EQ(test, andnot, &mask_empty, &mask_empty); in test_cpumask_iterators()
111 EXPECT_FOR_EACH_CPU_EQ(test, cpu_possible_mask); in test_cpumask_iterators()
112 EXPECT_FOR_EACH_CPU_WRAP_EQ(test, cpu_possible_mask); in test_cpumask_iterators()
113 EXPECT_FOR_EACH_CPU_OP_EQ(test, and, cpu_possible_mask, cpu_possible_mask); in test_cpumask_iterators()
114 EXPECT_FOR_EACH_CPU_OP_EQ(test, andnot, cpu_possible_mask, &mask_empty); in test_cpumask_iterators()
117 static void test_cpumask_iterators_builtin(struct kunit *test) in test_cpumask_iterators_builtin() argument
119 EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, possible); in test_cpumask_iterators_builtin()
124 EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, online); in test_cpumask_iterators_builtin()
125 EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, present); in test_cpumask_iterators_builtin()
130 static int test_cpumask_init(struct kunit *test) in test_cpumask_init() argument