diff --git a/CMakeLists.txt b/CMakeLists.txt index 845c175b..57ad6cba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,57 @@ -cmake_minimum_required(VERSION 3.10.0) +cmake_minimum_required(VERSION 3.20.0) project(StormEngine VERSION 0.1.0 LANGUAGES C) # Find sources file(GLOB_RECURSE SOURCES src/fluid/src/**.c) -#include header files +# include header files include_directories(src/fluid/includes) -#include jni +# include jni find_package(JNI REQUIRED) include_directories(${JNI_INCLUDE_DIRS}) -#include architecture flags -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -mavx -mavx2") - -#emit to shared-folder -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/shared-folder) - -#Create shared library +# Create shared library add_library(StormEngine SHARED ${SOURCES}) +# set props for the lib +target_compile_options(StormEngine PRIVATE -m64 -mavx -mavx2) +set_target_properties(StormEngine PROPERTIES + CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/shared-folder +) +# include and enable testing include(CTest) enable_testing() +# emit test driver to outdir +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/out/build/default) + +# Grab test files +file(GLOB_RECURSE TEST_FILES ${CMAKE_SOURCE_DIR}/test/c/**.c) +set(TEST_DRIVER test_driver.c) + +# preprocess the test files to use relative paths +set(TEST_SOURCES "") +foreach(TEST_FILE ${TEST_FILES}) + file(RELATIVE_PATH REL_TEST_FILE ${CMAKE_SOURCE_DIR} ${TEST_FILE}) + # get_filename_component (TEST_NAME ${TEST_FILE} NAME) + list(APPEND TEST_SOURCES ${REL_TEST_FILE}) +endforeach() + +# Add test sources +create_test_sourcelist(TEST_SOURCE_LIST ${TEST_DRIVER} ${TEST_SOURCES}) + +# Create test executable +add_executable(test_runner ${TEST_SOURCE_LIST}) + +# link the library to the test executable +target_link_libraries(test_runner StormEngine) + +# add tests for each test source file +foreach (TEST_FILE ${TEST_SOURCES}) + get_filename_component (TEST_NAME ${TEST_FILE} NAME_WE) + get_filename_component (TEST_PATH ${TEST_FILE} DIRECTORY) + add_test(NAME ${TEST_NAME} COMMAND test_runner ${TEST_PATH}/${TEST_NAME}) +endforeach () + diff --git a/Jenkinsfile b/Jenkinsfile index 674023ac..219744ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -89,5 +89,19 @@ pipeline { } } } + stage('Test') { + steps { + script { + catchError { + sh 'cd ./out/build/default && ctest && cd ../../..' + } + } + } + post { + always { + junit testResults: 'target/surefire-reports/*.xml', keepLongStdio: true, testDataPublishers: [[$class:'AttachmentPublisher']] + } + } + } } } \ No newline at end of file diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 2d9ccca5..189adb0f 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1220,6 +1220,10 @@ Fluid simulation normalization ratio Stabilized static liquids Integrate CMake + Ninja +(12/02/2024) +Add testing to native code side +Add native testing step to jenkins pipeline + # TODO diff --git a/test/c/StormEngineTests.c b/test/c/StormEngineTests.c new file mode 100644 index 00000000..5a18fa32 --- /dev/null +++ b/test/c/StormEngineTests.c @@ -0,0 +1,6 @@ +#include + +int test_c_StormEngineTests(int argc, char **argv){ + printf("it lives\n"); + return 0; +} \ No newline at end of file diff --git a/test/c/TestAsdf.c b/test/c/TestAsdf.c new file mode 100644 index 00000000..8ac1d033 --- /dev/null +++ b/test/c/TestAsdf.c @@ -0,0 +1,5 @@ + + +int test_c_TestAsdf(){ + return 0; +} \ No newline at end of file