1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

crash: Add option for failing assertion

This commit is contained in:
Linus Groh 2021-01-25 22:44:36 +01:00 committed by Andreas Kling
parent 6568cba731
commit 5978424cf9

View file

@ -122,6 +122,7 @@ int main(int argc, char** argv)
bool do_use_io_instruction = false;
bool do_read_cpu_counter = false;
bool do_pledge_violation = false;
bool do_failing_assertion = false;
auto args_parser = Core::ArgsParser();
args_parser.set_general_help(
@ -145,6 +146,7 @@ int main(int argc, char** argv)
args_parser.add_option(do_use_io_instruction, "Use an x86 I/O instruction in userspace", nullptr, 'I');
args_parser.add_option(do_read_cpu_counter, "Read the x86 TSC (Time Stamp Counter) directly", nullptr, 'c');
args_parser.add_option(do_pledge_violation, "Violate pledge()'d promises", nullptr, 'p');
args_parser.add_option(do_failing_assertion, "Perform a failing assertion", nullptr, 'n');
if (argc != 2) {
args_parser.print_usage(stderr, argv[0]);
@ -338,5 +340,12 @@ int main(int argc, char** argv)
}).run(run_type);
}
if (do_failing_assertion || do_all_crash_types) {
Crash("Perform a failing assertion", [] {
ASSERT(1 == 2);
return Crash::Failure::DidNotCrash;
}).run(run_type);
}
return 0;
}