aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/README4
-rw-r--r--tests/data/Makefile.am4
-rw-r--r--tests/data/test130526
-rw-r--r--tests/data/test55844
-rw-r--r--tests/data/test55944
-rw-r--r--tests/libtest/CMakeLists.txt8
-rw-r--r--tests/libtest/Makefile.inc8
-rw-r--r--tests/libtest/lib558.c188
-rw-r--r--tests/unit/Makefile.inc3
-rw-r--r--tests/unit/unit1305.c131
10 files changed, 166 insertions, 294 deletions
diff --git a/tests/README b/tests/README
index be22778cd..4d8e70c78 100644
--- a/tests/README
+++ b/tests/README
@@ -145,7 +145,9 @@ TEST CASE NUMBERS
600 - 699 SCP/SFTP
700 - 799 SOCKS4 (even numbers) and SOCK5 (odd numbers)
800 - 899 POP3, IMAP, SMTP
- 1000 - 1999 miscellaneous*
+ 1000 - 1299 miscellaneous*
+ 1300 - 1399 unit tests*
+ 1400 - 1999 miscellaneous*
2000 - x multiple sequential protocols per test case*
Since 30-apr-2003, there's nothing in the system that requires us to keep
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 3f8196d57..2967e7cf6 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -59,7 +59,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test1064 test1065 test1066 test1067 test1068 test1069 test1070 test1071 \
test1072 test1073 test1074 test1075 test1076 test1077 test1078 test1079 \
test1080 test1081 test1082 test1083 test1084 test1085 test633 test634 \
- test635 test636 test637 test558 test559 test1086 test1087 test1088 \
+ test635 test636 test637 test1086 test1087 test1088 \
test574 test575 test576 test577 test1113 test1114 test1089 test1090 \
test1091 test1092 test1093 test1094 test1095 test1096 test1097 test560 \
test561 test1098 test1099 test562 test563 test1100 test564 test1101 \
@@ -70,7 +70,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test313 test1115 test578 test579 test1116 test1200 test1201 test1202 \
test1203 test1117 test1118 test1119 test1120 test1300 test1301 test1302 \
test1303 test320 test321 test322 test323 test324 test1121 test581 test580 \
- test1304
+ test1304 test1305
filecheck:
@mkdir test-place; \
diff --git a/tests/data/test1305 b/tests/data/test1305
new file mode 100644
index 000000000..4efe321e1
--- /dev/null
+++ b/tests/data/test1305
@@ -0,0 +1,26 @@
+<testcase>
+<info>
+<keywords>
+unittest
+hash
+</keywords>
+</info>
+
+#
+# Client-side
+<client>
+<server>
+none
+</server>
+<features>
+unittest
+</features>
+ <name>
+internal hash create/add/destroy testing
+ </name>
+<tool>
+unit1305
+</tool>
+</client>
+
+</testcase>
diff --git a/tests/data/test558 b/tests/data/test558
deleted file mode 100644
index 5b69ea027..000000000
--- a/tests/data/test558
+++ /dev/null
@@ -1,44 +0,0 @@
-<testcase>
-#
-# Server-side
-<reply>
-</reply>
-
-# Client-side
-<client>
-<server>
-none
-</server>
-# tool is what to use instead of 'curl'
-<tool>
-lib558
-</tool>
-# precheck is a command line to run before the test,
-# to see if we can execute the test or not
-<precheck>
-./libtest/lib558 check
-</precheck>
-
-<name>
-internal hash create/destroy testing
-</name>
-<command>
-nothing
-</command>
-</client>
-
-#
-# Verify data after the test has been "shot"
-<verify>
-<stdout mode="text">
-easy handle init OK
-creating hash...
-hash creation OK
-destroying hash...
-hash destruction OK
-destroying easy handle...
-easy handle destruction OK
-</stdout>
-</verify>
-
-</testcase>
diff --git a/tests/data/test559 b/tests/data/test559
deleted file mode 100644
index ecaf54c7e..000000000
--- a/tests/data/test559
+++ /dev/null
@@ -1,44 +0,0 @@
-<testcase>
-#
-# Server-side
-<reply>
-</reply>
-
-# Client-side
-<client>
-<server>
-none
-</server>
-# tool is what to use instead of 'curl'
-<tool>
-lib559
-</tool>
-# precheck is a command line to run before the test,
-# to see if we can execute the test or not
-<precheck>
-./libtest/lib559 check
-</precheck>
-
-<name>
-internal hash create/add/destroy testing
-</name>
-<command>
-nothing
-</command>
-</client>
-
-#
-# Verify data after the test has been "shot"
-<verify>
-<stdout mode="text">
-easy handle init OK
-creating hash...
-hash creation OK
-destroying hash...
-hash destruction OK
-destroying easy handle...
-easy handle destruction OK
-</stdout>
-</verify>
-
-</testcase>
diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt
index 653e5315d..896686bd8 100644
--- a/tests/libtest/CMakeLists.txt
+++ b/tests/libtest/CMakeLists.txt
@@ -65,8 +65,7 @@ endforeach()
# lib547
# #lib548
# lib549 lib552 lib553 lib554 lib555 lib556
-# lib539 lib557 lib558
-# #lib559
+# lib539 lib557
# lib560
# )
@@ -120,8 +119,3 @@ endforeach()
# SET(SOURCE "lib547.c" ${SUPPORTFILES})
# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
# SETUP_TEST(${TEST_NAME} ${SOURCE})
-
-# SET(TEST_NAME lib559)
-# SET(SOURCE "lib558.c" ${SUPPORTFILES})
-# ADD_TESTUTIL_IF_NECESSARY(${TEST_NAME})
-# SETUP_TEST(${TEST_NAME} ${SOURCE})
diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc
index 2354ecc60..322feeac4 100644
--- a/tests/libtest/Makefile.inc
+++ b/tests/libtest/Makefile.inc
@@ -11,7 +11,7 @@ noinst_PROGRAMS = lib500 lib501 lib502 lib503 lib504 lib505 lib506 \
lib574 lib575 lib576 lib577 lib578 lib579 \
lib529 lib530 lib532 lib533 lib536 lib537 lib540 lib541 lib542 lib543 \
lib544 lib545 lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 \
- lib539 lib557 lib558 lib559 lib560 lib562 lib564 lib565 lib566 lib567 \
+ lib539 lib557 lib560 lib562 lib564 lib565 lib566 lib567 \
lib568 lib569 lib570 lib571 lib572 lib573 chkhostname
chkhostname_SOURCES = chkhostname.c $(top_srcdir)/lib/curl_gethostname.c
@@ -122,12 +122,6 @@ lib556_SOURCES = lib556.c $(SUPPORTFILES)
lib557_SOURCES = lib557.c $(SUPPORTFILES)
-lib558_SOURCES = lib558.c $(SUPPORTFILES)
-lib558_CFLAGS = -DLIB558
-
-lib559_SOURCES = lib558.c $(SUPPORTFILES)
-lib559_CFLAGS = -DLIB559
-
lib560_SOURCES = lib560.c $(SUPPORTFILES)
lib574_SOURCES = lib574.c $(SUPPORTFILES)
diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c
deleted file mode 100644
index 56f2a2612..000000000
--- a/tests/libtest/lib558.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*****************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- */
-
-#include "test.h"
-
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#ifdef HAVE_NETDB_H
-# include <netdb.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-# include <arpa/inet.h>
-#endif
-
-#define ENABLE_CURLX_PRINTF
-#include "curlx.h"
-
-#include "hash.h"
-#include "hostip.h"
-
-#include "curl_memory.h"
-#include "memdebug.h"
-
-/* This source file is used for test # 558 and 559 */
-
-/*
- * This hacky test bypasses the library external API,
- * using internal only libcurl functions. So don't be
- * surprised if we cannot run it when the library has
- * been built with hidden symbols, exporting only the
- * ones in the public API.
- */
-
-#if defined(CURL_HIDDEN_SYMBOLS)
-# define SKIP_TEST 1
-#elif defined(WIN32) && !defined(CURL_STATICLIB)
-# define SKIP_TEST 1
-#else
-# undef SKIP_TEST
-#endif
-
-
-#if !defined(SKIP_TEST)
-
-#ifdef LIB559
-static Curl_addrinfo *fake_ai(void)
-{
- Curl_addrinfo *ai;
- int ss_size;
-
- ss_size = sizeof (struct sockaddr_in);
-
- if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL)
- return NULL;
-
- if((ai->ai_canonname = strdup("dummy")) == NULL) {
- free(ai);
- return NULL;
- }
-
- if((ai->ai_addr = calloc(1, ss_size)) == NULL) {
- free(ai->ai_canonname);
- free(ai);
- return NULL;
- }
-
- ai->ai_family = AF_INET;
- ai->ai_addrlen = ss_size;
-
- return ai;
-}
-#endif /* LIB559 */
-
-
-int test(char *URL)
-{
- CURL *easyh = NULL;
- struct curl_hash *hp = NULL;
- int result = 0;
-
- if(!strcmp(URL, "check")) {
- /* test harness script verifying if this test can run */
- return 0; /* sure, run this! */
- }
-
- easyh = curl_easy_init();
- if(!easyh) {
- fprintf(stdout, "easy handle init failed\n");
- result = TEST_ERR_MAJOR_BAD;
- goto cleanup;
- }
- fprintf(stdout, "easy handle init OK\n");
-
- fprintf(stdout, "creating hash...\n");
- hp = Curl_mk_dnscache();
- if(!hp) {
- fprintf(stdout, "hash creation failed\n");
- result = TEST_ERR_MAJOR_BAD;
- goto cleanup;
- }
- fprintf(stdout, "hash creation OK\n");
-
- /**/
-#ifdef LIB559
- {
- char *data_key;
- struct Curl_dns_entry *data_node;
- struct Curl_dns_entry *nodep;
- size_t key_len;
-
- data_key = aprintf("%s:%d", "dummy", 0);
- if(!data_key) {
- fprintf(stdout, "data key creation failed\n");
- result = TEST_ERR_MAJOR_BAD;
- goto cleanup;
- }
- key_len = strlen(data_key);
-
- data_node = calloc(1, sizeof(struct Curl_dns_entry));
- if(!data_node) {
- fprintf(stdout, "data node creation failed\n");
- result = TEST_ERR_MAJOR_BAD;
- free(data_key);
- goto cleanup;
- }
-
- data_node->addr = fake_ai();
- if(!data_node->addr) {
- fprintf(stdout, "actual data creation failed\n");
- result = TEST_ERR_MAJOR_BAD;
- free(data_node);
- free(data_key);
- goto cleanup;
- }
-
- nodep = Curl_hash_add(hp, data_key, key_len+1, (void *)data_node);
- if(!nodep) {
- fprintf(stdout, "insertion into hash failed\n");
- result = TEST_ERR_MAJOR_BAD;
- Curl_freeaddrinfo(data_node->addr);
- free(data_node);
- free(data_key);
- goto cleanup;
- }
-
- free(data_key);
- }
-#endif /* LIB559 */
- /**/
-
-cleanup:
-
- fprintf(stdout, "destroying hash...\n");
- Curl_hash_destroy(hp);
- fprintf(stdout, "hash destruction OK\n");
-
- fprintf(stdout, "destroying easy handle...\n");
- curl_easy_cleanup(easyh);
- fprintf(stdout, "easy handle destruction OK\n");
-
- curl_global_cleanup();
-
- return result;
-}
-
-
-#else /* !defined(SKIP_TEST) */
-
-
-int test(char *URL)
-{
- (void)URL;
- fprintf(stdout, "libcurl built with hidden symbols");
- return 1; /* skip test */
-}
-
-
-#endif /* !defined(SKIP_TEST) */
diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc
index 6dd7a4165..537622d42 100644
--- a/tests/unit/Makefile.inc
+++ b/tests/unit/Makefile.inc
@@ -3,10 +3,11 @@
UNITFILES = curlcheck.h
# These are all unit test programs
-noinst_PROGRAMS = unit1300 unit1301 unit1302 unit1303 unit1304
+noinst_PROGRAMS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305
unit1300_SOURCES = unit1300.c $(UNITFILES)
unit1301_SOURCES = unit1301.c $(UNITFILES)
unit1302_SOURCES = unit1302.c $(UNITFILES)
unit1303_SOURCES = unit1303.c $(UNITFILES)
unit1304_SOURCES = unit1304.c $(UNITFILES)
+unit1305_SOURCES = unit1305.c $(UNITFILES)
diff --git a/tests/unit/unit1305.c b/tests/unit/unit1305.c
new file mode 100644
index 000000000..bcf7c43ff
--- /dev/null
+++ b/tests/unit/unit1305.c
@@ -0,0 +1,131 @@
+/*****************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ */
+
+#include "test.h"
+
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+
+#define ENABLE_CURLX_PRINTF
+#include "curlx.h"
+
+#include "hash.h"
+#include "hostip.h"
+#include "curlcheck.h"
+
+#include "curl_memory.h"
+#include "memdebug.h" /* LAST include file */
+
+static struct SessionHandle *data;
+static struct curl_hash *hp;
+static char *data_key;
+static struct Curl_dns_entry *data_node;
+
+static CURLcode unit_setup( void )
+{
+ data = curl_easy_init();
+ if (!data)
+ return CURLE_OUT_OF_MEMORY;
+
+ hp = Curl_mk_dnscache();
+ if(!hp) {
+ curl_easy_cleanup(data);
+ curl_global_cleanup();
+ return CURLE_OUT_OF_MEMORY;
+ }
+ return CURLE_OK;
+}
+
+static void unit_stop( void )
+{
+ if (data_node) {
+ Curl_freeaddrinfo(data_node->addr);
+ free(data_node);
+ }
+ if (data_key)
+ free(data_key);
+
+ Curl_hash_destroy(hp);
+
+ curl_easy_cleanup(data);
+ curl_global_cleanup();
+}
+
+static Curl_addrinfo *fake_ai(void)
+{
+ static Curl_addrinfo *ai;
+ int ss_size;
+
+ ss_size = sizeof (struct sockaddr_in);
+
+ if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL)
+ return NULL;
+
+ if((ai->ai_canonname = strdup("dummy")) == NULL) {
+ free(ai);
+ return NULL;
+ }
+
+ if((ai->ai_addr = calloc(1, ss_size)) == NULL) {
+ free(ai->ai_canonname);
+ free(ai);
+ return NULL;
+ }
+
+ ai->ai_family = AF_INET;
+ ai->ai_addrlen = ss_size;
+
+ return ai;
+}
+
+static CURLcode create_node(void)
+{
+ data_key = aprintf("%s:%d", "dummy", 0);
+ if (!data_key)
+ return CURLE_OUT_OF_MEMORY;
+
+ data_node = calloc(1, sizeof(struct Curl_dns_entry));
+ if (!data_node)
+ return CURLE_OUT_OF_MEMORY;
+
+ data_node->addr = fake_ai();
+ if (!data_node->addr)
+ return CURLE_OUT_OF_MEMORY;
+
+ return CURLE_OK;
+}
+
+
+UNITTEST_START
+
+ struct Curl_dns_entry *nodep;
+ size_t key_len;
+
+ CURLcode rc = create_node();
+ abort_unless(rc == CURLE_OK, "data node creation failed");
+ key_len = strlen(data_key);
+
+ nodep = Curl_hash_add(hp, data_key, key_len+1, data_node);
+ abort_unless(nodep, "insertion into hash failed");
+ /* Freeing will now be done by Curl_hash_destroy */
+ data_node = NULL;
+
+ /* To do: test retrieval, deletion, edge conditions */
+
+UNITTEST_STOP