ANDROID: kunit: Provision kunit as a vendor module
'kunit_test' member variable in task_struct is defined under CONFIG_KUNIT. Besides there are supportive functions in slub and kasan which gets conditionally compiled out. Allow kunit to be build as vendor module by removing compile time dependencies. Bug: 215096354 Change-Id: If57b1df6e479aa0388aabc53af5ae10e20a844b2 Signed-off-by: Shiraz Hashim <quic_shashim@quicinc.com>
This commit is contained in:
@@ -1353,9 +1353,7 @@ struct task_struct {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_KUNIT)
|
||||
struct kunit *kunit_test;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
||||
/* Index of current stored address in ret_stack: */
|
||||
|
||||
@@ -343,7 +343,6 @@ static bool report_enabled(void)
|
||||
return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags);
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_KUNIT)
|
||||
static void kasan_update_kunit_status(struct kunit *cur_test)
|
||||
{
|
||||
struct kunit_resource *resource;
|
||||
@@ -360,7 +359,6 @@ static void kasan_update_kunit_status(struct kunit *cur_test)
|
||||
WRITE_ONCE(kasan_data->report_found, true);
|
||||
kunit_put_resource(resource);
|
||||
}
|
||||
#endif /* IS_ENABLED(CONFIG_KUNIT) */
|
||||
|
||||
void kasan_report_invalid_free(void *object, unsigned long ip)
|
||||
{
|
||||
@@ -369,10 +367,8 @@ void kasan_report_invalid_free(void *object, unsigned long ip)
|
||||
|
||||
object = kasan_reset_tag(object);
|
||||
|
||||
#if IS_ENABLED(CONFIG_KUNIT)
|
||||
if (current->kunit_test)
|
||||
kasan_update_kunit_status(current->kunit_test);
|
||||
#endif /* IS_ENABLED(CONFIG_KUNIT) */
|
||||
|
||||
start_report(&flags);
|
||||
pr_err("BUG: KASAN: double-free or invalid-free in %pS\n", (void *)ip);
|
||||
@@ -389,10 +385,8 @@ void kasan_report_async(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
#if IS_ENABLED(CONFIG_KUNIT)
|
||||
if (current->kunit_test)
|
||||
kasan_update_kunit_status(current->kunit_test);
|
||||
#endif /* IS_ENABLED(CONFIG_KUNIT) */
|
||||
|
||||
start_report(&flags);
|
||||
pr_err("BUG: KASAN: invalid-access\n");
|
||||
@@ -411,10 +405,8 @@ static void __kasan_report(unsigned long addr, size_t size, bool is_write,
|
||||
void *untagged_addr;
|
||||
unsigned long flags;
|
||||
|
||||
#if IS_ENABLED(CONFIG_KUNIT)
|
||||
if (current->kunit_test)
|
||||
kasan_update_kunit_status(current->kunit_test);
|
||||
#endif /* IS_ENABLED(CONFIG_KUNIT) */
|
||||
|
||||
disable_trace_on_warning();
|
||||
|
||||
|
||||
@@ -530,7 +530,6 @@ static void __fill_map(unsigned long *obj_map, struct kmem_cache *s,
|
||||
set_bit(__obj_to_index(s, addr, p), obj_map);
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_KUNIT)
|
||||
static bool slab_add_kunit_errors(void)
|
||||
{
|
||||
struct kunit_resource *resource;
|
||||
@@ -546,9 +545,6 @@ static bool slab_add_kunit_errors(void)
|
||||
kunit_put_resource(resource);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
static inline bool slab_add_kunit_errors(void) { return false; }
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Determine a map of object in use on a page.
|
||||
|
||||
Reference in New Issue
Block a user