aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/testcurl/https/Makefile.am2
-rw-r--r--src/testcurl/https/daemon_https_test_get.c29
2 files changed, 18 insertions, 13 deletions
diff --git a/src/testcurl/https/Makefile.am b/src/testcurl/https/Makefile.am
index 22bc4e88..bc4599c6 100644
--- a/src/testcurl/https/Makefile.am
+++ b/src/testcurl/https/Makefile.am
@@ -4,7 +4,7 @@ AM_CPPFLAGS = -ggdb \
4-I$(top_srcdir)/src/daemon \ 4-I$(top_srcdir)/src/daemon \
5-I$(top_srcdir)/src/include 5-I$(top_srcdir)/src/include
6 6
7noinst_PROGRAMS = \ 7check_PROGRAMS = \
8 daemon_https_test_get 8 daemon_https_test_get
9 9
10TESTS = $(check_PROGRAMS) 10TESTS = $(check_PROGRAMS)
diff --git a/src/testcurl/https/daemon_https_test_get.c b/src/testcurl/https/daemon_https_test_get.c
index c1d23dd3..fa160d24 100644
--- a/src/testcurl/https/daemon_https_test_get.c
+++ b/src/testcurl/https/daemon_https_test_get.c
@@ -157,7 +157,7 @@ test_HTTPS_Get ()
157 char url[255]; 157 char url[255];
158 char **file_path; 158 char **file_path;
159 /* currently use hard coded certificate as test file - consider better alternatives */ 159 /* currently use hard coded certificate as test file - consider better alternatives */
160 char *test_file_name = "cert.pem"; 160 const char *test_file_name = "cert.pem";
161 struct stat test_file_stat; 161 struct stat test_file_stat;
162 int key_file, cert_file, test_file; 162 int key_file, cert_file, test_file;
163 163
@@ -170,11 +170,18 @@ test_HTTPS_Get ()
170 test_file = open (test_file_name, O_RDONLY); 170 test_file = open (test_file_name, O_RDONLY);
171 if (!test_file) 171 if (!test_file)
172 { 172 {
173 fprintf (stderr, "Error : failed to open test_file. errno:%d\n", errno); 173 fprintf (stderr, "Error: failed to open `%s': %s\n",
174 test_file_name,
175 strerror(errno));
174 return 1; 176 return 1;
175 } 177 }
176 if (stat (test_file_name, &test_file_stat) == -1) 178 if (stat (test_file_name, &test_file_stat) == -1)
177 return 1; 179 {
180 fprintf (stderr, "Error: failed to stat `%s': %s\n",
181 test_file_name,
182 strerror(errno));
183 return 2;
184 }
178 mem_test_file_local = malloc (sizeof (char) * test_file_stat.st_size); 185 mem_test_file_local = malloc (sizeof (char) * test_file_stat.st_size);
179 if (read (test_file, mem_test_file_local, test_file_stat.st_size) 186 if (read (test_file, mem_test_file_local, test_file_stat.st_size)
180 != test_file_stat.st_size) 187 != test_file_stat.st_size)
@@ -182,12 +189,12 @@ test_HTTPS_Get ()
182 close (test_file); 189 close (test_file);
183 fprintf (stderr, "Error: failed to read test file\n", 190 fprintf (stderr, "Error: failed to read test file\n",
184 curl_easy_strerror (errornum)); 191 curl_easy_strerror (errornum));
185 return 1; 192 return 4;
186 } 193 }
187 close (test_file); 194 close (test_file);
188 195
189 if (NULL == (cbc.buf = malloc (sizeof (char) * test_file_stat.st_size))) 196 if (NULL == (cbc.buf = malloc (sizeof (char) * test_file_stat.st_size)))
190 return 1; 197 return 8;
191 cbc.size = test_file_stat.st_size; 198 cbc.size = test_file_stat.st_size;
192 cbc.pos = 0; 199 cbc.pos = 0;
193 200
@@ -198,7 +205,7 @@ test_HTTPS_Get ()
198 MHD_OPTION_HTTPS_MEM_CERT, cert_pem, MHD_OPTION_END); 205 MHD_OPTION_HTTPS_MEM_CERT, cert_pem, MHD_OPTION_END);
199 206
200 if (d == NULL) 207 if (d == NULL)
201 return 1; 208 return 16;
202 209
203 /* construct url - this might use doc_path */ 210 /* construct url - this might use doc_path */
204 sprintf (url, "%s%s/%s", "https://localhost:42433", doc_path, 211 sprintf (url, "%s%s/%s", "https://localhost:42433", doc_path,
@@ -230,8 +237,8 @@ test_HTTPS_Get ()
230 fprintf (stderr, "curl_easy_perform failed: `%s'\n", 237 fprintf (stderr, "curl_easy_perform failed: `%s'\n",
231 curl_easy_strerror (errornum)); 238 curl_easy_strerror (errornum));
232 curl_easy_cleanup (c); 239 curl_easy_cleanup (c);
233 //MHD_stop_daemon (d); 240 MHD_stop_daemon (d);
234 return 2; 241 return 32;
235 } 242 }
236 243
237 curl_easy_cleanup (c); 244 curl_easy_cleanup (c);
@@ -240,7 +247,7 @@ test_HTTPS_Get ()
240 if (memcmp (cbc.buf, mem_test_file_local, test_file_stat.st_size) != 0) 247 if (memcmp (cbc.buf, mem_test_file_local, test_file_stat.st_size) != 0)
241 { 248 {
242 // TODO find proper error code 249 // TODO find proper error code
243 return 1; 250 return 64;
244 } 251 }
245 return 0; 252 return 0;
246} 253}
@@ -260,8 +267,6 @@ main (int argc, char *const *argv)
260 errorCount += test_HTTPS_Get (); 267 errorCount += test_HTTPS_Get ();
261 if (errorCount != 0) 268 if (errorCount != 0)
262 fprintf (stderr, "Error (code: %u)\n", errorCount); 269 fprintf (stderr, "Error (code: %u)\n", errorCount);
263 else
264 fprintf (stdout, "looks ok\n", errorCount);
265 curl_global_cleanup (); 270 curl_global_cleanup ();
266 return errorCount == 0; /* 0 == pass */ 271 return errorCount != 0;
267} 272}