Native code testing
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-12-02 13:38:54 -05:00
parent cb9dc3170d
commit b0aecef1ed
5 changed files with 70 additions and 10 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10.0)
cmake_minimum_required(VERSION 3.20.0)
project(StormEngine VERSION 0.1.0 LANGUAGES C)
# Find sources
@ -11,16 +11,47 @@ include_directories(src/fluid/includes)
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
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 ()

14
Jenkinsfile vendored
View File

@ -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']]
}
}
}
}
}

View File

@ -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

View File

@ -0,0 +1,6 @@
#include <stdio.h>
int test_c_StormEngineTests(int argc, char **argv){
printf("it lives\n");
return 0;
}

5
test/c/TestAsdf.c Normal file
View File

@ -0,0 +1,5 @@
int test_c_TestAsdf(){
return 0;
}