diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/test1401 | 5 | ||||
-rw-r--r-- | tests/libtest/lib1597.c | 70 | ||||
-rw-r--r-- | tests/libtest/lib1911.c | 1 |
3 files changed, 56 insertions, 20 deletions
diff --git a/tests/data/test1401 b/tests/data/test1401 index e4bc3b736..7edf76cc5 100644 --- a/tests/data/test1401 +++ b/tests/data/test1401 @@ -31,6 +31,11 @@ http <name> --libcurl for GET with various options </name> +<features> +http +ftp +file +</features> <setenv> SSL_CERT_FILE= </setenv> diff --git a/tests/libtest/lib1597.c b/tests/libtest/lib1597.c index d39fae663..cb167e84f 100644 --- a/tests/libtest/lib1597.c +++ b/tests/libtest/lib1597.c @@ -30,7 +30,7 @@ struct pair { const char *in; - CURLcode exp; + CURLcode *exp; }; int test(char *URL) @@ -38,27 +38,34 @@ int test(char *URL) CURL *curl = NULL; int res = 0; CURLcode result = CURLE_OK; + CURLcode ok = CURLE_OK; + CURLcode bad = CURLE_BAD_FUNCTION_ARGUMENT; + CURLcode unsup = CURLE_UNSUPPORTED_PROTOCOL; + CURLcode httpcode = CURLE_UNSUPPORTED_PROTOCOL; + CURLcode httpscode = CURLE_UNSUPPORTED_PROTOCOL; + curl_version_info_data *curlinfo; + const char *const *proto; + char protolist[1024]; + int n; int i; struct pair prots[] = { - {"goobar", CURLE_BAD_FUNCTION_ARGUMENT}, - {"http ", CURLE_BAD_FUNCTION_ARGUMENT}, - {" http", CURLE_BAD_FUNCTION_ARGUMENT}, - {"http", CURLE_OK}, - {"http,", CURLE_OK}, - {"https,", CURLE_OK}, - {"https,http", CURLE_OK}, - {"http,http", CURLE_OK}, - {"HTTP,HTTP", CURLE_OK}, - {",HTTP,HTTP", CURLE_OK}, - {"http,http,ft", CURLE_BAD_FUNCTION_ARGUMENT}, - {"", CURLE_BAD_FUNCTION_ARGUMENT}, - {",,", CURLE_BAD_FUNCTION_ARGUMENT}, - {"DICT,FILE,FTP,FTPS,GOPHER,GOPHERS,HTTP,HTTPS,IMAP,IMAPS,LDAP,LDAPS," - "POP3,POP3S,RTMP,RTMPE,RTMPS,RTMPT,RTMPTE,RTMPTS,RTSP,SCP,SFTP,SMB," - "SMBS,SMTP,SMTPS,TELNET,TFTP", CURLE_OK}, - {"all", CURLE_OK}, - {NULL, CURLE_OK}, + {"goobar", &unsup}, + {"http ", &unsup}, + {" http", &unsup}, + {"http", &httpcode}, + {"http,", &httpcode}, + {"https,", &httpscode}, + {"https,http", &httpscode}, + {"http,http", &httpcode}, + {"HTTP,HTTP", &httpcode}, + {",HTTP,HTTP", &httpcode}, + {"http,http,ft", &unsup}, + {"", &bad}, + {",,", &bad}, + {protolist, &ok}, + {"all", &ok}, + {NULL, NULL}, }; (void)URL; @@ -66,9 +73,32 @@ int test(char *URL) easy_init(curl); + /* Get enabled protocols.*/ + curlinfo = curl_version_info(CURLVERSION_NOW); + if(!curlinfo) { + fputs("curl_version_info failed\n", stderr); + res = (int) TEST_ERR_FAILURE; + goto test_cleanup; + } + + n = 0; + for(proto = curlinfo->protocols; *proto; proto++) { + if((size_t) n >= sizeof(protolist)) { + puts("protolist buffer too small\n"); + res = (int) TEST_ERR_FAILURE; + goto test_cleanup; + } + n += msnprintf(protolist + n, sizeof(protolist) - n, ",%s", *proto); + if(curl_strequal(*proto, "http")) + httpcode = CURLE_OK; + if(curl_strequal(*proto, "https")) + httpscode = CURLE_OK; + } + + /* Run the tests. */ for(i = 0; prots[i].in; i++) { result = curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, prots[i].in); - if(result != prots[i].exp) { + if(result != *prots[i].exp) { printf("unexpectedly '%s' returned %u\n", prots[i].in, result); break; diff --git a/tests/libtest/lib1911.c b/tests/libtest/lib1911.c index e78f64484..97b45040f 100644 --- a/tests/libtest/lib1911.c +++ b/tests/libtest/lib1911.c @@ -79,6 +79,7 @@ int test(char *URL) case CURLE_BAD_FUNCTION_ARGUMENT: /* the most normal */ case CURLE_UNKNOWN_OPTION: /* left out from the build */ case CURLE_NOT_BUILT_IN: /* not supported */ + case CURLE_UNSUPPORTED_PROTOCOL: /* detected by protocol2num() */ break; default: /* all other return codes are unexpected */ |