xref: /linux/kernel/trace/rv/monitors/sco/sco_kunit.c (revision 55ee4b931a7ffedc886175d265dd6e6d08fd4151)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/kernel.h>
3 #include <linux/rv.h>
4 #include <rv/kunit.h>
5 #include <trace/events/sched.h>
6 #include "sco_kunit.h"
7 
8 #if IS_REACHABLE(CONFIG_RV_MON_SCO)
9 
10 static void rv_test_sco(struct kunit *test)
11 {
12 	struct task_struct *target = rv_kunit_alloc_mock_task(test);
13 	struct rv_kunit_ctx *ctx = test->priv;
14 
15 	prepare_test(test, &rv_sco_ops.mon);
16 
17 	/* Ensure we keep the same per-cpu monitor */
18 	guard(migrate)();
19 
20 	/* Set state while scheduling */
21 	rv_sco_ops.handle_sched_set_state(NULL, target, TASK_INTERRUPTIBLE);
22 	rv_sco_ops.handle_schedule_entry(NULL, false);
23 	RV_KUNIT_EXPECT_REACTION_HERE(test, ctx)
24 		rv_sco_ops.handle_sched_set_state(NULL, target, TASK_INTERRUPTIBLE);
25 }
26 
27 #else
28 #define rv_test_sco rv_test_stub
29 #endif
30