@@ -53,11 +53,6 @@ struct kunit_try_catch {
void *context;
};
-void kunit_try_catch_init(struct kunit_try_catch *try_catch,
- struct kunit *test,
- kunit_try_catch_func_t try,
- kunit_try_catch_func_t catch);
-
void kunit_try_catch_run(struct kunit_try_catch *try_catch, void *context);
void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_catch);
@@ -67,9 +62,4 @@ static inline int kunit_try_catch_get_result(struct kunit_try_catch *try_catch)
return try_catch->try_result;
}
-/*
- * Exposed for testing only.
- */
-void kunit_generic_try_catch_init(struct kunit_try_catch *try_catch);
-
#endif /* _KUNIT_TRY_CATCH_H */
@@ -6,6 +6,7 @@
* Author: Brendan Higgins <brendanhiggins@google.com>
*/
#include <kunit/test.h>
+#include "try-catch-impl.h"
struct kunit_try_catch_test_context {
struct kunit_try_catch *try_catch;
@@ -11,6 +11,7 @@
#include <linux/kernel.h>
#include <linux/sched/debug.h>
#include "string-stream-impl.h"
+#include "try-catch-impl.h"
static void kunit_set_failure(struct kunit *test)
{
new file mode 100644
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * An API to allow a function, that may fail, to be executed, and recover in a
+ * controlled manner.
+ *
+ * Copyright (C) 2019, Google LLC.
+ * Author: Brendan Higgins <brendanhiggins@google.com>
+ */
+
+#ifndef _KUNIT_TRY_CATCH_IMPL_H
+#define _KUNIT_TRY_CATCH_IMPL_H
+
+#include <kunit/try-catch.h>
+#include <linux/types.h>
+
+struct kunit;
+
+void kunit_try_catch_init(struct kunit_try_catch *try_catch,
+ struct kunit *test,
+ kunit_try_catch_func_t try,
+ kunit_try_catch_func_t catch);
+
+#endif /* _KUNIT_TRY_CATCH_IMPL_H */
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/sched/sysctl.h>
+#include "try-catch-impl.h"
void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_catch)
{
also remove unused kunit_generic_try_catch Signed-off-by: Alan Maguire <alan.maguire@oracle.com> --- include/kunit/try-catch.h | 10 ---------- lib/kunit/test-test.c | 1 + lib/kunit/test.c | 1 + lib/kunit/try-catch-impl.h | 23 +++++++++++++++++++++++ lib/kunit/try-catch.c | 1 + 5 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 lib/kunit/try-catch-impl.h