[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / libc / test / UnitTest / ExecuteFunction.h
blob511249be0f3c95be6cb77363d16cf248693e6c7e
1 //===-- ExecuteFunction.h ---------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIBC_TEST_UNITTEST_EXECUTEFUNCTION_H
10 #define LLVM_LIBC_TEST_UNITTEST_EXECUTEFUNCTION_H
12 #include "src/__support/macros/config.h"
13 #include <stdint.h>
15 namespace LIBC_NAMESPACE_DECL {
16 namespace testutils {
18 class FunctionCaller {
19 public:
20 virtual ~FunctionCaller() {}
21 virtual void operator()() = 0;
24 struct ProcessStatus {
25 int platform_defined;
26 const char *failure = nullptr;
28 static constexpr unsigned TIMEOUT = ~0U;
30 static ProcessStatus error(const char *error) { return {0, error}; }
31 static ProcessStatus timed_out_ps() {
32 return {0, reinterpret_cast<const char *>(TIMEOUT)};
35 bool timed_out() const {
36 return failure == reinterpret_cast<const char *>(TIMEOUT);
38 const char *get_error() const { return timed_out() ? nullptr : failure; }
39 bool exited_normally();
40 int get_exit_code();
41 int get_fatal_signal();
44 ProcessStatus
45 invoke_in_subprocess(FunctionCaller *func,
46 unsigned timeout_ms = ProcessStatus::TIMEOUT);
48 const char *signal_as_string(int signum);
50 } // namespace testutils
51 } // namespace LIBC_NAMESPACE_DECL
53 #endif // LLVM_LIBC_TEST_UNITTEST_EXECUTEFUNCTION_H