1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

AK: Add initial support for AK testsuite on Windows

We now explicitly enabling support for the minimum libraries needed
to build and run the AK testsuite. 81/82 tests are running and
passing. The exception is LexicalPath, as some path behaviour on
Windows is different than Unix, so the current tests will have lots of
platform specific failures. The implementer of LexicalPathWindows
recommended windows-specific tests here, so I will do that in a
follow up.
This commit is contained in:
ayeteadoe 2025-05-19 16:16:18 -07:00 committed by Andrew Kaster
parent a11242f3de
commit 8cf01a25c2
Notes: github-actions[bot] 2025-05-20 16:59:46 +00:00
8 changed files with 53 additions and 15 deletions

View file

@ -13,9 +13,10 @@
#include <AK/Platform.h> #include <AK/Platform.h>
#include <AK/Types.h> #include <AK/Types.h>
#ifdef AK_OS_WINDOWS #ifdef AK_OS_WINDOWS
// https://learn.microsoft.com/en-us/windows/win32/api/winsock/ns-winsock-timeval
struct timeval { struct timeval {
long tv_sec; long tv_sec { 0 };
long tv_usec; long tv_usec { 0 };
}; };
#else #else
# include <sys/time.h> # include <sys/time.h>

View file

@ -1,3 +1,14 @@
add_subdirectory(LibRegex)
add_subdirectory(LibTest)
add_subdirectory(LibTextCodec)
add_subdirectory(LibUnicode)
add_subdirectory(LibURL)
# FIXME: Increase support for building targets on Windows
if (WIN32 AND ENABLE_WINDOWS_CI)
return()
endif()
add_subdirectory(LibCompress) add_subdirectory(LibCompress)
add_subdirectory(LibCrypto) add_subdirectory(LibCrypto)
add_subdirectory(LibDiff) add_subdirectory(LibDiff)
@ -7,16 +18,11 @@ add_subdirectory(LibHTTP)
add_subdirectory(LibIPC) add_subdirectory(LibIPC)
add_subdirectory(LibJS) add_subdirectory(LibJS)
add_subdirectory(LibLine) add_subdirectory(LibLine)
add_subdirectory(LibRegex)
add_subdirectory(LibRequests) add_subdirectory(LibRequests)
add_subdirectory(LibRIFF) add_subdirectory(LibRIFF)
add_subdirectory(LibSyntax) add_subdirectory(LibSyntax)
add_subdirectory(LibTest)
add_subdirectory(LibTextCodec)
add_subdirectory(LibThreading) add_subdirectory(LibThreading)
add_subdirectory(LibTLS) add_subdirectory(LibTLS)
add_subdirectory(LibUnicode)
add_subdirectory(LibURL)
add_subdirectory(LibWasm) add_subdirectory(LibWasm)
add_subdirectory(LibWebSocket) add_subdirectory(LibWebSocket)
add_subdirectory(LibXML) add_subdirectory(LibXML)

View file

@ -2,8 +2,6 @@ add_library(LibTestMain OBJECT TestMain.cpp AssertionHandler.cpp)
target_link_libraries(LibTestMain PUBLIC GenericClangPlugin) target_link_libraries(LibTestMain PUBLIC GenericClangPlugin)
add_library(JavaScriptTestRunnerMain OBJECT JavaScriptTestRunnerMain.cpp)
set(SOURCES set(SOURCES
TestSuite.cpp TestSuite.cpp
) )
@ -12,3 +10,10 @@ add_library(LibTest ${SOURCES})
lagom_generate_export_header(LibTest test) lagom_generate_export_header(LibTest test)
target_link_libraries(LibTest PRIVATE AK LibCore LibFileSystem) target_link_libraries(LibTest PRIVATE AK LibCore LibFileSystem)
set_target_properties(LibTest PROPERTIES OUTPUT_NAME lagom-test) set_target_properties(LibTest PROPERTIES OUTPUT_NAME lagom-test)
# FIXME: Increase support for building targets on Windows
if (WIN32 AND ENABLE_WINDOWS_CI)
return()
endif()
add_library(JavaScriptTestRunnerMain OBJECT JavaScriptTestRunnerMain.cpp)

View file

