mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
test(agc): cover partial guest mappings
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "prx/libc/include/GuestHeap.hpp"
|
||||
#include "prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp"
|
||||
#include <cstring>
|
||||
#include <array>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -44,4 +45,34 @@ void RunGuestAllocationTests() {
|
||||
Require(static_cast<unsigned char*>(pointer)[31] == 0x66, "aligned guest realloc lost data");
|
||||
GuestHeap::GuestHeapFree_nid_postfix(pointer);
|
||||
Require(GuestAllocations::GuestAllocationsAcquire_nid_postfix().empty(), "freed guest allocations remain registered");
|
||||
std::array<std::byte, 128> mapping{};
|
||||
{
|
||||
GuestAllocations::Mutation mutation;
|
||||
mutation.Add(mapping.data(), mapping.size(), true, true);
|
||||
reject([&] { mutation.RequireAvailable(mapping.data() + 32, 16); });
|
||||
mutation.Protect(mapping.data() + 32, 32, true, false, [] {});
|
||||
}
|
||||
{
|
||||
const auto lease = GuestAllocations::GuestAllocationsAcquire_nid_postfix();
|
||||
Require(lease.size() == 3 && lease[0]->bytes == 32 && !lease[1]->writable && lease[2]->bytes == 64, "partial protection did not split the mapping");
|
||||
GuestAllocations::Mutation mutation;
|
||||
reject([&] { mutation.Unmap(mapping.data() + 32, 32, [](const void*, bool) {}); });
|
||||
}
|
||||
{
|
||||
GuestAllocations::Mutation mutation;
|
||||
bool applied = false;
|
||||
mutation.Unmap(mapping.data() + 32, 32, [&](const void* allocation, bool last) {
|
||||
Require(allocation == mapping.data() && !last, "partial unmap released the allocation");
|
||||
applied = true;
|
||||
});
|
||||
Require(applied, "partial unmap callback was not called");
|
||||
reject([&] { mutation.Protect(mapping.data(), mapping.size(), true, true, [] {}); });
|
||||
mutation.Unmap(mapping.data(), 32, [&](const void* allocation, bool last) {
|
||||
Require(allocation == mapping.data() && !last, "first fragment released remaining mapping");
|
||||
});
|
||||
mutation.Unmap(mapping.data() + 64, 64, [&](const void* allocation, bool last) {
|
||||
Require(allocation == mapping.data() && last, "last fragment did not release the original allocation");
|
||||
});
|
||||
}
|
||||
Require(GuestAllocations::GuestAllocationsAcquire_nid_postfix().empty(), "unmapped fragments remain registered");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user