1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#include <string.h> 11e1051a39Sopenharmony_ci#include <openssl/opensslconf.h> 12e1051a39Sopenharmony_ci#include <openssl/err.h> 13e1051a39Sopenharmony_ci#include <openssl/macros.h> 14e1051a39Sopenharmony_ci 15e1051a39Sopenharmony_ci#include "testutil.h" 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_ci#if defined(OPENSSL_SYS_WINDOWS) 18e1051a39Sopenharmony_ci# include <windows.h> 19e1051a39Sopenharmony_ci#else 20e1051a39Sopenharmony_ci# include <errno.h> 21e1051a39Sopenharmony_ci#endif 22e1051a39Sopenharmony_ci 23e1051a39Sopenharmony_ci#ifndef OPENSSL_NO_DEPRECATED_3_0 24e1051a39Sopenharmony_ci# define IS_HEX(ch) ((ch >= '0' && ch <='9') || (ch >= 'A' && ch <='F')) 25e1051a39Sopenharmony_ci 26e1051a39Sopenharmony_cistatic int test_print_error_format(void) 27e1051a39Sopenharmony_ci{ 28e1051a39Sopenharmony_ci /* Variables used to construct an error line */ 29e1051a39Sopenharmony_ci char *lib; 30e1051a39Sopenharmony_ci const char *func = OPENSSL_FUNC; 31e1051a39Sopenharmony_ci char *reason; 32e1051a39Sopenharmony_ci# ifdef OPENSSL_NO_ERR 33e1051a39Sopenharmony_ci char reasonbuf[255]; 34e1051a39Sopenharmony_ci# endif 35e1051a39Sopenharmony_ci# ifndef OPENSSL_NO_FILENAMES 36e1051a39Sopenharmony_ci const char *file = OPENSSL_FILE; 37e1051a39Sopenharmony_ci const int line = OPENSSL_LINE; 38e1051a39Sopenharmony_ci# else 39e1051a39Sopenharmony_ci const char *file = ""; 40e1051a39Sopenharmony_ci const int line = 0; 41e1051a39Sopenharmony_ci# endif 42e1051a39Sopenharmony_ci /* The format for OpenSSL error lines */ 43e1051a39Sopenharmony_ci const char *expected_format = ":error:%08lX:%s:%s:%s:%s:%d"; 44e1051a39Sopenharmony_ci /*- 45e1051a39Sopenharmony_ci * ^^ ^^ ^^ ^^ ^^ 46e1051a39Sopenharmony_ci * "library" name --------------------------++ || || || || 47e1051a39Sopenharmony_ci * function name ------------------------------++ || || || 48e1051a39Sopenharmony_ci * reason string (system error string) -----------++ || || 49e1051a39Sopenharmony_ci * file name ----------------------------------------++ || 50e1051a39Sopenharmony_ci * line number -----------------------------------------++ 51e1051a39Sopenharmony_ci */ 52e1051a39Sopenharmony_ci char expected[512]; 53e1051a39Sopenharmony_ci 54e1051a39Sopenharmony_ci char *out = NULL, *p = NULL; 55e1051a39Sopenharmony_ci int ret = 0, len; 56e1051a39Sopenharmony_ci BIO *bio = NULL; 57e1051a39Sopenharmony_ci const int syserr = EPERM; 58e1051a39Sopenharmony_ci unsigned long errorcode; 59e1051a39Sopenharmony_ci unsigned long reasoncode; 60e1051a39Sopenharmony_ci 61e1051a39Sopenharmony_ci /* 62e1051a39Sopenharmony_ci * We set a mark here so we can clear the system error that we generate 63e1051a39Sopenharmony_ci * with ERR_PUT_error(). That is, after all, just a simulation to verify 64e1051a39Sopenharmony_ci * ERR_print_errors() output, not a real error. 65e1051a39Sopenharmony_ci */ 66e1051a39Sopenharmony_ci ERR_set_mark(); 67e1051a39Sopenharmony_ci 68e1051a39Sopenharmony_ci ERR_PUT_error(ERR_LIB_SYS, 0, syserr, file, line); 69e1051a39Sopenharmony_ci errorcode = ERR_peek_error(); 70e1051a39Sopenharmony_ci reasoncode = ERR_GET_REASON(errorcode); 71e1051a39Sopenharmony_ci 72e1051a39Sopenharmony_ci if (!TEST_int_eq(reasoncode, syserr)) { 73e1051a39Sopenharmony_ci ERR_pop_to_mark(); 74e1051a39Sopenharmony_ci goto err; 75e1051a39Sopenharmony_ci } 76e1051a39Sopenharmony_ci 77e1051a39Sopenharmony_ci# if !defined(OPENSSL_NO_ERR) 78e1051a39Sopenharmony_ci# if defined(OPENSSL_NO_AUTOERRINIT) 79e1051a39Sopenharmony_ci lib = "lib(2)"; 80e1051a39Sopenharmony_ci# else 81e1051a39Sopenharmony_ci lib = "system library"; 82e1051a39Sopenharmony_ci# endif 83e1051a39Sopenharmony_ci reason = strerror(syserr); 84e1051a39Sopenharmony_ci# else 85e1051a39Sopenharmony_ci lib = "lib(2)"; 86e1051a39Sopenharmony_ci BIO_snprintf(reasonbuf, sizeof(reasonbuf), "reason(%lu)", reasoncode); 87e1051a39Sopenharmony_ci reason = reasonbuf; 88e1051a39Sopenharmony_ci# endif 89e1051a39Sopenharmony_ci 90e1051a39Sopenharmony_ci BIO_snprintf(expected, sizeof(expected), expected_format, 91e1051a39Sopenharmony_ci errorcode, lib, func, reason, file, line); 92e1051a39Sopenharmony_ci 93e1051a39Sopenharmony_ci if (!TEST_ptr(bio = BIO_new(BIO_s_mem()))) 94e1051a39Sopenharmony_ci goto err; 95e1051a39Sopenharmony_ci 96e1051a39Sopenharmony_ci ERR_print_errors(bio); 97e1051a39Sopenharmony_ci 98e1051a39Sopenharmony_ci if (!TEST_int_gt(len = BIO_get_mem_data(bio, &out), 0)) 99e1051a39Sopenharmony_ci goto err; 100e1051a39Sopenharmony_ci /* Skip over the variable thread id at the start of the string */ 101e1051a39Sopenharmony_ci for (p = out; *p != ':' && *p != 0; ++p) { 102e1051a39Sopenharmony_ci if (!TEST_true(IS_HEX(*p))) 103e1051a39Sopenharmony_ci goto err; 104e1051a39Sopenharmony_ci } 105e1051a39Sopenharmony_ci if (!TEST_true(*p != 0) 106e1051a39Sopenharmony_ci || !TEST_strn_eq(expected, p, strlen(expected))) 107e1051a39Sopenharmony_ci goto err; 108e1051a39Sopenharmony_ci 109e1051a39Sopenharmony_ci ret = 1; 110e1051a39Sopenharmony_cierr: 111e1051a39Sopenharmony_ci BIO_free(bio); 112e1051a39Sopenharmony_ci return ret; 113e1051a39Sopenharmony_ci} 114e1051a39Sopenharmony_ci#endif 115e1051a39Sopenharmony_ci 116e1051a39Sopenharmony_ci/* Test that querying the error queue preserves the OS error. */ 117e1051a39Sopenharmony_cistatic int preserves_system_error(void) 118e1051a39Sopenharmony_ci{ 119e1051a39Sopenharmony_ci#if defined(OPENSSL_SYS_WINDOWS) 120e1051a39Sopenharmony_ci SetLastError(ERROR_INVALID_FUNCTION); 121e1051a39Sopenharmony_ci ERR_get_error(); 122e1051a39Sopenharmony_ci return TEST_int_eq(GetLastError(), ERROR_INVALID_FUNCTION); 123e1051a39Sopenharmony_ci#else 124e1051a39Sopenharmony_ci errno = EINVAL; 125e1051a39Sopenharmony_ci ERR_get_error(); 126e1051a39Sopenharmony_ci return TEST_int_eq(errno, EINVAL); 127e1051a39Sopenharmony_ci#endif 128e1051a39Sopenharmony_ci} 129e1051a39Sopenharmony_ci 130e1051a39Sopenharmony_ci/* Test that calls to ERR_add_error_[v]data append */ 131e1051a39Sopenharmony_cistatic int vdata_appends(void) 132e1051a39Sopenharmony_ci{ 133e1051a39Sopenharmony_ci const char *data; 134e1051a39Sopenharmony_ci 135e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE); 136e1051a39Sopenharmony_ci ERR_add_error_data(1, "hello "); 137e1051a39Sopenharmony_ci ERR_add_error_data(1, "world"); 138e1051a39Sopenharmony_ci ERR_peek_error_data(&data, NULL); 139e1051a39Sopenharmony_ci return TEST_str_eq(data, "hello world"); 140e1051a39Sopenharmony_ci} 141e1051a39Sopenharmony_ci 142e1051a39Sopenharmony_cistatic int raised_error(void) 143e1051a39Sopenharmony_ci{ 144e1051a39Sopenharmony_ci const char *f, *data; 145e1051a39Sopenharmony_ci int l; 146e1051a39Sopenharmony_ci unsigned long e; 147e1051a39Sopenharmony_ci 148e1051a39Sopenharmony_ci /* 149e1051a39Sopenharmony_ci * When OPENSSL_NO_ERR or OPENSSL_NO_FILENAMES, no file name or line 150e1051a39Sopenharmony_ci * number is saved, so no point checking them. 151e1051a39Sopenharmony_ci */ 152e1051a39Sopenharmony_ci#if !defined(OPENSSL_NO_FILENAMES) && !defined(OPENSSL_NO_ERR) 153e1051a39Sopenharmony_ci const char *file; 154e1051a39Sopenharmony_ci int line; 155e1051a39Sopenharmony_ci 156e1051a39Sopenharmony_ci file = __FILE__; 157e1051a39Sopenharmony_ci line = __LINE__ + 2; /* The error is generated on the ERR_raise_data line */ 158e1051a39Sopenharmony_ci#endif 159e1051a39Sopenharmony_ci ERR_raise_data(ERR_LIB_NONE, ERR_R_INTERNAL_ERROR, 160e1051a39Sopenharmony_ci "calling exit()"); 161e1051a39Sopenharmony_ci if (!TEST_ulong_ne(e = ERR_get_error_all(&f, &l, NULL, &data, NULL), 0) 162e1051a39Sopenharmony_ci || !TEST_int_eq(ERR_GET_REASON(e), ERR_R_INTERNAL_ERROR) 163e1051a39Sopenharmony_ci#if !defined(OPENSSL_NO_FILENAMES) && !defined(OPENSSL_NO_ERR) 164e1051a39Sopenharmony_ci || !TEST_int_eq(l, line) 165e1051a39Sopenharmony_ci || !TEST_str_eq(f, file) 166e1051a39Sopenharmony_ci#endif 167e1051a39Sopenharmony_ci || !TEST_str_eq(data, "calling exit()")) 168e1051a39Sopenharmony_ci return 0; 169e1051a39Sopenharmony_ci return 1; 170e1051a39Sopenharmony_ci} 171e1051a39Sopenharmony_ci 172e1051a39Sopenharmony_cistatic int test_marks(void) 173e1051a39Sopenharmony_ci{ 174e1051a39Sopenharmony_ci unsigned long mallocfail, shouldnot; 175e1051a39Sopenharmony_ci 176e1051a39Sopenharmony_ci /* Set an initial error */ 177e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE); 178e1051a39Sopenharmony_ci mallocfail = ERR_peek_last_error(); 179e1051a39Sopenharmony_ci if (!TEST_ulong_gt(mallocfail, 0)) 180e1051a39Sopenharmony_ci return 0; 181e1051a39Sopenharmony_ci 182e1051a39Sopenharmony_ci /* Setting and clearing a mark should not affect the error */ 183e1051a39Sopenharmony_ci if (!TEST_true(ERR_set_mark()) 184e1051a39Sopenharmony_ci || !TEST_true(ERR_pop_to_mark()) 185e1051a39Sopenharmony_ci || !TEST_ulong_eq(mallocfail, ERR_peek_last_error()) 186e1051a39Sopenharmony_ci || !TEST_true(ERR_set_mark()) 187e1051a39Sopenharmony_ci || !TEST_true(ERR_clear_last_mark()) 188e1051a39Sopenharmony_ci || !TEST_ulong_eq(mallocfail, ERR_peek_last_error())) 189e1051a39Sopenharmony_ci return 0; 190e1051a39Sopenharmony_ci 191e1051a39Sopenharmony_ci /* Test popping errors */ 192e1051a39Sopenharmony_ci if (!TEST_true(ERR_set_mark())) 193e1051a39Sopenharmony_ci return 0; 194e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR); 195e1051a39Sopenharmony_ci if (!TEST_ulong_ne(mallocfail, ERR_peek_last_error()) 196e1051a39Sopenharmony_ci || !TEST_true(ERR_pop_to_mark()) 197e1051a39Sopenharmony_ci || !TEST_ulong_eq(mallocfail, ERR_peek_last_error())) 198e1051a39Sopenharmony_ci return 0; 199e1051a39Sopenharmony_ci 200e1051a39Sopenharmony_ci /* Nested marks should also work */ 201e1051a39Sopenharmony_ci if (!TEST_true(ERR_set_mark()) 202e1051a39Sopenharmony_ci || !TEST_true(ERR_set_mark())) 203e1051a39Sopenharmony_ci return 0; 204e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR); 205e1051a39Sopenharmony_ci if (!TEST_ulong_ne(mallocfail, ERR_peek_last_error()) 206e1051a39Sopenharmony_ci || !TEST_true(ERR_pop_to_mark()) 207e1051a39Sopenharmony_ci || !TEST_true(ERR_pop_to_mark()) 208e1051a39Sopenharmony_ci || !TEST_ulong_eq(mallocfail, ERR_peek_last_error())) 209e1051a39Sopenharmony_ci return 0; 210e1051a39Sopenharmony_ci 211e1051a39Sopenharmony_ci if (!TEST_true(ERR_set_mark())) 212e1051a39Sopenharmony_ci return 0; 213e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 214e1051a39Sopenharmony_ci shouldnot = ERR_peek_last_error(); 215e1051a39Sopenharmony_ci if (!TEST_ulong_ne(mallocfail, shouldnot) 216e1051a39Sopenharmony_ci || !TEST_true(ERR_set_mark())) 217e1051a39Sopenharmony_ci return 0; 218e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR); 219e1051a39Sopenharmony_ci if (!TEST_ulong_ne(shouldnot, ERR_peek_last_error()) 220e1051a39Sopenharmony_ci || !TEST_true(ERR_pop_to_mark()) 221e1051a39Sopenharmony_ci || !TEST_ulong_eq(shouldnot, ERR_peek_last_error()) 222e1051a39Sopenharmony_ci || !TEST_true(ERR_pop_to_mark()) 223e1051a39Sopenharmony_ci || !TEST_ulong_eq(mallocfail, ERR_peek_last_error())) 224e1051a39Sopenharmony_ci return 0; 225e1051a39Sopenharmony_ci 226e1051a39Sopenharmony_ci /* Setting and clearing a mark should not affect the errors on the stack */ 227e1051a39Sopenharmony_ci if (!TEST_true(ERR_set_mark())) 228e1051a39Sopenharmony_ci return 0; 229e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 230e1051a39Sopenharmony_ci if (!TEST_true(ERR_clear_last_mark()) 231e1051a39Sopenharmony_ci || !TEST_ulong_eq(shouldnot, ERR_peek_last_error())) 232e1051a39Sopenharmony_ci return 0; 233e1051a39Sopenharmony_ci 234e1051a39Sopenharmony_ci /* 235e1051a39Sopenharmony_ci * Popping where no mark has been set should pop everything - but return 236e1051a39Sopenharmony_ci * a failure result 237e1051a39Sopenharmony_ci */ 238e1051a39Sopenharmony_ci if (!TEST_false(ERR_pop_to_mark()) 239e1051a39Sopenharmony_ci || !TEST_ulong_eq(0, ERR_peek_last_error())) 240e1051a39Sopenharmony_ci return 0; 241e1051a39Sopenharmony_ci 242e1051a39Sopenharmony_ci /* Clearing where there is no mark should fail */ 243e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE); 244e1051a39Sopenharmony_ci if (!TEST_false(ERR_clear_last_mark()) 245e1051a39Sopenharmony_ci /* "get" the last error to remove it */ 246e1051a39Sopenharmony_ci || !TEST_ulong_eq(mallocfail, ERR_get_error()) 247e1051a39Sopenharmony_ci || !TEST_ulong_eq(0, ERR_peek_last_error())) 248e1051a39Sopenharmony_ci return 0; 249e1051a39Sopenharmony_ci 250e1051a39Sopenharmony_ci /* 251e1051a39Sopenharmony_ci * Setting a mark where there are no errors in the stack should fail. 252e1051a39Sopenharmony_ci * NOTE: This is somewhat surprising behaviour but is historically how this 253e1051a39Sopenharmony_ci * function behaves. In practice we typically set marks without first 254e1051a39Sopenharmony_ci * checking whether there is anything on the stack - but we also don't 255e1051a39Sopenharmony_ci * tend to check the success of this function. It turns out to work anyway 256e1051a39Sopenharmony_ci * because although setting a mark with no errors fails, a subsequent call 257e1051a39Sopenharmony_ci * to ERR_pop_to_mark() or ERR_clear_last_mark() will do the right thing 258e1051a39Sopenharmony_ci * anyway (even though they will report a failure result). 259e1051a39Sopenharmony_ci */ 260e1051a39Sopenharmony_ci if (!TEST_false(ERR_set_mark())) 261e1051a39Sopenharmony_ci return 0; 262e1051a39Sopenharmony_ci 263e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_MALLOC_FAILURE); 264e1051a39Sopenharmony_ci if (!TEST_true(ERR_set_mark())) 265e1051a39Sopenharmony_ci return 0; 266e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR); 267e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 268e1051a39Sopenharmony_ci 269e1051a39Sopenharmony_ci /* Should be able to "pop" past 2 errors */ 270e1051a39Sopenharmony_ci if (!TEST_true(ERR_pop_to_mark()) 271e1051a39Sopenharmony_ci || !TEST_ulong_eq(mallocfail, ERR_peek_last_error())) 272e1051a39Sopenharmony_ci return 0; 273e1051a39Sopenharmony_ci 274e1051a39Sopenharmony_ci if (!TEST_true(ERR_set_mark())) 275e1051a39Sopenharmony_ci return 0; 276e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_INTERNAL_ERROR); 277e1051a39Sopenharmony_ci ERR_raise(ERR_LIB_CRYPTO, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 278e1051a39Sopenharmony_ci 279e1051a39Sopenharmony_ci /* Should be able to "clear" past 2 errors */ 280e1051a39Sopenharmony_ci if (!TEST_true(ERR_clear_last_mark()) 281e1051a39Sopenharmony_ci || !TEST_ulong_eq(shouldnot, ERR_peek_last_error())) 282e1051a39Sopenharmony_ci return 0; 283e1051a39Sopenharmony_ci 284e1051a39Sopenharmony_ci /* Clear remaining errors from last test */ 285e1051a39Sopenharmony_ci ERR_clear_error(); 286e1051a39Sopenharmony_ci 287e1051a39Sopenharmony_ci return 1; 288e1051a39Sopenharmony_ci} 289e1051a39Sopenharmony_ci 290e1051a39Sopenharmony_cistatic int test_clear_error(void) 291e1051a39Sopenharmony_ci{ 292e1051a39Sopenharmony_ci int flags = -1; 293e1051a39Sopenharmony_ci const char *data = NULL; 294e1051a39Sopenharmony_ci int res = 0; 295e1051a39Sopenharmony_ci 296e1051a39Sopenharmony_ci /* Raise an error with data and clear it */ 297e1051a39Sopenharmony_ci ERR_raise_data(0, 0, "hello %s", "world"); 298e1051a39Sopenharmony_ci ERR_peek_error_data(&data, &flags); 299e1051a39Sopenharmony_ci if (!TEST_str_eq(data, "hello world") 300e1051a39Sopenharmony_ci || !TEST_int_eq(flags, ERR_TXT_STRING | ERR_TXT_MALLOCED)) 301e1051a39Sopenharmony_ci goto err; 302e1051a39Sopenharmony_ci ERR_clear_error(); 303e1051a39Sopenharmony_ci 304e1051a39Sopenharmony_ci /* Raise a new error without data */ 305e1051a39Sopenharmony_ci ERR_raise(0, 0); 306e1051a39Sopenharmony_ci ERR_peek_error_data(&data, &flags); 307e1051a39Sopenharmony_ci if (!TEST_str_eq(data, "") 308e1051a39Sopenharmony_ci || !TEST_int_eq(flags, ERR_TXT_MALLOCED)) 309e1051a39Sopenharmony_ci goto err; 310e1051a39Sopenharmony_ci ERR_clear_error(); 311e1051a39Sopenharmony_ci 312e1051a39Sopenharmony_ci /* Raise a new error with data */ 313e1051a39Sopenharmony_ci ERR_raise_data(0, 0, "goodbye %s world", "cruel"); 314e1051a39Sopenharmony_ci ERR_peek_error_data(&data, &flags); 315e1051a39Sopenharmony_ci if (!TEST_str_eq(data, "goodbye cruel world") 316e1051a39Sopenharmony_ci || !TEST_int_eq(flags, ERR_TXT_STRING | ERR_TXT_MALLOCED)) 317e1051a39Sopenharmony_ci goto err; 318e1051a39Sopenharmony_ci ERR_clear_error(); 319e1051a39Sopenharmony_ci 320e1051a39Sopenharmony_ci /* 321e1051a39Sopenharmony_ci * Raise a new error without data to check that the malloced storage 322e1051a39Sopenharmony_ci * is freed properly 323e1051a39Sopenharmony_ci */ 324e1051a39Sopenharmony_ci ERR_raise(0, 0); 325e1051a39Sopenharmony_ci ERR_peek_error_data(&data, &flags); 326e1051a39Sopenharmony_ci if (!TEST_str_eq(data, "") 327e1051a39Sopenharmony_ci || !TEST_int_eq(flags, ERR_TXT_MALLOCED)) 328e1051a39Sopenharmony_ci goto err; 329e1051a39Sopenharmony_ci ERR_clear_error(); 330e1051a39Sopenharmony_ci 331e1051a39Sopenharmony_ci res = 1; 332e1051a39Sopenharmony_ci err: 333e1051a39Sopenharmony_ci ERR_clear_error(); 334e1051a39Sopenharmony_ci return res; 335e1051a39Sopenharmony_ci} 336e1051a39Sopenharmony_ci 337e1051a39Sopenharmony_ciint setup_tests(void) 338e1051a39Sopenharmony_ci{ 339e1051a39Sopenharmony_ci ADD_TEST(preserves_system_error); 340e1051a39Sopenharmony_ci ADD_TEST(vdata_appends); 341e1051a39Sopenharmony_ci ADD_TEST(raised_error); 342e1051a39Sopenharmony_ci#ifndef OPENSSL_NO_DEPRECATED_3_0 343e1051a39Sopenharmony_ci ADD_TEST(test_print_error_format); 344e1051a39Sopenharmony_ci#endif 345e1051a39Sopenharmony_ci ADD_TEST(test_marks); 346e1051a39Sopenharmony_ci ADD_TEST(test_clear_error); 347e1051a39Sopenharmony_ci return 1; 348e1051a39Sopenharmony_ci} 349