History

Merge tag 'linux-kselftest-kunit-fixes-6.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull KUnit fixes from Shuah Khan: "Three fixes to bugs that cause kernel crash, link error during build, and a third to fix kunit_test_init_section_suites() extra indirection issue" * tag 'linux-kselftest-kunit-fixes-6.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: fix kunit_test_init_section_suites(...) kunit: fix bug in KUNIT_EXPECT_MEMEQ kunit: Export kunit_running()

Linus Torvalds committed 3 years ago

Commit e7368fd2 parents 42c78a5 254c7133 files · +29 −18Browse files

Unified · Split

3 files
  1. include/kunit/test.h +3 −3
  2. lib/kunit/assert.c +25 −15
  3. lib/kunit/test.c +1 −0
include/kunit/test.h+3−3
@@ -303,7 +303,6 @@ static inline int kunit_run_all_tests(void) · 302 unmodified lines
303 */303 */
304#define kunit_test_init_section_suites(__suites...) \304#define kunit_test_init_section_suites(__suites...) \
305 __kunit_test_suites(CONCATENATE(__UNIQUE_ID(array), _probe), \305 __kunit_test_suites(CONCATENATE(__UNIQUE_ID(array), _probe), \
306 CONCATENATE(__UNIQUE_ID(suites), _probe), \
307 ##__suites)306 ##__suites)
308 307
309#define kunit_test_init_section_suite(suite) \308#define kunit_test_init_section_suite(suite) \
@@ -683,8 +682,9 @@ do { \ · 373 unmodified lines
683 .right_text = #right, \682 .right_text = #right, \
684 }; \683 }; \
685 \684 \
686 if (likely(memcmp(__left, __right, __size) op 0)) \685 if (likely(__left && __right)) \
687 break; \686 if (likely(memcmp(__left, __right, __size) op 0)) \
687 break; \
688 \688 \
689 _KUNIT_FAILED(test, \689 _KUNIT_FAILED(test, \
690 assert_type, \690 assert_type, \
lib/kunit/assert.c+25−15
@@ -241,24 +241,34 @@ void kunit_mem_assert_format(const struct kunit_assert *assert, · 240 unmodified lines
241 mem_assert = container_of(assert, struct kunit_mem_assert,241 mem_assert = container_of(assert, struct kunit_mem_assert,
242 assert);242 assert);
243 243
244 string_stream_add(stream,244 if (!mem_assert->left_value) {
245 KUNIT_SUBTEST_INDENT "Expected %s %s %s, but\n",245 string_stream_add(stream,
246 mem_assert->text->left_text,246 KUNIT_SUBTEST_INDENT "Expected %s is not null, but is\n",
247 mem_assert->text->operation,247 mem_assert->text->left_text);
248 mem_assert->text->right_text);248 } else if (!mem_assert->right_value) {
249 string_stream_add(stream,
250 KUNIT_SUBTEST_INDENT "Expected %s is not null, but is\n",
251 mem_assert->text->right_text);
252 } else {
253 string_stream_add(stream,
254 KUNIT_SUBTEST_INDENT "Expected %s %s %s, but\n",
255 mem_assert->text->left_text,
256 mem_assert->text->operation,
257 mem_assert->text->right_text);
249 258
250 string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n",259 string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n",
251 mem_assert->text->left_text);260 mem_assert->text->left_text);
252 kunit_assert_hexdump(stream, mem_assert->left_value,261 kunit_assert_hexdump(stream, mem_assert->left_value,
253 mem_assert->right_value, mem_assert->size);262 mem_assert->right_value, mem_assert->size);
254 263
255 string_stream_add(stream, "\n");264 string_stream_add(stream, "\n");
256 265
257 string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n",266 string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n",
258 mem_assert->text->right_text);267 mem_assert->text->right_text);
259 kunit_assert_hexdump(stream, mem_assert->right_value,268 kunit_assert_hexdump(stream, mem_assert->right_value,
260 mem_assert->left_value, mem_assert->size);269 mem_assert->left_value, mem_assert->size);
261 270
262 kunit_assert_print_msg(message, stream);271 kunit_assert_print_msg(message, stream);
272 }
263}273}
264EXPORT_SYMBOL_GPL(kunit_mem_assert_format);274EXPORT_SYMBOL_GPL(kunit_mem_assert_format);
lib/kunit/test.c+1−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#include "try-catch-impl.h"21#include "try-catch-impl.h"
22 22
23DEFINE_STATIC_KEY_FALSE(kunit_running);23DEFINE_STATIC_KEY_FALSE(kunit_running);
24EXPORT_SYMBOL_GPL(kunit_running);
24 25
25#if IS_BUILTIN(CONFIG_KUNIT)26#if IS_BUILTIN(CONFIG_KUNIT)
26/*27/*