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 "sts_kunit.h" 7 8 #if IS_REACHABLE(CONFIG_RV_MON_STS) 9 10 static void rv_test_sts(struct kunit *test) 11 { 12 struct task_struct *target = rv_kunit_alloc_mock_task(test); 13 struct task_struct *other = rv_kunit_alloc_mock_task(test); 14 struct rv_kunit_ctx *ctx = test->priv; 15 16 prepare_test(test, &rv_sts_ops.mon); 17 /* Per-CPU monitor, make sure we don't change CPU mid-test */ 18 guard(migrate)(); 19 20 /* Switch without disabling interrupts */ 21 rv_sts_ops.handle_schedule_exit(NULL, false); 22 rv_sts_ops.handle_schedule_entry(NULL, false); 23 RV_KUNIT_EXPECT_REACTION_HERE(test, ctx) 24 rv_sts_ops.handle_sched_switch(NULL, 0, target, other, TASK_RUNNING); 25 26 rv_sts_ops.handle_schedule_exit(NULL, false); 27 28 /* Schedule from interrupt context */ 29 rv_sts_ops.handle_schedule_entry(NULL, false); 30 rv_sts_ops.handle_irq_disable(NULL, 0, 0); 31 rv_sts_ops.handle_irq_entry(NULL, 0, NULL); 32 RV_KUNIT_EXPECT_REACTION_HERE(test, ctx) 33 rv_sts_ops.handle_sched_switch(NULL, 0, target, other, TASK_RUNNING); 34 rv_sts_ops.handle_irq_enable(NULL, 0, 0); 35 } 36 37 #else 38 #define rv_test_sts rv_test_stub 39 #endif 40