summaryrefslogtreecommitdiff
path: root/kernel/trace/rv/monitors/pagefault/pagefault_kunit.c
blob: 06369960b0087671a69e28dacf9c25078ba8dad9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/rv.h>
#include <rv/kunit.h>
#include <linux/sched/deadline.h>
#include <linux/sched/rt.h>
#include "pagefault_kunit.h"

#if IS_REACHABLE(CONFIG_RV_MON_PAGEFAULT)

static void rv_test_pagefault(struct kunit *test)
{
	struct task_struct *target = rv_kunit_alloc_mock_task(test);
	struct rv_kunit_ctx *ctx = test->priv;

	prepare_test(test, &rv_pagefault_ops.mon);

	/* Initial pagefault when non-RT to start the model without failure */
	target->policy = SCHED_NORMAL;
	target->prio = MAX_RT_PRIO + 20;
	rv_pagefault_ops.handle_task_newtask(NULL, target, 0);
	rv_mock_current(target);
	rv_pagefault_ops.handle_page_fault(NULL, 0, NULL, 0);

	/* RT task has a page fault */
	target->policy = SCHED_FIFO;
	target->prio = MAX_RT_PRIO - 1;
	RV_KUNIT_EXPECT_REACTION_HERE(test, ctx)
		rv_pagefault_ops.handle_page_fault(NULL, 0, NULL, 0);
}

#else
#define rv_test_pagefault rv_test_stub
#endif