diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2019-11-28 16:59:50 +0000 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2019-12-06 09:42:52 +0000 |
commit | d59123bdeecb84963290771bbc84e78a1154e122 (patch) | |
tree | d79a16a4446dde63c0aba20dbc88eaf12bee2daf | |
parent | 3b5f0929c20d90a980ae7d972881da538b7550c5 (diff) |
ci: Add testing to CMake
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r-- | CMakeLists.txt | 50 | ||||
-rw-r--r-- | appveyor.yml | 11 | ||||
-rwxr-xr-x | test-png | 22 |
3 files changed, 80 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 295eda3..7debd27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,9 +126,57 @@ target_link_libraries(vdservice wtsapi32 ) +enable_testing() +add_custom_target(check COMMAND ctest -C $<CONFIG>) + +if(CMAKE_CROSSCOMPILING) + set(CMAKE_CROSSCOMPILING_EMULATOR wine) +endif() + +add_executable(imagetest EXCLUDE_FROM_ALL + common/vdcommon.cpp + common/vdcommon.h + common/vdlog.cpp + common/vdlog.h + vdagent/imagetest.cpp + vdagent/image.cpp + vdagent/image.h + vdagent/imagepng.cpp + vdagent/imagepng.h +) +target_link_libraries(imagetest + ${PNG_LIBRARY} + ${ZLIB_LIBRARY} + wtsapi32 +) +add_test(NAME test-png COMMAND bash "${CMAKE_SOURCE_DIR}/test-png") + +add_executable(test-log EXCLUDE_FROM_ALL + common/vdcommon.cpp + common/vdcommon.h + common/vdlog.cpp + common/vdlog.h + common/test-log.cpp +) +add_test(NAME test-log COMMAND test-log) + +add_executable(test-shell EXCLUDE_FROM_ALL + vdagent/test-shell.cpp +) +target_link_libraries(test-shell + uuid + ole32 + oleaut32 + ${COMMSUPPW_LIBRARY} +) +add_test(NAME test-shell COMMAND test-shell) + +add_dependencies(check test-log test-shell imagetest) + if(MSVC) # select static CRT without debugging (/MT option) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15") - set_property(TARGET vdagent vdservice PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") + set_property(TARGET vdagent vdservice imagetest + PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") endif() endif() diff --git a/appveyor.yml b/appveyor.yml index b6462f6..db1329e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,25 +9,36 @@ install: - git submodule update --init --recursive - mkdir build32 - mkdir build64 + +- choco install --timeout 600 -y imagemagick.tool + - cd %VCPKG_ROOT% - git pull - .\bootstrap-vcpkg.bat - vcpkg install libpng:x64-windows-static libpng:x86-windows-static build_script: +- set CTEST_OUTPUT_ON_FAILURE=1 + - cd %APPVEYOR_BUILD_FOLDER%\build64 - cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -A x64 -DVCPKG_TARGET_TRIPLET=x64-windows-static .. - cmake --build . --config Release +- cmake --build . --config Release --target check - cd %APPVEYOR_BUILD_FOLDER%\build32 - cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake -A Win32 -DVCPKG_TARGET_TRIPLET=x86-windows-static .. - cmake --build . --config Release +- cmake --build . --config Release --target check after_build: - cd %APPVEYOR_BUILD_FOLDER%\build64 +- del Release\test* +- del Release\imagetest* - 7z a vdagent-win-x64.zip Release\* - cd %APPVEYOR_BUILD_FOLDER%\build32 +- del Release\test* +- del Release\imagetest* - 7z a vdagent-win-x86.zip Release\* artifacts: @@ -17,6 +17,24 @@ verbose() { fi } +# under Windows we don't need to run test under Wine +WINE=wine +if [ "x`uname -s`" != xLinux ]; then + WINE= +fi + +# this fixes search under Windows which often detect convert utility +# under system directory, look for the one in the same directory as +# mogrify +CONVERT="$(command -v mogrify)" +CONVERT="${CONVERT//mogrify/convert}" + +# MSVC build put executables under <Configuration> directory +IMAGETEST=imagetest.exe +if [ -e ./Release/imagetest.exe ]; then + IMAGETEST=./Release/imagetest.exe +fi + compare_images() { DIFF=$(compare -metric AE $1 $2 - 2>&1 > /dev/null || true) if [ "$DIFF" != "0" ]; then @@ -26,8 +44,8 @@ compare_images() { do_test() { echo "Running image $IMAGE with '$*'..." - convert $IMAGE "$@" $IN - wine imagetest.exe $IN $OUT_BMP $OUT + $CONVERT $IMAGE "$@" $IN + $WINE $IMAGETEST $IN $OUT_BMP $OUT verbose ls -lh $IN verbose identify $IN verbose identify $OUT_BMP |