summaryrefslogtreecommitdiff
path: root/Tests/LibJS
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-09-28 17:03:07 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-10-12 12:00:21 -0600
commit340a2a96a4252998c53fe93b2f111399d4d9202f (patch)
treecfabf9ad6c32faa41eed50d628efd0430c94eb8d /Tests/LibJS
parent1f542599229ea66dc7014d2ecc0bd0359fc48299 (diff)
downloadserenity-340a2a96a4252998c53fe93b2f111399d4d9202f.zip
test262-runner: Use names for the different exit codes
These are not used by test-test262 but can be used to quickly distinguish the type of problem if the runner fails when running manually.
Diffstat (limited to 'Tests/LibJS')
-rw-r--r--Tests/LibJS/test262-runner.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/Tests/LibJS/test262-runner.cpp b/Tests/LibJS/test262-runner.cpp
index 1073876543..94efca417e 100644
--- a/Tests/LibJS/test262-runner.cpp
+++ b/Tests/LibJS/test262-runner.cpp
@@ -566,6 +566,11 @@ extern "C" __attribute__((__noreturn__)) void __assert_fail(char const* assertio
}
#endif
+constexpr int exit_wrong_arguments = 2;
+constexpr int exit_stdout_setup_failed = 1;
+constexpr int exit_setup_input_failure = 7;
+constexpr int exit_read_file_failure = 3;
+
int main(int argc, char** argv)
{
int timeout = 10;
@@ -585,7 +590,7 @@ int main(int argc, char** argv)
#ifndef AK_OS_MACOS
if (disable_core_dumping && prctl(PR_SET_DUMPABLE, 0, 0) < 0) {
perror("prctl(PR_SET_DUMPABLE)");
- return 2;
+ return exit_wrong_arguments;
}
#endif
@@ -597,7 +602,7 @@ int main(int argc, char** argv)
if (timeout <= 0) {
warnln("timeout must be at least 1");
- return 2;
+ return exit_wrong_arguments;
}
AK::set_debug_enabled(enable_debug_printing);
@@ -609,19 +614,19 @@ int main(int argc, char** argv)
auto saved_stdout = dup(STDOUT_FILENO);
if (saved_stdout < 0) {
perror("dup");
- return 1;
+ return exit_stdout_setup_failed;
}
saved_stdout_fd = fdopen(saved_stdout, "w");
if (!saved_stdout_fd) {
perror("fdopen");
- return 1;
+ return exit_stdout_setup_failed;
}
int stdout_pipe[2];
if (pipe(stdout_pipe) < 0) {
perror("pipe");
- return 1;
+ return exit_stdout_setup_failed;
}
auto flags = fcntl(stdout_pipe[0], F_GETFL);
@@ -634,12 +639,12 @@ int main(int argc, char** argv)
if (dup2(stdout_pipe[1], STDOUT_FILENO) < 0) {
perror("dup2");
- return 1;
+ return exit_stdout_setup_failed;
}
if (close(stdout_pipe[1]) < 0) {
perror("close");
- return 1;
+ return exit_stdout_setup_failed;
}
auto collect_output = [&] {
@@ -665,12 +670,12 @@ int main(int argc, char** argv)
auto standard_input_or_error = Core::Stream::File::standard_input();
if (standard_input_or_error.is_error())
- return 7;
+ return exit_setup_input_failure;
Array<u8, 1024> input_buffer {};
auto buffered_standard_input_or_error = Core::Stream::BufferedFile::create(standard_input_or_error.release_value());
if (buffered_standard_input_or_error.is_error())
- return 7;
+ return exit_setup_input_failure;
auto& buffered_input_stream = buffered_standard_input_or_error.value();
@@ -687,7 +692,7 @@ int main(int argc, char** argv)
if (s_automatic_harness_detection_mode) {
if (!extract_harness_directory(path))
- return 4;
+ return exit_read_file_failure;
s_automatic_harness_detection_mode = false;
VERIFY(!s_harness_file_directory.is_empty());
}
@@ -695,7 +700,7 @@ int main(int argc, char** argv)
auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
if (file_or_error.is_error()) {
warnln("Could not open file: {}", path);
- return 3;
+ return exit_read_file_failure;
}
auto& file = file_or_error.value();
@@ -709,7 +714,7 @@ int main(int argc, char** argv)
auto contents_or_error = file->read_all();
if (contents_or_error.is_error()) {
warnln("Could not read contents of file: {}", path);
- return 3;
+ return exit_read_file_failure;
}
auto& contents = contents_or_error.value();
StringBuilder builder { contents.size() + strict_length };