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 "sssw_kunit.h" 7 8 #if IS_REACHABLE(CONFIG_RV_MON_SSSW) 9 10 static void rv_test_sssw(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_sssw_ops.mon); 17 18 /* Suspend without setting to sleepable */ 19 rv_sssw_ops.handle_sched_set_state(NULL, target, TASK_RUNNING); 20 RV_KUNIT_EXPECT_REACTION_HERE(test, ctx) 21 rv_sssw_ops.handle_sched_switch(NULL, 0, target, other, TASK_INTERRUPTIBLE); 22 23 /* Switch in after suspension without wakeup */ 24 rv_sssw_ops.handle_sched_wakeup(NULL, target); 25 rv_sssw_ops.handle_sched_set_state(NULL, target, TASK_INTERRUPTIBLE); 26 rv_sssw_ops.handle_sched_switch(NULL, 0, target, other, TASK_INTERRUPTIBLE); 27 RV_KUNIT_EXPECT_REACTION_HERE(test, ctx) 28 rv_sssw_ops.handle_sched_switch(NULL, 0, other, target, TASK_RUNNING); 29 } 30 31 #else 32 #define rv_test_sssw rv_test_stub 33 #endif 34