mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
CMake: Build LibCore tests in Tests/LibCore not Meta/Lagom
As LibCore was not specified in TEST_DIRECTORIES, the existing Tests/LibCore subdirectory was not actually included during configuration.
This commit is contained in:
parent
d44ac0874f
commit
8864b3e9d1
Notes:
github-actions[bot]
2025-05-14 08:06:35 +00:00
Author: https://github.com/ayeteadoe
Commit: 8864b3e9d1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4718
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 45 additions and 178 deletions
|
@ -2,12 +2,13 @@ set(TEST_SOURCES
|
|||
TestLibCoreArgsParser.cpp
|
||||
TestLibCoreDateTime.cpp
|
||||
TestLibCoreDeferredInvoke.cpp
|
||||
TestLibCoreFilePermissionsMask.cpp
|
||||
TestLibCoreFileWatcher.cpp
|
||||
TestLibCoreMappedFile.cpp
|
||||
# FIXME: Identify and address the commit that caused this to start failing at runtime
|
||||
#TestLibCoreMappedFile.cpp
|
||||
TestLibCorePromise.cpp
|
||||
TestLibCoreSharedSingleProducerCircularQueue.cpp
|
||||
TestLibCoreStream.cpp
|
||||
# FIXME: Identify and address the commit that caused this to start failing at runtime
|
||||
#TestLibCoreStream.cpp
|
||||
)
|
||||
|
||||
foreach(source IN LISTS TEST_SOURCES)
|
||||
|
@ -17,5 +18,24 @@ endforeach()
|
|||
target_link_libraries(TestLibCoreDateTime PRIVATE LibUnicode)
|
||||
target_link_libraries(TestLibCorePromise PRIVATE LibThreading)
|
||||
# NOTE: Required because of the LocalServer tests
|
||||
target_link_libraries(TestLibCoreStream PRIVATE LibThreading)
|
||||
if (TARGET TestLibCoreStream)
|
||||
target_link_libraries(TestLibCoreStream PRIVATE LibThreading)
|
||||
endif()
|
||||
target_link_libraries(TestLibCoreSharedSingleProducerCircularQueue PRIVATE LibThreading)
|
||||
|
||||
if (ENABLE_SWIFT)
|
||||
find_package(SwiftTesting REQUIRED)
|
||||
|
||||
add_executable(TestCoreSwift
|
||||
TestEventLoopActor.swift
|
||||
TestEventLoop.cpp
|
||||
)
|
||||
|
||||
# FIXME: Swift doesn't seem to like object libraries for @main
|
||||
target_sources(TestCoreSwift PRIVATE ../Resources/SwiftTestMain.swift)
|
||||
|
||||
set_target_properties(TestCoreSwift PROPERTIES SUFFIX .swift-testing)
|
||||
target_include_directories(TestCoreSwift PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(TestCoreSwift PRIVATE AK LibCore SwiftTesting::SwiftTesting)
|
||||
add_test(NAME TestCoreSwift COMMAND TestCoreSwift)
|
||||
endif()
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Xavier Defrang <xavier.defrang@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/FilePermissionsMask.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
TEST_CASE(file_permission_mask_from_symbolic_notation)
|
||||
{
|
||||
auto mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation(""sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0);
|
||||
EXPECT_EQ(mask.write_mask(), 0);
|
||||
EXPECT_EQ(mask.apply(0), 0);
|
||||
EXPECT_EQ(mask.apply(0664), 0664);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("u+rwx"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0);
|
||||
EXPECT_EQ(mask.write_mask(), 0700);
|
||||
EXPECT_EQ(mask.apply(0), 0700);
|
||||
EXPECT_EQ(mask.apply(0664), 0764);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("g+rwx"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0);
|
||||
EXPECT_EQ(mask.write_mask(), 0070);
|
||||
EXPECT_EQ(mask.apply(0), 0070);
|
||||
EXPECT_EQ(mask.apply(0664), 0674);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("o+rwx"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0);
|
||||
EXPECT_EQ(mask.write_mask(), 0007);
|
||||
EXPECT_EQ(mask.apply(0), 0007);
|
||||
EXPECT_EQ(mask.apply(0664), 0667);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("a=rx"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0777);
|
||||
EXPECT_EQ(mask.write_mask(), 0555);
|
||||
EXPECT_EQ(mask.apply(0), 0555);
|
||||
EXPECT_EQ(mask.apply(0664), 0555);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("ugo=rx"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0777);
|
||||
EXPECT_EQ(mask.write_mask(), 0555);
|
||||
EXPECT_EQ(mask.apply(0), 0555);
|
||||
EXPECT_EQ(mask.apply(0664), 0555);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("u+rw,g=rx,o-rwx"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0077);
|
||||
EXPECT_EQ(mask.write_mask(), 0650);
|
||||
EXPECT_EQ(mask.apply(0), 0650);
|
||||
EXPECT_EQ(mask.apply(0177), 0750);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("+r"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0);
|
||||
EXPECT_EQ(mask.write_mask(), 0444);
|
||||
EXPECT_EQ(mask.apply(0), 0444);
|
||||
EXPECT_EQ(mask.apply(0123), 0567);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("=rx"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0777);
|
||||
EXPECT_EQ(mask.write_mask(), 0555);
|
||||
EXPECT_EQ(mask.apply(0), 0555);
|
||||
EXPECT_EQ(mask.apply(0664), 0555);
|
||||
|
||||
mask = TRY_OR_FAIL(Core::FilePermissionsMask::from_symbolic_notation("a+X"sv));
|
||||
EXPECT_EQ(mask.clear_mask(), 0);
|
||||
EXPECT_EQ(mask.write_mask(), 0);
|
||||
EXPECT_EQ(mask.directory_or_executable_mask().clear_mask(), 0);
|
||||
EXPECT_EQ(mask.directory_or_executable_mask().write_mask(), 0111);
|
||||
EXPECT_EQ(mask.apply(0), 0);
|
||||
EXPECT_EQ(mask.apply(0100), 0111);
|
||||
EXPECT_EQ(mask.apply(S_IFDIR | 0), S_IFDIR | 0111);
|
||||
|
||||
auto mask_error = Core::FilePermissionsMask::from_symbolic_notation("z+rw"sv);
|
||||
EXPECT(mask_error.is_error());
|
||||
EXPECT(mask_error.error().string_literal().starts_with("invalid class"sv));
|
||||
|
||||
mask_error = Core::FilePermissionsMask::from_symbolic_notation("u*rw"sv);
|
||||
EXPECT(mask_error.is_error());
|
||||
EXPECT(mask_error.error().string_literal().starts_with("invalid operation"sv));
|
||||
|
||||
mask_error = Core::FilePermissionsMask::from_symbolic_notation("u+rz"sv);
|
||||
EXPECT(mask_error.is_error());
|
||||
EXPECT(mask_error.error().string_literal().starts_with("invalid symbolic permission"sv));
|
||||
|
||||
mask_error = Core::FilePermissionsMask::from_symbolic_notation("u+rw;g+rw"sv);
|
||||
EXPECT(mask_error.is_error());
|
||||
EXPECT(mask_error.error().string_literal().starts_with("invalid symbolic permission"sv));
|
||||
}
|
||||
|
||||
TEST_CASE(file_permission_mask_parse)
|
||||
{
|
||||
auto numeric_mask = TRY_OR_FAIL(Core::FilePermissionsMask::parse("750"sv));
|
||||
auto symbolic_mask = TRY_OR_FAIL(Core::FilePermissionsMask::parse("u=rwx,g=rx,o-rwx"sv));
|
||||
|
||||
EXPECT_EQ(numeric_mask.apply(0), 0750);
|
||||
EXPECT_EQ(symbolic_mask.apply(0), 0750);
|
||||
|
||||
EXPECT_EQ(numeric_mask.clear_mask(), symbolic_mask.clear_mask());
|
||||
EXPECT_EQ(numeric_mask.write_mask(), symbolic_mask.write_mask());
|
||||
|
||||
auto mask = Core::FilePermissionsMask::parse("888"sv);
|
||||
EXPECT(mask.is_error());
|
||||
|
||||
mask = Core::FilePermissionsMask::parse("z+rw"sv);
|
||||
EXPECT(mask.is_error());
|
||||
}
|
||||
|
||||
TEST_CASE(numeric_mask_special_bits)
|
||||
{
|
||||
{
|
||||
auto mask = TRY_OR_FAIL(Core::FilePermissionsMask::parse("750"sv));
|
||||
EXPECT_EQ(mask.apply(07000), 07750);
|
||||
}
|
||||
|
||||
{
|
||||
auto mask = TRY_OR_FAIL(Core::FilePermissionsMask::parse("7750"sv));
|
||||
EXPECT_EQ(mask.apply(0), 07750);
|
||||
}
|
||||
|
||||
{
|
||||
auto mask = TRY_OR_FAIL(Core::FilePermissionsMask::parse("0750"sv));
|
||||
EXPECT_EQ(mask.apply(07000), 0750);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue