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 "opid_kunit.h" 7 8 #if IS_REACHABLE(CONFIG_RV_MON_OPID) 9 10 static void rv_test_opid(struct kunit *test) 11 { 12 struct rv_kunit_ctx *ctx = test->priv; 13 14 prepare_test(test, &rv_opid_ops.mon); 15 16 /* Ensure we keep the same per-cpu monitor */ 17 guard(migrate)(); 18 KUNIT_EXPECT_TRUE(test, preemptible()); 19 20 /* Wakeup with preemption and interrupts enabled */ 21 RV_KUNIT_EXPECT_REACTION_HERE(test, ctx) 22 rv_opid_ops.handle_sched_waking(NULL, NULL); 23 24 /* Need resched with interrupts enabled */ 25 RV_KUNIT_EXPECT_REACTION_HERE(test, ctx) { 26 scoped_guard(preempt) 27 rv_opid_ops.handle_sched_need_resched(NULL, NULL, 0, TIF_NEED_RESCHED); 28 } 29 } 30 31 #else 32 #define rv_test_opid rv_test_stub 33 #endif 34