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.
We just added a new C header file for use with test modules that are intended to be run with kselftest. We can reduce code duplication by using this header. Use new kselftest header to reduce code duplication in test_printf and test_bitmap test modules. Acked-by: Kees Cook <[email protected]> Signed-off-by: Tobin C. Harding <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
- Loading branch information
Tobin C. Harding
authored and
Shuah Khan
committed
Apr 8, 2019
1 parent
eebf4dd
commit 6b1a4d5
Showing
2 changed files
with
9 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
#include <linux/slab.h> | ||
#include <linux/string.h> | ||
|
||
#include "../tools/testing/selftests/kselftest_module.h" | ||
|
||
static unsigned total_tests __initdata; | ||
static unsigned failed_tests __initdata; | ||
|
||
|
@@ -361,30 +363,16 @@ static void noinline __init test_mem_optimisations(void) | |
} | ||
} | ||
|
||
static int __init test_bitmap_init(void) | ||
static void __init selftest(void) | ||
{ | ||
test_zero_clear(); | ||
test_fill_set(); | ||
test_copy(); | ||
test_bitmap_arr32(); | ||
test_bitmap_parselist(); | ||
test_mem_optimisations(); | ||
|
||
if (failed_tests == 0) | ||
pr_info("all %u tests passed\n", total_tests); | ||
else | ||
pr_warn("failed %u out of %u tests\n", | ||
failed_tests, total_tests); | ||
|
||
return failed_tests ? -EINVAL : 0; | ||
} | ||
|
||
static void __exit test_bitmap_cleanup(void) | ||
{ | ||
} | ||
|
||
module_init(test_bitmap_init); | ||
module_exit(test_bitmap_cleanup); | ||
|
||
KSTM_MODULE_LOADERS(test_bitmap); | ||
MODULE_AUTHOR("david decotigny <[email protected]>"); | ||
MODULE_LICENSE("GPL"); |
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 |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
#include <linux/gfp.h> | ||
#include <linux/mm.h> | ||
|
||
#include "../tools/testing/selftests/kselftest_module.h" | ||
|
||
#define BUF_SIZE 256 | ||
#define PAD_SIZE 16 | ||
#define FILL_CHAR '$' | ||
|
@@ -590,12 +592,11 @@ test_pointer(void) | |
flags(); | ||
} | ||
|
||
static int __init | ||
test_printf_init(void) | ||
static void __init selftest(void) | ||
{ | ||
alloced_buffer = kmalloc(BUF_SIZE + 2*PAD_SIZE, GFP_KERNEL); | ||
if (!alloced_buffer) | ||
return -ENOMEM; | ||
return; | ||
test_buffer = alloced_buffer + PAD_SIZE; | ||
|
||
test_basic(); | ||
|
@@ -604,22 +605,8 @@ test_printf_init(void) | |
test_pointer(); | ||
|
||
kfree(alloced_buffer); | ||
|
||
if (failed_tests == 0) | ||
pr_info("all %u tests passed\n", total_tests); | ||
else | ||
pr_warn("failed %u out of %u tests\n", failed_tests, total_tests); | ||
|
||
return failed_tests ? -EINVAL : 0; | ||
} | ||
|
||
module_init(test_printf_init); | ||
|
||
static void __exit test_printf_exit(void) | ||
{ | ||
} | ||
|
||
module_exit(test_printf_exit); | ||
|
||
KSTM_MODULE_LOADERS(test_printf); | ||
MODULE_AUTHOR("Rasmus Villemoes <[email protected]>"); | ||
MODULE_LICENSE("GPL"); |