Hi Tiffany,

kernel test robot noticed the following build warnings:

[auto build test WARNING on staging/staging-testing]
[also build test WARNING on staging/staging-next staging/staging-linus 
shuah-kselftest/kunit shuah-kselftest/kunit-fixes linus/master v6.16-rc3 
next-20250627]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    
https://github.com/intel-lab-lkp/linux/commits/Tiffany-Yang/binder-Fix-selftest-page-indexing/20250628-044044
base:   staging/staging-testing
patch link:    
https://lore.kernel.org/r/20250627203748.881022-6-ynaffit%40google.com
patch subject: [PATCH 5/5] binder: encapsulate individual alloc test cases
config: i386-buildonly-randconfig-001-20250628 
(https://download.01.org/0day-ci/archive/20250628/202506281959.hfotiujs-...@intel.com/config)
compiler: clang version 20.1.7 (https://github.com/llvm/llvm-project 
6146a88f60492b520a36f8f8f3231e15f3cc6082)
reproduce (this is a W=1 build): 
(https://download.01.org/0day-ci/archive/20250628/202506281959.hfotiujs-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <l...@intel.com>
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202506281959.hfotiujs-...@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/android/tests/binder_alloc_kunit.c:256:18: warning: format specifies 
>> type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') 
>> [-Wformat]
     255 |                             "Initial buffers not freed correctly: 
%lu/%lu pages not on lru list",
         |                                                                      
 ~~~
         |                                                                      
 %zu
     256 |                             failures, pages);
         |                                       ^~~~~
   include/kunit/test.h:987:11: note: expanded from macro 'KUNIT_EXPECT_EQ_MSG'
     986 |                                    fmt,                              
          \
         |                                    ~~~
     987 |                                     ##__VA_ARGS__)
         |                                       ^~~~~~~~~~~
   include/kunit/test.h:823:11: note: expanded from macro 
'KUNIT_BINARY_INT_ASSERTION'
     822 |                                     fmt,                             
          \
         |                                     ~~~
     823 |                                     ##__VA_ARGS__)
         |                                       ^~~~~~~~~~~
   include/kunit/test.h:807:11: note: expanded from macro 
'KUNIT_BASE_BINARY_ASSERTION'
     806 |                       fmt,                                           
          \
         |                       ~~~
     807 |                       ##__VA_ARGS__);                                
          \
         |                         ^~~~~~~~~~~
   include/kunit/test.h:689:11: note: expanded from macro '_KUNIT_FAILED'
     688 |                                     fmt,                             
          \
         |                                     ~~~
     689 |                                     ##__VA_ARGS__);                  
          \
         |                                       ^~~~~~~~~~~
   drivers/android/tests/binder_alloc_kunit.c:279:18: warning: format specifies 
type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') 
[-Wformat]
     278 |                             "Reallocated buffers not freed 
correctly: %lu/%lu pages not on lru list",
         |                                                                      
     ~~~
         |                                                                      
     %zu
     279 |                             failures, pages);
         |                                       ^~~~~
   include/kunit/test.h:987:11: note: expanded from macro 'KUNIT_EXPECT_EQ_MSG'
     986 |                                    fmt,                              
          \
         |                                    ~~~
     987 |                                     ##__VA_ARGS__)
         |                                       ^~~~~~~~~~~
   include/kunit/test.h:823:11: note: expanded from macro 
'KUNIT_BINARY_INT_ASSERTION'
     822 |                                     fmt,                             
          \
         |                                     ~~~
     823 |                                     ##__VA_ARGS__)
         |                                       ^~~~~~~~~~~
   include/kunit/test.h:807:11: note: expanded from macro 
'KUNIT_BASE_BINARY_ASSERTION'
     806 |                       fmt,                                           
          \
         |                       ~~~
     807 |                       ##__VA_ARGS__);                                
          \
         |                         ^~~~~~~~~~~
   include/kunit/test.h:689:11: note: expanded from macro '_KUNIT_FAILED'
     688 |                                     fmt,                             
          \
         |                                     ~~~
     689 |                                     ##__VA_ARGS__);                  
          \
         |                                       ^~~~~~~~~~~
