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