diff --git a/test/emu/nanos6/CMakeLists.txt b/test/emu/nanos6/CMakeLists.txt index 642250a..d8fec56 100644 --- a/test/emu/nanos6/CMakeLists.txt +++ b/test/emu/nanos6/CMakeLists.txt @@ -6,6 +6,7 @@ test_emu(nested-tasks-bad.c SHOULD_FAIL REGEX "body_execute: body(id=1,taskid=1) state must be Created but is Running") test_emu(task-types.c MP) test_emu(blocking.c MP) +test_emu(if0-pause-parent.c) test_emu(ss-mismatch.c SHOULD_FAIL REGEX "thread [0-9]\\+ ended with 1 stacked nanos6 subsystems") test_emu(delayed-connect-ss.c) diff --git a/test/emu/nanos6/if0-pause-parent.c b/test/emu/nanos6/if0-pause-parent.c new file mode 100644 index 0000000..c30f1e1 --- /dev/null +++ b/test/emu/nanos6/if0-pause-parent.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +#include +#include "compat.h" +#include "instr.h" +#include "instr_nanos6.h" + +/* Ensure that we can accept a Nanos6 task model in which the parent gets paused + * before the if0 task begins. */ + +int +main(void) +{ + instr_start(0, 1); + instr_nanos6_init(); + + int ntasks = 100; + uint32_t typeid = 1; + + instr_nanos6_type_create(typeid); + + /* Create and run the tasks, one nested into another */ + for (int32_t id = 1; id <= ntasks; id++) { + instr_nanos6_handle_task_enter(); + instr_nanos6_task_create_begin(); + instr_nanos6_task_create(id, typeid); + instr_nanos6_task_create_end(); + instr_nanos6_task_body_enter(); + instr_nanos6_task_execute(id); + sleep_us(500); + instr_nanos6_task_pause(id); + } + + /* End the tasks in the opposite order */ + for (int32_t id = ntasks; id >= 1; id--) { + instr_nanos6_task_resume(id); + instr_nanos6_task_end(id); + instr_nanos6_task_body_exit(); + instr_nanos6_handle_task_exit(); + } + + instr_end(); + + return 0; +}