2021-05-07 10:43:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2023-07-15 10:33:22 +00:00
|
|
|
* Copyright (c) 2019-2020, Shannon Booth <shannon@serenityos.org>
|
2021-05-07 10:43:41 +00:00
|
|
|
* Copyright (c) 2021, Brian Gianforaro <bgianf@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2021-05-07 10:43:41 +00:00
|
|
|
#include <AK/Function.h>
|
2021-12-15 08:20:38 +00:00
|
|
|
#include <AK/Variant.h>
|
2021-05-07 10:43:41 +00:00
|
|
|
|
|
|
|
namespace Test {
|
|
|
|
|
|
|
|
class Crash {
|
|
|
|
public:
|
|
|
|
enum class RunType {
|
|
|
|
UsingChildProcess,
|
|
|
|
UsingCurrentProcess,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class Failure {
|
|
|
|
DidNotCrash,
|
|
|
|
UnexpectedError,
|
|
|
|
};
|
|
|
|
|
2021-12-17 17:12:47 +00:00
|
|
|
static constexpr int ANY_SIGNAL = -1;
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
Crash(DeprecatedString test_type, Function<Crash::Failure()> crash_function, int crash_signal = ANY_SIGNAL);
|
2021-05-07 10:43:41 +00:00
|
|
|
|
2021-05-07 11:38:56 +00:00
|
|
|
bool run(RunType run_type = RunType::UsingChildProcess);
|
2021-05-07 10:43:41 +00:00
|
|
|
|
|
|
|
private:
|
2021-12-15 08:20:38 +00:00
|
|
|
using Report = Variant<Failure, int>;
|
|
|
|
bool do_report(Report report);
|
2021-12-15 07:58:40 +00:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString m_type;
|
2021-05-07 10:43:41 +00:00
|
|
|
Function<Crash::Failure()> m_crash_function;
|
2021-12-17 17:12:47 +00:00
|
|
|
int m_crash_signal;
|
2021-05-07 10:43:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|