Merge tag 'linux-kselftest-kunit-5.10-rc1' of git://git.kernel.org/pub/scm/linux...
[linux-2.6-microblaze.git] / lib / kunit / test.c
index de07876..750704a 100644 (file)
 #include <linux/kernel.h>
 #include <linux/kref.h>
 #include <linux/sched/debug.h>
+#include <linux/sched.h>
 
 #include "debugfs.h"
 #include "string-stream.h"
 #include "try-catch-impl.h"
 
-static void kunit_set_failure(struct kunit *test)
-{
-       WRITE_ONCE(test->success, false);
-}
-
 /*
  * Append formatted message to log, size of which is limited to
  * KUNIT_LOG_SIZE bytes (including null terminating byte).
@@ -277,6 +273,10 @@ static void kunit_try_run_case(void *data)
        struct kunit_suite *suite = ctx->suite;
        struct kunit_case *test_case = ctx->test_case;
 
+#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT))
+       current->kunit_test = test;
+#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT) */
+
        /*
         * kunit_run_case_internal may encounter a fatal error; if it does,
         * abort will be called, this thread will exit, and finally the parent
@@ -591,6 +591,9 @@ void kunit_cleanup(struct kunit *test)
                spin_unlock(&test->lock);
                kunit_remove_resource(test, res);
        }
+#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT))
+       current->kunit_test = NULL;
+#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)*/
 }
 EXPORT_SYMBOL_GPL(kunit_cleanup);