@ -20,6 +20,7 @@ set(AK_TEST_SOURCES
TestDisjointChunks.cpp TestDisjointChunks.cpp
TestDistinctNumeric.cpp TestDistinctNumeric.cpp
TestDoublyLinkedList.cpp TestDoublyLinkedList.cpp
TestDuration.cpp
TestEndian.cpp TestEndian.cpp
TestEnumBits.cpp TestEnumBits.cpp
TestEnumerate.cpp TestEnumerate.cpp
@ -44,7 +45,6 @@ set(AK_TEST_SOURCES
TestIntrusiveRedBlackTree.cpp TestIntrusiveRedBlackTree.cpp
TestJSON.cpp TestJSON.cpp
TestLEB128.cpp TestLEB128.cpp
TestLexicalPath.cpp
TestMemory.cpp TestMemory.cpp
TestMemoryStream.cpp TestMemoryStream.cpp
TestNeverDestroyed.cpp TestNeverDestroyed.cpp
@ -70,7 +70,6 @@ set(AK_TEST_SOURCES
TestStringFloatingPointConversions.cpp TestStringFloatingPointConversions.cpp
TestStringUtils.cpp TestStringUtils.cpp
TestStringView.cpp TestStringView.cpp
TestDuration.cpp
TestTrie.cpp TestTrie.cpp
TestTuple.cpp TestTuple.cpp
TestTypeTraits.cpp TestTypeTraits.cpp
@ -83,10 +82,21 @@ set(AK_TEST_SOURCES
TestWeakPtr.cpp TestWeakPtr.cpp
) )
# FIXME: LexicalPathWindows has some parenting and path parts sizing inconsistencies with LexicalPath, so it deserves
# it's own platform-specific tests to avoid if-def soup in the Unix-based tests.
if(NOT WIN32)
list(APPEND AK_TEST_SOURCES TestLexicalPath.cpp)
endif()
foreach(source IN LISTS AK_TEST_SOURCES) foreach(source IN LISTS AK_TEST_SOURCES)
serenity_test("${source}" AK) serenity_test("${source}" AK)
endforeach() endforeach()
if (WIN32)
# FIXME: Windows on ARM
target_link_libraries(TestUFixedBigInt PRIVATE clang_rt.builtins-x86_64.lib)
endif()
if (CXX_COMPILER_SUPPORTS_BLOCKS) if (CXX_COMPILER_SUPPORTS_BLOCKS)
serenity_test(TestFunction.mm AK NAME TestFunction) serenity_test(TestFunction.mm AK NAME TestFunction)
target_link_libraries(TestFunction PRIVATE ${BLOCKS_REQUIRED_LIBRARIES}) target_link_libraries(TestFunction PRIVATE ${BLOCKS_REQUIRED_LIBRARIES})

View file

@ -7,11 +7,10 @@
#include <LibTest/TestCase.h> #include <LibTest/TestCase.h>
#include <AK/Time.h> #include <AK/Time.h>
#include <sys/time.h>
using AK::Duration; using AK::Duration;
#if defined(__TIMESIZE) && __TIMESIZE < 64 #if (defined(__TIMESIZE) && __TIMESIZE < 64) || defined(AK_OS_WINDOWS) // NOTE: See AK/Time.h, on Windows we hardcode to long's for timeval
# define TIME_T_IS_32BIT # define TIME_T_IS_32BIT
#endif #endif

View file

@ -9,8 +9,10 @@
#include <AK/ByteString.h> #include <AK/ByteString.h>
#include <AK/StringBuilder.h> #include <AK/StringBuilder.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <math.h>
#include <unistd.h> #ifdef AK_OS_WINDOWS
# include <stdio.h>
#endif
TEST_CASE(is_integral_works_properly) TEST_CASE(is_integral_works_properly)
{ {
@ -232,8 +234,12 @@ TEST_CASE(file_descriptor)
{ {
char filename[] = "/tmp/test-file-descriptor-XXXXXX"; char filename[] = "/tmp/test-file-descriptor-XXXXXX";
#ifdef AK_OS_WINDOWS
FILE* file = tmpfile();
#else
int fd = mkstemp(filename); int fd = mkstemp(filename);
FILE* file = fdopen(fd, "w+"); FILE* file = fdopen(fd, "w+");
#endif
outln(file, "{}", "Hello, World!"); outln(file, "{}", "Hello, World!");
out(file, "foo"); out(file, "foo");

View file

@ -1,4 +1,10 @@
add_subdirectory(AK) add_subdirectory(AK)
# FIXME: Increase support for building targets on Windows
if (WIN32 AND ENABLE_WINDOWS_CI)
return()
endif()
add_subdirectory(LibCrypto) add_subdirectory(LibCrypto)
add_subdirectory(LibCompress) add_subdirectory(LibCompress)
add_subdirectory(LibCore) add_subdirectory(LibCore)

View file

@ -1,3 +1,8 @@
# FIXME: Increase support for building targets on Windows
if (WIN32 AND ENABLE_WINDOWS_CI)
return()
endif()
lagom_utility(abench SOURCES abench.cpp LIBS LibMain LibFileSystem LibMedia) lagom_utility(abench SOURCES abench.cpp LIBS LibMain LibFileSystem LibMedia)
lagom_utility(dns SOURCES dns.cpp LIBS LibDNS LibMain LibTLS LibCrypto) lagom_utility(dns SOURCES dns.cpp LIBS LibDNS LibMain LibTLS LibCrypto)