From c23a55278a0f6e62e950e3ed2e6a4c8aefd27c37 Mon Sep 17 00:00:00 2001 From: djtodoro Date: Fri, 6 Dec 2024 15:24:22 +0100 Subject: [PATCH] test: Run lit with 1 thread - This was causing PAGE FAULT Kernel BUG - Improve CMake - Renable a bunch of native tests to be run with make check --- CMakeLists.txt | 66 ++----------------- test/CMakeLists.txt | 3 +- test/native/ftrace-disable-enable.test | 16 ++--- test/native/hide-unhide-module.test | 1 - test/native/hiden-file-in-all-dirs.test | 1 - test/native/hiden-file.test | 1 - test/native/nc-backdoor-bdclient.test | 1 - test/native/nc-backdoor-echo-s.test | 1 - test/native/nc-backdoor-plus-pid.test | 1 - ...c-backdoor-remove-and-install-nc-tool.test | 1 - test/native/nc-backdoor.test | 1 - test/native/proc-timeout.test | 1 - test/native/simple-insmod-lkm.test | 1 - 13 files changed, 13 insertions(+), 82 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cbcb79..a7c0611 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,78 +68,20 @@ message(STATUS "NATIVE_TESTS: ${NATIVE_TESTS}") message(STATUS "DEPLOY build: ${DEPLOY}") message(STATUS "DEBUG build: ${DEBUG}") -# Define COMPILER_OPTIONS as a list -set(COMPILER_OPTIONS - -Wno-error - "-DPROCNAME=\"${PROCNAME}\"" - "-DMODNAME=\"${MODNAME}\"" - -DKSOCKET_EMBEDDED - ${DEBUG_PR} - -DCPUHACK - -DPRCTIMEOUT=1200 - "-DUUIDGEN=\"${UUIDGEN_OUTPUT}\"" - "-DJOURNALCTL=\"${JOURNALCTL}\"" -) - -# Combine the list into a space-separated string -string(JOIN " " COMPILER_OPTIONS_STR ${COMPILER_OPTIONS}) - -# Define EXTRA_CFLAGS as a list and join it into a string -set(EXTRA_CFLAGS_LIST - "-I${KERNEL_DIR}/include" - "-I${CMAKE_CURRENT_SOURCE_DIR}/src" - "-I${CMAKE_CURRENT_SOURCE_DIR}/fs" - "-I$(KERNEL_DIR)/include/generated" - ${COMPILER_OPTIONS} -) - -string(JOIN " " EXTRA_CFLAGS_STR ${EXTRA_CFLAGS_LIST}) - -message("-- Extra CFLAGS: ${EXTRA_CFLAGS_STR}") - -# Step 7: Define Source Files and Extra Flags -set(SRC - src/${MODNAME}.c - src/pid.c - src/fs.c - src/sys.c - src/sock.c - src/util.c - src/vm.c -) - -# Step 8: Create the 'persist' Target using configure_file -set(UUIDGEN_SH "${UUIDGEN_OUTPUT}.sh") -set(UUIDGEN_KO "${UUIDGEN_OUTPUT}.ko") - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/persist.S.in ${CMAKE_CURRENT_BINARY_DIR}/persist.S @ONLY) - -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/persist.o ${CMAKE_CURRENT_BINARY_DIR}/persist - COMMAND ${AS} --64 ${CMAKE_CURRENT_BINARY_DIR}/persist.S -statistics -fatal-warnings -size-check=error -o ${CMAKE_CURRENT_BINARY_DIR}/persist.o - COMMAND ${LD} -Ttext 200000 --oformat binary -o ${CMAKE_CURRENT_BINARY_DIR}/persist ${CMAKE_CURRENT_BINARY_DIR}/persist.o - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/persist.S - COMMENT "Building persist binary" -) - -# Step 9: Rename the custom target to avoid name collision -add_custom_target(build_persist DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/persist) - -# Step 10: Create the 'kovid' Target +# Step 7: Create the 'kovid' Target add_custom_target(kovid ALL - DEPENDS build_persist - COMMAND make -C "${KERNEL_DIR}" M="${CMAKE_CURRENT_SOURCE_DIR}" modules KBUILD_EXTRA_CFLAGS="${EXTRA_CFLAGS_STR}" V=1 + COMMAND echo "-- We use CMake for tests only - kovid.ko is being built from Makefile in the root folder" COMMENT "Building kovid kernel module" ) -# Step 11: Handle Cleaning +# Step 8: Handle Cleaning add_custom_target(clean-kovid COMMAND make -C "${KERNEL_DIR}" M="${CMAKE_CURRENT_SOURCE_DIR}" clean COMMAND ${CMAKE_COMMAND} -E rm -f ${CMAKE_CURRENT_BINARY_DIR}/persist ${CMAKE_CURRENT_BINARY_DIR}/persist.o ${CMAKE_CURRENT_BINARY_DIR}/persist.S COMMENT "Cleaning kovid module" ) -# Step 12: Copy kovid.ko and qemu-runner.sh to the build directory +# Step 9: Copy kovid.ko and qemu-runner.sh to the build directory add_custom_command(TARGET kovid POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/kovid.ko ${CMAKE_CURRENT_BINARY_DIR}/kovid.ko COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test/Artefacts/qemu-runner.sh ${CMAKE_CURRENT_BINARY_DIR}/qemu-runner.sh diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6161024..8da0cfe 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -60,10 +60,11 @@ else() add_lit_testsuite(check-kovid "Running the KOVID regression tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${KOVID_TEST_DEPENDS} + ARGS --threads=1 ) endif() set_target_properties(check-kovid PROPERTIES FOLDER "Tests") # Add the main lit testsuites -add_lit_testsuites(KOVID ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${KOVID_TEST_DEPENDS}) \ No newline at end of file +add_lit_testsuites(KOVID ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${KOVID_TEST_DEPENDS}) diff --git a/test/native/ftrace-disable-enable.test b/test/native/ftrace-disable-enable.test index dd4d9bf..fb00cc1 100644 --- a/test/native/ftrace-disable-enable.test +++ b/test/native/ftrace-disable-enable.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS @@ -49,14 +48,13 @@ sudo dmesg # CHECK: Kovid functionality with ftrace_enabled=2 is working. # CHECK: Value of ftrace_enabled after writing -1: 1 -# CHECK: kv: using kprobe for kallsyms_lookup_name -# CHECK: Waiting for event -# CHECK: loaded -# CHECK: Got event -# CHECK: hide: {{.*}} -# CHECK: hide: {{.*}} -# CHECK: Got event -# CHECK: unloaded +# CHECK: sys_init: ftrace hook 0 +# CHECK: sys_init: ftrace hook 1 +# CHECK: sys_init: ftrace hook 2 +# CHECK: sys_init: ftrace hook 3 +# CHECK: sys_init: ftrace hook 4 +# CHECK: sys_init: ftrace hook 5 +# CHECK: sys_init: ftrace hook 6 # FIXME: It should print # Value of ftrace_enabled after writing 2: 1 diff --git a/test/native/hide-unhide-module.test b/test/native/hide-unhide-module.test index 96db504..13ceff5 100644 --- a/test/native/hide-unhide-module.test +++ b/test/native/hide-unhide-module.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/hiden-file-in-all-dirs.test b/test/native/hiden-file-in-all-dirs.test index 45a9d20..24192f1 100644 --- a/test/native/hiden-file-in-all-dirs.test +++ b/test/native/hiden-file-in-all-dirs.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/hiden-file.test b/test/native/hiden-file.test index aef8702..ec7c388 100644 --- a/test/native/hiden-file.test +++ b/test/native/hiden-file.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/nc-backdoor-bdclient.test b/test/native/nc-backdoor-bdclient.test index f6ce207..646796b 100644 --- a/test/native/nc-backdoor-bdclient.test +++ b/test/native/nc-backdoor-bdclient.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/nc-backdoor-echo-s.test b/test/native/nc-backdoor-echo-s.test index 4e1035d..22c3e3e 100644 --- a/test/native/nc-backdoor-echo-s.test +++ b/test/native/nc-backdoor-echo-s.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/nc-backdoor-plus-pid.test b/test/native/nc-backdoor-plus-pid.test index b02c5be..a561e93 100644 --- a/test/native/nc-backdoor-plus-pid.test +++ b/test/native/nc-backdoor-plus-pid.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/nc-backdoor-remove-and-install-nc-tool.test b/test/native/nc-backdoor-remove-and-install-nc-tool.test index 4c02b80..d0b3a42 100644 --- a/test/native/nc-backdoor-remove-and-install-nc-tool.test +++ b/test/native/nc-backdoor-remove-and-install-nc-tool.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/nc-backdoor.test b/test/native/nc-backdoor.test index be76639..eb974fe 100644 --- a/test/native/nc-backdoor.test +++ b/test/native/nc-backdoor.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/proc-timeout.test b/test/native/proc-timeout.test index a1f80fc..7e92de6 100644 --- a/test/native/proc-timeout.test +++ b/test/native/proc-timeout.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS diff --git a/test/native/simple-insmod-lkm.test b/test/native/simple-insmod-lkm.test index 38278b7..9e3ea73 100644 --- a/test/native/simple-insmod-lkm.test +++ b/test/native/simple-insmod-lkm.test @@ -1,4 +1,3 @@ -# REQUIRES: 0 # REQUIRES: DEBUG_ONLY # REQUIRES: NATIVE_TESTS