diff options
author | Kenneth Myhra <kennethmyhra@gmail.com> | 2022-03-30 08:49:43 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-03-30 09:53:11 +0100 |
commit | 6581cf47ab4e2e5d3ed98df18fee12016f109b3b (patch) | |
tree | 7fb2994adc5d652ecc7b053b04e9968c34475a4c /Userland/Utilities/test.cpp | |
parent | 704e1d13f46f33302f80698018e86554a5006d14 (diff) | |
download | serenity-6581cf47ab4e2e5d3ed98df18fee12016f109b3b.zip |
test: Port to LibMain
Diffstat (limited to 'Userland/Utilities/test.cpp')
-rw-r--r-- | Userland/Utilities/test.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Userland/Utilities/test.cpp b/Userland/Utilities/test.cpp index 2590787da7..553656fd0e 100644 --- a/Userland/Utilities/test.cpp +++ b/Userland/Utilities/test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, the SerenityOS developers. + * Copyright (c) 2020-2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -8,7 +8,8 @@ #include <AK/LexicalPath.h> #include <AK/NonnullOwnPtr.h> #include <AK/OwnPtr.h> -#include <LibCore/File.h> +#include <LibCore/System.h> +#include <LibMain/Main.h> #include <stdio.h> #include <sys/stat.h> #include <unistd.h> @@ -490,25 +491,27 @@ static OwnPtr<Condition> parse_complex_expression(char* argv[]) return command; } -int main(int argc, char* argv[]) +ErrorOr<int> serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath", nullptr) < 0) { - perror("pledge"); + auto maybe_error = Core::System::pledge("stdio rpath"); + if (maybe_error.is_error()) { + warnln("{}", maybe_error.error()); return 126; } - if (LexicalPath::basename(argv[0]) == "[") { + int argc = arguments.argc; + if (LexicalPath::basename(arguments.strings[0]) == "[") { --argc; - if (StringView { argv[argc] } != "]") + if (StringView { arguments.strings[argc] } != "]") fatal_error("test invoked as '[' requires a closing bracket ']'"); - argv[argc] = nullptr; + arguments.strings[argc] = nullptr; } // Exit false when no arguments are given. if (argc == 1) return 1; - auto condition = parse_complex_expression(argv); + auto condition = parse_complex_expression(arguments.argv); if (optind != argc - 1) fatal_error("Too many arguments"); auto result = condition ? condition->check() : false; |