diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-04-03 16:21:10 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-04-03 22:38:36 +0200 |
commit | a981141b199702ffd780a4390e601db565102c65 (patch) | |
tree | c92b2a21887fb1f9683372c2564584d1ee79fea7 /tests | |
parent | d3252e000c96f31456667c3033c13d83e2628d29 (diff) |
unit: make unit test source code checksrc compliant
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/curlcheck.h | 17 | ||||
-rw-r--r-- | tests/unit/unit1300.c | 6 | ||||
-rw-r--r-- | tests/unit/unit1302.c | 14 | ||||
-rw-r--r-- | tests/unit/unit1303.c | 4 | ||||
-rw-r--r-- | tests/unit/unit1304.c | 22 | ||||
-rw-r--r-- | tests/unit/unit1305.c | 14 | ||||
-rw-r--r-- | tests/unit/unit1394.c | 14 | ||||
-rw-r--r-- | tests/unit/unit1396.c | 4 | ||||
-rw-r--r-- | tests/unit/unit1397.c | 70 | ||||
-rw-r--r-- | tests/unit/unit1600.c | 6 | ||||
-rw-r--r-- | tests/unit/unit1601.c | 3 | ||||
-rw-r--r-- | tests/unit/unit1602.c | 3 |
12 files changed, 110 insertions, 67 deletions
diff --git a/tests/unit/curlcheck.h b/tests/unit/curlcheck.h index 22f05c188..db813db7c 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 @@ -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++; \ } @@ -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/unit1302.c b/tests/unit/unit1302.c index 165c7081a..bc180f77d 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 @@ -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..0d655b7bf 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 @@ -30,7 +30,7 @@ static struct SessionHandle *data; static CURLcode unit_setup( void ) { data = curl_easy_init(); - if (!data) + if(!data) return CURLE_OUT_OF_MEMORY; return CURLE_OK; } 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..093333a79 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 @@ -48,7 +48,7 @@ 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); @@ -62,7 +62,7 @@ static CURLcode unit_setup( 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/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..37e8e49de 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 */ @@ -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/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..0d56f9cd9 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 @@ -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 */ |