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-5.6-rc1-kunit' of git://git.kernel.org/pub…
…/scm/linux/kernel/git/shuah/linux-kselftest Pull Kselftest kunit updates from Shuah Khan: "This kunit update consists of: - Support for building kunit as a module from Alan Maguire - AppArmor KUnit tests for policy unpack from Mike Salvatore" * tag 'linux-kselftest-5.6-rc1-kunit' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: building kunit as a module breaks allmodconfig kunit: update documentation to describe module-based build kunit: allow kunit to be loaded as a module kunit: remove timeout dependence on sysctl_hung_task_timeout_seconds kunit: allow kunit tests to be loaded as a module kunit: hide unexported try-catch interface in try-catch-impl.h kunit: move string-stream.h to lib/kunit apparmor: add AppArmor KUnit tests for policy unpack
- Loading branch information
Showing
28 changed files
with
788 additions
and
74 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
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
#include <kunit/assert.h> | ||
#include <kunit/try-catch.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/slab.h> | ||
#include <linux/types.h> | ||
|
||
|
@@ -197,31 +198,47 @@ void kunit_init_test(struct kunit *test, const char *name); | |
int kunit_run_tests(struct kunit_suite *suite); | ||
|
||
/** | ||
* kunit_test_suite() - used to register a &struct kunit_suite with KUnit. | ||
* kunit_test_suites() - used to register one or more &struct kunit_suite | ||
* with KUnit. | ||
* | ||
* @suite: a statically allocated &struct kunit_suite. | ||
* @suites: a statically allocated list of &struct kunit_suite. | ||
* | ||
* Registers @suite with the test framework. See &struct kunit_suite for | ||
* Registers @suites with the test framework. See &struct kunit_suite for | ||
* more information. | ||
* | ||
* NOTE: Currently KUnit tests are all run as late_initcalls; this means | ||
* When builtin, KUnit tests are all run as late_initcalls; this means | ||
* that they cannot test anything where tests must run at a different init | ||
* phase. One significant restriction resulting from this is that KUnit | ||
* cannot reliably test anything that is initialize in the late_init phase; | ||
* another is that KUnit is useless to test things that need to be run in | ||
* an earlier init phase. | ||
* | ||
* An alternative is to build the tests as a module. Because modules | ||
* do not support multiple late_initcall()s, we need to initialize an | ||
* array of suites for a module. | ||
* | ||
* TODO([email protected]): Don't run all KUnit tests as | ||
* late_initcalls. I have some future work planned to dispatch all KUnit | ||
* tests from the same place, and at the very least to do so after | ||
* everything else is definitely initialized. | ||
*/ | ||
#define kunit_test_suite(suite) \ | ||
static int kunit_suite_init##suite(void) \ | ||
{ \ | ||
return kunit_run_tests(&suite); \ | ||
} \ | ||
late_initcall(kunit_suite_init##suite) | ||
#define kunit_test_suites(...) \ | ||
static struct kunit_suite *suites[] = { __VA_ARGS__, NULL}; \ | ||
static int kunit_test_suites_init(void) \ | ||
{ \ | ||
unsigned int i; \ | ||
for (i = 0; suites[i] != NULL; i++) \ | ||
kunit_run_tests(suites[i]); \ | ||
return 0; \ | ||
} \ | ||
late_initcall(kunit_test_suites_init); \ | ||
static void __exit kunit_test_suites_exit(void) \ | ||
{ \ | ||
return; \ | ||
} \ | ||
module_exit(kunit_test_suites_exit) | ||
|
||
#define kunit_test_suite(suite) kunit_test_suites(&suite) | ||
|
||
/* | ||
* Like kunit_alloc_resource() below, but returns the struct kunit_resource | ||
|
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
obj-$(CONFIG_KUNIT) += test.o \ | ||
obj-$(CONFIG_KUNIT) += kunit.o | ||
|
||
kunit-objs += test.o \ | ||
string-stream.o \ | ||
assert.o \ | ||
try-catch.o | ||
|
||
obj-$(CONFIG_KUNIT_TEST) += test-test.o \ | ||
string-stream-test.o | ||
obj-$(CONFIG_KUNIT_TEST) += kunit-test.o | ||
|
||
# string-stream-test compiles built-in only. | ||
ifeq ($(CONFIG_KUNIT_TEST),y) | ||
obj-$(CONFIG_KUNIT_TEST) += string-stream-test.o | ||
endif | ||
|
||
obj-$(CONFIG_KUNIT_EXAMPLE_TEST) += example-test.o | ||
obj-$(CONFIG_KUNIT_EXAMPLE_TEST) += kunit-example-test.o |
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,10 +6,11 @@ | |
* Author: Brendan Higgins <[email protected]> | ||
*/ | ||
|
||
#include <kunit/string-stream.h> | ||
#include <kunit/test.h> | ||
#include <linux/slab.h> | ||
|
||
#include "string-stream.h" | ||
|
||
static void string_stream_test_empty_on_creation(struct kunit *test) | ||
{ | ||
struct string_stream *stream = alloc_string_stream(test, GFP_KERNEL); | ||
|
@@ -49,4 +50,4 @@ static struct kunit_suite string_stream_test_suite = { | |
.name = "string-stream-test", | ||
.test_cases = string_stream_test_cases | ||
}; | ||
kunit_test_suite(string_stream_test_suite); | ||
kunit_test_suites(&string_stream_test_suite); |
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,11 +6,12 @@ | |
* Author: Brendan Higgins <[email protected]> | ||
*/ | ||
|
||
#include <kunit/string-stream.h> | ||
#include <kunit/test.h> | ||
#include <linux/list.h> | ||
#include <linux/slab.h> | ||
|
||
#include "string-stream.h" | ||
|
||
struct string_stream_fragment_alloc_context { | ||
struct kunit *test; | ||
int len; | ||
|
File renamed without changes.
Oops, something went wrong.