mirror of
https://github.com/torvalds/linux.git
synced 2026-10-15 20:30:02 +02:00
Validate the functionality of LTL monitors by injecting events in a controlled environment (KUnit) and expecting reactions, just like it is done in DA monitors. Reviewed-by: Nam Cao <namcao@linutronix.de> Link: https://lore.kernel.org/r/20260723074534.43521-15-gmonaco@redhat.com Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
35 lines
965 B
C
35 lines
965 B
C
// 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
|