diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/rv/da_monitor.h | 1 | ||||
| -rw-r--r-- | include/rv/kunit.h | 14 | ||||
| -rw-r--r-- | include/rv/ltl_monitor.h | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index db57a8a704f9..e3cf85c9ce55 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -16,6 +16,7 @@ #include <rv/automata.h> #include <linux/rv.h> +#include <rv/kunit.h> #include <linux/stringify.h> #include <linux/bug.h> #include <linux/sched.h> diff --git a/include/rv/kunit.h b/include/rv/kunit.h index ff98b5137285..31e0b93c40ea 100644 --- a/include/rv/kunit.h +++ b/include/rv/kunit.h @@ -2,7 +2,10 @@ /* * Copyright (C) 2026-2029 Red Hat, Inc. Gabriele Monaco <gmonaco@redhat.com> * - * Declaration of utilities to run KUnit tests. + * Declaration of wrappers to allow mocking core functionality, like current, + * and other testing utilities. + * Necessary only when mocking may be needed. If the RV KUnit test is + * enabled, the wrappers incur an additional function call overhead. */ #ifndef _RV_KUNIT_H @@ -57,5 +60,14 @@ void prepare_test(struct kunit *test, const struct rv_kunit_mon *mon); void teardown_test(void *arg); struct task_struct *rv_kunit_alloc_mock_task(struct kunit *test); +void rv_mock_current(struct task_struct *tsk); +struct task_struct *rv_get_mock_current(void); + +#define rv_get_current() (unlikely(kunit_get_current_test()) ? rv_get_mock_current() : current) + +#else /* !CONFIG_RV_MONITORS_KUNIT_TEST */ + +#define rv_get_current() current + #endif /* CONFIG_RV_MONITORS_KUNIT_TEST */ #endif /* _RV_KUNIT_H */ diff --git a/include/rv/ltl_monitor.h b/include/rv/ltl_monitor.h index 56e83edcf0c4..d7dc01db4dd9 100644 --- a/include/rv/ltl_monitor.h +++ b/include/rv/ltl_monitor.h @@ -9,6 +9,7 @@ #include <linux/stringify.h> #include <linux/seq_buf.h> #include <rv/instrumentation.h> +#include <rv/kunit.h> #include <trace/events/task.h> #include <trace/events/sched.h> |
