summaryrefslogtreecommitdiff
path: root/tests/mini-eagain.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2011-04-04 22:02:27 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2011-04-04 22:02:27 +0200
commitef11a5ad23c899f1b739b02aabe983238a9773f2 (patch)
tree5aa0050c9505e020f9ef3d38131d7ffc518e4807 /tests/mini-eagain.c
parentca41fc31917d97f4a6b9aa8323a1317c1657d9af (diff)
downloadgnutls-ef11a5ad23c899f1b739b02aabe983238a9773f2.tar.gz
The mini-* programs were combined.
Diffstat (limited to 'tests/mini-eagain.c')
-rw-r--r--tests/mini-eagain.c105
1 files changed, 4 insertions, 101 deletions
diff --git a/tests/mini-eagain.c b/tests/mini-eagain.c
index 3b2ea2951c..78314f0365 100644
--- a/tests/mini-eagain.c
+++ b/tests/mini-eagain.c
@@ -32,6 +32,7 @@
#include <gnutls/crypto.h>
#include "utils.h"
+#define RANDOMIZE
#include "eagain-common.h"
static void
@@ -93,112 +94,14 @@ doit (void)
gnutls_transport_set_pull_function (client, client_pull);
handshake = 1;
- sret = cret = GNUTLS_E_AGAIN;
- do
- {
- if (cret == GNUTLS_E_AGAIN)
- {
- //success ("loop invoking client:\n");
- cret = gnutls_handshake (client);
- //success ("client %d: %s\n", cret, gnutls_strerror (cret));
- }
-
- if (sret == GNUTLS_E_AGAIN)
- {
- //success ("loop invoking server:\n");
- sret = gnutls_handshake (server);
- //success ("server %d: %s\n", sret, gnutls_strerror (sret));
- }
- }
- while (cret == GNUTLS_E_AGAIN || sret == GNUTLS_E_AGAIN);
-
- if (cret < 0 || sret < 0)
- {
- fprintf(stderr, "client: %s\n", gnutls_strerror(cret));
- fprintf(stderr, "server: %s\n", gnutls_strerror(sret));
- fail("Handshake failed\n");
- exit(1);
- }
+ HANDSHAKE(client, server);
handshake = 0;
if (debug)
success ("Handshake established\n");
- do
- {
- ret = gnutls_record_send (client, MSG, strlen (MSG));
- }
- while(ret == GNUTLS_E_AGAIN);
- //success ("client: sent %d\n", ns);
-
- do
- {
- //success("transferred: %d\n", transferred);
-
- do
- {
- ret = gnutls_record_recv (server, buffer, MAX_BUF);
- }
- while(ret == GNUTLS_E_AGAIN);
-
- if (ret == 0)
- fail ("server: didn't receive any data\n");
- else if (ret < 0)
- {
- // if (debug)
- // fputs ("#", stdout);
- fail ("server: error: %s\n", gnutls_strerror (ret));
- }
- else
- {
- transferred += ret;
- // if (debug)
- // fputs ("*", stdout);
- }
-
- msglen = strlen (MSG);
- do
- {
- ns = gnutls_record_send (server, MSG, msglen);
- }
- while (ns == GNUTLS_E_AGAIN);
-
- do
- {
- ret = gnutls_record_recv (client, buffer, MAX_BUF);
- }
- while(ret == GNUTLS_E_AGAIN);
-
- if (ret == 0)
- {
- fail ("client: Peer has closed the TLS connection\n");
- }
- else if (ret < 0)
- {
- if (debug)
- fputs ("!", stdout);
- fail ("client: Error: %s\n", gnutls_strerror (ret));
- }
- else
- {
- if (msglen != ret || memcmp (buffer, MSG, msglen) != 0)
- {
- fail ("client: Transmitted data do not match\n");
- }
-
- /* echo back */
- do
- {
- ns = gnutls_record_send (client, buffer, msglen);
- }
- while (ns == GNUTLS_E_AGAIN);
-
- transferred += ret;
- if (debug)
- fputs (".", stdout);
- }
- }
- while (transferred < 70000);
+ msglen = strlen(MSG);
+ TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
if (debug)
fputs ("\n", stdout);