1 1.1 christos /* 2 1.1 christos * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the OpenSSL license (the "License"). You may not use 5 1.1 christos * this file except in compliance with the License. You can obtain a copy 6 1.1 christos * in the file LICENSE in the source distribution or at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos */ 9 1.1 christos 10 1.1 christos #include <openssl/opensslconf.h> 11 1.1 christos #include <openssl/err.h> 12 1.1 christos 13 1.1 christos #include "testutil.h" 14 1.1 christos 15 1.1 christos #if defined(OPENSSL_SYS_WINDOWS) 16 1.1 christos # include <windows.h> 17 1.1 christos #else 18 1.1 christos # include <errno.h> 19 1.1 christos #endif 20 1.1 christos 21 1.1 christos /* Test that querying the error queue preserves the OS error. */ 22 1.1 christos static int preserves_system_error(void) 23 1.1 christos { 24 1.1 christos #if defined(OPENSSL_SYS_WINDOWS) 25 1.1 christos SetLastError(ERROR_INVALID_FUNCTION); 26 1.1 christos ERR_get_error(); 27 1.1 christos return GetLastError() == ERROR_INVALID_FUNCTION; 28 1.1 christos #else 29 1.1 christos errno = EINVAL; 30 1.1 christos ERR_get_error(); 31 1.1 christos return errno == EINVAL; 32 1.1 christos #endif 33 1.1 christos } 34 1.1 christos 35 1.1 christos int main(int argc, char **argv) 36 1.1 christos { 37 1.1 christos ADD_TEST(preserves_system_error); 38 1.1 christos 39 1.1 christos return run_tests(argv[0]); 40 1.1 christos } 41