diff options
author | Seonah Moon <seonah1.moon@samsung.com> | 2016-09-23 13:49:53 +0900 |
---|---|---|
committer | Seonah Moon <seonah1.moon@samsung.com> | 2016-09-23 13:50:15 +0900 |
commit | 3e62527ed71a7a362d7ec321e7f026edab35f8e2 (patch) | |
tree | 7f3b26146600554e22d60afbe69035821056f299 /tests/unit | |
parent | 0a710b32648c435f792f5993fdefa2d96f802580 (diff) | |
download | curl-3e62527ed71a7a362d7ec321e7f026edab35f8e2.tar.gz curl-3e62527ed71a7a362d7ec321e7f026edab35f8e2.tar.bz2 curl-3e62527ed71a7a362d7ec321e7f026edab35f8e2.zip |
Imported Upstream version 7.50.2upstream/7.50.2
Change-Id: I91c6040940a21b2bebab9d6cab11d50767b7bac4
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/Makefile.am | 5 | ||||
-rw-r--r-- | tests/unit/Makefile.in | 7 | ||||
-rw-r--r-- | tests/unit/curlcheck.h | 21 | ||||
-rw-r--r-- | tests/unit/unit1300.c | 6 | ||||
-rw-r--r-- | tests/unit/unit1301.c | 20 | ||||
-rw-r--r-- | tests/unit/unit1302.c | 36 | ||||
-rw-r--r-- | tests/unit/unit1303.c | 10 | ||||
-rw-r--r-- | tests/unit/unit1304.c | 22 | ||||
-rw-r--r-- | tests/unit/unit1305.c | 20 | ||||
-rw-r--r-- | tests/unit/unit1307.c | 8 | ||||
-rw-r--r-- | tests/unit/unit1394.c | 14 | ||||
-rw-r--r-- | tests/unit/unit1396.c | 4 | ||||
-rw-r--r-- | tests/unit/unit1397.c | 72 | ||||
-rw-r--r-- | tests/unit/unit1398.c | 26 | ||||
-rw-r--r-- | tests/unit/unit1600.c | 6 | ||||
-rw-r--r-- | tests/unit/unit1601.c | 3 | ||||
-rw-r--r-- | tests/unit/unit1602.c | 7 | ||||
-rw-r--r-- | tests/unit/unit1603.c | 6 | ||||
-rw-r--r-- | tests/unit/unit1604.c | 4 |
19 files changed, 174 insertions, 123 deletions
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 33af1ec0e..d4987d69d 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -71,6 +71,9 @@ AM_CPPFLAGS += -DCURL_STATICLIB -DUNITTESTS # Makefile.inc provides neat definitions include Makefile.inc +checksrc: + @PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c + if BUILD_UNITTESTS noinst_PROGRAMS = $(UNITPROGS) else diff --git a/tests/unit/Makefile.in b/tests/unit/Makefile.in index e4d694b31..e4ef7852f 100644 --- a/tests/unit/Makefile.in +++ b/tests/unit/Makefile.in @@ -527,7 +527,7 @@ top_srcdir = @top_srcdir@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -1650,6 +1650,11 @@ uninstall-am: .PRECIOUS: Makefile +# Makefile.inc provides neat definitions + +checksrc: + @PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/tests/unit/curlcheck.h b/tests/unit/curlcheck.h index 22f05c188..0660e2bed 100644 --- a/tests/unit/curlcheck.h +++ b/tests/unit/curlcheck.h @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -24,7 +24,7 @@ /* The fail macros mark the current test step as failed, and continue */ #define fail_if(expr, msg) \ if(expr) { \ - fprintf(stderr, "%s:%d Assertion '%s' met: %s\n" , \ + fprintf(stderr, "%s:%d Assertion '%s' met: %s\n", \ __FILE__, __LINE__, #expr, msg); \ unitfail++; \ } @@ -38,10 +38,10 @@ #define verify_memory(dynamic, check, len) \ if(dynamic && memcmp(dynamic, check, len)) { \ - fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \ - __FILE__, __LINE__, len, hexdump((unsigned char *)check, len)); \ + fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \ + __FILE__, __LINE__, len, hexdump((unsigned char *)check, len)); \ fprintf(stderr, "%s:%d the same as '%s'\n", \ - __FILE__, __LINE__, hexdump((unsigned char *)dynamic, len)); \ + __FILE__, __LINE__, hexdump((unsigned char *)dynamic, len)); \ unitfail++; \ } @@ -57,7 +57,7 @@ /* The abort macros mark the current test step as failed, and exit the test */ #define abort_if(expr, msg) \ if(expr) { \ - fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n" , \ + fprintf(stderr, "%s:%d Abort assertion '%s' met: %s\n", \ __FILE__, __LINE__, #expr, msg); \ unitfail++; \ goto unit_test_abort; \ @@ -85,10 +85,11 @@ extern int unitfail; #define UNITTEST_START \ int test(char *arg) \ { \ - (void)arg; \ - if (unit_setup()) { \ - fail("unit_setup() failure"); \ - } else { + (void)arg; \ + if(unit_setup()) { \ + fail("unit_setup() failure"); \ + } \ + else { #define UNITTEST_STOP \ goto unit_test_abort; /* avoid warning */ \ diff --git a/tests/unit/unit1300.c b/tests/unit/unit1300.c index 2040f702b..c4d9dd90d 100644 --- a/tests/unit/unit1300.c +++ b/tests/unit/unit1300.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -41,8 +41,8 @@ static CURLcode unit_setup(void) return CURLE_OUT_OF_MEMORY; llist_destination = Curl_llist_alloc(test_curl_llist_dtor); if(!llist_destination) { - Curl_llist_destroy(llist, NULL); - return CURLE_OUT_OF_MEMORY; + Curl_llist_destroy(llist, NULL); + return CURLE_OUT_OF_MEMORY; } return CURLE_OK; diff --git a/tests/unit/unit1301.c b/tests/unit/unit1301.c index a50fc67d6..928076e29 100644 --- a/tests/unit/unit1301.c +++ b/tests/unit/unit1301.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,32 +23,32 @@ #include "strequal.h" -static CURLcode unit_setup( void ) {return CURLE_OK;} -static void unit_stop( void ) {} +static CURLcode unit_setup(void) {return CURLE_OK;} +static void unit_stop(void) {} UNITTEST_START int rc; rc = curl_strequal("iii", "III"); -fail_unless( rc != 0 , "return code should be zero" ); +fail_unless(rc != 0, "return code should be zero"); rc = curl_strequal("iiia", "III"); -fail_unless( rc == 0 , "return code should be zero" ); +fail_unless(rc == 0, "return code should be zero"); rc = curl_strequal("iii", "IIIa"); -fail_unless( rc == 0 , "return code should be zero" ); +fail_unless(rc == 0, "return code should be zero"); rc = curl_strequal("iiiA", "IIIa"); -fail_unless( rc != 0 , "return code should be non-zero" ); +fail_unless(rc != 0, "return code should be non-zero"); rc = curl_strnequal("iii", "III", 3); -fail_unless( rc != 0 , "return code should be non-zero" ); +fail_unless(rc != 0, "return code should be non-zero"); rc = curl_strnequal("iiiABC", "IIIcba", 3); -fail_unless( rc != 0 , "return code should be non-zero" ); +fail_unless(rc != 0, "return code should be non-zero"); rc = curl_strnequal("ii", "II", 3); -fail_unless( rc != 0 , "return code should be non-zero" ); +fail_unless(rc != 0, "return code should be non-zero"); UNITTEST_STOP diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c index 165c7081a..8dae5aad1 100644 --- a/tests/unit/unit1302.c +++ b/tests/unit/unit1302.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -26,9 +26,9 @@ #include "curl_base64.h" #include "memdebug.h" /* LAST include file */ -static struct SessionHandle *data; +static struct Curl_easy *data; -static CURLcode unit_setup( void ) +static CURLcode unit_setup(void) { data = curl_easy_init(); if(!data) @@ -36,7 +36,7 @@ static CURLcode unit_setup( void ) return CURLE_OK; } -static void unit_stop( void ) +static void unit_stop(void) { curl_easy_cleanup(data); } @@ -52,50 +52,50 @@ CURLcode rc; rc = Curl_base64_encode(data, "i", 1, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 4, "size should be 4"); -verify_memory( output, "aQ==", 4); +verify_memory(output, "aQ==", 4); Curl_safefree(output); rc = Curl_base64_encode(data, "ii", 2, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 4, "size should be 4"); -verify_memory( output, "aWk=", 4); +verify_memory(output, "aWk=", 4); Curl_safefree(output); rc = Curl_base64_encode(data, "iii", 3, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 4, "size should be 4"); -verify_memory( output, "aWlp", 4); +verify_memory(output, "aWlp", 4); Curl_safefree(output); rc = Curl_base64_encode(data, "iiii", 4, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 8, "size should be 8"); -verify_memory( output, "aWlpaQ==", 8); +verify_memory(output, "aWlpaQ==", 8); Curl_safefree(output); rc = Curl_base64_encode(data, "\xff\x01\xfe\x02", 4, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 8, "size should be 8"); -verify_memory( output, "/wH+Ag==", 8); +verify_memory(output, "/wH+Ag==", 8); Curl_safefree(output); rc = Curl_base64url_encode(data, "\xff\x01\xfe\x02", 4, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 8, "size should be 8"); -verify_memory( output, "_wH-Ag==", 8); +verify_memory(output, "_wH-Ag==", 8); Curl_safefree(output); rc = Curl_base64url_encode(data, "iiii", 4, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 8, "size should be 8"); -verify_memory( output, "aWlpaQ==", 8); +verify_memory(output, "aWlpaQ==", 8); Curl_safefree(output); /* 0 length makes it do strlen() */ rc = Curl_base64_encode(data, "iiii", 0, &output, &size); fail_unless(rc == CURLE_OK, "return code should be CURLE_OK"); fail_unless(size == 8, "size should be 8"); -verify_memory( output, "aWlpaQ==", 8); +verify_memory(output, "aWlpaQ==", 8); Curl_safefree(output); rc = Curl_base64_decode("aWlpaQ==", &decoded, &size); @@ -126,7 +126,8 @@ Curl_safefree(decoded); size = 1; /* not zero */ decoded = &anychar; /* not NULL */ rc = Curl_base64_decode("aQ", &decoded, &size); -fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, "return code should be CURLE_BAD_CONTENT_ENCODING"); +fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, + "return code should be CURLE_BAD_CONTENT_ENCODING"); fail_unless(size == 0, "size should be 0"); fail_if(decoded, "returned pointer should be NULL"); @@ -134,7 +135,8 @@ fail_if(decoded, "returned pointer should be NULL"); size = 1; /* not zero */ decoded = &anychar; /* not NULL */ rc = Curl_base64_decode("a===", &decoded, &size); -fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, "return code should be CURLE_BAD_CONTENT_ENCODING"); +fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, + "return code should be CURLE_BAD_CONTENT_ENCODING"); fail_unless(size == 0, "size should be 0"); fail_if(decoded, "returned pointer should be NULL"); @@ -142,7 +144,8 @@ fail_if(decoded, "returned pointer should be NULL"); size = 1; /* not zero */ decoded = &anychar; /* not NULL */ rc = Curl_base64_decode("a=Q=", &decoded, &size); -fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, "return code should be CURLE_BAD_CONTENT_ENCODING"); +fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, + "return code should be CURLE_BAD_CONTENT_ENCODING"); fail_unless(size == 0, "size should be 0"); fail_if(decoded, "returned pointer should be NULL"); @@ -150,7 +153,8 @@ fail_if(decoded, "returned pointer should be NULL"); size = 1; /* not zero */ decoded = &anychar; /* not NULL */ rc = Curl_base64_decode("a\x1f==", &decoded, &size); -fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, "return code should be CURLE_BAD_CONTENT_ENCODING"); +fail_unless(rc == CURLE_BAD_CONTENT_ENCODING, + "return code should be CURLE_BAD_CONTENT_ENCODING"); fail_unless(size == 0, "size should be 0"); fail_if(decoded, "returned pointer should be NULL"); diff --git a/tests/unit/unit1303.c b/tests/unit/unit1303.c index 70be2a862..a4bd59826 100644 --- a/tests/unit/unit1303.c +++ b/tests/unit/unit1303.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -25,17 +25,17 @@ #include "connect.h" #include "memdebug.h" /* LAST include file */ -static struct SessionHandle *data; +static struct Curl_easy *data; -static CURLcode unit_setup( void ) +static CURLcode unit_setup(void) { data = curl_easy_init(); - if (!data) + if(!data) return CURLE_OUT_OF_MEMORY; return CURLE_OK; } -static void unit_stop( void ) +static void unit_stop(void) { curl_easy_cleanup(data); } diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c index 8c306e44e..11bba390f 100644 --- a/tests/unit/unit1304.c +++ b/tests/unit/unit1304.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,10 +31,10 @@ static CURLcode unit_setup(void) { password = strdup(""); login = strdup(""); - if (!password || !login) { - Curl_safefree(password); - Curl_safefree(login); - return CURLE_OUT_OF_MEMORY; + if(!password || !login) { + Curl_safefree(password); + Curl_safefree(login); + return CURLE_OUT_OF_MEMORY; } return CURLE_OK; } @@ -72,7 +72,8 @@ UNITTEST_START abort_unless(password != NULL, "returned NULL!"); fail_unless(password[0] == 0, "password should not have been changed"); abort_unless(login != NULL, "returned NULL!"); - fail_unless(strncmp(login, "me", 2) == 0, "login should not have been changed"); + fail_unless(strncmp(login, "me", 2) == 0, + "login should not have been changed"); /* * Test a non existent login and host in our netrc file. @@ -85,7 +86,8 @@ UNITTEST_START abort_unless(password != NULL, "returned NULL!"); fail_unless(password[0] == 0, "password should not have been changed"); abort_unless(login != NULL, "returned NULL!"); - fail_unless(strncmp(login, "me", 2) == 0, "login should not have been changed"); + fail_unless(strncmp(login, "me", 2) == 0, + "login should not have been changed"); /* * Test a non existent login (substring of an existing one) in our @@ -99,7 +101,8 @@ UNITTEST_START abort_unless(password != NULL, "returned NULL!"); fail_unless(password[0] == 0, "password should not have been changed"); abort_unless(login != NULL, "returned NULL!"); - fail_unless(strncmp(login, "admi", 4) == 0, "login should not have been changed"); + fail_unless(strncmp(login, "admi", 4) == 0, + "login should not have been changed"); /* * Test a non existent login (superstring of an existing one) @@ -113,7 +116,8 @@ UNITTEST_START abort_unless(password != NULL, "returned NULL!"); fail_unless(password[0] == 0, "password should not have been changed"); abort_unless(login != NULL, "returned NULL!"); - fail_unless(strncmp(login, "adminn", 6) == 0, "login should not have been changed"); + fail_unless(strncmp(login, "adminn", 6) == 0, + "login should not have been changed"); /* * Test for the first existing host in our netrc file diff --git a/tests/unit/unit1305.c b/tests/unit/unit1305.c index c99435d68..ad270f565 100644 --- a/tests/unit/unit1305.c +++ b/tests/unit/unit1305.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -39,16 +39,16 @@ #include "memdebug.h" /* LAST include file */ -static struct SessionHandle *data; +static struct Curl_easy *data; static struct curl_hash hp; static char *data_key; static struct Curl_dns_entry *data_node; -static CURLcode unit_setup( void ) +static CURLcode unit_setup(void) { int rc; data = curl_easy_init(); - if (!data) + if(!data) return CURLE_OUT_OF_MEMORY; rc = Curl_mk_dnscache(&hp); @@ -60,9 +60,9 @@ static CURLcode unit_setup( void ) return CURLE_OK; } -static void unit_stop( void ) +static void unit_stop(void) { - if (data_node) { + if(data_node) { Curl_freeaddrinfo(data_node->addr); free(data_node); } @@ -103,15 +103,15 @@ static Curl_addrinfo *fake_ai(void) static CURLcode create_node(void) { data_key = aprintf("%s:%d", "dummy", 0); - if (!data_key) + if(!data_key) return CURLE_OUT_OF_MEMORY; data_node = calloc(1, sizeof(struct Curl_dns_entry)); - if (!data_node) + if(!data_node) return CURLE_OUT_OF_MEMORY; data_node->addr = fake_ai(); - if (!data_node->addr) + if(!data_node->addr) return CURLE_OUT_OF_MEMORY; return CURLE_OK; @@ -124,7 +124,7 @@ UNITTEST_START size_t key_len; /* Test 1305 exits without adding anything to the hash */ - if (strcmp(arg, "1305") != 0) { + if(strcmp(arg, "1305") != 0) { CURLcode rc = create_node(); abort_unless(rc == CURLE_OK, "data node creation failed"); key_len = strlen(data_key); diff --git a/tests/unit/unit1307.c b/tests/unit/unit1307.c index 89f49832f..576462274 100644 --- a/tests/unit/unit1307.c +++ b/tests/unit/unit1307.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -160,7 +160,7 @@ static const struct testcase tests[] = { { "****.txt", ".txt", MATCH }, /* empty string or pattern */ - { "", "", MATCH } , + { "", "", MATCH }, { "", "hello", NOMATCH }, { "file", "", NOMATCH }, { "?", "", NOMATCH }, @@ -208,12 +208,12 @@ static const struct testcase tests[] = { { "", "", MATCH } }; -static CURLcode unit_setup( void ) +static CURLcode unit_setup(void) { return CURLE_OK; } -static void unit_stop( void ) +static void unit_stop(void) { } diff --git a/tests/unit/unit1394.c b/tests/unit/unit1394.c index 3818016dd..667991d1e 100644 --- a/tests/unit/unit1394.c +++ b/tests/unit/unit1394.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -84,12 +84,14 @@ UNITTEST_START "for -E param '%s'\n", p[1], certname, p[0]); fail("assertion failure"); } - } else { + } + else { printf("expected certname '%s' but got NULL " "for -E param '%s'\n", p[1], p[0]); fail("assertion failure"); } - } else { + } + else { if(certname) { printf("expected certname NULL but got '%s' " "for -E param '%s'\n", certname, p[0]); @@ -103,12 +105,14 @@ UNITTEST_START "for -E param '%s'\n", p[2], passphrase, p[0]); fail("assertion failure"); } - } else { + } + else { printf("expected passphrase '%s' but got NULL " "for -E param '%s'\n", p[2], p[0]); fail("assertion failure"); } - } else { + } + else { if(passphrase) { printf("expected passphrase NULL but got '%s' " "for -E param '%s'\n", passphrase, p[0]); diff --git a/tests/unit/unit1396.c b/tests/unit/unit1396.c index 8a78c9502..84a5162dd 100644 --- a/tests/unit/unit1396.c +++ b/tests/unit/unit1396.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -30,7 +30,7 @@ static CURLcode unit_setup(void) static void unit_stop(void) { - if (hnd) + if(hnd) curl_easy_cleanup(hnd); } diff --git a/tests/unit/unit1397.c b/tests/unit/unit1397.c index c05c119db..539433ca0 100644 --- a/tests/unit/unit1397.c +++ b/tests/unit/unit1397.c @@ -1,3 +1,24 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include "curlcheck.h" #include "hostcheck.h" /* from the lib dir */ @@ -7,7 +28,7 @@ static CURLcode unit_setup(void) return CURLE_OK; } -static void unit_stop( void ) +static void unit_stop(void) { /* done before shutting down and exiting */ } @@ -19,29 +40,36 @@ UNITTEST_START /* here you start doing things and checking that the results are good */ -fail_unless( Curl_cert_hostcheck("www.example.com", "www.example.com"), "good 1" ); -fail_unless( Curl_cert_hostcheck("*.example.com", "www.example.com"), "good 2" ); -fail_unless( Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"), "good 3" ); -fail_unless( Curl_cert_hostcheck("f*.example.com", "foo.example.com"), "good 4" ); -fail_unless( Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"), "good 5" ); - -fail_if( Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1" ); -fail_if( Curl_cert_hostcheck("*", "www.example.com"), "bad 2" ); -fail_if( Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3" ); -fail_if( Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4" ); -fail_if( Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5" ); -fail_if( Curl_cert_hostcheck("*.com", "example.com"), "bad 6" ); -fail_if( Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7" ); -fail_if( Curl_cert_hostcheck("*.example.", "www.example."), "bad 8" ); -fail_if( Curl_cert_hostcheck("*.example.", "www.example"), "bad 9" ); -fail_if( Curl_cert_hostcheck("", "www"), "bad 10" ); -fail_if( Curl_cert_hostcheck("*", "www"), "bad 11" ); -fail_if( Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12" ); -fail_if( Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13" ); +fail_unless(Curl_cert_hostcheck("www.example.com", "www.example.com"), + "good 1"); +fail_unless(Curl_cert_hostcheck("*.example.com", "www.example.com"), + "good 2"); +fail_unless(Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"), + "good 3"); +fail_unless(Curl_cert_hostcheck("f*.example.com", "foo.example.com"), + "good 4"); +fail_unless(Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"), + "good 5"); + +fail_if(Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1"); +fail_if(Curl_cert_hostcheck("*", "www.example.com"), "bad 2"); +fail_if(Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3"); +fail_if(Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4"); +fail_if(Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5"); +fail_if(Curl_cert_hostcheck("*.com", "example.com"), "bad 6"); +fail_if(Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7"); +fail_if(Curl_cert_hostcheck("*.example.", "www.example."), "bad 8"); +fail_if(Curl_cert_hostcheck("*.example.", "www.example"), "bad 9"); +fail_if(Curl_cert_hostcheck("", "www"), "bad 10"); +fail_if(Curl_cert_hostcheck("*", "www"), "bad 11"); +fail_if(Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12"); +fail_if(Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13"); #ifdef ENABLE_IPV6 -fail_if( Curl_cert_hostcheck("*::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "bad 14" ); -fail_unless( Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "good 6" ); +fail_if(Curl_cert_hostcheck("*::3285:a9ff:fe46:b619", + "fe80::3285:a9ff:fe46:b619"), "bad 14"); +fail_unless(Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619", + "fe80::3285:a9ff:fe46:b619"), "good 6"); #endif #endif diff --git a/tests/unit/unit1398.c b/tests/unit/unit1398.c index e9cc6753c..9491c46c5 100644 --- a/tests/unit/unit1398.c +++ b/tests/unit/unit1398.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,8 +23,8 @@ #include "curl/mprintf.h" -static CURLcode unit_setup( void ) {return CURLE_OK;} -static void unit_stop( void ) {} +static CURLcode unit_setup(void) {return CURLE_OK;} +static void unit_stop(void) {} UNITTEST_START @@ -38,54 +38,54 @@ char output[24]; /* without a trailing zero */ rc = curl_msnprintf(output, 4, "%.*s", width, buf); -fail_unless( rc == 3 , "return code should be 3" ); +fail_unless(rc == 3, "return code should be 3"); fail_unless(!strcmp(output, "bug"), "wrong output"); /* with a trailing zero */ rc = curl_msnprintf(output, 4, "%.*s", width, str); -fail_unless( rc == 3 , "return code should be 3" ); +fail_unless(rc == 3, "return code should be 3"); fail_unless(!strcmp(output, "bug"), "wrong output"); width = 2; /* one byte less */ rc = curl_msnprintf(output, 4, "%.*s", width, buf); -fail_unless( rc == 2 , "return code should be 2" ); +fail_unless(rc == 2, "return code should be 2"); fail_unless(!strcmp(output, "bu"), "wrong output"); /* string with larger precision */ rc = curl_msnprintf(output, 8, "%.8s", str); -fail_unless( rc == 3 , "return code should be 3" ); +fail_unless(rc == 3, "return code should be 3"); fail_unless(!strcmp(output, "bug"), "wrong output"); /* longer string with precision */ rc = curl_msnprintf(output, 8, "%.3s", "0123456789"); -fail_unless( rc == 3 , "return code should be 3" ); +fail_unless(rc == 3, "return code should be 3"); fail_unless(!strcmp(output, "012"), "wrong output"); /* negative width */ rc = curl_msnprintf(output, 8, "%-8s", str); -fail_unless( rc == 8 , "return code should be 8" ); +fail_unless(rc == 8, "return code should be 8"); fail_unless(!strcmp(output, "bug "), "wrong output"); /* larger width that string length */ rc = curl_msnprintf(output, 8, "%8s", str); -fail_unless( rc == 8 , "return code should be 8" ); +fail_unless(rc == 8, "return code should be 8"); fail_unless(!strcmp(output, " bu"), "wrong output"); /* output a number in a limited output */ rc = curl_msnprintf(output, 4, "%d", 10240); /* TODO: this should return 5 to be POSIX/snprintf compliant! */ -fail_unless( rc == 4 , "return code should be 4" ); +fail_unless(rc == 4, "return code should be 4"); fail_unless(!strcmp(output, "102"), "wrong output"); /* padded strings */ rc = curl_msnprintf(output, 16, "%8s%8s", str, str); -fail_unless( rc == 16 , "return code should be 16" ); +fail_unless(rc == 16, "return code should be 16"); fail_unless(!strcmp(output, " bug bu"), "wrong output"); /* padded numbers */ rc = curl_msnprintf(output, 16, "%8d%8d", 1234, 5678); -fail_unless( rc == 16 , "return code should be 16" ); +fail_unless(rc == 16, "return code should be 16"); fail_unless(!strcmp(output, " 1234 567"), "wrong output"); UNITTEST_STOP diff --git a/tests/unit/unit1600.c b/tests/unit/unit1600.c index 2769e9045..f0f9cc1f4 100644 --- a/tests/unit/unit1600.c +++ b/tests/unit/unit1600.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -39,7 +39,8 @@ static void unit_stop(void) UNITTEST_START -#if defined(USE_NTLM) && (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)) +#if defined(USE_NTLM) && (!defined(USE_WINDOWS_SSPI) || \ + defined(USE_WIN32_CRYPTO)) unsigned char output[21]; unsigned char *testp = output; Curl_ntlm_core_mk_nt_hash(easy, "1", output); @@ -54,6 +55,7 @@ UNITTEST_START "\x39\xaf\x87\xa6\x75\x0a\x7a\x00\xba\xa0" "\xd3\x4f\x04\x9e\xc1\xd0\x00\x00\x00\x00\x00", 21); +/* !checksrc! disable LONGLINE 2 */ Curl_ntlm_core_mk_nt_hash(easy, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", output); verify_memory(testp, diff --git a/tests/unit/unit1601.c b/tests/unit/unit1601.c index 91c850c9e..a6120e1c2 100644 --- a/tests/unit/unit1601.c +++ b/tests/unit/unit1601.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -40,6 +40,7 @@ UNITTEST_START unsigned char *testp = output; Curl_md5it(output, (const unsigned char *)"1"); +/* !checksrc! disable LONGLINE 2 */ verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f\x75\x84\x9b", 16); diff --git a/tests/unit/unit1602.c b/tests/unit/unit1602.c index 63815551c..c67c0a555 100644 --- a/tests/unit/unit1602.c +++ b/tests/unit/unit1602.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -36,13 +36,13 @@ static void mydtor(void *p) free(ptr); } -static CURLcode unit_setup( void ) +static CURLcode unit_setup(void) { return Curl_hash_init(&hash_static, 7, Curl_hash_str, Curl_str_key_compare, mydtor); } -static void unit_stop( void ) +static void unit_stop(void) { Curl_hash_destroy(&hash_static); } @@ -64,7 +64,6 @@ UNITTEST_START if(!nodep) free(value); abort_unless(nodep, "insertion into hash failed"); - Curl_hash_clean(&hash_static); /* Attempt to add another key/value pair */ diff --git a/tests/unit/unit1603.c b/tests/unit/unit1603.c index ffcd756e2..c20b20b0e 100644 --- a/tests/unit/unit1603.c +++ b/tests/unit/unit1603.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2015 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -37,13 +37,13 @@ static void mydtor(void *p) (void)p; /* unused */ } -static CURLcode unit_setup( void ) +static CURLcode unit_setup(void) { return Curl_hash_init(&hash_static, slots, Curl_hash_str, Curl_str_key_compare, mydtor); } -static void unit_stop( void ) +static void unit_stop(void) { Curl_hash_destroy(&hash_static); } diff --git a/tests/unit/unit1604.c b/tests/unit/unit1604.c index c61f010dc..242be0005 100644 --- a/tests/unit/unit1604.c +++ b/tests/unit/unit1604.c @@ -45,7 +45,7 @@ static void unit_stop(void) static char *getflagstr(int flags) { char *buf = malloc(256); fail_unless(buf, "out of memory"); - sprintf(buf, "%s,%s,%s,%s", + snprintf(buf, 256, "%s,%s,%s,%s", ((flags & SANITIZE_ALLOW_COLONS) ? "SANITIZE_ALLOW_COLONS" : ""), ((flags & SANITIZE_ALLOW_PATH) ? "SANITIZE_ALLOW_PATH" : ""), ((flags & SANITIZE_ALLOW_RESERVED) ? "SANITIZE_ALLOW_RESERVED" : ""), @@ -56,7 +56,7 @@ static char *getflagstr(int flags) { static char *getcurlcodestr(int cc) { char *buf = malloc(256); fail_unless(buf, "out of memory"); - sprintf(buf, "%s (%d)", + snprintf(buf, 256, "%s (%d)", (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" : cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" : cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" : |