Files
clang-p2996/libc/utils/testutils/ExecuteFunction.h
Alex Brachet 0368997402 [libc] [UnitTest] Create death tests
Summary: This patch adds `EXPECT_EXITS` and `EXPECT_DEATH` macros for testing exit codes and deadly signals. They are less convoluted than their analogs in GTEST and don't have matchers but just take an int for either the exit code or the signal respectively. Nor do they have any regex match against the stdout/stderr of the child process.

Reviewers: sivachandra, gchatelet

Reviewed By: sivachandra

Subscribers: mgorny, MaskRay, tschuett, libc-commits

Differential Revision: https://reviews.llvm.org/D74665
2020-02-24 17:53:43 -05:00

37 lines
947 B
C++

//===---------------------- ExecuteFunction.h -------------------*- C++ -*-===//
//
// 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_UTILS_TESTUTILS_EXECUTEFUNCTION_H
#define LLVM_LIBC_UTILS_TESTUTILS_EXECUTEFUNCTION_H
namespace __llvm_libc {
namespace testutils {
class FunctionCaller {
public:
virtual ~FunctionCaller() {}
virtual void operator()() = 0;
};
struct ProcessStatus {
int PlatformDefined;
bool exitedNormally();
int getExitCode();
int getFatalSignal();
};
ProcessStatus invokeInSubprocess(FunctionCaller *Func);
const char *signalAsString(int Signum);
} // namespace testutils
} // namespace __llvm_libc
#endif // LLVM_LIBC_UTILS_TESTUTILS_EXECUTEFUNCTION_H