diff options
| author | Amlal <amlal@nekernel.org> | 2025-08-12 15:25:04 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-08-12 15:25:04 +0200 |
| commit | a2d091a55cdc465a4f90181f2b404bdd062dbad6 (patch) | |
| tree | 9c62d0c14aafb6ee4f520bfc7cbef00816ea200e /tests/test_02_linker | |
| parent | b77d1d0a876b845d98c8828da27b2d828378138f (diff) | |
feat: Linker test and improvements to the linker.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'tests/test_02_linker')
| -rw-r--r-- | tests/test_02_linker/CMakeLists.txt | 23 | ||||
| -rw-r--r-- | tests/test_02_linker/linker_test.cc | 24 | ||||
| -rw-r--r-- | tests/test_02_linker/sample/sample.cc | 3 | ||||
| -rw-r--r-- | tests/test_02_linker/sample/sample.cc.pp | 3 |
4 files changed, 53 insertions, 0 deletions
diff --git a/tests/test_02_linker/CMakeLists.txt b/tests/test_02_linker/CMakeLists.txt new file mode 100644 index 0000000..f3493fc --- /dev/null +++ b/tests/test_02_linker/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.10) +project(NeCTILinkerTest) + +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip +) + +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +enable_testing() + +add_executable(LinkerTestBasic linker_test.cc) +target_link_libraries(LinkerTestBasic gtest_main) + +set_property(TARGET LinkerTestBasic PROPERTY CXX_STANDARD 20) +target_include_directories(LinkerTestBasic PUBLIC ../../) + +include(GoogleTest) +gtest_discover_tests(LinkerTestBasic) diff --git a/tests/test_02_linker/linker_test.cc b/tests/test_02_linker/linker_test.cc new file mode 100644 index 0000000..88d51de --- /dev/null +++ b/tests/test_02_linker/linker_test.cc @@ -0,0 +1,24 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025 Amlal EL Mahrouss, all rights reserved + + ------------------------------------------- */ + + +/// @brief Linker Unit test, from the C++ unit to the final executable. +/// @author Amlal El Mahrouss + +#include <gtest/gtest.h> + +TEST(LinkerTest, BasicLinkTest) +{ + /// @note this is the driver, it will look for a .cc.pp (.pp stands for pre-processed) + auto expr = std::system("pef-amd64-cxxdrv sample/sample.cc"); + EXPECT_TRUE(expr == 0) << "C++ Driver did not compile the easy C++ unit."; + + expr = std::system("asm -asm:x64 sample/sample.cc.pp.masm"); + EXPECT_TRUE(expr == 0) << "Assembler did not assemble the easy asm unit."; + + expr = std::system("ld64 -fat-binary sample/sample.cc.pp.obj -start __NECTI_main -output main.exec"); + EXPECT_TRUE(expr == 0) << "Linker did not link the easy object."; +} diff --git a/tests/test_02_linker/sample/sample.cc b/tests/test_02_linker/sample/sample.cc new file mode 100644 index 0000000..4cce7f6 --- /dev/null +++ b/tests/test_02_linker/sample/sample.cc @@ -0,0 +1,3 @@ +int main() { + return 0; +} diff --git a/tests/test_02_linker/sample/sample.cc.pp b/tests/test_02_linker/sample/sample.cc.pp new file mode 100644 index 0000000..cb3f748 --- /dev/null +++ b/tests/test_02_linker/sample/sample.cc.pp @@ -0,0 +1,3 @@ +int main() { + return 0; +} |
