Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/libs/prx/libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,16 @@ if(BUILD_TESTING)
set_tests_properties(guest_wide_conversion PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test_executable(guest_wmemmove_snapshot_tests ${LIBS_INCLUDE_DIR}/tests/GuestWmemmoveSnapshot.cpp)
target_include_directories(guest_wmemmove_snapshot_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_wmemmove_snapshot_tests PRIVATE libc)
configure_windows_unwind(guest_wmemmove_snapshot_tests)
add_test(NAME guest_wmemmove_snapshot COMMAND guest_wmemmove_snapshot_tests)
set_tests_properties(guest_wmemmove_snapshot PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_wmemmove_snapshot PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test_executable(guest_one_runs_tests ${LIBS_INCLUDE_DIR}/tests/GuestOneRuns.cpp)
target_include_directories(guest_one_runs_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_one_runs_tests PRIVATE libc)
Expand Down
33 changes: 33 additions & 0 deletions core/libs/tests/GuestWmemmoveSnapshot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "prx/libc/include/Api.hpp"
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>

static void Require(bool condition) {
if (!condition) {
std::fputs("GuestWmemmoveSnapshot check failed\n", stderr);
std::abort();
}
}

int main() {
constexpr std::array<char16_t, 8> values = {0, 1, 0xff, 0xff00, 0xd800, 0xdc00, 0xffff, 0x1234};
for (std::size_t count = 0; count <= 96; ++count) {
for (std::size_t source = 16; source <= 48; ++source) {
for (std::size_t destination = 16; destination <= 48; ++destination) {
std::array<char16_t, 192> original{};
for (std::size_t i = 0; i < original.size(); ++i) original[i] = values[(i + count) % values.size()];
auto actual = original, expected = original;
for (std::size_t i = 0; i < count; ++i) expected[destination + i] = original[source + i];
Require(wmemmove_nid_postfix(actual.data() + destination, actual.data() + source, count) == actual.data() + destination);
Require(actual == expected);
}
}
}
}
Loading