]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
tests: clear error queue before executing a testcase
authorTomas Mraz <tomas@openssl.org>
Mon, 24 Oct 2022 10:28:58 +0000 (12:28 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 27 Oct 2022 16:39:29 +0000 (18:39 +0200)
There can be errors in the queue from previous tests and
we look at it to verify we do not add spurious errors in
some testcases.

Fixes #19477

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19483)

(cherry picked from commit 4bae06d47ae26b37a948d31f11884e1813f6d669)

test/cmsapitest.c
test/recordlentest.c
test/sslcorrupttest.c
test/testutil/driver.c

index 8187fec76158bd828658892ca5ec17751590e88f..ee08c0c97452a5c5ff14b6ded4138e381ba7c51b 100644 (file)
@@ -340,8 +340,6 @@ static int test_d2i_CMS_decode(const int idx)
     long buf_len = 0;
     int ret = 0;
 
-    ERR_clear_error();
-
     if (!TEST_ptr(bio = BIO_new_file(derin, "r")))
       goto end;
 
index 8567964ce17ace04da2e05c5399df13beff3ce05..c693b089139f481ad523f44013346cb8b4d201e9 100644 (file)
@@ -101,8 +101,6 @@ static int test_record_overflow(int idx)
         return 1;
 #endif
 
-    ERR_clear_error();
-
     if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
                                        TLS_client_method(),
                                        TLS1_VERSION, 0,
index 57ce2a8a8ef49753240c2ce4f222ec85ef6aa5a9..50c3bf7eebaeddc3d6d8e8f3c1c7bd179bf04a96 100644 (file)
@@ -192,8 +192,6 @@ static int test_ssl_corrupt(int testidx)
 
     docorrupt = 0;
 
-    ERR_clear_error();
-
     TEST_info("Starting #%d, %s", testidx, cipher_list[testidx]);
 
     if (!TEST_true(create_ssl_ctx_pair(NULL, TLS_server_method(),
index efb5785d7d2a1621fdcada886136cbbb30317833..6427d235af20e919bfe1fcc6880d2425b86abae3 100644 (file)
@@ -331,6 +331,7 @@ int run_tests(const char *test_prog_name)
             test_flush_tapout();
         } else if (all_tests[i].num == -1) {
             set_test_title(all_tests[i].test_case_name);
+            ERR_clear_error();
             verdict = all_tests[i].test_fn();
             finalize(verdict != 0);
             test_verdict(verdict, "%d - %s", test_case_count + 1, test_title);
@@ -365,6 +366,7 @@ int run_tests(const char *test_prog_name)
                 j = (j + jstep) % all_tests[i].num;
                 if (single_iter != -1 && ((jj + 1) != single_iter))
                     continue;
+                ERR_clear_error();
                 v = all_tests[i].param_test_fn(j);
 
                 if (v == 0) {