forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'linux-kselftest-kunit-6.4-rc1' of git://git.kernel.org/pub…
…/scm/linux/kernel/git/shuah/linux-kselftest Pull KUnit updates from Shuah Khan: - several fixes to kunit tool - new klist structure test - support for m68k under QEMU - support for overriding the QEMU serial port - support for SH under QEMU * tag 'linux-kselftest-kunit-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: add tests for using current KUnit test field kunit: tool: Add support for SH under QEMU kunit: tool: Add support for overriding the QEMU serial port .gitignore: Unignore .kunitconfig list: test: Test the klist structure kunit: increase KUNIT_LOG_SIZE to 2048 bytes kunit: Use gfp in kunit_alloc_resource() kernel-doc kunit: tool: fix pre-existing `mypy --strict` errors and update run_checks.py kunit: tool: remove unused imports and variables kunit: tool: add subscripts for type annotations where appropriate kunit: fix bug of extra newline characters in debugfs logs kunit: fix bug in the order of lines in debugfs logs kunit: fix bug in debugfs logs of parameterized tests kunit: tool: Add support for m68k under QEMU
- Loading branch information
Showing
17 changed files
with
491 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* Author: Brendan Higgins <[email protected]> | ||
*/ | ||
#include <kunit/test.h> | ||
#include <kunit/test-bug.h> | ||
|
||
#include "try-catch-impl.h" | ||
|
||
|
@@ -443,18 +444,6 @@ static struct kunit_suite kunit_resource_test_suite = { | |
.test_cases = kunit_resource_test_cases, | ||
}; | ||
|
||
static void kunit_log_test(struct kunit *test); | ||
|
||
static struct kunit_case kunit_log_test_cases[] = { | ||
KUNIT_CASE(kunit_log_test), | ||
{} | ||
}; | ||
|
||
static struct kunit_suite kunit_log_test_suite = { | ||
.name = "kunit-log-test", | ||
.test_cases = kunit_log_test_cases, | ||
}; | ||
|
||
static void kunit_log_test(struct kunit *test) | ||
{ | ||
struct kunit_suite suite; | ||
|
@@ -481,6 +470,29 @@ static void kunit_log_test(struct kunit *test) | |
#endif | ||
} | ||
|
||
static void kunit_log_newline_test(struct kunit *test) | ||
{ | ||
kunit_info(test, "Add newline\n"); | ||
if (test->log) { | ||
KUNIT_ASSERT_NOT_NULL_MSG(test, strstr(test->log, "Add newline\n"), | ||
"Missing log line, full log:\n%s", test->log); | ||
KUNIT_EXPECT_NULL(test, strstr(test->log, "Add newline\n\n")); | ||
} else { | ||
kunit_skip(test, "only useful when debugfs is enabled"); | ||
} | ||
} | ||
|
||
static struct kunit_case kunit_log_test_cases[] = { | ||
KUNIT_CASE(kunit_log_test), | ||
KUNIT_CASE(kunit_log_newline_test), | ||
{} | ||
}; | ||
|
||
static struct kunit_suite kunit_log_test_suite = { | ||
.name = "kunit-log-test", | ||
.test_cases = kunit_log_test_cases, | ||
}; | ||
|
||
static void kunit_status_set_failure_test(struct kunit *test) | ||
{ | ||
struct kunit fake; | ||
|
@@ -521,7 +533,46 @@ static struct kunit_suite kunit_status_test_suite = { | |
.test_cases = kunit_status_test_cases, | ||
}; | ||
|
||
static void kunit_current_test(struct kunit *test) | ||
{ | ||
/* Check results of both current->kunit_test and | ||
* kunit_get_current_test() are equivalent to current test. | ||
*/ | ||
KUNIT_EXPECT_PTR_EQ(test, test, current->kunit_test); | ||
KUNIT_EXPECT_PTR_EQ(test, test, kunit_get_current_test()); | ||
} | ||
|
||
static void kunit_current_fail_test(struct kunit *test) | ||
{ | ||
struct kunit fake; | ||
|
||
kunit_init_test(&fake, "fake test", NULL); | ||
KUNIT_EXPECT_EQ(test, fake.status, KUNIT_SUCCESS); | ||
|
||
/* Set current->kunit_test to fake test. */ | ||
current->kunit_test = &fake; | ||
|
||
kunit_fail_current_test("This should make `fake` test fail."); | ||
KUNIT_EXPECT_EQ(test, fake.status, (enum kunit_status)KUNIT_FAILURE); | ||
kunit_cleanup(&fake); | ||
|
||
/* Reset current->kunit_test to current test. */ | ||
current->kunit_test = test; | ||
} | ||
|
||
static struct kunit_case kunit_current_test_cases[] = { | ||
KUNIT_CASE(kunit_current_test), | ||
KUNIT_CASE(kunit_current_fail_test), | ||
{} | ||
}; | ||
|
||
static struct kunit_suite kunit_current_test_suite = { | ||
.name = "kunit_current", | ||
.test_cases = kunit_current_test_cases, | ||
}; | ||
|
||
kunit_test_suites(&kunit_try_catch_test_suite, &kunit_resource_test_suite, | ||
&kunit_log_test_suite, &kunit_status_test_suite); | ||
&kunit_log_test_suite, &kunit_status_test_suite, | ||
&kunit_current_test_suite); | ||
|
||
MODULE_LICENSE("GPL v2"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.