Add a test for d2i_AutoPrivateKey_ex with a non-default libctx
[openssl.git] / test / test_test.c
index 2610cbf9f29f8113cf5b4c4a37eac9f5311ccb20..35c612726ff6be7e0d8766d38e137458aba9849b 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright (c) 2017, Oracle and/or its affiliates.  All rights reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -191,6 +191,29 @@ err:
     return 0;
 }
 
+static int test_time_t(void)
+{
+    if (!TEST(1, TEST_time_t_eq((time_t)10, (time_t)10))
+        | !TEST(0, TEST_time_t_eq((time_t)10, (time_t)12))
+        | !TEST(1, TEST_time_t_ne((time_t)10, (time_t)12))
+        | !TEST(0, TEST_time_t_ne((time_t)24, (time_t)24))
+        | !TEST(1, TEST_time_t_lt((time_t)30, (time_t)88))
+        | !TEST(0, TEST_time_t_lt((time_t)88, (time_t)30))
+        | !TEST(1, TEST_time_t_le((time_t)30, (time_t)88))
+        | !TEST(1, TEST_time_t_le((time_t)33, (time_t)33))
+        | !TEST(0, TEST_time_t_le((time_t)88, (time_t)30))
+        | !TEST(1, TEST_time_t_gt((time_t)52, (time_t)33))
+        | !TEST(0, TEST_time_t_gt((time_t)33, (time_t)52))
+        | !TEST(1, TEST_time_t_ge((time_t)52, (time_t)33))
+        | !TEST(1, TEST_time_t_ge((time_t)38, (time_t)38))
+        | !TEST(0, TEST_time_t_ge((time_t)33, (time_t)52)))
+        goto err;
+    return 1;
+
+err:
+    return 0;
+}
+
 static int test_pointer(void)
 {
     int x = 0;
@@ -468,7 +491,7 @@ static int test_single_eval(void)
            && TEST_ptr_eq(p, buf + 1)
            && TEST_ptr_null(p = NULL)
            /* strings */
-           && TEST_str_eq(p = "123456" + 1, "23456")
+           && TEST_str_eq(p = &("123456"[1]), "23456")
            && TEST_str_eq("3456", ++p)
            && TEST_str_ne(p++, "456")
            /* memory */
@@ -508,6 +531,24 @@ static int test_bn_output(int n)
     return 1;
 }
 
+static int test_skip_one(void)
+{
+    return TEST_skip("skip test");
+}
+
+static int test_skip_many(int n)
+{
+    return TEST_skip("skip tests: %d", n);
+}
+
+static int test_skip_null(void)
+{
+    /*
+     * This is not a recommended way of skipping a test, a reason or
+     * description should be included.
+     */
+    return TEST_skip(NULL);
+}
 
 int setup_tests(void)
 {
@@ -518,6 +559,7 @@ int setup_tests(void)
     ADD_TEST(test_long);
     ADD_TEST(test_ulong);
     ADD_TEST(test_size_t);
+    ADD_TEST(test_time_t);
     ADD_TEST(test_pointer);
     ADD_TEST(test_bool);
     ADD_TEST(test_string);
@@ -530,5 +572,8 @@ int setup_tests(void)
     ADD_TEST(test_single_eval);
     ADD_TEST(test_output);
     ADD_ALL_TESTS(test_bn_output, OSSL_NELEM(bn_output_tests));
+    ADD_TEST(test_skip_one);
+    ADD_TEST(test_skip_null);
+    ADD_ALL_TESTS(test_skip_many, 3);
     return 1;
 }