ovni/test/emu/nosv/task-pause-from-submit.c
Rodrigo Arias 354f2f50eb Register emulation models only if required
Until now, emulation models were always being registered via probe(),
which causes the emulator to initialize all the channels. To reduce the
overhead, the channels were not connected or registered in the bay
until the first event of that model was received. This delayed connect
was causing issues in muxes where the newly connected model required
refreshing the touched channels. Which in turn was causing unexpected
PRV events.

By determining which models we need to enable, we can remove the delayed
connect mechanism and just enable those models at initialization time,
and connect the channels.
2023-11-16 12:39:05 +01:00

70 lines
1.9 KiB
C

/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdint.h>
#include <stdio.h>
#include "common.h"
#include "emu_prv.h"
#include "instr.h"
#include "instr_nosv.h"
#include "emu/nosv/nosv_priv.h"
int
main(void)
{
/* Tests the case where a task is paused from nosv_submit():
*
* A VTp event causes a pop of the subsystem channel, which is expected
* to be ST_TASK_RUNNING. This is not true in the case of a blocking
* submit (NOSV_SUBMIT_BLOCKING), which calls nosv_pause from inside
* nosv_submit, causing the transition to happen from the unexpected
* ST_API_SUBMIT state.
*/
instr_start(0, 1);
instr_nosv_init();
/* Match the PRV line in the trace */
FILE *f = fopen("match.sh", "w");
if (f == NULL)
die("fopen failed:");
uint32_t typeid = 100;
instr_nosv_type_create(typeid);
instr_nosv_task_create(1, typeid);
instr_nosv_task_execute(1);
/* When starting a task, it must cause the subsystems to enter
* the "Task: In body" state */
int prvtype = PRV_NOSV_SUBSYSTEM;
int st = ST_TASK_BODY;
fprintf(f, "grep ':%ld:%d:%d$' ovni/thread.prv\n", get_delta(), prvtype, st);
fprintf(f, "grep ':%ld:%d:%d$' ovni/cpu.prv\n", get_delta(), prvtype, st);
instr_nosv_submit_enter(); /* Blocking submit */
instr_nosv_task_pause(1);
/* Should be left in the submit state, so no state transition in
* subsystems view */
fprintf(f, "! grep ':%ld:%d:[0-9]*$' ovni/thread.prv\n", get_delta(), prvtype);
fprintf(f, "! grep ':%ld:%d:[0-9]*$' ovni/cpu.prv\n", get_delta(), prvtype);
/* But the task state must be set to pause, so the task id
* must be null */
prvtype = PRV_NOSV_TASKID;
fprintf(f, "grep ':%ld:%d:0$' ovni/thread.prv\n", get_delta(), prvtype);
fprintf(f, "grep ':%ld:%d:0$' ovni/cpu.prv\n", get_delta(), prvtype);
instr_nosv_submit_exit();
instr_nosv_task_resume(1);
instr_nosv_task_end(1);
fclose(f);
instr_end();
return 0;
}