SHA512/224 and SHA512/256
[openssl.git] / test / dtlstest.c
index b766802148cae75f3850c4d127ec5891e6fe2524..7e511f7d6f9e7484cc587003ceab5bfc98e0000f 100644 (file)
@@ -17,6 +17,7 @@
 
 static char *cert = NULL;
 static char *privkey = NULL;
+static unsigned int timer_cb_count;
 
 #define NUM_TESTS   2
 
@@ -40,6 +41,16 @@ static unsigned char certstatus[] = {
 
 #define RECORD_SEQUENCE 10
 
+static unsigned int timer_cb(SSL *s, unsigned int timer_us)
+{
+    ++timer_cb_count;
+
+    if (timer_us == 0)
+        return 1000000;
+    else
+        return 2 * timer_us;
+}
+
 static int test_dtls_unprocessed(int testidx)
 {
     SSL_CTX *sctx = NULL, *cctx = NULL;
@@ -47,6 +58,8 @@ static int test_dtls_unprocessed(int testidx)
     BIO *c_to_s_fbio, *c_to_s_mempacket;
     int testresult = 0;
 
+    timer_cb_count = 0;
+
     if (!TEST_true(create_ssl_ctx_pair(DTLS_server_method(),
                                        DTLS_client_method(), &sctx,
                                        &cctx, cert, privkey)))
@@ -64,6 +77,8 @@ static int test_dtls_unprocessed(int testidx)
                                       NULL, c_to_s_fbio)))
         goto end;
 
+    DTLS_set_timer_cb(clientssl1, timer_cb);
+
     if (testidx == 1)
         certstatus[RECORD_SEQUENCE] = 0xff;
 
@@ -83,6 +98,11 @@ static int test_dtls_unprocessed(int testidx)
                                          SSL_ERROR_NONE)))
         goto end;
 
+    if (timer_cb_count == 0) {
+        printf("timer_callback was not called.\n");
+        goto end;
+    }
+
     testresult = 1;
  end:
     SSL_free(serverssl1);
@@ -93,22 +113,18 @@ static int test_dtls_unprocessed(int testidx)
     return testresult;
 }
 
-int test_main(int argc, char *argv[])
+int setup_tests(void)
 {
-    int testresult = 1;
-
-    if (!TEST_int_eq(argc, 3))
-        return 1;
-
-    cert = argv[1];
-    privkey = argv[2];
+    if (!TEST_ptr(cert = test_get_argument(0))
+            || !TEST_ptr(privkey = test_get_argument(1)))
+        return 0;
 
     ADD_ALL_TESTS(test_dtls_unprocessed, NUM_TESTS);
+    return 1;
+}
 
-    testresult = run_tests(argv[0]);
-
+void cleanup_tests(void)
+{
     bio_f_tls_dump_filter_free();
     bio_s_mempacket_test_free();
-
-    return testresult;
 }