/* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2021, Andrew Kaster * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #ifdef KERNEL # define TEST_MAIN test_main #else # define TEST_MAIN main #endif int TEST_MAIN(int argc, char** argv) { if (argc < 1 || !argv[0] || '\0' == *argv[0]) { warnln("Test main does not have a valid test name!"); return 1; } Vector arguments; arguments.ensure_capacity(argc); for (auto i = 0; i < argc; ++i) arguments.append({ argv[i], strlen(argv[i]) }); int ret = ::Test::TestSuite::the().main(argv[0], arguments); ::Test::TestSuite::release(); // As TestSuite::main() returns the number of test cases that did not pass, // ret can be >=256 which cannot be returned as an exit status directly. // Return 0 if all of the test cases pass and return 1 otherwise. return ret != 0; }