>> drivers/android/tests/binder_alloc_kunit.c:320:53: warning: format specifies 
>> type 'ssize_t' (aka 'int') but the argument has type 'unsigned long' 
>> [-Wformat]
     320 |                         kunit_err(test, "case %zd: [%s] | %s - %s - 
%s", *runs,
         |                                               ~~~                    
    ^~~~~
         |                                               %lu
   include/kunit/test.h:650:38: note: expanded from macro 'kunit_err'
     650 |         kunit_printk(KERN_ERR, test, fmt, ##__VA_ARGS__)
         |                                      ~~~    ^~~~~~~~~~~
   include/kunit/test.h:616:21: note: expanded from macro 'kunit_printk'
     615 |         kunit_log(lvl, test, KUNIT_SUBTEST_INDENT "# %s: " fmt,      
   \
         |                                                            ~~~
     616 |                   (test)->name, ##__VA_ARGS__)
         |                                   ^~~~~~~~~~~
   include/kunit/test.h:609:21: note: expanded from macro 'kunit_log'
     609 |                 printk(lvl fmt, ##__VA_ARGS__);                      
   \
         |                            ~~~    ^~~~~~~~~~~
   include/linux/printk.h:507:60: note: expanded from macro 'printk'
     507 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, 
##__VA_ARGS__)
         |                                                     ~~~    
^~~~~~~~~~~
   include/linux/printk.h:479:19: note: expanded from macro 'printk_index_wrap'
     479 |                 _p_func(_fmt, ##__VA_ARGS__);                        
   \
         |                         ~~~~    ^~~~~~~~~~~
>> drivers/android/tests/binder_alloc_kunit.c:320:53: warning: format specifies 
>> type 'ssize_t' (aka 'int') but the argument has type 'unsigned long' 
>> [-Wformat]
     320 |                         kunit_err(test, "case %zd: [%s] | %s - %s - 
%s", *runs,
         |                                               ~~~                    
    ^~~~~
         |                                               %lu
   include/kunit/test.h:650:38: note: expanded from macro 'kunit_err'
     650 |         kunit_printk(KERN_ERR, test, fmt, ##__VA_ARGS__)
         |                                      ~~~    ^~~~~~~~~~~
   include/kunit/test.h:616:21: note: expanded from macro 'kunit_printk'
     615 |         kunit_log(lvl, test, KUNIT_SUBTEST_INDENT "# %s: " fmt,      
   \
         |                                                            ~~~
     616 |                   (test)->name, ##__VA_ARGS__)
         |                                   ^~~~~~~~~~~
   include/kunit/test.h:611:8: note: expanded from macro 'kunit_log'
     610 |                 kunit_log_append((test_or_suite)->log,  fmt,         
   \
         |                                                         ~~~
     611 |                                  ##__VA_ARGS__);                     
   \
         |                                    ^~~~~~~~~~~
   4 warnings generated.


vim +256 drivers/android/tests/binder_alloc_kunit.c

   230  
   231  /* Executes one full test run for the given test case. */
   232  static bool binder_alloc_test_alloc_free(struct kunit *test,
   233                                           struct binder_alloc *alloc,
   234                                           struct 
binder_alloc_test_case_info *tc,
   235                                           size_t end)
   236  {
   237          size_t pages = PAGE_ALIGN(end) / PAGE_SIZE;
   238          struct binder_buffer *buffers[BUFFER_NUM];
   239          unsigned long failures;
   240          bool failed = false;
   241  
   242          failures = binder_alloc_test_alloc_buf(test, alloc, buffers,
   243                                                 tc->buffer_sizes,
   244                                                 tc->free_sequence);
   245          failed = failed || failures;
   246          KUNIT_EXPECT_EQ_MSG(test, failures, 0,
   247                              "Initial allocation failed: %lu/%u buffers 
with errors",
   248                              failures, BUFFER_NUM);
   249  
   250          failures = binder_alloc_test_free_buf(test, alloc, buffers,
   251                                                tc->buffer_sizes,
   252                                                tc->free_sequence, end);
   253          failed = failed || failures;
   254          KUNIT_EXPECT_EQ_MSG(test, failures, 0,
   255                              "Initial buffers not freed correctly: 
%lu/%lu pages not on lru list",
 > 256                              failures, pages);
   257  
   258          /* Allocate from lru. */
   259          failures = binder_alloc_test_alloc_buf(test, alloc, buffers,
   260                                                 tc->buffer_sizes,
   261                                                 tc->free_sequence);
   262          failed = failed || failures;
   263          KUNIT_EXPECT_EQ_MSG(test, failures, 0,
   264                              "Reallocation failed: %lu/%u buffers with 
errors",
   265                              failures, BUFFER_NUM);
   266  
   267          failures = list_lru_count(alloc->freelist);
   268          failed = failed || failures;
   269          KUNIT_EXPECT_EQ_MSG(test, failures, 0,
   270                              "lru list should be empty after 
reallocation but still has %lu pages",
   271                              failures);
   272  
   273          failures = binder_alloc_test_free_buf(test, alloc, buffers,
   274                                                tc->buffer_sizes,
   275                                                tc->free_sequence, end);
   276          failed = failed || failures;
   277          KUNIT_EXPECT_EQ_MSG(test, failures, 0,
   278                              "Reallocated buffers not freed correctly: 
%lu/%lu pages not on lru list",
   279                              failures, pages);
   280  
   281          failures = binder_alloc_test_free_page(test, alloc);
   282          failed = failed || failures;
   283          KUNIT_EXPECT_EQ_MSG(test, failures, 0,
   284                              "Failed to clean up allocated pages: 
%lu/%lu pages still installed",
   285                              failures, (alloc->buffer_size / PAGE_SIZE));
   286  
   287          return failed;
   288  }
   289  
   290  static bool is_dup(int *seq, int index, int val)
   291  {
   292          int i;
   293  
   294          for (i = 0; i < index; i++) {
   295                  if (seq[i] == val)
   296                          return true;
   297          }
   298          return false;
   299  }
   300  
   301  /* Generate BUFFER_NUM factorial free orders. */
   302  static void permute_frees(struct kunit *test, struct binder_alloc 
*alloc,
   303                            struct binder_alloc_test_case_info *tc,
   304                            unsigned long *runs, unsigned long *failures,
   305                            int index, size_t end)
   306  {
   307          bool case_failed;
   308          int i;
   309  
   310          if (index == BUFFER_NUM) {
   311                  char freeseq_buf[FREESEQ_BUFLEN];
   312  
   313                  case_failed = binder_alloc_test_alloc_free(test, alloc, 
tc, end);
   314                  *runs += 1;
   315                  *failures += case_failed;
   316  
   317                  if (case_failed || PRINT_ALL_CASES) {
   318                          stringify_free_seq(test, tc->free_sequence, 
freeseq_buf,
   319                                             FREESEQ_BUFLEN);
 > 320                          kunit_err(test, "case %zd: [%s] | %s - %s - 
 > %s", *runs,
   321                                    case_failed ? "FAILED" : "PASSED",
   322                                    tc->front_pages ? "front" : "back ",
   323                                    tc->alignments, freeseq_buf);
   324                  }
   325  
   326                  return;
   327          }
   328          for (i = 0; i < BUFFER_NUM; i++) {
   329                  if (is_dup(tc->free_sequence, index, i))
   330                          continue;
   331                  tc->free_sequence[index] = i;
   332                  permute_frees(test, alloc, tc, runs, failures, index + 
1, end);
   333          }
   334  }
   335  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Reply via email to