summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-07 14:57:33 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-03-07 14:57:33 +0100
commitb64851f5c5654f9f28bd18b42155e5daea8c7e50 (patch)
tree4aff5ac6070a09ba52c6bf3252e1a98ee9541e1e /src
parent9b9a5b20b95f82b7adf5698fcc12915acf6f7b92 (diff)
[FIX] Fixes in toolchain testing.compiler_kit-test-overhaul
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/CompilerKit/test/Linkers/DynamicLinker64+MachO.test.cpp42
-rw-r--r--src/CompilerKit/test/Linkers/DynamicLinker64+PEF.test.cpp44
-rw-r--r--src/CompilerKit/test/Linkers/ck-linker-test-osx-posix.json5
-rw-r--r--src/CompilerKit/test/Linkers/ck-linker-test-pef-posix.json3
4 files changed, 72 insertions, 22 deletions
diff --git a/src/CompilerKit/test/Linkers/DynamicLinker64+MachO.test.cpp b/src/CompilerKit/test/Linkers/DynamicLinker64+MachO.test.cpp
index a08abc5..c9d41fc 100644
--- a/src/CompilerKit/test/Linkers/DynamicLinker64+MachO.test.cpp
+++ b/src/CompilerKit/test/Linkers/DynamicLinker64+MachO.test.cpp
@@ -6,22 +6,46 @@
/// @author Amlal El Mahrouss
#include <CompilerKit/Detail/Config.h>
-#include <gtest/gtest.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/Utilities/Compiler.h>
+#include <CompilerKit/Utilities/DLL.h>
-CK_IMPORT_C Int32 DynamicLinker64MachO(Int32 argc, char** argv);
+#include <gtest/gtest.h>
-static Int32 kArgc{};
-static char** kArgv{};
+static Int32 argc{};
+static char** argv{};
-Int32 main(Int32 argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
+Int32 main(Int32 _argc, char** _argv) {
+ ::testing::InitGoogleTest(&_argc, _argv);
- kArgc = argc;
- kArgv = argv;
+ argc = _argc;
+ argv = _argv;
return RUN_ALL_TESTS();
}
+#ifdef __APPLE__
+static auto kPath = "/usr/local/lib/libCompilerKit.dylib";
+#else
+static auto kPath = "/usr/lib/libCompilerKit.so";
+#endif
+
+static auto kSymbol = "DynamicLinker64MachO";
+
TEST(LinkerRunMachO, LinkerExitsCorrectly) {
- EXPECT_TRUE(DynamicLinker64MachO(kArgc, kArgv) == 0);
+ CompilerKit::ModuleLoader dylib;
+ dylib(kPath, kSymbol);
+
+ CompilerKit::ModuleLoader::EntryT entrypoint_cxx =
+ reinterpret_cast<CompilerKit::ModuleLoader::EntryT>(dylib.fEntrypoint);
+
+ if (!entrypoint_cxx) {
+ kStdOut;
+ std::printf("error: Could not find entrypoint in %s: %s\n", kPath, dlerror());
+
+ return;
+ }
+
+ auto ret =(entrypoint_cxx(argc, const_cast<const char**>(argv)) == NECTAR_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE;
+ EXPECT_TRUE(ret == EXIT_SUCCESS);
}
diff --git a/src/CompilerKit/test/Linkers/DynamicLinker64+PEF.test.cpp b/src/CompilerKit/test/Linkers/DynamicLinker64+PEF.test.cpp
index 7cd3645..1b801d7 100644
--- a/src/CompilerKit/test/Linkers/DynamicLinker64+PEF.test.cpp
+++ b/src/CompilerKit/test/Linkers/DynamicLinker64+PEF.test.cpp
@@ -6,22 +6,46 @@
/// @author Amlal El Mahrouss
#include <CompilerKit/Detail/Config.h>
-#include <gtest/gtest.h>
+#include <CompilerKit/ErrorID.h>
+#include <CompilerKit/Utilities/Compiler.h>
+#include <CompilerKit/Utilities/DLL.h>
-CK_IMPORT_C Int32 DynamicLinker64PEF(Int32 argc, char** argv);
+#include <gtest/gtest.h>
-static Int32 kArgc{};
-static char** kArgv{};
+static Int32 argc{};
+static char** argv{};
-Int32 main(Int32 argc, char** argv) {
- ::testing::InitGoogleTest(&argc, argv);
+Int32 main(Int32 _argc, char** _argv) {
+ ::testing::InitGoogleTest(&_argc, _argv);
- kArgc = argc;
- kArgv = argv;
+ argc = _argc;
+ argv = _argv;
return RUN_ALL_TESTS();
}
-TEST(LinkerRunPEF, LinkerExitsCorrectly) {
- EXPECT_TRUE(DynamicLinker64PEF(kArgc, kArgv) == 0);
+#ifdef __APPLE__
+static auto kPath = "/usr/local/lib/libCompilerKit.dylib";
+#else
+static auto kPath = "/usr/lib/libCompilerKit.so";
+#endif
+
+static auto kSymbol = "DynamicLinker64PEF";
+
+TEST(LinkerRunMachO, LinkerExitsCorrectly) {
+ CompilerKit::ModuleLoader dylib;
+ dylib(kPath, kSymbol);
+
+ CompilerKit::ModuleLoader::EntryT entrypoint_cxx =
+ reinterpret_cast<CompilerKit::ModuleLoader::EntryT>(dylib.fEntrypoint);
+
+ if (!entrypoint_cxx) {
+ kStdOut;
+ std::printf("error: Could not find entrypoint in %s: %s\n", kPath, dlerror());
+
+ return;
+ }
+
+ auto ret =(entrypoint_cxx(argc, const_cast<const char**>(argv)) == NECTAR_SUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE;
+ EXPECT_TRUE(ret == EXIT_SUCCESS);
}
diff --git a/src/CompilerKit/test/Linkers/ck-linker-test-osx-posix.json b/src/CompilerKit/test/Linkers/ck-linker-test-osx-posix.json
index 14eb174..790bc63 100644
--- a/src/CompilerKit/test/Linkers/ck-linker-test-osx-posix.json
+++ b/src/CompilerKit/test/Linkers/ck-linker-test-osx-posix.json
@@ -17,8 +17,9 @@
"-lgtest",
"-lCompilerKit"
],
- "cpp_macros": [
- "__NECTAR__=202505",
+ "cpp_macros": [
+ "CK_POSIX",
+ "__NECTAR__=202603",
"kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
],
"run_after_build": true
diff --git a/src/CompilerKit/test/Linkers/ck-linker-test-pef-posix.json b/src/CompilerKit/test/Linkers/ck-linker-test-pef-posix.json
index b1ee0d7..08ebf15 100644
--- a/src/CompilerKit/test/Linkers/ck-linker-test-pef-posix.json
+++ b/src/CompilerKit/test/Linkers/ck-linker-test-pef-posix.json
@@ -17,7 +17,8 @@
"-lgtest"
],
"cpp_macros": [
- "__NECTAR__=202505",
+ "__NECTAR__=202603",
+ "CK_POSIX",
"kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)"
],
"run_after_build": true