mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
minor bugfixes in testcases
This commit is contained in:
@@ -147,22 +147,19 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
|
||||
if (NULL == (doc_path = malloc (doc_path_len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
return -1;
|
||||
}
|
||||
if (getcwd (doc_path, doc_path_len) == NULL)
|
||||
{
|
||||
fclose (test_fd);
|
||||
free (doc_path);
|
||||
fprintf (stderr, "Error: failed to get working directory. %s\n",
|
||||
strerror (errno));
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NULL == (mem_test_file_local = malloc (len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
return -1;
|
||||
}
|
||||
@@ -170,15 +167,17 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
fseek (test_fd, 0, SEEK_SET);
|
||||
if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
|
||||
{
|
||||
fclose (test_fd);
|
||||
free (mem_test_file_local);
|
||||
free (doc_path);
|
||||
fprintf (stderr, "Error: failed to read test file. %s\n",
|
||||
strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
|
||||
if (NULL == (cbc.buf = malloc (len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
free (mem_test_file_local);
|
||||
free (doc_path);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
return -1;
|
||||
}
|
||||
@@ -219,6 +218,9 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
fprintf (stderr, "curl_easy_perform failed: `%s'\n",
|
||||
curl_easy_strerror (errornum));
|
||||
curl_easy_cleanup (c);
|
||||
free (mem_test_file_local);
|
||||
free (doc_path);
|
||||
free (cbc.buf);
|
||||
return errornum;
|
||||
}
|
||||
|
||||
@@ -229,6 +231,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
fprintf (stderr, "Error: local file & received file differ.\n");
|
||||
free (cbc.buf);
|
||||
free (mem_test_file_local);
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -281,12 +284,14 @@ setupTestFile ()
|
||||
{
|
||||
fprintf (stderr, "Error: failed to write `%s. %s'\n",
|
||||
test_file_name, strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
if (fflush (test_fd))
|
||||
{
|
||||
fprintf (stderr, "Error: failed to flush test file stream. %s\n",
|
||||
strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -341,6 +346,7 @@ main (int argc, char *const *argv)
|
||||
if (0 != curl_global_init (CURL_GLOBAL_ALL))
|
||||
{
|
||||
fprintf (stderr, "Error: %s\n", strerror (errno));
|
||||
fclose (test_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,13 +143,11 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version,
|
||||
doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
|
||||
if (NULL == (doc_path = malloc (doc_path_len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
return -1;
|
||||
}
|
||||
if (getcwd (doc_path, doc_path_len) == NULL)
|
||||
{
|
||||
fclose (test_fd);
|
||||
free (doc_path);
|
||||
fprintf (stderr, "Error: failed to get working directory. %s\n",
|
||||
strerror (errno));
|
||||
@@ -160,7 +158,6 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version,
|
||||
fseek (test_fd, 0, SEEK_SET);
|
||||
if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, "Error: failed to read test file. %s\n",
|
||||
strerror (errno));
|
||||
return -1;
|
||||
@@ -168,7 +165,6 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version,
|
||||
|
||||
if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, "Error: failed to read test file. %s\n",
|
||||
strerror (errno));
|
||||
return -1;
|
||||
@@ -294,12 +290,14 @@ setupTestFile ()
|
||||
{
|
||||
fprintf (stderr, "Error: failed to write `%s. %s'\n",
|
||||
test_file_name, strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
if (fflush (test_fd))
|
||||
{
|
||||
fprintf (stderr, "Error: failed to flush test file stream. %s\n",
|
||||
strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -327,6 +325,7 @@ main (int argc, char *const *argv)
|
||||
{
|
||||
fprintf (stderr, "Error (code: %u). l:%d f:%s\n", errorCount, __LINE__,
|
||||
__FUNCTION__);
|
||||
fclose (test_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ setup (MHD_gtls_session_t * session,
|
||||
MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred)
|
||||
{
|
||||
int ret;
|
||||
const char **err_pos;
|
||||
const char *err_pos;
|
||||
|
||||
MHD__gnutls_certificate_allocate_credentials (xcred);
|
||||
|
||||
@@ -74,7 +74,7 @@ setup (MHD_gtls_session_t * session,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
|
||||
MHD__gnutls_init (session, GNUTLS_CLIENT);
|
||||
ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos);
|
||||
ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", &err_pos);
|
||||
if (ret < 0)
|
||||
{
|
||||
return -1;
|
||||
@@ -112,6 +112,13 @@ test_alert_close_notify (MHD_gtls_session_t session)
|
||||
struct sockaddr_in sa;
|
||||
|
||||
sd = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sd == -1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Failed to create socket: %s\n",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
memset (&sa, '\0', sizeof (struct sockaddr_in));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons (42433);
|
||||
@@ -161,6 +168,13 @@ test_alert_unexpected_message (MHD_gtls_session_t session)
|
||||
struct sockaddr_in sa;
|
||||
|
||||
sd = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sd == -1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Failed to create socket: %s\n",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
memset (&sa, '\0', sizeof (struct sockaddr_in));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons (42433);
|
||||
|
||||
@@ -144,39 +144,39 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
|
||||
if (NULL == (doc_path = malloc (doc_path_len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
return -1;
|
||||
}
|
||||
if (getcwd (doc_path, doc_path_len) == NULL)
|
||||
{
|
||||
fclose (test_fd);
|
||||
free (doc_path);
|
||||
fprintf (stderr, "Error: failed to get working directory. %s\n",
|
||||
strerror (errno));
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NULL == (mem_test_file_local = malloc (len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fseek (test_fd, 0, SEEK_SET);
|
||||
if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, "Error: failed to read test file. %s\n",
|
||||
strerror (errno));
|
||||
free (doc_path);
|
||||
free (mem_test_file_local);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
free (doc_path);
|
||||
free (mem_test_file_local);
|
||||
return -1;
|
||||
}
|
||||
cbc.size = len;
|
||||
@@ -218,6 +218,9 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
fprintf (stderr, "curl_easy_perform failed: `%s'\n",
|
||||
curl_easy_strerror (errornum));
|
||||
curl_easy_cleanup (c);
|
||||
free (cbc.buf);
|
||||
free (doc_path);
|
||||
free (mem_test_file_local);
|
||||
return errornum;
|
||||
}
|
||||
|
||||
@@ -228,6 +231,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
fprintf (stderr, "Error: local file & received file differ.\n");
|
||||
free (cbc.buf);
|
||||
free (mem_test_file_local);
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -308,12 +312,14 @@ setup_ca_cert ()
|
||||
{
|
||||
fprintf (stderr, "Error: failed to write `%s. %s'\n",
|
||||
ca_cert_file_name, strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
if (fflush (fd))
|
||||
{
|
||||
fprintf (stderr, "Error: failed to flush ca cert file stream. %s\n",
|
||||
strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -342,6 +348,7 @@ main (int argc, char *const *argv)
|
||||
if (0 != curl_global_init (CURL_GLOBAL_ALL))
|
||||
{
|
||||
fprintf (stderr, "Error (code: %u)\n", errorCount);
|
||||
fclose (test_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ setup (MHD_gtls_session_t * session,
|
||||
MHD_gnutls_datum_t * cert, MHD_gtls_cert_credentials_t * xcred)
|
||||
{
|
||||
int ret;
|
||||
const char **err_pos;
|
||||
const char *err_pos;
|
||||
|
||||
MHD__gnutls_certificate_allocate_credentials (xcred);
|
||||
|
||||
@@ -76,7 +76,7 @@ setup (MHD_gtls_session_t * session,
|
||||
GNUTLS_X509_FMT_PEM);
|
||||
|
||||
MHD__gnutls_init (session, GNUTLS_CLIENT);
|
||||
ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", err_pos);
|
||||
ret = MHD__gnutls_priority_set_direct (*session, "NORMAL", &err_pos);
|
||||
if (ret < 0)
|
||||
{
|
||||
return -1;
|
||||
@@ -116,6 +116,13 @@ test_out_of_context_cipher_change (MHD_gtls_session_t session)
|
||||
struct sockaddr_in sa;
|
||||
|
||||
sd = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sd == -1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Failed to create socket: %s\n",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
memset (&sa, '\0', sizeof (struct sockaddr_in));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons (42433);
|
||||
|
||||
@@ -160,39 +160,37 @@ test_https_transfer (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
|
||||
if (NULL == (doc_path = malloc (doc_path_len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
return -1;
|
||||
}
|
||||
if (getcwd (doc_path, doc_path_len) == NULL)
|
||||
{
|
||||
fclose (test_fd);
|
||||
free (doc_path);
|
||||
fprintf (stderr, "Error: failed to get working directory. %s\n",
|
||||
strerror (errno));
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NULL == (mem_test_file_local = malloc (len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
fseek (test_fd, 0, SEEK_SET);
|
||||
if (fread (mem_test_file_local, sizeof (char), len, test_fd) != len)
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, "Error: failed to read test file. %s\n",
|
||||
strerror (errno));
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
|
||||
{
|
||||
fclose (test_fd);
|
||||
fprintf (stderr, MHD_E_MEM);
|
||||
free (doc_path);
|
||||
return -1;
|
||||
}
|
||||
cbc.size = len;
|
||||
@@ -267,12 +265,14 @@ setupTestFile ()
|
||||
{
|
||||
fprintf (stderr, "Error: failed to write `%s. %s'\n",
|
||||
test_file_name, strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
if (fflush (test_fd))
|
||||
{
|
||||
fprintf (stderr, "Error: failed to flush test file stream. %s\n",
|
||||
strerror (errno));
|
||||
fclose (test_fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -406,6 +406,7 @@ main (int argc, char *const *argv)
|
||||
if (0 != curl_global_init (CURL_GLOBAL_ALL))
|
||||
{
|
||||
fprintf (stderr, "Error: %s\n", strerror (errno));
|
||||
fclose (test_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,7 @@ test_https_transfer (FILE * test_fd, char *cipher_suite, int proto_version)
|
||||
{
|
||||
fclose (test_fd);
|
||||
free (doc_path);
|
||||
free (mem_test_file_local);
|
||||
fprintf (stderr, "Error: failed to read test file. %s\n",
|
||||
strerror (errno));
|
||||
return -1;
|
||||
|
||||
@@ -103,6 +103,13 @@ test_tls_session_time_out (MHD_gtls_session_t session)
|
||||
struct sockaddr_in sa;
|
||||
|
||||
sd = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sd == -1)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Failed to create socket: %s\n",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
memset (&sa, '\0', sizeof (struct sockaddr_in));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons (42433);
|
||||
|
||||
Reference in New Issue
Block a user