~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/cpumask_kunit.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /lib/cpumask_kunit.c (Version linux-6.12-rc7) and /lib/cpumask_kunit.c (Version linux-4.15.18)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 
  2 /*                                                
  3  * KUnit tests for cpumask.                       
  4  *                                                
  5  * Author: Sander Vanheule <sander@svanheule.n    
  6  */                                               
  7                                                   
  8 #include <kunit/test.h>                           
  9 #include <linux/cpu.h>                            
 10 #include <linux/cpumask.h>                        
 11                                                   
 12 #define MASK_MSG(m) \                             
 13         "%s contains %sCPUs %*pbl", #m, (cpuma    
 14         nr_cpumask_bits, cpumask_bits(m)          
 15                                                   
 16 #define EXPECT_FOR_EACH_CPU_EQ(test, mask)        
 17         do {                                      
 18                 const cpumask_t *m = (mask);      
 19                 int mask_weight = cpumask_weig    
 20                 int cpu, iter = 0;                
 21                 for_each_cpu(cpu, m)              
 22                         iter++;                   
 23                 KUNIT_EXPECT_EQ_MSG((test), ma    
 24         } while (0)                               
 25                                                   
 26 #define EXPECT_FOR_EACH_CPU_OP_EQ(test, op, ma    
 27         do {                                      
 28                 const cpumask_t *m1 = (mask1);    
 29                 const cpumask_t *m2 = (mask2);    
 30                 int weight;                       
 31                 int cpu, iter = 0;                
 32                 cpumask_##op(&mask_tmp, m1, m2    
 33                 weight = cpumask_weight(&mask_    
 34                 for_each_cpu_##op(cpu, mask1,     
 35                         iter++;                   
 36                 KUNIT_EXPECT_EQ((test), weight    
 37         } while (0)                               
 38                                                   
 39 #define EXPECT_FOR_EACH_CPU_WRAP_EQ(test, mask    
 40         do {                                      
 41                 const cpumask_t *m = (mask);      
 42                 int mask_weight = cpumask_weig    
 43                 int cpu, iter = 0;                
 44                 for_each_cpu_wrap(cpu, m, nr_c    
 45                         iter++;                   
 46                 KUNIT_EXPECT_EQ_MSG((test), ma    
 47         } while (0)                               
 48                                                   
 49 #define EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, n    
 50         do {                                      
 51                 int mask_weight = num_##name##    
 52                 int cpu, iter = 0;                
 53                 for_each_##name##_cpu(cpu)        
 54                         iter++;                   
 55                 KUNIT_EXPECT_EQ_MSG((test), ma    
 56         } while (0)                               
 57                                                   
 58 static cpumask_t mask_empty;                      
 59 static cpumask_t mask_all;                        
 60 static cpumask_t mask_tmp;                        
 61                                                   
 62 static void test_cpumask_weight(struct kunit *    
 63 {                                                 
 64         KUNIT_EXPECT_TRUE_MSG(test, cpumask_em    
 65         KUNIT_EXPECT_TRUE_MSG(test, cpumask_fu    
 66                                                   
 67         KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_w    
 68         KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids,     
 69                             MASK_MSG(cpu_possi    
 70         KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids,     
 71 }                                                 
 72                                                   
 73 static void test_cpumask_first(struct kunit *t    
 74 {                                                 
 75         KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids,     
 76         KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_f    
 77                                                   
 78         KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_f    
 79         KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids,     
 80                             MASK_MSG(cpu_possi    
 81 }                                                 
 82                                                   
 83 static void test_cpumask_last(struct kunit *te    
 84 {                                                 
 85         KUNIT_EXPECT_LE_MSG(test, nr_cpumask_b    
 86                             MASK_MSG(&mask_emp    
 87         KUNIT_EXPECT_EQ_MSG(test, nr_cpu_ids -    
 88                             MASK_MSG(cpu_possi    
 89 }                                                 
 90                                                   
 91 static void test_cpumask_next(struct kunit *te    
 92 {                                                 
 93         KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_n    
 94         KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids,     
 95                             MASK_MSG(cpu_possi    
 96                                                   
 97         KUNIT_EXPECT_LE_MSG(test, nr_cpu_ids,     
 98                             MASK_MSG(&mask_emp    
 99         KUNIT_EXPECT_EQ_MSG(test, 0, cpumask_n    
100                             MASK_MSG(cpu_possi    
101 }                                                 
102                                                   
103 static void test_cpumask_iterators(struct kuni    
104 {                                                 
105         EXPECT_FOR_EACH_CPU_EQ(test, &mask_emp    
106         EXPECT_FOR_EACH_CPU_WRAP_EQ(test, &mas    
107         EXPECT_FOR_EACH_CPU_OP_EQ(test, and, &    
108         EXPECT_FOR_EACH_CPU_OP_EQ(test, and, c    
109         EXPECT_FOR_EACH_CPU_OP_EQ(test, andnot    
110                                                   
111         EXPECT_FOR_EACH_CPU_EQ(test, cpu_possi    
112         EXPECT_FOR_EACH_CPU_WRAP_EQ(test, cpu_    
113         EXPECT_FOR_EACH_CPU_OP_EQ(test, and, c    
114         EXPECT_FOR_EACH_CPU_OP_EQ(test, andnot    
115 }                                                 
116                                                   
117 static void test_cpumask_iterators_builtin(str    
118 {                                                 
119         EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, p    
120                                                   
121         /* Ensure the dynamic masks are stable    
122         cpu_hotplug_disable();                    
123                                                   
124         EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, o    
125         EXPECT_FOR_EACH_CPU_BUILTIN_EQ(test, p    
126                                                   
127         cpu_hotplug_enable();                     
128 }                                                 
129                                                   
130 static int test_cpumask_init(struct kunit *tes    
131 {                                                 
132         cpumask_clear(&mask_empty);               
133         cpumask_setall(&mask_all);                
134                                                   
135         return 0;                                 
136 }                                                 
137                                                   
138 static struct kunit_case test_cpumask_cases[]     
139         KUNIT_CASE(test_cpumask_weight),          
140         KUNIT_CASE(test_cpumask_first),           
141         KUNIT_CASE(test_cpumask_last),            
142         KUNIT_CASE(test_cpumask_next),            
143         KUNIT_CASE(test_cpumask_iterators),       
144         KUNIT_CASE(test_cpumask_iterators_buil    
145         {}                                        
146 };                                                
147                                                   
148 static struct kunit_suite test_cpumask_suite =    
149         .name = "cpumask",                        
150         .init = test_cpumask_init,                
151         .test_cases = test_cpumask_cases,         
152 };                                                
153 kunit_test_suite(test_cpumask_suite);             
154                                                   
155 MODULE_DESCRIPTION("KUnit tests for cpumask");    
156 MODULE_LICENSE("GPL");                            
157                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php