Skip to content

Commit 364a7a6

Browse files
authored
common : remove common_has_curl() (ggml-org#16351)
`test-arg-parser.cpp` has been updated to work consistently, regardless of whether CURL or SSL support is available, and now always points to `ggml.ai`. The previous timeout test has been removed, but it can be added back by providing a dedicated URL under `ggml.ai`. Signed-off-by: Adrien Gallouët <[email protected]>
1 parent 2df5bcf commit 364a7a6

File tree

3 files changed

+26
-52
lines changed

3 files changed

+26
-52
lines changed

common/arg.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,6 @@ static std::string read_etag(const std::string & path) {
266266

267267
#ifdef LLAMA_USE_CURL
268268

269-
bool common_has_curl() {
270-
return true;
271-
}
272-
273269
//
274270
// CURL utils
275271
//
@@ -585,10 +581,6 @@ std::pair<long, std::vector<char>> common_remote_get_content(const std::string &
585581

586582
#else
587583

588-
bool common_has_curl() {
589-
return false;
590-
}
591-
592584
struct common_url {
593585
std::string scheme;
594586
std::string user;

common/arg.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ bool common_params_parse(int argc, char ** argv, common_params & params, llama_e
7878

7979
// function to be used by test-arg-parser
8080
common_params_context common_params_parser_init(common_params & params, llama_example ex, void(*print_usage)(int, char **) = nullptr);
81-
bool common_has_curl();
8281

8382
struct common_remote_params {
8483
std::vector<std::string> headers;

tests/test-arg-parser.cpp

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -126,52 +126,35 @@ int main(void) {
126126
assert(params.cpuparams.n_threads == 1010);
127127
#endif // _WIN32
128128

129-
if (common_has_curl()) {
130-
printf("test-arg-parser: test curl-related functions\n\n");
131-
const char * GOOD_URL = "https://ggml.ai/";
132-
const char * BAD_URL = "https://www.google.com/404";
133-
const char * BIG_FILE = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v1.bin";
134-
135-
{
136-
printf("test-arg-parser: test good URL\n\n");
137-
auto res = common_remote_get_content(GOOD_URL, {});
138-
assert(res.first == 200);
139-
assert(res.second.size() > 0);
140-
std::string str(res.second.data(), res.second.size());
141-
assert(str.find("llama.cpp") != std::string::npos);
142-
}
143-
144-
{
145-
printf("test-arg-parser: test bad URL\n\n");
146-
auto res = common_remote_get_content(BAD_URL, {});
147-
assert(res.first == 404);
148-
}
129+
printf("test-arg-parser: test curl-related functions\n\n");
130+
const char * GOOD_URL = "http://ggml.ai/";
131+
const char * BAD_URL = "http://ggml.ai/404";
132+
133+
{
134+
printf("test-arg-parser: test good URL\n\n");
135+
auto res = common_remote_get_content(GOOD_URL, {});
136+
assert(res.first == 200);
137+
assert(res.second.size() > 0);
138+
std::string str(res.second.data(), res.second.size());
139+
assert(str.find("llama.cpp") != std::string::npos);
140+
}
149141

150-
{
151-
printf("test-arg-parser: test max size error\n");
152-
common_remote_params params;
153-
params.max_size = 1;
154-
try {
155-
common_remote_get_content(GOOD_URL, params);
156-
assert(false && "it should throw an error");
157-
} catch (std::exception & e) {
158-
printf(" expected error: %s\n\n", e.what());
159-
}
160-
}
142+
{
143+
printf("test-arg-parser: test bad URL\n\n");
144+
auto res = common_remote_get_content(BAD_URL, {});
145+
assert(res.first == 404);
146+
}
161147

162-
{
163-
printf("test-arg-parser: test timeout error\n");
164-
common_remote_params params;
165-
params.timeout = 1;
166-
try {
167-
common_remote_get_content(BIG_FILE, params);
168-
assert(false && "it should throw an error");
169-
} catch (std::exception & e) {
170-
printf(" expected error: %s\n\n", e.what());
171-
}
148+
{
149+
printf("test-arg-parser: test max size error\n");
150+
common_remote_params params;
151+
params.max_size = 1;
152+
try {
153+
common_remote_get_content(GOOD_URL, params);
154+
assert(false && "it should throw an error");
155+
} catch (std::exception & e) {
156+
printf(" expected error: %s\n\n", e.what());
172157
}
173-
} else {
174-
printf("test-arg-parser: no curl, skipping curl-related functions\n");
175158
}
176159

177160
printf("test-arg-parser: all tests OK\n\n");

0 commit comments

Comments
 (0)