mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
Tests/LibCore: Enable several tests in Windows CI
These are the set of tests that were already building and passing with little to no modifications required.
This commit is contained in:
parent
cd15b1a2c9
commit
9d7971c111
|
|
@ -217,6 +217,9 @@ int getpid()
|
|||
|
||||
ErrorOr<int> dup(int handle)
|
||||
{
|
||||
if (handle < 0) {
|
||||
return Error::from_windows_error(ERROR_INVALID_HANDLE);
|
||||
}
|
||||
if (is_socket(handle)) {
|
||||
WSAPROTOCOL_INFO pi = {};
|
||||
if (WSADuplicateSocket(handle, GetCurrentProcessId(), &pi))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
add_subdirectory(AK)
|
||||
add_subdirectory(LibCompress)
|
||||
add_subdirectory(LibCore)
|
||||
add_subdirectory(LibCrypto)
|
||||
add_subdirectory(LibDiff)
|
||||
add_subdirectory(LibGC)
|
||||
|
|
@ -22,7 +23,6 @@ if (WIN32 AND ENABLE_WINDOWS_CI)
|
|||
return()
|
||||
endif()
|
||||
|
||||
add_subdirectory(LibCore)
|
||||
add_subdirectory(LibDNS)
|
||||
add_subdirectory(LibXML)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
set(TEST_SOURCES
|
||||
TestLibCoreArgsParser.cpp
|
||||
TestLibCoreDateTime.cpp
|
||||
TestLibCoreDeferredInvoke.cpp
|
||||
TestLibCoreFileWatcher.cpp
|
||||
TestLibCoreMappedFile.cpp
|
||||
TestLibCoreMimeType.cpp
|
||||
TestLibCorePromise.cpp
|
||||
TestLibCoreSharedSingleProducerCircularQueue.cpp
|
||||
|
|
@ -11,7 +10,8 @@ set(TEST_SOURCES
|
|||
# FIXME: Change these tests to use a portable tempfile directory
|
||||
if (NOT WIN32)
|
||||
list(APPEND TEST_SOURCES
|
||||
TestLibCoreMappedFile.cpp
|
||||
TestLibCoreDateTime.cpp
|
||||
TestLibCoreFileWatcher.cpp
|
||||
TestLibCoreStream.cpp
|
||||
)
|
||||
endif()
|
||||
|
|
@ -20,7 +20,9 @@ foreach(source IN LISTS TEST_SOURCES)
|
|||
ladybird_test("${source}" LibCore)
|
||||
endforeach()
|
||||
|
||||
target_link_libraries(TestLibCoreDateTime PRIVATE LibUnicode)
|
||||
if (TARGET TestLibCoreDateTime)
|
||||
target_link_libraries(TestLibCoreDateTime PRIVATE LibUnicode)
|
||||
endif()
|
||||
target_link_libraries(TestLibCorePromise PRIVATE LibThreading)
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(TestLibCoreStream PRIVATE LibThreading)
|
||||
|
|
|
|||
|
|
@ -10,16 +10,17 @@
|
|||
#include <AK/String.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
TEST_CASE(mapped_file_open)
|
||||
{
|
||||
// Fill the file with a little content so we can write to it.
|
||||
constexpr auto text = "Here's some text to be mmapped."sv;
|
||||
{
|
||||
auto maybe_file = Core::File::open("/tmp/file-open-test.txt"sv, Core::File::OpenMode::Write);
|
||||
auto maybe_file = Core::File::open(ByteString::formatted("{}/{}", Core::StandardPaths::tempfile_directory(), "file-open-test.txt"sv), Core::File::OpenMode::Write);
|
||||
if (maybe_file.is_error()) {
|
||||
warnln("Failed to open the file: {}", strerror(maybe_file.error().code()));
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
@ -27,7 +28,7 @@ TEST_CASE(mapped_file_open)
|
|||
TRY_OR_FAIL(maybe_file.value()->write_until_depleted(text.bytes()));
|
||||
}
|
||||
|
||||
auto maybe_file = Core::MappedFile::map("/tmp/file-open-test.txt"sv, Core::MappedFile::Mode::ReadWrite);
|
||||
auto maybe_file = Core::MappedFile::map(ByteString::formatted("{}/{}", Core::StandardPaths::tempfile_directory(), "file-open-test.txt"sv), Core::MappedFile::Mode::ReadWrite);
|
||||
if (maybe_file.is_error()) {
|
||||
warnln("Failed to open the file: {}", strerror(maybe_file.error().code()));
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
@ -108,7 +109,7 @@ BENCHMARK_CASE(file_tell)
|
|||
|
||||
TEST_CASE(mapped_file_adopt_fd)
|
||||
{
|
||||
int rc = ::open("./long_lines.txt", O_RDONLY);
|
||||
int rc = TRY_OR_FAIL(Core::System::open("./long_lines.txt"sv, O_RDONLY));
|
||||
EXPECT(rc >= 0);
|
||||
|
||||
auto file = TRY_OR_FAIL(Core::MappedFile::map_from_fd_and_close(rc, "./long_lines.txt"sv));
|
||||
|
|
@ -131,7 +132,11 @@ TEST_CASE(mapped_file_adopt_invalid_fd)
|
|||
{
|
||||
auto maybe_file = Core::MappedFile::map_from_fd_and_close(-1, "./long_lines.txt"sv);
|
||||
EXPECT(maybe_file.is_error());
|
||||
#if !defined(AK_OS_WINDOWS)
|
||||
EXPECT_EQ(maybe_file.error().code(), EBADF);
|
||||
#else
|
||||
EXPECT_EQ(maybe_file.error().code(), 6); // ERROR_INVALID_HANDLE
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE(mapped_file_tell_and_seek)
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Promise.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCore/ThreadedPromise.h>
|
||||
#include <LibTest/TestSuite.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
TEST_CASE(promise_await_async_event)
|
||||
{
|
||||
|
|
@ -115,6 +115,9 @@ TEST_CASE(promise_map_already_resolved)
|
|||
EXPECT_EQ(result.value(), 42);
|
||||
}
|
||||
|
||||
// FIXME: Support EventLoop::WaitMode::PollForEvents on Windows, otherwise ThreadedPromise::await() blocks forever
|
||||
|
||||
#if !defined(AK_OS_WINDOWS)
|
||||
TEST_CASE(threaded_promise_instantly_resolved)
|
||||
{
|
||||
Core::EventLoop loop;
|
||||
|
|
@ -165,7 +168,7 @@ TEST_CASE(threaded_promise_resolved_later)
|
|||
auto thread = Threading::Thread::construct([&, promise] {
|
||||
thread_id = pthread_self();
|
||||
while (!unblock_thread)
|
||||
usleep(500);
|
||||
MUST(Core::System::sleep_ms(5));
|
||||
promise->resolve(42);
|
||||
return 0;
|
||||
});
|
||||
|
|
@ -219,3 +222,5 @@ TEST_CASE(threaded_promise_synchronously_resolved)
|
|||
EXPECT(resolved);
|
||||
EXPECT(!rejected);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user