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

From: kernel test robot
Date: Fri Oct 23 2020 - 13:33:48 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.9 next-20201023]
[cannot apply to tytso-fscrypt/master]
[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/20201023-230827
base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: x86_64-randconfig-s021-20201023 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-17-g2d3af347-dirty
# https://github.com/0day-ci/linux/commit/67c9830f2988a5b2153f7bb05396611947ee6677
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Arpitha-Raghunandan/kunit-Support-for-Parameterized-Testing/20201023-230827
git checkout 67c9830f2988a5b2153f7bb05396611947ee6677
# 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>


"sparse warnings: (new ones prefixed by >>)"
fs/ext4/inode-test.c: note: in included file:
>> include/kunit/test.h:1732:9: sparse: sparse: incompatible types in comparison expression (different type sizes):
>> include/kunit/test.h:1732:9: sparse: unsigned long *
>> include/kunit/test.h:1732:9: sparse: int *

vim +1732 include/kunit/test.h

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

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

Attachment: .config.gz
Description: application/gzip