Re: [PATCH 6/6] test_hash.c: refactor into kunit
From: kernel test robot
Date: Thu Aug 26 2021 - 06:11:19 EST
Hi Isabella,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc7 next-20210825]
[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]
url: https://github.com/0day-ci/linux/commits/Isabella-Basso/test_hash-c-refactor-into-KUnit/20210826-092911
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 73f3af7b4611d77bdaea303fb639333eb28e37d7
config: parisc-randconfig-r014-20210825 (attached as .config)
compiler: hppa64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/89fe4c8eec63dcabd6d3e8f3f71f3c2248d18dab
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Isabella-Basso/test_hash-c-refactor-into-KUnit/20210826-092911
git checkout 89fe4c8eec63dcabd6d3e8f3f71f3c2248d18dab
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
All error/warnings (new ones prefixed by >>):
lib/test_hash.c: In function 'test_int_hash32':
lib/test_hash.c:62:50: warning: passing argument 1 of '__hash_32_generic' makes integer from pointer without a cast [-Wint-conversion]
62 | hash_or[1][0] |= *h2 = __hash_32_generic(h0);
| ^~
| |
| u32 * {aka unsigned int *}
In file included from lib/test_hash.c:18:
include/linux/hash.h:60:41: note: expected 'u32' {aka 'unsigned int'} but argument is of type 'u32 *' {aka 'unsigned int *'}
60 | static inline u32 __hash_32_generic(u32 val)
| ~~~~^~~
lib/test_hash.c:68:1: error: no return statement in function returning non-void [-Werror=return-type]
68 | }
| ^
lib/test_hash.c: In function 'test_int_hash64':
>> lib/test_hash.c:75:31: error: invalid type argument of unary '*' (have 'long long unsigned int')
75 | *h2 = hash_64_generic(*h64, *k);
| ^~~~
>> lib/test_hash.c:75:37: error: invalid type argument of unary '*' (have 'int')
75 | *h2 = hash_64_generic(*h64, *k);
| ^~
In file included from lib/test_hash.c:20:
lib/test_hash.c:79:29: error: invalid type argument of unary '*' (have 'long long unsigned int')
79 | *h64, *k, *h1, *h2);
| ^~~~
include/kunit/test.h:775:30: note: in definition of macro 'KUNIT_ASSERTION'
775 | ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/kunit/test.h:891:9: note: in expansion of macro 'KUNIT_BASE_BINARY_ASSERTION'
891 | KUNIT_BASE_BINARY_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/kunit/test.h:980:9: note: in expansion of macro 'KUNIT_BASE_EQ_MSG_ASSERTION'
980 | KUNIT_BASE_EQ_MSG_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/kunit/test.h:1644:9: note: in expansion of macro 'KUNIT_BINARY_EQ_MSG_ASSERTION'
1644 | KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/test_hash.c:77:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
77 | KUNIT_ASSERT_EQ_MSG(test, *h1, *h2,
| ^~~~~~~~~~~~~~~~~~~
lib/test_hash.c:79:35: error: invalid type argument of unary '*' (have 'int')
79 | *h64, *k, *h1, *h2);
| ^~
include/kunit/test.h:775:30: note: in definition of macro 'KUNIT_ASSERTION'
775 | ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/kunit/test.h:891:9: note: in expansion of macro 'KUNIT_BASE_BINARY_ASSERTION'
891 | KUNIT_BASE_BINARY_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/kunit/test.h:980:9: note: in expansion of macro 'KUNIT_BASE_EQ_MSG_ASSERTION'
980 | KUNIT_BASE_EQ_MSG_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/kunit/test.h:1644:9: note: in expansion of macro 'KUNIT_BINARY_EQ_MSG_ASSERTION'
1644 | KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/test_hash.c:77:9: note: in expansion of macro 'KUNIT_ASSERT_EQ_MSG'
77 | KUNIT_ASSERT_EQ_MSG(test, *h1, *h2,
| ^~~~~~~~~~~~~~~~~~~
lib/test_hash.c:85:1: error: no return statement in function returning non-void [-Werror=return-type]
85 | }
| ^
lib/test_hash.c: In function 'test_int_hash':
lib/test_hash.c:110:24: error: 'return' with a value, in function returning void [-Werror=return-type]
110 | return false;
| ^~~~~
lib/test_hash.c:97:13: note: declared here
97 | static void test_int_hash(struct kunit *test, unsigned long long h64)
| ^~~~~~~~~~~~~
>> lib/test_hash.c:129:39: warning: passing argument 2 of 'test_int_hash64' makes integer from pointer without a cast [-Wint-conversion]
129 | test_int_hash64(test, &h64, &h0, &h1, &h2, &m, &k);
| ^~~~
| |
| long long unsigned int *
lib/test_hash.c:72:68: note: expected 'long long unsigned int' but argument is of type 'long long unsigned int *'
72 | static bool test_int_hash64(struct kunit *test, unsigned long long h64, u32 *h0, u32 *h1,
| ~~~~~~~~~~~~~~~~~~~^~~
lib/test_hash.c:129:64: warning: passing argument 7 of 'test_int_hash64' makes integer from pointer without a cast [-Wint-conversion]
129 | test_int_hash64(test, &h64, &h0, &h1, &h2, &m, &k);
| ^~
| |
| int *
lib/test_hash.c:73:44: note: expected 'int' but argument is of type 'int *'
73 | u32 *h2, u32 const *m, int k)
| ~~~~^
cc1: some warnings being treated as errors
vim +75 lib/test_hash.c
7d8047a5cceb31 Isabella Basso 2021-08-25 70
7d8047a5cceb31 Isabella Basso 2021-08-25 71 #ifdef HAVE_ARCH_HASH_64
89fe4c8eec63dc Isabella Basso 2021-08-25 72 static bool test_int_hash64(struct kunit *test, unsigned long long h64, u32 *h0, u32 *h1,
89fe4c8eec63dc Isabella Basso 2021-08-25 73 u32 *h2, u32 const *m, int k)
7d8047a5cceb31 Isabella Basso 2021-08-25 74 {
7d8047a5cceb31 Isabella Basso 2021-08-25 @75 *h2 = hash_64_generic(*h64, *k);
7d8047a5cceb31 Isabella Basso 2021-08-25 76 #if HAVE_ARCH_HASH_64 == 1
89fe4c8eec63dc Isabella Basso 2021-08-25 77 KUNIT_ASSERT_EQ_MSG(test, *h1, *h2,
89fe4c8eec63dc Isabella Basso 2021-08-25 78 "hash_64(%#llx, %d) = %#x != hash_64_generic() = %#x",
7d8047a5cceb31 Isabella Basso 2021-08-25 79 *h64, *k, *h1, *h2);
7d8047a5cceb31 Isabella Basso 2021-08-25 80 #else
89fe4c8eec63dc Isabella Basso 2021-08-25 81 KUNIT_ASSERT_LE_MSG(test, *h1, *h2,
89fe4c8eec63dc Isabella Basso 2021-08-25 82 "hash_64_generic(%#llx, %d) = %#x > %#x",
7d8047a5cceb31 Isabella Basso 2021-08-25 83 *h64, *k, *h1, *m);
7d8047a5cceb31 Isabella Basso 2021-08-25 84 #endif
7d8047a5cceb31 Isabella Basso 2021-08-25 85 }
7d8047a5cceb31 Isabella Basso 2021-08-25 86 #endif
7d8047a5cceb31 Isabella Basso 2021-08-25 87
468a9428521e7d George Spelvin 2016-05-26 88 /*
468a9428521e7d George Spelvin 2016-05-26 89 * Test the various integer hash functions. h64 (or its low-order bits)
468a9428521e7d George Spelvin 2016-05-26 90 * is the integer to hash. hash_or accumulates the OR of the hash values,
468a9428521e7d George Spelvin 2016-05-26 91 * which are later checked to see that they cover all the requested bits.
468a9428521e7d George Spelvin 2016-05-26 92 *
468a9428521e7d George Spelvin 2016-05-26 93 * Because these functions (as opposed to the string hashes) are all
468a9428521e7d George Spelvin 2016-05-26 94 * inline, the code being tested is actually in the module, and you can
468a9428521e7d George Spelvin 2016-05-26 95 * recompile and re-test the module without rebooting.
468a9428521e7d George Spelvin 2016-05-26 96 */
89fe4c8eec63dc Isabella Basso 2021-08-25 97 static void test_int_hash(struct kunit *test, unsigned long long h64)
468a9428521e7d George Spelvin 2016-05-26 98 {
468a9428521e7d George Spelvin 2016-05-26 99 int k;
7d8047a5cceb31 Isabella Basso 2021-08-25 100 u32 h0 = (u32)h64, h1;
7d8047a5cceb31 Isabella Basso 2021-08-25 101
7d8047a5cceb31 Isabella Basso 2021-08-25 102 #if defined HAVE_ARCH__HASH_32 || defined HAVE_ARCH_HASH_64
7d8047a5cceb31 Isabella Basso 2021-08-25 103 u32 h2;
7d8047a5cceb31 Isabella Basso 2021-08-25 104 #endif
468a9428521e7d George Spelvin 2016-05-26 105
468a9428521e7d George Spelvin 2016-05-26 106 /* Test __hash32 */
468a9428521e7d George Spelvin 2016-05-26 107 hash_or[0][0] |= h1 = __hash_32(h0);
468a9428521e7d George Spelvin 2016-05-26 108 #ifdef HAVE_ARCH__HASH_32
89fe4c8eec63dc Isabella Basso 2021-08-25 109 if (!test_int_hash32(test, &h0, &h1, &h2))
468a9428521e7d George Spelvin 2016-05-26 110 return false;
468a9428521e7d George Spelvin 2016-05-26 111 #endif
468a9428521e7d George Spelvin 2016-05-26 112
468a9428521e7d George Spelvin 2016-05-26 113 /* Test k = 1..32 bits */
468a9428521e7d George Spelvin 2016-05-26 114 for (k = 1; k <= 32; k++) {
468a9428521e7d George Spelvin 2016-05-26 115 u32 const m = ((u32)2 << (k-1)) - 1; /* Low k bits set */
468a9428521e7d George Spelvin 2016-05-26 116
468a9428521e7d George Spelvin 2016-05-26 117 /* Test hash_32 */
468a9428521e7d George Spelvin 2016-05-26 118 hash_or[0][k] |= h1 = hash_32(h0, k);
89fe4c8eec63dc Isabella Basso 2021-08-25 119 KUNIT_ASSERT_LE_MSG(test, h1, m,
89fe4c8eec63dc Isabella Basso 2021-08-25 120 "hash_32(%#x, %d) = %#x > %#x",
89fe4c8eec63dc Isabella Basso 2021-08-25 121 h0, k, h1, m);
d41da448b96d6d Isabella Basso 2021-08-25 122
468a9428521e7d George Spelvin 2016-05-26 123 /* Test hash_64 */
468a9428521e7d George Spelvin 2016-05-26 124 hash_or[1][k] |= h1 = hash_64(h64, k);
89fe4c8eec63dc Isabella Basso 2021-08-25 125 KUNIT_ASSERT_LE_MSG(test, h1, m,
89fe4c8eec63dc Isabella Basso 2021-08-25 126 "hash_64(%#llx, %d) = %#x > %#x",
89fe4c8eec63dc Isabella Basso 2021-08-25 127 h64, k, h1, m);
468a9428521e7d George Spelvin 2016-05-26 128 #ifdef HAVE_ARCH_HASH_64
89fe4c8eec63dc Isabella Basso 2021-08-25 @129 test_int_hash64(test, &h64, &h0, &h1, &h2, &m, &k);
468a9428521e7d George Spelvin 2016-05-26 130 #endif
468a9428521e7d George Spelvin 2016-05-26 131 }
468a9428521e7d George Spelvin 2016-05-26 132 }
468a9428521e7d George Spelvin 2016-05-26 133
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip