mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 11:42:38 +03:00
LibTest: Convert Crash test runner to outln(..)
This commit is contained in:
parent
7f51754780
commit
4b8b8b91c2
Notes:
sideshowbarker
2024-07-18 18:33:53 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/4b8b8b91c2d Pull-request: https://github.com/SerenityOS/serenity/pull/6912 Reviewed-by: https://github.com/linusg
@ -20,19 +20,19 @@ Crash::Crash(String test_type, Function<Crash::Failure()> crash_function)
|
||||
|
||||
bool Crash::run(RunType run_type)
|
||||
{
|
||||
printf("\x1B[33mTesting\x1B[0m: \"%s\"\n", m_type.characters());
|
||||
outln("\x1B[33mTesting\x1B[0m: \"{}\"", m_type);
|
||||
|
||||
auto run_crash_and_print_if_error = [this]() -> bool {
|
||||
auto failure = m_crash_function();
|
||||
|
||||
// If we got here something went wrong
|
||||
printf("\x1B[31mFAIL\x1B[0m: ");
|
||||
out("\x1B[31mFAIL\x1B[0m: ");
|
||||
switch (failure) {
|
||||
case Failure::DidNotCrash:
|
||||
printf("Did not crash!\n");
|
||||
outln("Did not crash!");
|
||||
break;
|
||||
case Failure::UnexpectedError:
|
||||
printf("Unexpected error!\n");
|
||||
outln("Unexpected error!");
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
@ -43,7 +43,6 @@ bool Crash::run(RunType run_type)
|
||||
if (run_type == RunType::UsingCurrentProcess) {
|
||||
return run_crash_and_print_if_error();
|
||||
} else {
|
||||
|
||||
// Run the test in a child process so that we do not crash the crash program :^)
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
@ -57,7 +56,7 @@ bool Crash::run(RunType run_type)
|
||||
int status;
|
||||
waitpid(pid, &status, 0);
|
||||
if (WIFSIGNALED(status)) {
|
||||
printf("\x1B[32mPASS\x1B[0m: Terminated with signal %d\n", WTERMSIG(status));
|
||||
outln("\x1B[32mPASS\x1B[0m: Terminated with signal {}", WTERMSIG(status));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user