This adds a new test fixture class FEnvSafeTest (usable as a base class for other fixtures) that ensures each test doesn't perturb the `fenv_t` state that the next test will start with. It also provides types and methods tests can use to explicitly wrap code under test either to check that it doesn't perturb the state or to save and restore the state around particular test code. All the fenv and math tests are updated to use this so that none can affect another. Expectations that code under test and/or tests themselves don't perturb state can be added later.
25 lines
939 B
C++
25 lines
939 B
C++
//===-- List of all FE_* constants for tests -----------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===---------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIBC_TEST_SRC_FENV_EXCEPTS_H
|
|
#define LLVM_LIBC_TEST_SRC_FENV_EXCEPTS_H
|
|
|
|
#include "hdr/fenv_macros.h"
|
|
|
|
constexpr int EXCEPTS[] = {
|
|
FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW, FE_UNDERFLOW,
|
|
};
|
|
|
|
// We '|' the individual exception flags instead of using FE_ALL_EXCEPT
|
|
// as it can include non-standard extensions. Note that we should be able
|
|
// to compile this file with headers from other libcs as well.
|
|
constexpr int ALL_EXCEPTS =
|
|
FE_DIVBYZERO | FE_INVALID | FE_INEXACT | FE_OVERFLOW | FE_UNDERFLOW;
|
|
|
|
#endif // LLVM_LIBC_TEST_SRC_FENV_EXCEPTS_H
|