Commit cccac4fb authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

test1521: test *all* curl_easy_setopt options

mk-lib1521.pl generates a test program (lib1521.c) that calls
curl_easy_setopt() for every known option with a few typical values to
make sure they work (ignoring the return codes).

Some small changes were necessary to avoid asserts and NULL accesses
when doing this.

The perl script needs to be manually rerun when we add new options.

Closes #1543
parent b95a07ea
Loading
Loading
Loading
Loading
+24 −22
Original line number Diff line number Diff line
@@ -2137,6 +2137,7 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
void Curl_http2_add_child(struct Curl_easy *parent, struct Curl_easy *child,
                          bool exclusive)
{
  if(parent) {
    struct Curl_http2_dep **tail;
    struct Curl_http2_dep *dep = calloc(1, sizeof(struct Curl_http2_dep));
    dep->data = child;
@@ -2165,6 +2166,7 @@ void Curl_http2_add_child(struct Curl_easy *parent, struct Curl_easy *child,

    DEBUGASSERT(!*tail);
    *tail = dep;
  }

  child->set.stream_depends_on = parent;
  child->set.stream_depends_e = exclusive;
+16 −6
Original line number Diff line number Diff line
@@ -1023,8 +1023,8 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
     * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
     * other - POST is kept as POST after 301 and 302
     */
    int postRedir = curlx_sltosi(va_arg(param, long));
    data->set.keep_post = postRedir & CURL_REDIR_POST_ALL;
    arg = va_arg(param, long);
    data->set.keep_post = arg & CURL_REDIR_POST_ALL;
  }
  break;

@@ -2075,13 +2075,19 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
    /*
     * Set what local port to bind the socket to when performing an operation.
     */
    data->set.localport = curlx_sltous(va_arg(param, long));
    arg = va_arg(param, long);
    if((arg < 0) || (arg > 65535))
      return CURLE_BAD_FUNCTION_ARGUMENT;
    data->set.localport = curlx_sltous(arg);
    break;
  case CURLOPT_LOCALPORTRANGE:
    /*
     * Set number of local ports to try, starting with CURLOPT_LOCALPORT.
     */
    data->set.localportrange = curlx_sltosi(va_arg(param, long));
    arg = va_arg(param, long);
    if((arg < 0) || (arg > 65535))
      return CURLE_BAD_FUNCTION_ARGUMENT;
    data->set.localportrange = curlx_sltosi(arg);
    break;
  case CURLOPT_KRBLEVEL:
    /*
@@ -2812,13 +2818,17 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
      data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
    break;
  case CURLOPT_TLSAUTH_TYPE:
    if(strncasecompare((char *)va_arg(param, char *), "SRP", strlen("SRP")))
    argptr = va_arg(param, char *);
    if(!argptr ||
       strncasecompare(argptr, "SRP", strlen("SRP")))
      data->set.ssl.authtype = CURL_TLSAUTH_SRP;
    else
      data->set.ssl.authtype = CURL_TLSAUTH_NONE;
    break;
  case CURLOPT_PROXY_TLSAUTH_TYPE:
    if(strncasecompare((char *)va_arg(param, char *), "SRP", strlen("SRP")))
    argptr = va_arg(param, char *);
    if(!argptr ||
       strncasecompare(argptr, "SRP", strlen("SRP")))
      data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP;
    else
      data->set.proxy_ssl.authtype = CURL_TLSAUTH_NONE;
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \
test1516 test1517 \
\
test1520 \
test1520 test1521 \
\
test1525 test1526 test1527 test1528 test1529 test1530 test1531 test1532 \
test1533 test1534 test1535 test1536 test1537 test1538 \

tests/data/test1521

0 → 100644
+30 −0
Original line number Diff line number Diff line
<testcase>
<info>
<keywords>
curl_easy_setopt
</keywords>
</info>

#
# Client-side
<client>
<server>
none
</server>
<tool>
lib1521
</tool>

 <name>
try ALL curl_easy_setopt options
 </name>
 <command>
unused
</command>
</client>

#
# Verify data after the test has been "shot"
<verify>
</verify>
</testcase>
+4 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
 lib583 lib585 lib586 lib587        lib590 lib591 lib597 lib598 lib599   \
 lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
 lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515         lib1517 \
 lib1520 \
 lib1520 lib1521 \
 lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \
 lib1534 lib1535 lib1536 lib1537 lib1538 \
 lib1540 lib1541 \
@@ -368,6 +368,9 @@ lib1517_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1517
lib1520_SOURCES = lib1520.c $(SUPPORTFILES)
lib1520_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1520

lib1521_SOURCES = lib1521.c $(SUPPORTFILES)
lib1521_CPPFLAGS = $(AM_CPPFLAGS)

lib1525_SOURCES = lib1525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
lib1525_LDADD = $(TESTUTIL_LIBS)
lib1525_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1525
Loading