Skip to content
Merged
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
53 changes: 34 additions & 19 deletions tests/test-arg-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,30 +181,45 @@
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);
}
Comment on lines +194 to +200
} 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());
}
}
}

Expand Down
Loading