Re: [PATCH v3 2/2] fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature

From: kernel test robot
Date: Mon Oct 26 2020 - 16:20:34 EST


Hi Arpitha,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ext4/dev]
[also build test WARNING on linus/master v5.10-rc1 next-20201026]
[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/Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201027-023812
base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.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/1c6cd3899d5ed7da9b746ba887779ca2c89c5bab
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201027-023812
git checkout 1c6cd3899d5ed7da9b746ba887779ca2c89c5bab
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k

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

All warnings (new ones prefixed by >>):

In file included from include/linux/err.h:5,
from include/kunit/assert.h:12,
from include/kunit/test.h:12,
from fs/ext4/inode-test.c:7:
include/linux/scatterlist.h: In function 'sg_set_buf':
arch/m68k/include/asm/page_mm.h:169:49: warning: ordered comparison of pointer with null pointer [-Wextra]
169 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
| ^~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/scatterlist.h:143:2: note: in expansion of macro 'BUG_ON'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~
include/linux/scatterlist.h:143:10: note: in expansion of macro 'virt_addr_valid'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~~~~~~~~~~
In file included from fs/ext4/inode-test.c:7:
fs/ext4/inode-test.c: In function 'ext4_inode_gen_params':
>> include/kunit/test.h:1733:58: warning: return discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1733 | return __next - (array) < ARRAY_SIZE((array)) ? __next : NULL; \
fs/ext4/inode-test.c:214:1: note: in expansion of macro 'KUNIT_PARAM_GENERATOR'
214 | KUNIT_PARAM_GENERATOR(ext4_inode, test_data);
| ^~~~~~~~~~~~~~~~~~~~~

vim +/const +1733 include/kunit/test.h

73cda7bb8bfb1d Brendan Higgins 2019-09-23 1152
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1153 #define KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, assert_type, ptr) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1154 KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1155 assert_type, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1156 ptr, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1157 NULL)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1158
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1159 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1160 * KUNIT_EXPECT_TRUE() - Causes a test failure when the expression is not true.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1161 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1162 * @condition: an arbitrary boolean expression. The test fails when this does
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1163 * not evaluate to true.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1164 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1165 * This and expectations of the form `KUNIT_EXPECT_*` will cause the test case
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1166 * to fail when the specified condition is not met; however, it will not prevent
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1167 * the test case from continuing to run; this is otherwise known as an
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1168 * *expectation failure*.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1169 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1170 #define KUNIT_EXPECT_TRUE(test, condition) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1171 KUNIT_TRUE_ASSERTION(test, KUNIT_EXPECTATION, condition)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1172
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1173 #define KUNIT_EXPECT_TRUE_MSG(test, condition, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1174 KUNIT_TRUE_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1175 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1176 condition, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1177 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1178 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1179
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1180 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1181 * KUNIT_EXPECT_FALSE() - Makes a test failure when the expression is not false.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1182 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1183 * @condition: an arbitrary boolean expression. The test fails when this does
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1184 * not evaluate to false.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1185 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1186 * Sets an expectation that @condition evaluates to false. See
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1187 * KUNIT_EXPECT_TRUE() for more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1188 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1189 #define KUNIT_EXPECT_FALSE(test, condition) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1190 KUNIT_FALSE_ASSERTION(test, KUNIT_EXPECTATION, condition)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1191
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1192 #define KUNIT_EXPECT_FALSE_MSG(test, condition, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1193 KUNIT_FALSE_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1194 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1195 condition, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1196 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1197 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1198
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1199 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1200 * KUNIT_EXPECT_EQ() - Sets an expectation that @left and @right are equal.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1201 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1202 * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1203 * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1204 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1205 * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1206 * equal. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1207 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1208 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1209 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1210 #define KUNIT_EXPECT_EQ(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1211 KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1212
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1213 #define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1214 KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1215 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1216 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1217 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1218 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1219 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1220
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1221 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1222 * KUNIT_EXPECT_PTR_EQ() - Expects that pointers @left and @right are equal.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1223 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1224 * @left: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1225 * @right: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1226 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1227 * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1228 * equal. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1229 * KUNIT_EXPECT_TRUE(@test, (@left) == (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1230 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1231 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1232 #define KUNIT_EXPECT_PTR_EQ(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1233 KUNIT_BINARY_PTR_EQ_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1234 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1235 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1236 right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1237
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1238 #define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1239 KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1240 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1241 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1242 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1243 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1244 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1245
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1246 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1247 * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1248 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1249 * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1250 * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1251 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1252 * Sets an expectation that the values that @left and @right evaluate to are not
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1253 * equal. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1254 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1255 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1256 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1257 #define KUNIT_EXPECT_NE(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1258 KUNIT_BINARY_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1259
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1260 #define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1261 KUNIT_BINARY_NE_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1262 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1263 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1264 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1265 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1266 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1267
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1268 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1269 * KUNIT_EXPECT_PTR_NE() - Expects that pointers @left and @right are not equal.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1270 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1271 * @left: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1272 * @right: an arbitrary expression that evaluates to a pointer.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1273 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1274 * Sets an expectation that the values that @left and @right evaluate to are not
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1275 * equal. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1276 * KUNIT_EXPECT_TRUE(@test, (@left) != (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1277 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1278 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1279 #define KUNIT_EXPECT_PTR_NE(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1280 KUNIT_BINARY_PTR_NE_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1281 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1282 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1283 right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1284
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1285 #define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1286 KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1287 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1288 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1289 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1290 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1291 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1292
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1293 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1294 * KUNIT_EXPECT_LT() - An expectation that @left is less than @right.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1295 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1296 * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1297 * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1298 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1299 * Sets an expectation that the value that @left evaluates to is less than the
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1300 * value that @right evaluates to. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1301 * KUNIT_EXPECT_TRUE(@test, (@left) < (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1302 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1303 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1304 #define KUNIT_EXPECT_LT(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1305 KUNIT_BINARY_LT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1306
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1307 #define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1308 KUNIT_BINARY_LT_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1309 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1310 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1311 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1312 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1313 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1314
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1315 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1316 * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1317 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1318 * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1319 * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1320 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1321 * Sets an expectation that the value that @left evaluates to is less than or
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1322 * equal to the value that @right evaluates to. Semantically this is equivalent
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1323 * to KUNIT_EXPECT_TRUE(@test, (@left) <= (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1324 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1325 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1326 #define KUNIT_EXPECT_LE(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1327 KUNIT_BINARY_LE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1328
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1329 #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1330 KUNIT_BINARY_LE_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1331 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1332 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1333 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1334 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1335 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1336
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1337 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1338 * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1339 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1340 * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1341 * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1342 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1343 * Sets an expectation that the value that @left evaluates to is greater than
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1344 * the value that @right evaluates to. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1345 * KUNIT_EXPECT_TRUE(@test, (@left) > (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1346 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1347 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1348 #define KUNIT_EXPECT_GT(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1349 KUNIT_BINARY_GT_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1350
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1351 #define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1352 KUNIT_BINARY_GT_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1353 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1354 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1355 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1356 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1357 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1358
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1359 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1360 * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1361 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1362 * @left: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1363 * @right: an arbitrary expression that evaluates to a primitive C type.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1364 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1365 * Sets an expectation that the value that @left evaluates to is greater than
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1366 * the value that @right evaluates to. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1367 * KUNIT_EXPECT_TRUE(@test, (@left) >= (@right)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1368 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1369 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1370 #define KUNIT_EXPECT_GE(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1371 KUNIT_BINARY_GE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1372
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1373 #define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1374 KUNIT_BINARY_GE_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1375 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1376 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1377 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1378 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1379 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1380
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1381 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1382 * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1383 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1384 * @left: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1385 * @right: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1386 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1387 * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1388 * equal. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1389 * KUNIT_EXPECT_TRUE(@test, !strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1390 * for more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1391 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1392 #define KUNIT_EXPECT_STREQ(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1393 KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1394
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1395 #define KUNIT_EXPECT_STREQ_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1396 KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1397 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1398 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1399 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1400 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1401 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1402
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1403 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1404 * KUNIT_EXPECT_STRNEQ() - Expects that strings @left and @right are not equal.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1405 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1406 * @left: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1407 * @right: an arbitrary expression that evaluates to a null terminated string.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1408 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1409 * Sets an expectation that the values that @left and @right evaluate to are
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1410 * not equal. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1411 * KUNIT_EXPECT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_EXPECT_TRUE()
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1412 * for more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1413 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1414 #define KUNIT_EXPECT_STRNEQ(test, left, right) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1415 KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_EXPECTATION, left, right)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1416
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1417 #define KUNIT_EXPECT_STRNEQ_MSG(test, left, right, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1418 KUNIT_BINARY_STR_NE_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1419 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1420 left, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1421 right, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1422 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1423 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1424
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1425 /**
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1426 * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1427 * @test: The test context object.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1428 * @ptr: an arbitrary pointer.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1429 *
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1430 * Sets an expectation that the value that @ptr evaluates to is not null and not
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1431 * an errno stored in a pointer. This is semantically equivalent to
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1432 * KUNIT_EXPECT_TRUE(@test, !IS_ERR_OR_NULL(@ptr)). See KUNIT_EXPECT_TRUE() for
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1433 * more information.
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1434 */
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1435 #define KUNIT_EXPECT_NOT_ERR_OR_NULL(test, ptr) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1436 KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_EXPECTATION, ptr)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1437
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1438 #define KUNIT_EXPECT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...) \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1439 KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1440 KUNIT_EXPECTATION, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1441 ptr, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1442 fmt, \
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1443 ##__VA_ARGS__)
73cda7bb8bfb1d Brendan Higgins 2019-09-23 1444
e4aea8f8532b55 Brendan Higgins 2019-09-23 1445 #define KUNIT_ASSERT_FAILURE(test, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1446 KUNIT_FAIL_ASSERTION(test, KUNIT_ASSERTION, fmt, ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1447
e4aea8f8532b55 Brendan Higgins 2019-09-23 1448 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1449 * KUNIT_ASSERT_TRUE() - Sets an assertion that @condition is true.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1450 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1451 * @condition: an arbitrary boolean expression. The test fails and aborts when
e4aea8f8532b55 Brendan Higgins 2019-09-23 1452 * this does not evaluate to true.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1453 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1454 * This and assertions of the form `KUNIT_ASSERT_*` will cause the test case to
e4aea8f8532b55 Brendan Higgins 2019-09-23 1455 * fail *and immediately abort* when the specified condition is not met. Unlike
e4aea8f8532b55 Brendan Higgins 2019-09-23 1456 * an expectation failure, it will prevent the test case from continuing to run;
e4aea8f8532b55 Brendan Higgins 2019-09-23 1457 * this is otherwise known as an *assertion failure*.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1458 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1459 #define KUNIT_ASSERT_TRUE(test, condition) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1460 KUNIT_TRUE_ASSERTION(test, KUNIT_ASSERTION, condition)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1461
e4aea8f8532b55 Brendan Higgins 2019-09-23 1462 #define KUNIT_ASSERT_TRUE_MSG(test, condition, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1463 KUNIT_TRUE_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1464 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1465 condition, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1466 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1467 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1468
e4aea8f8532b55 Brendan Higgins 2019-09-23 1469 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1470 * KUNIT_ASSERT_FALSE() - Sets an assertion that @condition is false.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1471 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1472 * @condition: an arbitrary boolean expression.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1473 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1474 * Sets an assertion that the value that @condition evaluates to is false. This
e4aea8f8532b55 Brendan Higgins 2019-09-23 1475 * is the same as KUNIT_EXPECT_FALSE(), except it causes an assertion failure
e4aea8f8532b55 Brendan Higgins 2019-09-23 1476 * (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1477 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1478 #define KUNIT_ASSERT_FALSE(test, condition) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1479 KUNIT_FALSE_ASSERTION(test, KUNIT_ASSERTION, condition)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1480
e4aea8f8532b55 Brendan Higgins 2019-09-23 1481 #define KUNIT_ASSERT_FALSE_MSG(test, condition, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1482 KUNIT_FALSE_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1483 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1484 condition, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1485 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1486 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1487
e4aea8f8532b55 Brendan Higgins 2019-09-23 1488 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1489 * KUNIT_ASSERT_EQ() - Sets an assertion that @left and @right are equal.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1490 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1491 * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1492 * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1493 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1494 * Sets an assertion that the values that @left and @right evaluate to are
e4aea8f8532b55 Brendan Higgins 2019-09-23 1495 * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
e4aea8f8532b55 Brendan Higgins 2019-09-23 1496 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1497 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1498 #define KUNIT_ASSERT_EQ(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1499 KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1500
e4aea8f8532b55 Brendan Higgins 2019-09-23 1501 #define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1502 KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1503 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1504 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1505 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1506 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1507 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1508
e4aea8f8532b55 Brendan Higgins 2019-09-23 1509 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1510 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1511 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1512 * @left: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1513 * @right: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1514 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1515 * Sets an assertion that the values that @left and @right evaluate to are
e4aea8f8532b55 Brendan Higgins 2019-09-23 1516 * equal. This is the same as KUNIT_EXPECT_EQ(), except it causes an assertion
e4aea8f8532b55 Brendan Higgins 2019-09-23 1517 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1518 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1519 #define KUNIT_ASSERT_PTR_EQ(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1520 KUNIT_BINARY_PTR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1521
e4aea8f8532b55 Brendan Higgins 2019-09-23 1522 #define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1523 KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1524 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1525 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1526 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1527 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1528 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1529
e4aea8f8532b55 Brendan Higgins 2019-09-23 1530 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1531 * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1532 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1533 * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1534 * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1535 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1536 * Sets an assertion that the values that @left and @right evaluate to are not
e4aea8f8532b55 Brendan Higgins 2019-09-23 1537 * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
e4aea8f8532b55 Brendan Higgins 2019-09-23 1538 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1539 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1540 #define KUNIT_ASSERT_NE(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1541 KUNIT_BINARY_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1542
e4aea8f8532b55 Brendan Higgins 2019-09-23 1543 #define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1544 KUNIT_BINARY_NE_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1545 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1546 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1547 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1548 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1549 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1550
e4aea8f8532b55 Brendan Higgins 2019-09-23 1551 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1552 * KUNIT_ASSERT_PTR_NE() - Asserts that pointers @left and @right are not equal.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1553 * KUNIT_ASSERT_PTR_EQ() - Asserts that pointers @left and @right are equal.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1554 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1555 * @left: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1556 * @right: an arbitrary expression that evaluates to a pointer.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1557 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1558 * Sets an assertion that the values that @left and @right evaluate to are not
e4aea8f8532b55 Brendan Higgins 2019-09-23 1559 * equal. This is the same as KUNIT_EXPECT_NE(), except it causes an assertion
e4aea8f8532b55 Brendan Higgins 2019-09-23 1560 * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1561 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1562 #define KUNIT_ASSERT_PTR_NE(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1563 KUNIT_BINARY_PTR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1564
e4aea8f8532b55 Brendan Higgins 2019-09-23 1565 #define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1566 KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1567 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1568 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1569 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1570 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1571 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1572 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1573 * KUNIT_ASSERT_LT() - An assertion that @left is less than @right.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1574 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1575 * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1576 * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1577 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1578 * Sets an assertion that the value that @left evaluates to is less than the
e4aea8f8532b55 Brendan Higgins 2019-09-23 1579 * value that @right evaluates to. This is the same as KUNIT_EXPECT_LT(), except
e4aea8f8532b55 Brendan Higgins 2019-09-23 1580 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
e4aea8f8532b55 Brendan Higgins 2019-09-23 1581 * is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1582 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1583 #define KUNIT_ASSERT_LT(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1584 KUNIT_BINARY_LT_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1585
e4aea8f8532b55 Brendan Higgins 2019-09-23 1586 #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1587 KUNIT_BINARY_LT_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1588 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1589 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1590 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1591 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1592 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1593 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1594 * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1595 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1596 * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1597 * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1598 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1599 * Sets an assertion that the value that @left evaluates to is less than or
e4aea8f8532b55 Brendan Higgins 2019-09-23 1600 * equal to the value that @right evaluates to. This is the same as
e4aea8f8532b55 Brendan Higgins 2019-09-23 1601 * KUNIT_EXPECT_LE(), except it causes an assertion failure (see
e4aea8f8532b55 Brendan Higgins 2019-09-23 1602 * KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1603 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1604 #define KUNIT_ASSERT_LE(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1605 KUNIT_BINARY_LE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1606
e4aea8f8532b55 Brendan Higgins 2019-09-23 1607 #define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1608 KUNIT_BINARY_LE_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1609 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1610 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1611 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1612 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1613 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1614
e4aea8f8532b55 Brendan Higgins 2019-09-23 1615 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1616 * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1617 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1618 * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1619 * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1620 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1621 * Sets an assertion that the value that @left evaluates to is greater than the
e4aea8f8532b55 Brendan Higgins 2019-09-23 1622 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GT(), except
e4aea8f8532b55 Brendan Higgins 2019-09-23 1623 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
e4aea8f8532b55 Brendan Higgins 2019-09-23 1624 * is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1625 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1626 #define KUNIT_ASSERT_GT(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1627 KUNIT_BINARY_GT_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1628
e4aea8f8532b55 Brendan Higgins 2019-09-23 1629 #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1630 KUNIT_BINARY_GT_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1631 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1632 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1633 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1634 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1635 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1636
e4aea8f8532b55 Brendan Higgins 2019-09-23 1637 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1638 * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1639 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1640 * @left: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1641 * @right: an arbitrary expression that evaluates to a primitive C type.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1642 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1643 * Sets an assertion that the value that @left evaluates to is greater than the
e4aea8f8532b55 Brendan Higgins 2019-09-23 1644 * value that @right evaluates to. This is the same as KUNIT_EXPECT_GE(), except
e4aea8f8532b55 Brendan Higgins 2019-09-23 1645 * it causes an assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion
e4aea8f8532b55 Brendan Higgins 2019-09-23 1646 * is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1647 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1648 #define KUNIT_ASSERT_GE(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1649 KUNIT_BINARY_GE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1650
e4aea8f8532b55 Brendan Higgins 2019-09-23 1651 #define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1652 KUNIT_BINARY_GE_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1653 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1654 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1655 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1656 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1657 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1658
e4aea8f8532b55 Brendan Higgins 2019-09-23 1659 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1660 * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1661 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1662 * @left: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1663 * @right: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1664 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1665 * Sets an assertion that the values that @left and @right evaluate to are
e4aea8f8532b55 Brendan Higgins 2019-09-23 1666 * equal. This is the same as KUNIT_EXPECT_STREQ(), except it causes an
e4aea8f8532b55 Brendan Higgins 2019-09-23 1667 * assertion failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1668 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1669 #define KUNIT_ASSERT_STREQ(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1670 KUNIT_BINARY_STR_EQ_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1671
e4aea8f8532b55 Brendan Higgins 2019-09-23 1672 #define KUNIT_ASSERT_STREQ_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1673 KUNIT_BINARY_STR_EQ_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1674 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1675 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1676 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1677 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1678 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1679
e4aea8f8532b55 Brendan Higgins 2019-09-23 1680 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1681 * KUNIT_ASSERT_STRNEQ() - Expects that strings @left and @right are not equal.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1682 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1683 * @left: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1684 * @right: an arbitrary expression that evaluates to a null terminated string.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1685 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1686 * Sets an expectation that the values that @left and @right evaluate to are
e4aea8f8532b55 Brendan Higgins 2019-09-23 1687 * not equal. This is semantically equivalent to
e4aea8f8532b55 Brendan Higgins 2019-09-23 1688 * KUNIT_ASSERT_TRUE(@test, strcmp((@left), (@right))). See KUNIT_ASSERT_TRUE()
e4aea8f8532b55 Brendan Higgins 2019-09-23 1689 * for more information.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1690 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1691 #define KUNIT_ASSERT_STRNEQ(test, left, right) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1692 KUNIT_BINARY_STR_NE_ASSERTION(test, KUNIT_ASSERTION, left, right)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1693
e4aea8f8532b55 Brendan Higgins 2019-09-23 1694 #define KUNIT_ASSERT_STRNEQ_MSG(test, left, right, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1695 KUNIT_BINARY_STR_NE_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1696 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1697 left, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1698 right, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1699 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1700 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1701
e4aea8f8532b55 Brendan Higgins 2019-09-23 1702 /**
e4aea8f8532b55 Brendan Higgins 2019-09-23 1703 * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1704 * @test: The test context object.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1705 * @ptr: an arbitrary pointer.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1706 *
e4aea8f8532b55 Brendan Higgins 2019-09-23 1707 * Sets an assertion that the value that @ptr evaluates to is not null and not
e4aea8f8532b55 Brendan Higgins 2019-09-23 1708 * an errno stored in a pointer. This is the same as
e4aea8f8532b55 Brendan Higgins 2019-09-23 1709 * KUNIT_EXPECT_NOT_ERR_OR_NULL(), except it causes an assertion failure (see
e4aea8f8532b55 Brendan Higgins 2019-09-23 1710 * KUNIT_ASSERT_TRUE()) when the assertion is not met.
e4aea8f8532b55 Brendan Higgins 2019-09-23 1711 */
e4aea8f8532b55 Brendan Higgins 2019-09-23 1712 #define KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1713 KUNIT_PTR_NOT_ERR_OR_NULL_ASSERTION(test, KUNIT_ASSERTION, ptr)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1714
e4aea8f8532b55 Brendan Higgins 2019-09-23 1715 #define KUNIT_ASSERT_NOT_ERR_OR_NULL_MSG(test, ptr, fmt, ...) \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1716 KUNIT_PTR_NOT_ERR_OR_NULL_MSG_ASSERTION(test, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1717 KUNIT_ASSERTION, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1718 ptr, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1719 fmt, \
e4aea8f8532b55 Brendan Higgins 2019-09-23 1720 ##__VA_ARGS__)
e4aea8f8532b55 Brendan Higgins 2019-09-23 1721
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1722 /**
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1723 * KUNIT_PARAM_GENERATOR() - Helper method for test parameter generators
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1724 * required in parameterized tests.
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1725 * @name: prefix of the name for the test parameter generator function.
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1726 * @prev: a pointer to the previous test parameter, NULL for first parameter.
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1727 * @array: a user-supplied pointer to an array of test parameters.
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1728 */
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1729 #define KUNIT_PARAM_GENERATOR(name, array) \
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1730 static void *name##_gen_params(void *prev) \
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1731 { \
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1732 typeof((array)[0]) * __next = prev ? ((typeof(__next)) prev) + 1 : (array); \
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 @1733 return __next - (array) < ARRAY_SIZE((array)) ? __next : NULL; \
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1734 }
6b4ee29da75136 Arpitha Raghunandan 2020-10-27 1735

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

Attachment: .config.gz
Description: application/gzip