@@ -126,6 +126,53 @@ 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://raw.githubusercontent.com/ggml-org/llama.cpp/refs/heads/master/README.md" ;
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+ }
149+
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+ }
161+
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+ }
172+ }
173+ } else {
174+ printf (" test-arg-parser: no curl, skipping curl-related functions\n " );
175+ }
129176
130177 printf (" test-arg-parser: all tests OK\n\n " );
131178}
0 commit comments