Merge pull request #2251 from zmeizy/claude/sce-net-without-ipv6

test(net): skip only the IPv6 socket checks on a host without IPv6
This commit is contained in:
Dean
2026-10-10 10:46:43 +13:00
committed by GitHub
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ if(BUILD_TESTING)
target_link_libraries(guest_sce_net_tests PRIVATE libSceNet libSceNetCtl libkernel libc)
configure_windows_unwind(guest_sce_net_tests)
add_test(NAME guest_sce_net COMMAND guest_sce_net_tests)
set_tests_properties(guest_sce_net PROPERTIES TIMEOUT 20)
set_tests_properties(guest_sce_net PROPERTIES TIMEOUT 20 SKIP_RETURN_CODE 77)
if(WIN32)
set_tests_properties(guest_sce_net PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNet>")
+11
View File
@@ -4,6 +4,7 @@
#include <array>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stdexcept>
@@ -169,6 +170,8 @@ static void CheckAddressText(int family, const char* text) {
Require(sceNetInetNtop(family, address.data(), nullptr, output.size()) == nullptr && *sceNetErrnoLoc() == 22);
}
static bool ipv6Unavailable = false;
static void CheckUnspecifiedIpv6() {
std::array<std::uint8_t, 16> unspecified{};
Require(sceNetInetPton(28, "::", unspecified.data()) == 1);
@@ -178,6 +181,10 @@ static void CheckUnspecifiedIpv6() {
Require(std::strcmp(text, "::") == 0 && text[3] == 'x');
const int receiver = sceNetSocket("ipv6-any", 28, 2, 17);
if (receiver < 0 && *sceNetErrnoLoc() == 47) {
ipv6Unavailable = true;
return;
}
const int sender = sceNetSocket("ipv6-loopback", 28, 2, 17);
Require(receiver >= 0 && sender >= 0);
std::array<std::uint8_t, 28> address{28, 28};
@@ -371,4 +378,8 @@ int main() {
int state = -1;
Require(sceNetCtlGetState(&state) == 0);
Require(state == 0 || state == 3);
if (ipv6Unavailable) {
std::puts("skipped the IPv6 socket checks, the host has no IPv6");
return 77;
}
}