Skip to content

Commit

Permalink
Merge pull request #153 from carloslack/fix-page-fault
Browse files Browse the repository at this point in the history
test: Run lit with 1 thread
  • Loading branch information
carloslack authored Dec 6, 2024
2 parents d971907 + c23a552 commit 4cd3cde
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 82 deletions.
66 changes: 4 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
add_lit_testsuites(KOVID ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${KOVID_TEST_DEPENDS})
16 changes: 7 additions & 9 deletions test/native/ftrace-disable-enable.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/native/hide-unhide-module.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/hiden-file-in-all-dirs.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/hiden-file.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/nc-backdoor-bdclient.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/nc-backdoor-echo-s.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/nc-backdoor-plus-pid.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/nc-backdoor-remove-and-install-nc-tool.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/nc-backdoor.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/proc-timeout.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down
1 change: 0 additions & 1 deletion test/native/simple-insmod-lkm.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REQUIRES: 0
# REQUIRES: DEBUG_ONLY
# REQUIRES: NATIVE_TESTS

Expand Down

0 comments on commit 4cd3cde

Please sign in to comment.