Blame test/errtest.c

Packit c4476c
/*
Packit c4476c
 * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
 *
Packit c4476c
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
 * this file except in compliance with the License.  You can obtain a copy
Packit c4476c
 * in the file LICENSE in the source distribution or at
Packit c4476c
 * https://www.openssl.org/source/license.html
Packit c4476c
 */
Packit c4476c
Packit c4476c
#include <openssl/opensslconf.h>
Packit c4476c
#include <openssl/err.h>
Packit c4476c
Packit c4476c
#include "testutil.h"
Packit c4476c
Packit c4476c
#if defined(OPENSSL_SYS_WINDOWS)
Packit c4476c
# include <windows.h>
Packit c4476c
#else
Packit c4476c
# include <errno.h>
Packit c4476c
#endif
Packit c4476c
Packit c4476c
/* Test that querying the error queue preserves the OS error. */
Packit c4476c
static int preserves_system_error(void)
Packit c4476c
{
Packit c4476c
#if defined(OPENSSL_SYS_WINDOWS)
Packit c4476c
    SetLastError(ERROR_INVALID_FUNCTION);
Packit c4476c
    ERR_get_error();
Packit c4476c
    return TEST_int_eq(GetLastError(), ERROR_INVALID_FUNCTION);
Packit c4476c
#else
Packit c4476c
    errno = EINVAL;
Packit c4476c
    ERR_get_error();
Packit c4476c
    return TEST_int_eq(errno, EINVAL);
Packit c4476c
#endif
Packit c4476c
}
Packit c4476c
Packit c4476c
int setup_tests(void)
Packit c4476c
{
Packit c4476c
    ADD_TEST(preserves_system_error);
Packit c4476c
    return 1;
Packit c4476c
}