diff options
Diffstat (limited to 'Tests/RunCMake')
16 files changed, 148 insertions, 0 deletions
diff --git a/Tests/RunCMake/AndroidTestUtilities/CMakeLists.txt b/Tests/RunCMake/AndroidTestUtilities/CMakeLists.txt new file mode 100644 index 0000000..dc92486 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.6) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/AndroidTestUtilities/RunCMakeTest.cmake b/Tests/RunCMake/AndroidTestUtilities/RunCMakeTest.cmake new file mode 100644 index 0000000..f0ae24b --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/RunCMakeTest.cmake @@ -0,0 +1,20 @@ +include(RunCMake) + +function(run_ATU case target) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + if(target) + set(build_args --target ${target}) + else() + set(build_args) + endif() + run_cmake(${case}) + run_cmake_command(${case}Build ${CMAKE_COMMAND} --build . --config Debug ${build_args}) +endfunction() + +run_ATU(SetupTest1 "") +run_ATU(SetupTest2 "tests") +run_ATU(SetupTest3 "tests") diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest1.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest1.cmake new file mode 100644 index 0000000..1c9098b --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest1.cmake @@ -0,0 +1,17 @@ +enable_testing() +include(AndroidTestUtilities) + +find_program(adb_executable adb) + +set(ExternalData_URL_TEMPLATES + "https://data.kitware.com/api/v1/file/hashsum/%(algo)/%(hash)/download" + ) + +set(test_files "data/a.txt") + +set(ANDROID 1) + +android_add_test_data(setup_test + FILES ${test_files} + DEVICE_TEST_DIR "/data/local/tests/example1" + DEVICE_OBJECT_STORE "/sdcard/.ExternalData/SHA") diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest1Build-check.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest1Build-check.cmake new file mode 100644 index 0000000..ef7569d --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest1Build-check.cmake @@ -0,0 +1,5 @@ +include(${CMAKE_CURRENT_LIST_DIR}/check.cmake) +compare_build_to_expected(FILES + "data/a.txt" + ) +check_for_setup_test() diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest2.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest2.cmake new file mode 100644 index 0000000..cf4c764 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest2.cmake @@ -0,0 +1,30 @@ +enable_testing() +include(AndroidTestUtilities) + +add_custom_target(tests) +find_program(adb_executable adb) + +set(ExternalData_URL_TEMPLATES + "https://data.kitware.com/api/v1/file/hashsum/%(algo)/%(hash)/download" + ) +set(test_files + "data/a.txt" + "data/subfolder/b.txt" + "data/subfolder/protobuffer.p" + ) + +set(test_libs "data/subfolder/exampleLib.txt") + +set(ANDROID 1) + +android_add_test_data(setup_test + FILES ${test_files} + LIBS ${test_libs} + DEVICE_TEST_DIR "/data/local/tests/example2" + DEVICE_OBJECT_STORE "/sdcard/.ExternalData/SHA" + NO_LINK_REGEX "\\.p$") + +set_property( + TARGET setup_test + PROPERTY EXCLUDE_FROM_ALL 1) +add_dependencies(tests setup_test) diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest2Build-check.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest2Build-check.cmake new file mode 100644 index 0000000..6adbd59 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest2Build-check.cmake @@ -0,0 +1,7 @@ +include(${CMAKE_CURRENT_LIST_DIR}/check.cmake) +compare_build_to_expected(FILES + "data/a.txt" + "data/subfolder/b.txt" + "data/subfolder/protobuffer.p" + ) +check_for_setup_test() diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest3.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest3.cmake new file mode 100644 index 0000000..b32b6b1 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest3.cmake @@ -0,0 +1,33 @@ +enable_testing() +include(AndroidTestUtilities) + +add_custom_target(tests) +find_program(adb_executable adb) + +set(ExternalData_URL_TEMPLATES + "https://data.kitware.com/api/v1/file/hashsum/%(algo)/%(hash)/download" + ) +set(test_dir "/data/local/tests/example3") +set(test_files + "data/a.txt" + "data/subfolder/b.txt" + ) +set(test_libs "libs/exampleLib.txt") +set(files_dest "${test_dir}/storage_folder") +set(libs_dest "${test_dir}/lib/lib/lib") + +set(ANDROID 1) + +android_add_test_data(setup_test + FILES ${test_files} + LIBS ${test_libs} + FILES_DEST ${files_dest} + LIBS_DEST ${libs_dest} + DEVICE_TEST_DIR "/data/local/tests/example3" + DEVICE_OBJECT_STORE "/sdcard/.ExternalData/SHA" + NO_LINK_REGEX "\\.p$") + +set_property( + TARGET setup_test + PROPERTY EXCLUDE_FROM_ALL 1) +add_dependencies(tests setup_test) diff --git a/Tests/RunCMake/AndroidTestUtilities/SetupTest3Build-check.cmake b/Tests/RunCMake/AndroidTestUtilities/SetupTest3Build-check.cmake new file mode 100644 index 0000000..3062cdc --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/SetupTest3Build-check.cmake @@ -0,0 +1,6 @@ +include(${CMAKE_CURRENT_LIST_DIR}/check.cmake) +compare_build_to_expected(FILES + "data/a.txt" + "data/subfolder/b.txt" + ) +check_for_setup_test() diff --git a/Tests/RunCMake/AndroidTestUtilities/check.cmake b/Tests/RunCMake/AndroidTestUtilities/check.cmake new file mode 100644 index 0000000..ccd4d74 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/check.cmake @@ -0,0 +1,20 @@ +function(compare_build_to_expected) + cmake_parse_arguments(_comp "" "" "FILES" ${ARGN}) + set(missing) + foreach(file ${_comp_FILES}) + if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${file}") + list(APPEND missing "${file}") + endif() + endforeach() + if(missing) + string(APPEND RunCMake_TEST_FAILED "Missing files:\n ${missing}") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() +endfunction() + +function(check_for_setup_test) + file(STRINGS "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" output_var REGEX "add_test\\(setup_test.*") + if(NOT output_var) + set(RunCMake_TEST_FAILED "Could not find the test: setup_test" PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/AndroidTestUtilities/data/a.txt b/Tests/RunCMake/AndroidTestUtilities/data/a.txt new file mode 100644 index 0000000..9d454fb --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/data/a.txt @@ -0,0 +1 @@ +Here is a file to test. diff --git a/Tests/RunCMake/AndroidTestUtilities/data/proto.proto b/Tests/RunCMake/AndroidTestUtilities/data/proto.proto new file mode 100644 index 0000000..7402a3a --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/data/proto.proto @@ -0,0 +1 @@ +proto.proto diff --git a/Tests/RunCMake/AndroidTestUtilities/data/subfolder/b.txt b/Tests/RunCMake/AndroidTestUtilities/data/subfolder/b.txt new file mode 100644 index 0000000..c8c6a89 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/data/subfolder/b.txt @@ -0,0 +1 @@ +SetupTest2.cmake diff --git a/Tests/RunCMake/AndroidTestUtilities/data/subfolder/protobuffer.p b/Tests/RunCMake/AndroidTestUtilities/data/subfolder/protobuffer.p new file mode 100644 index 0000000..a5dc7d2 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/data/subfolder/protobuffer.p @@ -0,0 +1 @@ +protobuffer.p diff --git a/Tests/RunCMake/AndroidTestUtilities/libs/exampleLib.so b/Tests/RunCMake/AndroidTestUtilities/libs/exampleLib.so new file mode 100644 index 0000000..f4cdf82 --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/libs/exampleLib.so @@ -0,0 +1 @@ +here is a fake lib. diff --git a/Tests/RunCMake/AndroidTestUtilities/libs/exampleLib.txt b/Tests/RunCMake/AndroidTestUtilities/libs/exampleLib.txt new file mode 100644 index 0000000..308921a --- /dev/null +++ b/Tests/RunCMake/AndroidTestUtilities/libs/exampleLib.txt @@ -0,0 +1 @@ +here is an example lib! diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 778982f..9e9903d 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -131,6 +131,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) ) endif() +add_RunCMake_test(AndroidTestUtilities) add_RunCMake_test(BuildDepends) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) |