Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: hide unexported try-catch interface in try-catch-impl.h

Define function as static inline in try-catch-impl.h to allow it to
be used in kunit itself and tests. Also remove unused
kunit_generic_try_catch

Co-developed-by: Knut Omang <knut.omang@oracle.com>
Signed-off-by: Knut Omang <knut.omang@oracle.com>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Tested-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Alan Maguire and committed by
Shuah Khan
9bbb11c6 109fb06f

+32 -22
-10
include/kunit/try-catch.h
··· 53 53 void *context; 54 54 }; 55 55 56 - void kunit_try_catch_init(struct kunit_try_catch *try_catch, 57 - struct kunit *test, 58 - kunit_try_catch_func_t try, 59 - kunit_try_catch_func_t catch); 60 - 61 56 void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context); 62 57 63 58 void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_catch); ··· 61 66 { 62 67 return try_catch->try_result; 63 68 } 64 - 65 - /* 66 - * Exposed for testing only. 67 - */ 68 - void kunit_generic_try_catch_init(struct kunit_try_catch *try_catch); 69 69 70 70 #endif /* _KUNIT_TRY_CATCH_H */
+2
lib/kunit/test-test.c
··· 7 7 */ 8 8 #include <kunit/test.h> 9 9 10 + #include "try-catch-impl.h" 11 + 10 12 struct kunit_try_catch_test_context { 11 13 struct kunit_try_catch *try_catch; 12 14 bool function_called;
+1 -1
lib/kunit/test.c
··· 7 7 */ 8 8 9 9 #include <kunit/test.h> 10 - #include <kunit/try-catch.h> 11 10 #include <linux/kernel.h> 12 11 #include <linux/sched/debug.h> 13 12 14 13 #include "string-stream.h" 14 + #include "try-catch-impl.h" 15 15 16 16 static void kunit_set_failure(struct kunit *test) 17 17 {
+27
lib/kunit/try-catch-impl.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Internal kunit try catch implementation to be shared with tests. 4 + * 5 + * Copyright (C) 2019, Google LLC. 6 + * Author: Brendan Higgins <brendanhiggins@google.com> 7 + */ 8 + 9 + #ifndef _KUNIT_TRY_CATCH_IMPL_H 10 + #define _KUNIT_TRY_CATCH_IMPL_H 11 + 12 + #include <kunit/try-catch.h> 13 + #include <linux/types.h> 14 + 15 + struct kunit; 16 + 17 + static inline void kunit_try_catch_init(struct kunit_try_catch *try_catch, 18 + struct kunit *test, 19 + kunit_try_catch_func_t try, 20 + kunit_try_catch_func_t catch) 21 + { 22 + try_catch->test = test; 23 + try_catch->try = try; 24 + try_catch->catch = catch; 25 + } 26 + 27 + #endif /* _KUNIT_TRY_CATCH_IMPL_H */
+2 -11
lib/kunit/try-catch.c
··· 8 8 */ 9 9 10 10 #include <kunit/test.h> 11 - #include <kunit/try-catch.h> 12 11 #include <linux/completion.h> 13 12 #include <linux/kernel.h> 14 13 #include <linux/kthread.h> 15 14 #include <linux/sched/sysctl.h> 15 + 16 + #include "try-catch-impl.h" 16 17 17 18 void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_catch) 18 19 { ··· 106 105 kunit_err(test, "Unknown error: %d\n", exit_code); 107 106 108 107 try_catch->catch(try_catch->context); 109 - } 110 - 111 - void kunit_try_catch_init(struct kunit_try_catch *try_catch, 112 - struct kunit *test, 113 - kunit_try_catch_func_t try, 114 - kunit_try_catch_func_t catch) 115 - { 116 - try_catch->test = test; 117 - try_catch->try = try; 118 - try_catch->catch = catch; 119 108 }