Add comprehensive tests for ProcessKernel and Usecode VM functionality
- Implemented tests for ProcessKernel in entity_dispatch_entry_tests.cpp, covering process creation, termination, and scanning of runnable processes. - Enhanced fixed_map_tests.cpp with tests for item allocation and release, including recycling of items and process ownership. - Expanded flex_archive_tests.cpp to validate the interaction between usecode events and item processes, ensuring correct behavior of spawned tasks and rendering. - Introduced usecode_vm_tests.cpp to thoroughly test the UsecodeInterpreterState and UsecodeProcessTask functionalities, including stack operations and opcode services.
This commit is contained in:
parent
e757bb33d0
commit
08a907f322
14 changed files with 1784 additions and 34 deletions
|
|
@ -151,6 +151,33 @@ int main()
|
|||
assert(createdKernel.processAt(2) == syncing && createdGroups[2] == 3);
|
||||
assert(syncing->bytes[0x16] == 0x40 && syncing->bytes[0x17] == 0);
|
||||
|
||||
remorse::ProcessKernel usecodeKernel;
|
||||
remorse::u16 usecodeGroups[32]{};
|
||||
for (int index = 0; index < 3; ++index) {
|
||||
usecodeKernel.createProcess(1, usecodeGroups);
|
||||
}
|
||||
auto* usecodeContext = usecodeKernel.createUsecodeProcess(1, usecodeGroups);
|
||||
const remorse::u16 usecodeProcessId = static_cast<remorse::u16>(
|
||||
usecodeContext->base.bytes[2] | (static_cast<remorse::u16>(usecodeContext->base.bytes[3]) << 8));
|
||||
assert(usecodeKernel.allocationSizeAt(usecodeProcessId) == 0x124 &&
|
||||
std::strcmp(usecodeKernel.processNameAt(usecodeProcessId), "Usecode") == 0);
|
||||
assert(usecodeKernel.setProcessInfo(usecodeProcessId, 0x0207, 0x1234));
|
||||
int usecodeRuns = 0;
|
||||
usecodeKernel.scanRunnableProcesses(1, [](remorse::EntityDispatchEntryBase& process, void* context) {
|
||||
auto& scan = *static_cast<int*>(context);
|
||||
if (process.bytes[2] == 3 && process.bytes[3] == 0) {
|
||||
++scan;
|
||||
}
|
||||
}, &usecodeRuns);
|
||||
assert(usecodeRuns == 1 && usecodeKernel.processAt(usecodeProcessId) == &usecodeContext->base);
|
||||
usecodeKernel.terminateProcess(usecodeProcessId, usecodeGroups);
|
||||
assert(usecodeKernel.processAt(usecodeProcessId) == &usecodeContext->base &&
|
||||
(usecodeContext->base.bytes[0x16] & 0x08) != 0 &&
|
||||
usecodeKernel.processCount() == 3 && usecodeGroups[1] == 3);
|
||||
usecodeKernel.clearTerminatedProcesses();
|
||||
assert(usecodeKernel.processAt(usecodeProcessId) == nullptr &&
|
||||
usecodeKernel.terminatedProcessCount() == 0);
|
||||
|
||||
createdKernel.setSyncContext(true, 1);
|
||||
next->bytes[0x18] |= 0x02;
|
||||
auto* retiring = createdKernel.createProcess(2, createdGroups);
|
||||
|
|
@ -269,6 +296,16 @@ int main()
|
|||
assert((ran == std::vector<remorse::u16>{2, 3}));
|
||||
assert(specialGroup->bytes[0x08] == 30);
|
||||
|
||||
remorse::ProcessKernel automaticGroupKernel;
|
||||
remorse::u16 automaticGroupCounts[32]{};
|
||||
automaticGroupKernel.createProcess(3, automaticGroupCounts);
|
||||
std::vector<remorse::u16> automaticGroupRuns;
|
||||
automaticGroupKernel.scanRunnableProcesses(2, recordRun, &automaticGroupRuns);
|
||||
assert(automaticGroupRuns.empty() && automaticGroupKernel.activeGroup() == 3 &&
|
||||
!automaticGroupKernel.groupSelectionPending());
|
||||
automaticGroupKernel.scanRunnableProcesses(3, recordRun, &automaticGroupRuns);
|
||||
assert((automaticGroupRuns == std::vector<remorse::u16>{0}));
|
||||
|
||||
remorse::ProcessKernel spawningKernel;
|
||||
remorse::u16 spawningGroups[32]{};
|
||||
spawningKernel.createProcess(1, spawningGroups);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue