Re: [PATCH v2] lib: kunit: Convert test_sort to KUnit test

From: kernel test robot
Date: Mon Aug 03 2020 - 02:17:31 EST


Hi Vitor,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on d43c7fb05765152d4d4a39a8ef957c4ea14d8847]

url: https://github.com/0day-ci/linux/commits/Vitor-Massaru-Iha/lib-kunit-Convert-test_sort-to-KUnit-test/20200730-031404
base: d43c7fb05765152d4d4a39a8ef957c4ea14d8847
config: x86_64-randconfig-s022-20200803 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-117-g8c7aee71-dirty
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

ld: lib/sort_kunit.o: in function `kunit_test_suites_init':
>> lib/sort_kunit.c:47: undefined reference to `__kunit_test_suites_init'
ld: lib/sort_kunit.o: in function `sort_test':
>> lib/sort_kunit.c:19: undefined reference to `kunit_unary_assert_format'
>> ld: lib/sort_kunit.c:19: undefined reference to `kunit_do_assertion'
>> ld: lib/sort_kunit.c:30: undefined reference to `kunit_fail_assert_format'
ld: lib/sort_kunit.c:30: undefined reference to `kunit_do_assertion'
ld: lib/sort_kunit.o: in function `kunit_test_suites_exit':
>> lib/sort_kunit.c:47: undefined reference to `__kunit_test_suites_exit'

vim +47 lib/sort_kunit.c

13
14 static void __init sort_test(struct kunit *test)
15 {
16 int *a, i, r = 1;
17
18 a = kmalloc_array(TEST_LEN, sizeof(*a), GFP_KERNEL);
> 19 KUNIT_ASSERT_FALSE_MSG(test, a == NULL, "kmalloc_array failed");
20
21 for (i = 0; i < TEST_LEN; i++) {
22 r = (r * 725861) % 6599;
23 a[i] = r;
24 }
25
26 sort(a, TEST_LEN, sizeof(*a), cmpint, NULL);
27
28 for (i = 0; i < TEST_LEN-1; i++)
29 if (a[i] > a[i+1]) {
> 30 KUNIT_FAIL(test, "test has failed");
31 goto exit;
32 }
33 exit:
34 kfree(a);
35 }
36
37 static struct kunit_case __refdata sort_test_cases[] = {
38 KUNIT_CASE(sort_test),
39 {}
40 };
41
42 static struct kunit_suite sort_test_suite = {
43 .name = "sort",
44 .test_cases = sort_test_cases,
45 };
46
> 47 kunit_test_suites(&sort_test_suite);
48

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip