[CMake] Enable testing through busybox

With this commit, it is possible to run the full test suite on
Windows machines when busybox-w32 is installed. This program is
available through chocolatey with 'choco install busybox'

CMake tests for availability of busybox and use if available. As
chocolatey is the preferred method of fetching software for
Github actions, this commit paves the way for running the full
test suite on Windows for CI
This commit is contained in:
Martijn van Beurden 2022-01-10 19:35:39 +01:00
parent 0ec47a87b4
commit ce31a1d51f
2 changed files with 33 additions and 24 deletions

View File

@ -3,23 +3,29 @@ if(WIN32)
endif()
if(NOT UNIX)
add_test(NAME libFLAC
COMMAND $<TARGET_FILE:test_libFLAC>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if(BUILD_CXXLIBS)
add_test(NAME libFLAC++
COMMAND $<TARGET_FILE:test_libFLAC++>
find_program(BUSYBOX_EXE busybox)
if(NOT BUSYBOX_EXE)
message(STATUS "Could NOT find busybox, only basic tests are enabled")
add_test(NAME libFLAC
COMMAND $<TARGET_FILE:test_libFLAC>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if(BUILD_CXXLIBS)
add_test(NAME libFLAC++
COMMAND $<TARGET_FILE:test_libFLAC++>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
if(BUILD_PROGRAMS)
add_test(NAME flac_help
COMMAND $<TARGET_FILE:flacapp> --help
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME metaflac_help
COMMAND $<TARGET_FILE:metaflac> --help
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
return()
else()
set(BUSYBOX_CMD "sh")
endif()
if(BUILD_PROGRAMS)
add_test(NAME flac_help
COMMAND $<TARGET_FILE:flacapp> --help
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test(NAME metaflac_help
COMMAND $<TARGET_FILE:metaflac> --help
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
return()
endif()
set(top_srcdir "${PROJECT_SOURCE_DIR}")
@ -29,38 +35,38 @@ configure_file(common.sh.in common.sh @ONLY)
set(ALL_TESTS libFLAC grabbag flac metaflac replaygain seeking streams compression)
add_test(NAME libFLAC
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_libFLAC.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_libFLAC.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
if(BUILD_CXXLIBS)
add_test(NAME libFLAC++
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_libFLAC++.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_libFLAC++.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
list(APPEND ALL_TESTS libFLAC++)
endif()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cuesheets")
add_test(NAME grabbag
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_grabbag.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_grabbag.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
add_test(NAME flac
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_flac.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_flac.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/metaflac-test-files")
add_test(NAME metaflac
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_metaflac.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_metaflac.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
add_test(NAME replaygain
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_replaygain.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_replaygain.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
add_test(NAME seeking
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_seeking.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_seeking.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
add_test(NAME streams
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_streams.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_streams.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# increase this if standard 1500 seconds are not enough
# set_tests_properties(streams PROPERTIES TIMEOUT 1500)
add_test(NAME compression
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test_compression.sh"
COMMAND ${BUSYBOX_EXE} ${BUSYBOX_CMD} "${CMAKE_CURRENT_SOURCE_DIR}/test_compression.sh"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
set_property(TEST ${ALL_TESTS} APPEND PROPERTY ENVIRONMENT ECHO_C=\\c)

View File

@ -43,6 +43,9 @@ LD_LIBRARY_PATH=../src/share/utf8/.libs:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PATH=`pwd`/../objs/$CMAKE_CONFIG_TYPE:$PATH
PATH=`pwd`/../objs:$PATH
EXE=@EXEEXT@
# Needed for building out-of-tree where source files are in the $top_srcdir tree