2 * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/opensslconf.h>
11 #include <openssl/err.h>
15 #if defined(OPENSSL_SYS_WINDOWS)
21 /* Test that querying the error queue preserves the OS error. */
22 static int preserves_system_error(void)
24 #if defined(OPENSSL_SYS_WINDOWS)
25 SetLastError(ERROR_INVALID_FUNCTION);
27 return TEST_int_eq(GetLastError(), ERROR_INVALID_FUNCTION);
31 return TEST_int_eq(errno, EINVAL);
35 /* Test that calls to ERR_add_error_[v]data append */
36 static int vdata_appends(void)
40 CRYPTOerr(0, ERR_R_MALLOC_FAILURE);
41 ERR_add_error_data(1, "hello ");
42 ERR_add_error_data(1, "world");
43 ERR_get_error_line_data(NULL, NULL, &data, NULL);
44 return TEST_str_eq(data, "hello world");
49 ADD_TEST(preserves_system_error);
50 ADD_TEST(vdata_appends);