diff --git a/tests/test-arg-parser.cpp b/tests/test-arg-parser.cpp index 0dd8422e7366..57b415db43b9 100644 --- a/tests/test-arg-parser.cpp +++ b/tests/test-arg-parser.cpp @@ -181,30 +181,45 @@ int main(void) { const char * GOOD_URL = "http://ggml.ai/"; const char * BAD_URL = "http://ggml.ai/404"; + // The download tests exercise the HTTP path and need working outbound + // network. CI runners (self-hosted / windows-vulkan) don't always have it, + // so a connectivity failure must not fail the whole arg-parser suite on an + // unrelated network issue. Probe once via the good URL: assert the download + // semantics only when the endpoint is actually reachable, otherwise skip. + bool network_ok = false; { printf("test-arg-parser: test good URL\n\n"); - auto res = common_remote_get_content(GOOD_URL, {}); - assert(res.first == 200); - assert(res.second.size() > 0); - std::string str(res.second.data(), res.second.size()); - assert(str.find("llama.cpp") != std::string::npos); + try { + auto res = common_remote_get_content(GOOD_URL, {}); + if (res.first == 200 && res.second.size() > 0) { + std::string str(res.second.data(), res.second.size()); + assert(str.find("llama.cpp") != std::string::npos); + network_ok = true; + } else { + printf(" good URL returned %d, no usable network -- skipping download tests\n\n", res.first); + } + } catch (const std::exception & e) { + printf(" good URL unreachable (%s) -- skipping download tests\n\n", e.what()); + } } - { - printf("test-arg-parser: test bad URL\n\n"); - auto res = common_remote_get_content(BAD_URL, {}); - assert(res.first == 404); - } + if (network_ok) { + { + printf("test-arg-parser: test bad URL\n\n"); + auto res = common_remote_get_content(BAD_URL, {}); + assert(res.first == 404); + } - { - printf("test-arg-parser: test max size error\n"); - common_remote_params params; - params.max_size = 1; - try { - common_remote_get_content(GOOD_URL, params); - assert(false && "it should throw an error"); - } catch (std::exception & e) { - printf(" expected error: %s\n\n", e.what()); + { + printf("test-arg-parser: test max size error\n"); + common_remote_params params; + params.max_size = 1; + try { + common_remote_get_content(GOOD_URL, params); + assert(false && "it should throw an error"); + } catch (std::exception & e) { + printf(" expected error: %s\n\n", e.what()); + } } }