diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-06 06:36:01 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-06 06:37:15 +0100 |
| commit | ac993e1cf8ec4c55cbd1e80c7b94ac492d6dc4e8 (patch) | |
| tree | 7993e57bdab4fa9b6400d81ae477c736193de352 /test/kernel_test | |
| parent | a5f3fdf32ba6aa34a5dd05eeb807446a9f046393 (diff) | |
[FEAT] HeapMgr: Add LockDelegate to allocation calls, and re-introduce double-free prevention.
[CHORE] FileMgr: Cleanup and tweaks.
[CHORE] ABI: Update copyright year.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'test/kernel_test')
| -rw-r--r-- | test/kernel_test/Makefile | 22 | ||||
| -rw-r--r-- | test/kernel_test/error.test.cc | 67 | ||||
| -rw-r--r-- | test/kernel_test/print.test.cc | 73 | ||||
| -rw-r--r-- | test/kernel_test/process.test.cc | 78 |
4 files changed, 0 insertions, 240 deletions
diff --git a/test/kernel_test/Makefile b/test/kernel_test/Makefile deleted file mode 100644 index c4057a5e..00000000 --- a/test/kernel_test/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -################################################## -# (c) Amlal El Mahrouss and NeKernel Authors, licensed under the Apache 2.0 license. -# This file is for kernel testing. -################################################## - -GCC=x86_64-w64-mingw32-g++ -Wl,-subsystem=17 -LIB=-L../../src/libSystem -lSystem -STD=-std=c++20 -DKT_TESTING_ENABLED -INCLUDE=-I../../src -I../../public -I../../public/frameworks/ -I../../ - -OBJ_FILES = \ - error.test.exe \ - print.test.exe \ - process.test.exe - -.PHONY: all -all: $(OBJ_FILES) - -%.exe: %.cc - @echo "==> Building test: $@" - $(GCC) $(LIB) $< \ - $(STD) $(INCLUDE) -o $(basename $<).exe
\ No newline at end of file diff --git a/test/kernel_test/error.test.cc b/test/kernel_test/error.test.cc deleted file mode 100644 index ece8f71d..00000000 --- a/test/kernel_test/error.test.cc +++ /dev/null @@ -1,67 +0,0 @@ -/// \file error.test.cc -/// \brief Error handling API tests. -/// \author Amlal El Mahrouss (amlal at nekernel dot org) - -#include <libSystem/SystemKit/System.h> -#include <public/frameworks/KernelTest.fwrk/headers/TestCase.h> - -/// \note ErrGetLastError tests -KT_DECL_TEST(ErrGetLastErrorInitial, []() -> bool { - SInt32 error = ErrGetLastError(); - return error >= 0; -}); - -KT_DECL_TEST(ErrGetLastErrorAfterSuccess, []() -> bool { - auto heap = MmCreateHeap(1024, 0); - if (!heap) return NO; - - SInt32 error = ErrGetLastError(); - MmDestroyHeap(heap); - - return error == 0; -}); - -KT_DECL_TEST(ErrGetLastErrorAfterFailure, []() -> bool { - auto heap = MmCreateHeap(0, 0); - - SInt32 error = ErrGetLastError(); - - return error != 0; -}); - -KT_DECL_TEST(ErrGetLastErrorAfterInvalidFile, []() -> bool { - auto file = IoOpenFile("/invalid/path/that/does/not/exist", nullptr); - - SInt32 error = ErrGetLastError(); - - if (file) IoCloseFile(file); - - return error != 0; -}); - -KT_DECL_TEST(ErrGetLastErrorAfterNullOp, []() -> bool { - auto ptr = MmCopyMemory(nullptr, nullptr, 10); - - SInt32 error = ErrGetLastError(); - - return error != 0; -}); - -KT_DECL_TEST(ErrGetLastErrorMultipleCalls, []() -> bool { - SInt32 error1 = ErrGetLastError(); - SInt32 error2 = ErrGetLastError(); - - return error1 == error2; -}); - -/// \brief Run error tests. -IMPORT_C SInt32 KT_TEST_MAIN() { - KT_RUN_TEST(ErrGetLastErrorInitial); - KT_RUN_TEST(ErrGetLastErrorAfterSuccess); - KT_RUN_TEST(ErrGetLastErrorAfterFailure); - KT_RUN_TEST(ErrGetLastErrorAfterInvalidFile); - KT_RUN_TEST(ErrGetLastErrorAfterNullOp); - KT_RUN_TEST(ErrGetLastErrorMultipleCalls); - - return KT_TEST_SUCCESS; -} diff --git a/test/kernel_test/print.test.cc b/test/kernel_test/print.test.cc deleted file mode 100644 index 4f9bc828..00000000 --- a/test/kernel_test/print.test.cc +++ /dev/null @@ -1,73 +0,0 @@ -/// \file kout.test.cc -/// \brief Konsole Out tests. - -#include <libSystem/SystemKit/System.h> -#include <public/frameworks/KernelTest.fwrk/headers/TestCase.h> - -/// \note PrintGet tests -KT_DECL_TEST(PrintIsNull, []() -> bool { return PrintGet("/null/") == nullptr; }); -KT_DECL_TEST(PrintIsNotNull, []() -> bool { return PrintGet(nullptr) != nullptr; }); - -/// \note PrintCreate/PrintRelease tests -KT_DECL_TEST(PrintCreateValid, []() -> bool { - auto handle = PrintCreate(); - if (!handle) return NO; - PrintRelease(handle); - return YES; -}); - -KT_DECL_TEST(PrintReleaseValid, []() -> bool { - auto handle = PrintCreate(); - if (!handle) return NO; - return PrintRelease(handle) == 0; -}); - -KT_DECL_TEST(PrintReleaseNull, []() -> bool { return PrintRelease(nullptr) != 0; }); - -/// \note PrintOut tests -KT_DECL_TEST(PrintOutValid, []() -> bool { - SInt32 result = PrintOut(nullptr, "Test output\n"); - return result >= 0; -}); - -KT_DECL_TEST(PrintOutWithHandle, []() -> bool { - auto handle = PrintCreate(); - SInt32 result = PrintOut(handle, "Test with handle\n"); - PrintRelease(handle); - return result >= 0; -}); - -KT_DECL_TEST(PrintOutNull, []() -> bool { - SInt32 result = PrintOut(nullptr, nullptr); - return result < 0; -}); - -KT_DECL_TEST(PrintOutFormatted, []() -> bool { - SInt32 result = PrintOut(nullptr, "Value: %d\n", 42); - return result >= 0; -}); - -/// \note PrintIn tests -KT_DECL_TEST(PrintInValid, []() -> bool { - SInt32 result = PrintIn(nullptr, "Input prompt: "); - return result >= 0; -}); - -/// \brief Run 'kout' test. -SInt32 KT_TEST_MAIN() { - KT_RUN_TEST(PrintIsNull); - KT_RUN_TEST(PrintIsNotNull); - - KT_RUN_TEST(PrintCreateValid); - KT_RUN_TEST(PrintReleaseValid); - KT_RUN_TEST(PrintReleaseNull); - - KT_RUN_TEST(PrintOutValid); - KT_RUN_TEST(PrintOutWithHandle); - KT_RUN_TEST(PrintOutNull); - KT_RUN_TEST(PrintOutFormatted); - - KT_RUN_TEST(PrintInValid); - - return KT_TEST_SUCCESS; -} diff --git a/test/kernel_test/process.test.cc b/test/kernel_test/process.test.cc deleted file mode 100644 index 2ec7d191..00000000 --- a/test/kernel_test/process.test.cc +++ /dev/null @@ -1,78 +0,0 @@ -/// \file process.test.cc -/// \brief Process management tests. -/// \author Amlal El Mahrouss (amlal at nekernel dot org) - -#include <KernelTest.fwrk/headers/TestCase.h> -#include <libSystem/SystemKit/System.h> - -/// \note RtlSpawnProcess tests -KT_DECL_TEST(ProcessHasFailed, []() -> bool { - /// \todo we return -1 here, should we document that or classify as common knowledge? - return RtlSpawnProcess("/", 0, nullptr, nullptr, 0) == -1; -}); - -KT_DECL_TEST(ProcessHasSucceeded, []() -> bool { - /// \note Any process greater than zero, exists within a specific team domain (real-time, high, or - /// low domains). - return RtlSpawnProcess("/system/list", 0, nullptr, nullptr, 0) > 0; -}); - -KT_DECL_TEST(ProcessSpawnNullPath, - []() -> bool { return RtlSpawnProcess(nullptr, 0, nullptr, nullptr, 0) == -1; }); - -KT_DECL_TEST(ProcessSpawnInvalidPath, []() -> bool { - return RtlSpawnProcess("/invalid/nonexistent", 0, nullptr, nullptr, 0) == -1; -}); - -/// \note RtlSpawnIB tests -KT_DECL_TEST(ProcessSpawnIBValid, []() -> bool { - UIntPtr pid = RtlSpawnProcess("/system/list", 0, nullptr, nullptr, 0); - if (pid <= 0) return NO; - - UInt32 result = RtlSpawnIB(pid); - return result == 0; -}); - -KT_DECL_TEST(ProcessSpawnIBInvalid, []() -> bool { - UInt32 result = RtlSpawnIB(0); - return result > 0; -}); - -/// \note RtlExitProcess tests -KT_DECL_TEST(ProcessExitValid, []() -> bool { - UIntPtr pid = RtlSpawnProcess("/system/list", 0, nullptr, nullptr, 0); - if (pid <= 0) return NO; - - Bool result = RtlExitProcess(pid, 0); - return result == YES; -}); - -KT_DECL_TEST(ProcessExitWithCode, []() -> bool { - UIntPtr pid = RtlSpawnProcess("/system/list", 0, nullptr, nullptr, 0); - if (pid <= 0) return NO; - - Bool result = RtlExitProcess(pid, 42); - return result == YES; -}); - -KT_DECL_TEST(ProcessExitInvalid, []() -> bool { - Bool result = RtlExitProcess(0, 0); - return result == NO; -}); - -/// \brief Run 'process' test. -IMPORT_C SInt32 KT_TEST_MAIN() { - KT_RUN_TEST(ProcessHasFailed); - KT_RUN_TEST(ProcessHasSucceeded); - KT_RUN_TEST(ProcessSpawnNullPath); - KT_RUN_TEST(ProcessSpawnInvalidPath); - - KT_RUN_TEST(ProcessSpawnIBValid); - KT_RUN_TEST(ProcessSpawnIBInvalid); - - KT_RUN_TEST(ProcessExitValid); - KT_RUN_TEST(ProcessExitWithCode); - KT_RUN_TEST(ProcessExitInvalid); - - return KT_TEST_SUCCESS; -} |
