Files
AnyPS5/core/libs/tests/GuestDynamicLoaderVariants.cpp
bfd1d5b568 fix(libc): compare the relinked module stem without the last extension only
The stem of a request and of a relinked module name was cut at the first dot,
so a request for Engine.Render.prx that missed could load Engine.Core.prx.guest.prx.
Only the last extension is removed now, as the review of the stem lookup asked,
and the variant-names test requests a dotted name that must not load the sibling
fixture module.

Co-Authored-By: lendinglibrary <340867775+lendinglibrary@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 20:50:03 +02:00

25 lines
985 B
C++

#include "prx/libc/include/general/VabiMacros.hpp"
#include <cstdio>
#include <cstdlib>
#include <source_location>
extern "C" {
void* APS5_VABI dlopen_nid_postfix(const char*, int);
void* APS5_VABI dlsym_nid_postfix(void*, const char*);
int APS5_VABI dlclose_nid_postfix(void*);
}
static void Require(bool value, const std::source_location& location = std::source_location::current()) {
if (value) return;
std::fprintf(stderr, "guest_dynamic_loader_variants: failed at %s:%u\n", location.file_name(), location.line());
std::abort();
}
int main() {
using Add = int (APS5_VABI *)(int, int);
void* extension = dlopen_nid_postfix("guest_module_fixture.prx", 2);
Require(extension != nullptr);
auto add = reinterpret_cast<Add>(dlsym_nid_postfix(extension, "GuestModuleAdd"));
Require(add && add(19, 23) == 42);
Require(dlclose_nid_postfix(extension) == 0);
Require(dlopen_nid_postfix("guest_module_fixture.other.prx", 2) == nullptr);
return 0;
}