diff --git a/.github/workflows/build-macos-latest.yml b/.github/workflows/build-macos-latest.yml index 485cdb8..e6d286e 100644 --- a/.github/workflows/build-macos-latest.yml +++ b/.github/workflows/build-macos-latest.yml @@ -29,6 +29,23 @@ jobs: with: submodules: 'recursive' + - name: Install libraries + run: | + checkPkgAndInstall() + { + while [ $# -ne 0 ] + do + rm -f '/usr/local/bin/2to3' + if brew ls --versions $1 ; then + brew upgrade $1 + else + brew install $1 + fi + shift + done + } + checkPkgAndInstall cunit + - name: Create Build Environment # Some projects don't allow in-source building, so create a separate build directory # We'll use this as our working directory for all subsequent commands @@ -42,17 +59,17 @@ jobs: # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_TESTS=1 - name: Build working-directory: ${{github.workspace}}/build shell: bash # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE + run: cmake --build . --config $BUILD_TYPE -j 16 - name: Test working-directory: ${{github.workspace}}/build shell: bash # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C $BUILD_TYPE + run: ctest -C $BUILD_TYPE -j 16 --output-on-failure diff --git a/.github/workflows/build-ubuntu-latest.yml b/.github/workflows/build-ubuntu-latest.yml index e34e6cc..5172866 100644 --- a/.github/workflows/build-ubuntu-latest.yml +++ b/.github/workflows/build-ubuntu-latest.yml @@ -29,6 +29,11 @@ jobs: with: submodules: 'recursive' + - name: Install libraries + run: | + sudo apt-get update + sudo apt-get install cmake libcunit1 libcunit1-doc libcunit1-dev + - name: Create Build Environment # Some projects don't allow in-source building, so create a separate build directory # We'll use this as our working directory for all subsequent commands @@ -42,17 +47,17 @@ jobs: # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DENABLE_TESTS=1 - name: Build working-directory: ${{github.workspace}}/build shell: bash # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE + run: cmake --build . --config $BUILD_TYPE -j 16 - name: Test working-directory: ${{github.workspace}}/build shell: bash # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C $BUILD_TYPE + run: ctest -C $BUILD_TYPE -j 16 --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index e68276f..30ee30e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,13 @@ set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") ############################# OPTIONS SECTION ########################## +option(ENABLE_TESTS "Enable tests [default: OFF]" OFF) +if (ENABLE_TESTS) + # Enable testing functionality. + enable_testing() + set(ENABLE_LIBLCB_TESTS TRUE) +endif() + # Now CMAKE_INSTALL_PREFIX is a base prefix for everything. if (NOT CONFDIR) set(CONFDIR "${CMAKE_INSTALL_PREFIX}/etc/msd_lite") @@ -234,12 +241,13 @@ add_definitions(-DHAVE_CONFIG_H) ################################ SUBDIRS SECTION ####################### -add_definitions(-DHTTP_SRV_XML_CONFIG) -add_definitions(-DSOCKET_XML_CONFIG) -add_definitions(-DTHREAD_POOL_SETTINGS_XML) include(src/liblcb/CMakeLists.txt) add_subdirectory(src) +if (ENABLE_TESTS) + #add_subdirectory(tests) +endif() + ############################ TARGETS SECTION ########################### add_custom_target(dist ${CMAKE_CURRENT_SOURCE_DIR}/dist.sh diff --git a/msd_lite.project b/msd_lite.project index d2d8df0..8794c0e 100644 --- a/msd_lite.project +++ b/msd_lite.project @@ -1,5 +1,9 @@ + + + + diff --git a/readme.md b/readme.md index ca6fcd3..8ffc6af 100644 --- a/readme.md +++ b/readme.md @@ -49,6 +49,16 @@ make -j 8 ``` +## Run tests +``` +mkdir -p build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=1 .. +cmake --build . --config Release -j 16 +ctest -C Release --output-on-failure -j 16 +``` + + ## Usage ``` msd_lite [-d] [-v] [-c file] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e05650e..7e04616 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,6 +20,9 @@ set(MSD_LITE_BIN msd_lite.c liblcb/src/utils/xml.c) add_executable(msd_lite ${MSD_LITE_BIN}) +target_compile_definitions(msd_lite PRIVATE -DHTTP_SRV_XML_CONFIG) +target_compile_definitions(msd_lite PRIVATE -DSOCKET_XML_CONFIG) +target_compile_definitions(msd_lite PRIVATE -DTHREAD_POOL_SETTINGS_XML) set_target_properties(msd_lite PROPERTIES LINKER_LANGUAGE C) target_link_libraries(msd_lite ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_EXE_LINKER_FLAGS}) diff --git a/src/liblcb b/src/liblcb index 088348c..4db42f6 160000 --- a/src/liblcb +++ b/src/liblcb @@ -1 +1 @@ -Subproject commit 088348cb891cea72d3fc361967907d8e6fee77db +Subproject commit 4db42f6a957e9b96595268c381e8a3930aea2cff