mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-07 00:20:07 +01:00
When shutting down helper processes, PosixSocketHelper::close() in SocketWindows when trying to close the socket fd with WSANOTINITIALISED. This was due to us initiating WinSock2 during static initialization and presumably also not terminating WinSock2 properly. Similar to WinSock2 initiation, calling CRT during static initialization is considered dangerous given the CRT DLL itself may not yet be initialized. Because of the above, we move to perform this Windows-specific runtime setup/teardown calls into the main() functions.
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2021, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/Format.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibTest/TestSuite.h>
|
|
#if defined(AK_OS_WINDOWS)
|
|
# include <AK/Windows.h>
|
|
#endif
|
|
|
|
#define TEST_MAIN main
|
|
|
|
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;
|
|
}
|
|
|
|
#if defined(AK_OS_WINDOWS)
|
|
windows_init();
|
|
#endif
|
|
|
|
Vector<StringView> 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();
|
|
#if defined(AK_OS_WINDOWS)
|
|
windows_shutdown();
|
|
#endif
|
|
// 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;
|
|
}
|