diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/Makefile.inc | 34 | ||||
-rw-r--r-- | tests/unit/unit1300.c | 52 | ||||
-rw-r--r-- | tests/unit/unit1601.c | 20 | ||||
-rw-r--r-- | tests/unit/unit1610.c | 60 | ||||
-rw-r--r-- | tests/unit/unit1611.c | 58 | ||||
-rw-r--r-- | tests/unit/unit1612.c | 66 | ||||
-rw-r--r-- | tests/unit/unit1651.c | 4 | ||||
-rw-r--r-- | tests/unit/unit1654.c | 4 |
8 files changed, 233 insertions, 65 deletions
diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 6ad42bd42..158619657 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -1,3 +1,25 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 1998 - 2020, 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. +# +########################################################################### + # these files are used in every single unit test program UNITFILES = curlcheck.h \ @@ -10,7 +32,8 @@ UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \ unit1330 unit1394 unit1395 unit1396 unit1397 unit1398 \ unit1399 \ unit1600 unit1601 unit1602 unit1603 unit1604 unit1605 unit1606 unit1607 \ - unit1608 unit1609 unit1620 unit1621 \ + unit1608 unit1609 unit1610 unit1611 unit1612 \ + unit1620 unit1621 \ unit1650 unit1651 unit1652 unit1653 unit1654 unit1655 unit1300_SOURCES = unit1300.c $(UNITFILES) @@ -97,6 +120,15 @@ unit1608_CPPFLAGS = $(AM_CPPFLAGS) unit1609_SOURCES = unit1609.c $(UNITFILES) unit1609_CPPFLAGS = $(AM_CPPFLAGS) +unit1610_SOURCES = unit1610.c $(UNITFILES) +unit1610_CPPFLAGS = $(AM_CPPFLAGS) + +unit1611_SOURCES = unit1611.c $(UNITFILES) +unit1611_CPPFLAGS = $(AM_CPPFLAGS) + +unit1612_SOURCES = unit1612.c $(UNITFILES) +unit1612_CPPFLAGS = $(AM_CPPFLAGS) + unit1620_SOURCES = unit1620.c $(UNITFILES) unit1620_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/tests/unit/unit1300.c b/tests/unit/unit1300.c index 5cfa6daf3..5d8799779 100644 --- a/tests/unit/unit1300.c +++ b/tests/unit/unit1300.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2020, 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 @@ -54,7 +54,6 @@ UNITTEST_START struct curl_llist_element case2_list; struct curl_llist_element case3_list; struct curl_llist_element case4_list; - struct curl_llist_element case5_list; struct curl_llist_element *head; struct curl_llist_element *element_next; struct curl_llist_element *element_prev; @@ -216,55 +215,6 @@ UNITTEST_START fail_unless(llist.tail == NULL, "llist tail is not NULL while the llist is empty"); - /* @testing Curl_llist_move(struct curl_llist *, - * struct curl_llist_element *, struct curl_llist *, - * struct curl_llist_element *); - */ - - /** - * @case 1: - * moving head from an llist containing one element to an empty llist - * @assumptions: - * 1: llist size will be 0 - * 2: llist_destination size will be 1 - * 3: llist head will be NULL - * 4: llist_destination head == llist_destination tail != NULL - */ - - /* - * @setup - * add one element to the list - */ - - Curl_llist_insert_next(&llist, llist.head, &unusedData_case1, - &case5_list); - /* necessary assertions */ - - abort_unless(Curl_llist_count(&llist) == 1, - "Number of list elements is not as expected, Aborting"); - abort_unless(Curl_llist_count(&llist_destination) == 0, - "Number of list elements is not as expected, Aborting"); - - /*actual testing code*/ - Curl_llist_move(&llist, llist.head, &llist_destination, NULL); - fail_unless(Curl_llist_count(&llist) == 0, - "moving element from llist didn't decrement the size"); - - fail_unless(Curl_llist_count(&llist_destination) == 1, - "moving element to llist_destination didn't increment the size"); - - fail_unless(llist.head == NULL, - "llist head not set to null after moving the head"); - - fail_unless(llist_destination.head != NULL, - "llist_destination head set to null after moving an element"); - - fail_unless(llist_destination.tail != NULL, - "llist_destination tail set to null after moving an element"); - - fail_unless(llist_destination.tail == llist_destination.head, - "llist_destination tail doesn't equal llist_destination head"); - Curl_llist_destroy(&llist, NULL); Curl_llist_destroy(&llist_destination, NULL); } diff --git a/tests/unit/unit1601.c b/tests/unit/unit1601.c index a6120e1c2..bf00bc7e9 100644 --- a/tests/unit/unit1601.c +++ b/tests/unit/unit1601.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2020, 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,18 +36,20 @@ static void unit_stop(void) UNITTEST_START #ifndef CURL_DISABLE_CRYPTO_AUTH - unsigned char output[16]; + const char string1[] = "1"; + const char string2[] = "hello-you-fool"; + unsigned char output[MD5_DIGEST_LEN]; 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); + Curl_md5it(output, (const unsigned char *) string1, strlen(string1)); - Curl_md5it(output, (const unsigned char *)"hello-you-fool"); + verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f" + "\x75\x84\x9b", MD5_DIGEST_LEN); - verify_memory(testp, - "\x88\x67\x0b\x6d\x5d\x74\x2f\xad\xa5\xcd\xf9\xb6\x82\x87\x5f\x22", 16); + Curl_md5it(output, (const unsigned char *) string2, strlen(string2)); + + verify_memory(testp, "\x88\x67\x0b\x6d\x5d\x74\x2f\xad\xa5\xcd\xf9\xb6\x82" + "\x87\x5f\x22", MD5_DIGEST_LEN); #endif diff --git a/tests/unit/unit1610.c b/tests/unit/unit1610.c new file mode 100644 index 000000000..bb9c937c9 --- /dev/null +++ b/tests/unit/unit1610.c @@ -0,0 +1,60 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2020, 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 "curl_sha256.h" + +static CURLcode unit_setup(void) +{ + return CURLE_OK; +} + +static void unit_stop(void) +{ + +} + +UNITTEST_START + +#ifndef CURL_DISABLE_CRYPTO_AUTH + const char string1[] = "1"; + const char string2[] = "hello-you-fool"; + unsigned char output[SHA256_DIGEST_LENGTH]; + unsigned char *testp = output; + + Curl_sha256it(output, (const unsigned char *) string1, strlen(string1)); + + verify_memory(testp, + "\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f" + "\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87" + "\x5b\x4b", SHA256_DIGEST_LENGTH); + + Curl_sha256it(output, (const unsigned char *) string2, strlen(string2)); + + verify_memory(testp, + "\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26" + "\x30\xd1\x19\x9c\x1f\x02\x17\xf4\x7c\x96\x20\xf3\xef\xe8\x27" + "\x15\xae", SHA256_DIGEST_LENGTH); +#endif + + +UNITTEST_STOP diff --git a/tests/unit/unit1611.c b/tests/unit/unit1611.c new file mode 100644 index 000000000..bc19f8a5c --- /dev/null +++ b/tests/unit/unit1611.c @@ -0,0 +1,58 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2020, 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 "curl_md4.h" + +static CURLcode unit_setup(void) +{ + return CURLE_OK; +} + +static void unit_stop(void) +{ + +} + +UNITTEST_START + +#ifndef CURL_DISABLE_CRYPTO_AUTH + const char string1[] = "1"; + const char string2[] = "hello-you-fool"; + unsigned char output[MD4_DIGEST_LENGTH]; + unsigned char *testp = output; + + Curl_md4it(output, (const unsigned char *) string1, strlen(string1)); + + verify_memory(testp, + "\x8b\xe1\xec\x69\x7b\x14\xad\x3a\x53\xb3\x71\x43\x61\x20\x64" + "\x1d", MD4_DIGEST_LENGTH); + + Curl_md4it(output, (const unsigned char *) string2, strlen(string2)); + + verify_memory(testp, + "\xa7\x16\x1c\xad\x7e\xbe\xdb\xbc\xf8\xc7\x23\x10\x2d\x2c\xe2" + "\x0b", MD4_DIGEST_LENGTH); +#endif + + +UNITTEST_STOP diff --git a/tests/unit/unit1612.c b/tests/unit/unit1612.c new file mode 100644 index 000000000..3fb2de033 --- /dev/null +++ b/tests/unit/unit1612.c @@ -0,0 +1,66 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2020, 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 "curl_hmac.h" +#include "curl_md5.h" + +static CURLcode unit_setup(void) +{ + return CURLE_OK; +} + +static void unit_stop(void) +{ + +} + +UNITTEST_START + +#ifndef CURL_DISABLE_CRYPTO_AUTH + const char password[] = "Pa55worD"; + const char string1[] = "1"; + const char string2[] = "hello-you-fool"; + unsigned char output[HMAC_MD5_LENGTH]; + unsigned char *testp = output; + + Curl_hmacit(Curl_HMAC_MD5, + (const unsigned char *) password, strlen(password), + (const unsigned char *) string1, strlen(string1), + output); + + verify_memory(testp, + "\xd1\x29\x75\x43\x58\xdc\xab\x78\xdf\xcd\x7f\x2b\x29\x31\x13" + "\x37", HMAC_MD5_LENGTH); + + Curl_hmacit(Curl_HMAC_MD5, + (const unsigned char *) password, strlen(password), + (const unsigned char *) string2, strlen(string2), + output); + + verify_memory(testp, + "\x75\xf1\xa7\xb9\xf5\x40\xe5\xa4\x98\x83\x9f\x64\x5a\x27\x6d" + "\xd0", HMAC_MD5_LENGTH); +#endif + + +UNITTEST_STOP diff --git a/tests/unit/unit1651.c b/tests/unit/unit1651.c index 3652601f9..44dbf4b51 100644 --- a/tests/unit/unit1651.c +++ b/tests/unit/unit1651.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2018 - 2020, 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 @@ -368,7 +368,7 @@ UNITTEST_START for(byte = 1 ; byte < 255; byte += 17) { for(i = 0; i < 45; i++) { char backup = cert[i]; - cert[i] = (unsigned char)byte&0xff; + cert[i] = (unsigned char) (byte & 0xff); (void) Curl_extract_certinfo(&conn, 0, beg, end); cert[i] = backup; } diff --git a/tests/unit/unit1654.c b/tests/unit/unit1654.c index a800d9c3a..d05d0b214 100644 --- a/tests/unit/unit1654.c +++ b/tests/unit/unit1654.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2019 - 2020, 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 @@ -124,7 +124,7 @@ UNITTEST_START } fail_unless(asi->num == 10, "wrong number of entries"); - Curl_altsvc_save(asi, outname); + Curl_altsvc_save(curl, asi, outname); curl_easy_cleanup(curl); fail: |