mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
unit: make unit test source code checksrc compliant
This commit is contained in:
parent
d3252e000c
commit
a981141b19
@ -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
|
||||
@ -88,7 +88,8 @@ extern int unitfail;
|
||||
(void)arg; \
|
||||
if(unit_setup()) { \
|
||||
fail("unit_setup() failure"); \
|
||||
} else {
|
||||
} \
|
||||
else {
|
||||
|
||||
#define UNITTEST_STOP \
|
||||
goto unit_test_abort; /* avoid warning */ \
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]);
|
||||
|
@ -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
|
||||
|
@ -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,11 +40,16 @@ 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_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" );
|
||||
@ -40,8 +66,10 @@ 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
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user