diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 104c2f4e..4f7a8cb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ env: BUILD_TYPE: DEBUG jobs: - build: + d_build: # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix @@ -20,12 +20,80 @@ jobs: - uses: actions/checkout@v2 - name: Install Dependencies - run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev + run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmysqlclient-dev + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DDEBUG=1 -DMYSQL=1 + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install Dependencies + run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev libmysqlclient-dev + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DMYSQL=1 + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} + + nsql_d_build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install Dependencies + run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DDEBUG=1 + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} + + nsql_build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install Dependencies + run: sudo apt-get install -y libgpg-error-dev libgcrypt20-dev - name: Configure CMake # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{github.workspace}}/build - name: Build # Build your program with the given configuration diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fe19e5f..6ae94e4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) enable_testing() endif() -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -O0 -fprofile-arcs -ftest-coverage") include_directories(include) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index d0b8eb33..16e27cc0 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -56,3 +56,37 @@ foreach(SOURCE_PATH ${SOURCE_FILES}) endforeach(SOURCE_PATH ${SOURCE_FILES}) target_include_directories (Crypto PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +set(OBJECT_DIR ${PROJECT_BINARY_DIR}/src/CMakeFiles/Crypto.dir/src_main) + + +# Create the gcov target. Run coverage tests with 'make gcov' +add_custom_target(gcov + COMMAND mkdir -p coverage + COMMAND ${CMAKE_MAKE_PROGRAM} test + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + ) +add_custom_command(TARGET gcov + COMMAND echo "=================== GCOV ====================" + COMMAND gcov -b -o ${OBJECT_DIR} crypto_aos.c.gnco crypto_config.c.gnco crypto_key_mgmt.c.gnco crypto_mc.c.gnco crypto_print.c.gnco crypto_tc.c.gnco crypto_tm.c.gnco crypto_user.c.gnco crypto.c.gnco sadb_routine_inmemory.template.c.gnco sadb_routine.c.gnco + # | grep -A 5 "Adder.cpp" > CoverageSummary.tmp + #COMMAND cat CoverageSummary.tmp + #COMMAND echo "-- Coverage files have been output to ${PROJECT_BINARY_DIR}/coverage" + COMMAND lcov -c --directory ${OBJECT_DIR} --output-file ${PROJECT_BINARY_DIR}/coverage/results.info + COMMAND genhtml ${PROJECT_BINARY_DIR}/coverage/results.info --output-directory ${PROJECT_BINARY_DIR}/coverage/results + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/coverage + ) +add_dependencies(gcov ut_tc_apply) +# Make sure to clean up the coverage folder +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES coverage) + + + +# Create the gcov-clean target. This cleans the build as well as generated +# .gcda and .gcno files. +add_custom_target(scrub +COMMAND ${CMAKE_MAKE_PROGRAM} clean +COMMAND rm -f ${OBJECT_DIR}/*.gcno +COMMAND rm -f ${OBJECT_DIR}/*.gcda +WORKING_DIRECTORY ${PROJECT_BINARY_DIR} +)