diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-05-26 22:40:48 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-05-26 22:40:48 +0300 |
commit | 632b8532fb6742d722c1a0accdb48db604837700 (patch) | |
tree | d9d96fe611767ddc2d6f6fd0290b3adbf5638725 /src/testcurl | |
parent | eb622eb2cbae5d628bd489ff5aee8a657f1e4f31 (diff) | |
download | libmicrohttpd-632b8532fb6742d722c1a0accdb48db604837700.tar.gz libmicrohttpd-632b8532fb6742d722c1a0accdb48db604837700.zip |
test_get: implemented more detailed reports
Diffstat (limited to 'src/testcurl')
-rw-r--r-- | src/testcurl/Makefile.am | 4 | ||||
-rw-r--r-- | src/testcurl/test_get.c | 156 |
2 files changed, 133 insertions, 27 deletions
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am index 881615a8..7177b290 100644 --- a/src/testcurl/Makefile.am +++ b/src/testcurl/Makefile.am | |||
@@ -109,7 +109,7 @@ test_concurrent_stop_LDADD = \ | |||
109 | $(PTHREAD_LIBS) @LIBCURL@ | 109 | $(PTHREAD_LIBS) @LIBCURL@ |
110 | 110 | ||
111 | test_get_SOURCES = \ | 111 | test_get_SOURCES = \ |
112 | test_get.c mhd_has_in_name.h | 112 | test_get.c |
113 | test_get_LDADD = \ | 113 | test_get_LDADD = \ |
114 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ | 114 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ |
115 | @LIBCURL@ | 115 | @LIBCURL@ |
@@ -257,7 +257,7 @@ test_put_chunked_LDADD = \ | |||
257 | @LIBCURL@ | 257 | @LIBCURL@ |
258 | 258 | ||
259 | test_get11_SOURCES = \ | 259 | test_get11_SOURCES = \ |
260 | test_get.c mhd_has_in_name.h | 260 | test_get.c |
261 | test_get11_LDADD = \ | 261 | test_get11_LDADD = \ |
262 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ | 262 | $(top_builddir)/src/microhttpd/libmicrohttpd.la \ |
263 | @LIBCURL@ | 263 | @LIBCURL@ |
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c index 793a8f30..567b0787 100644 --- a/src/testcurl/test_get.c +++ b/src/testcurl/test_get.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <string.h> | 31 | #include <string.h> |
32 | #include <time.h> | 32 | #include <time.h> |
33 | #include "mhd_has_in_name.h" | 33 | #include "test_helpers.h" |
34 | #include "mhd_sockets.h" /* only macros used */ | 34 | #include "mhd_sockets.h" /* only macros used */ |
35 | 35 | ||
36 | 36 | ||
@@ -92,7 +92,7 @@ log_cb (void *cls, | |||
92 | fprintf (stderr, | 92 | fprintf (stderr, |
93 | "Wrong URI: `%s'\n", | 93 | "Wrong URI: `%s'\n", |
94 | uri); | 94 | uri); |
95 | abort (); | 95 | _exit (22); |
96 | } | 96 | } |
97 | return NULL; | 97 | return NULL; |
98 | } | 98 | } |
@@ -130,7 +130,11 @@ ahc_echo (void *cls, | |||
130 | if ( (NULL == v) || | 130 | if ( (NULL == v) || |
131 | (0 != strcmp ("&", | 131 | (0 != strcmp ("&", |
132 | v)) ) | 132 | v)) ) |
133 | abort (); | 133 | { |
134 | fprintf (stderr, "Found while looking for 'a=&': 'a=%s'\n", | ||
135 | NULL == v ? "NULL" : v); | ||
136 | _exit (17); | ||
137 | } | ||
134 | v = NULL; | 138 | v = NULL; |
135 | if (MHD_YES != MHD_lookup_connection_value_n (connection, | 139 | if (MHD_YES != MHD_lookup_connection_value_n (connection, |
136 | MHD_GET_ARGUMENT_KIND, | 140 | MHD_GET_ARGUMENT_KIND, |
@@ -138,11 +142,18 @@ ahc_echo (void *cls, | |||
138 | 1, | 142 | 1, |
139 | &v, | 143 | &v, |
140 | NULL)) | 144 | NULL)) |
141 | abort (); | 145 | { |
146 | fprintf (stderr, "Not found 'b' GET argument.\n"); | ||
147 | _exit (18); | ||
148 | } | ||
142 | if ( (NULL == v) || | 149 | if ( (NULL == v) || |
143 | (0 != strcmp ("c", | 150 | (0 != strcmp ("c", |
144 | v)) ) | 151 | v)) ) |
145 | abort (); | 152 | { |
153 | fprintf (stderr, "Found while looking for 'b=c': 'b=%s'\n", | ||
154 | NULL == v ? "NULL" : v); | ||
155 | _exit (19); | ||
156 | } | ||
146 | response = MHD_create_response_from_buffer (strlen (url), | 157 | response = MHD_create_response_from_buffer (strlen (url), |
147 | (void *) url, | 158 | (void *) url, |
148 | MHD_RESPMEM_MUST_COPY); | 159 | MHD_RESPMEM_MUST_COPY); |
@@ -151,7 +162,10 @@ ahc_echo (void *cls, | |||
151 | response); | 162 | response); |
152 | MHD_destroy_response (response); | 163 | MHD_destroy_response (response); |
153 | if (ret == MHD_NO) | 164 | if (ret == MHD_NO) |
154 | abort (); | 165 | { |
166 | fprintf (stderr, "Failed to queue response.\n"); | ||
167 | _exit (19); | ||
168 | } | ||
155 | return ret; | 169 | return ret; |
156 | } | 170 | } |
157 | 171 | ||
@@ -707,7 +721,10 @@ ahc_empty (void *cls, | |||
707 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 721 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
708 | MHD_destroy_response (response); | 722 | MHD_destroy_response (response); |
709 | if (ret == MHD_NO) | 723 | if (ret == MHD_NO) |
710 | abort (); | 724 | { |
725 | fprintf (stderr, "Failed to queue response.\n"); | ||
726 | _exit (20); | ||
727 | } | ||
711 | return ret; | 728 | return ret; |
712 | } | 729 | } |
713 | 730 | ||
@@ -805,44 +822,133 @@ int | |||
805 | main (int argc, char *const *argv) | 822 | main (int argc, char *const *argv) |
806 | { | 823 | { |
807 | unsigned int errorCount = 0; | 824 | unsigned int errorCount = 0; |
808 | (void) argc; /* Unused. Silence compiler warning. */ | 825 | unsigned int test_result = 0; |
826 | int verbose = 0; | ||
809 | 827 | ||
810 | if (NULL == argv || 0 == argv[0]) | 828 | if (NULL == argv || 0 == argv[0]) |
811 | return 99; | 829 | return 99; |
812 | oneone = has_in_name (argv[0], "11"); | 830 | oneone = has_in_name (argv[0], "11"); |
831 | verbose = has_param (argc, argv, "-v") || has_param (argc, argv, "--verbose"); | ||
813 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) | 832 | if (0 != curl_global_init (CURL_GLOBAL_WIN32)) |
814 | return 2; | 833 | return 2; |
815 | global_port = 0; | 834 | global_port = 0; |
816 | errorCount += testExternalGet (); | 835 | test_result = testExternalGet (); |
836 | if (test_result) | ||
837 | fprintf (stderr, "FAILED: testExternalGet () - %u.\n", test_result); | ||
838 | else if (verbose) | ||
839 | printf ("PASSED: testExternalGet ().\n"); | ||
840 | errorCount += test_result; | ||
817 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS)) | 841 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_THREADS)) |
818 | { | 842 | { |
819 | errorCount += testInternalGet (0); | 843 | test_result += testInternalGet (0); |
820 | errorCount += testMultithreadedGet (0); | 844 | if (test_result) |
821 | errorCount += testMultithreadedPoolGet (0); | 845 | fprintf (stderr, "FAILED: testInternalGet (0) - %u.\n", test_result); |
822 | errorCount += testUnknownPortGet (0); | 846 | else if (verbose) |
823 | errorCount += testStopRace (0); | 847 | printf ("PASSED: testInternalGet (0).\n"); |
824 | errorCount += testEmptyGet (0); | 848 | errorCount += test_result; |
849 | test_result += testMultithreadedGet (0); | ||
850 | if (test_result) | ||
851 | fprintf (stderr, "FAILED: testMultithreadedGet (0) - %u.\n", test_result); | ||
852 | else if (verbose) | ||
853 | printf ("PASSED: testMultithreadedGet (0).\n"); | ||
854 | errorCount += test_result; | ||
855 | test_result += testMultithreadedPoolGet (0); | ||
856 | if (test_result) | ||
857 | fprintf (stderr, "FAILED: testMultithreadedPoolGet (0) - %u.\n", test_result); | ||
858 | else if (verbose) | ||
859 | printf ("PASSED: testMultithreadedPoolGet (0).\n"); | ||
860 | errorCount += test_result; | ||
861 | test_result += testUnknownPortGet (0); | ||
862 | if (test_result) | ||
863 | fprintf (stderr, "FAILED: testUnknownPortGet (0) - %u.\n", test_result); | ||
864 | else if (verbose) | ||
865 | printf ("PASSED: testUnknownPortGet (0).\n"); | ||
866 | errorCount += test_result; | ||
867 | test_result += testStopRace (0); | ||
868 | if (test_result) | ||
869 | fprintf (stderr, "FAILED: testStopRace (0) - %u.\n", test_result); | ||
870 | else if (verbose) | ||
871 | printf ("PASSED: testStopRace (0).\n"); | ||
872 | errorCount += test_result; | ||
873 | test_result += testEmptyGet (0); | ||
874 | if (test_result) | ||
875 | fprintf (stderr, "FAILED: testEmptyGet (0) - %u.\n", test_result); | ||
876 | else if (verbose) | ||
877 | printf ("PASSED: testEmptyGet (0).\n"); | ||
878 | errorCount += test_result; | ||
825 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL)) | 879 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_POLL)) |
826 | { | 880 | { |
827 | errorCount += testInternalGet(MHD_USE_POLL); | 881 | test_result += testInternalGet(MHD_USE_POLL); |
828 | errorCount += testMultithreadedGet(MHD_USE_POLL); | 882 | if (test_result) |
829 | errorCount += testMultithreadedPoolGet(MHD_USE_POLL); | 883 | fprintf (stderr, "FAILED: testInternalGet (MHD_USE_POLL) - %u.\n", test_result); |
830 | errorCount += testUnknownPortGet(MHD_USE_POLL); | 884 | else if (verbose) |
831 | errorCount += testStopRace(MHD_USE_POLL); | 885 | printf ("PASSED: testInternalGet (MHD_USE_POLL).\n"); |
832 | errorCount += testEmptyGet(MHD_USE_POLL); | 886 | errorCount += test_result; |
887 | test_result += testMultithreadedGet(MHD_USE_POLL); | ||
888 | if (test_result) | ||
889 | fprintf (stderr, "FAILED: testMultithreadedGet (MHD_USE_POLL) - %u.\n", test_result); | ||
890 | else if (verbose) | ||
891 | printf ("PASSED: testMultithreadedGet (MHD_USE_POLL).\n"); | ||
892 | errorCount += test_result; | ||
893 | test_result += testMultithreadedPoolGet(MHD_USE_POLL); | ||
894 | if (test_result) | ||
895 | fprintf (stderr, "FAILED: testMultithreadedPoolGet (MHD_USE_POLL) - %u.\n", test_result); | ||
896 | else if (verbose) | ||
897 | printf ("PASSED: testMultithreadedPoolGet (MHD_USE_POLL).\n"); | ||
898 | errorCount += test_result; | ||
899 | test_result += testUnknownPortGet(MHD_USE_POLL); | ||
900 | if (test_result) | ||
901 | fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_POLL) - %u.\n", test_result); | ||
902 | else if (verbose) | ||
903 | printf ("PASSED: testUnknownPortGet (MHD_USE_POLL).\n"); | ||
904 | errorCount += test_result; | ||
905 | test_result += testStopRace(MHD_USE_POLL); | ||
906 | if (test_result) | ||
907 | fprintf (stderr, "FAILED: testStopRace (MHD_USE_POLL) - %u.\n", test_result); | ||
908 | else if (verbose) | ||
909 | printf ("PASSED: testStopRace (MHD_USE_POLL).\n"); | ||
910 | errorCount += test_result; | ||
911 | test_result += testEmptyGet(MHD_USE_POLL); | ||
912 | if (test_result) | ||
913 | fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_POLL) - %u.\n", test_result); | ||
914 | else if (verbose) | ||
915 | printf ("PASSED: testEmptyGet (MHD_USE_POLL).\n"); | ||
916 | errorCount += test_result; | ||
833 | } | 917 | } |
834 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL)) | 918 | if (MHD_YES == MHD_is_feature_supported(MHD_FEATURE_EPOLL)) |
835 | { | 919 | { |
836 | errorCount += testInternalGet(MHD_USE_EPOLL); | 920 | test_result += testInternalGet(MHD_USE_EPOLL); |
837 | errorCount += testMultithreadedPoolGet(MHD_USE_EPOLL); | 921 | if (test_result) |
838 | errorCount += testUnknownPortGet(MHD_USE_EPOLL); | 922 | fprintf (stderr, "FAILED: testInternalGet (MHD_USE_EPOLL) - %u.\n", test_result); |
839 | errorCount += testEmptyGet(MHD_USE_EPOLL); | 923 | else if (verbose) |
924 | printf ("PASSED: testInternalGet (MHD_USE_EPOLL).\n"); | ||
925 | errorCount += test_result; | ||
926 | test_result += testMultithreadedPoolGet(MHD_USE_EPOLL); | ||
927 | if (test_result) | ||
928 | fprintf (stderr, "FAILED: testMultithreadedPoolGet (MHD_USE_EPOLL) - %u.\n", test_result); | ||
929 | else if (verbose) | ||
930 | printf ("PASSED: testMultithreadedPoolGet (MHD_USE_EPOLL).\n"); | ||
931 | errorCount += test_result; | ||
932 | test_result += testUnknownPortGet(MHD_USE_EPOLL); | ||
933 | if (test_result) | ||
934 | fprintf (stderr, "FAILED: testUnknownPortGet (MHD_USE_EPOLL) - %u.\n", test_result); | ||
935 | else if (verbose) | ||
936 | printf ("PASSED: testUnknownPortGet (MHD_USE_EPOLL).\n"); | ||
937 | errorCount += test_result; | ||
938 | test_result += testEmptyGet(MHD_USE_EPOLL); | ||
939 | if (test_result) | ||
940 | fprintf (stderr, "FAILED: testEmptyGet (MHD_USE_EPOLL) - %u.\n", test_result); | ||
941 | else if (verbose) | ||
942 | printf ("PASSED: testEmptyGet (MHD_USE_EPOLL).\n"); | ||
943 | errorCount += test_result; | ||
840 | } | 944 | } |
841 | } | 945 | } |
842 | if (0 != errorCount) | 946 | if (0 != errorCount) |
843 | fprintf (stderr, | 947 | fprintf (stderr, |
844 | "Error (code: %u)\n", | 948 | "Error (code: %u)\n", |
845 | errorCount); | 949 | errorCount); |
950 | else if (verbose) | ||
951 | printf ("All tests passed.\n"); | ||
846 | curl_global_cleanup (); | 952 | curl_global_cleanup (); |
847 | return errorCount != 0; /* 0 == pass */ | 953 | return errorCount != 0; /* 0 == pass */ |
848 | } | 954 | } |