| gtest = dependency('gtest', main: true, disabler: true, required: false) |
| gmock = dependency('gmock', disabler: true, required: false) |
| if not gtest.found() or not gmock.found() |
| gtest_opts = import('cmake').subproject_options() |
| gtest_opts.add_cmake_defines({'CMAKE_CXX_FLAGS': '-Wno-pedantic'}) |
| gtest_proj = import('cmake').subproject( |
| 'googletest', |
| options: gtest_opts, |
| required: false) |
| if gtest_proj.found() |
| gtest = declare_dependency( |
| dependencies: [ |
| dependency('threads'), |
| gtest_proj.dependency('gtest'), |
| gtest_proj.dependency('gtest_main'), |
| ]) |
| gmock = gtest_proj.dependency('gmock') |
| else |
| assert(not get_option('tests').enabled(), 'Googletest is required') |
| endif |
| endif |
| |
| stdplus_gtest_dep = dependency('stdplus-gtest') |
| |
| run_with_tmp = find_program('run_with_tmp', native: true) |
| |
| add_test_setup( |
| 'valgrind', |
| exe_wrapper: [run_with_tmp, 'valgrind'], |
| env: {'TMPTMPL': 'flashupdate-test.XXXXXXXXXX'}) |
| |
| flashupdate_args_test = executable( |
| 'flashupdate_args', |
| 'args.cpp', |
| build_by_default: false, |
| implicit_include_directories: false, |
| dependencies: [libflashupdate, stdplus_gtest_dep, gtest, gmock]) |
| test('flashupdate/args', flashupdate_args_test) |
| |
| |
| flashupdate_config_test = executable( |
| 'flashupdate_config', |
| 'config.cpp', |
| build_by_default: false, |
| implicit_include_directories: false, |
| dependencies: [libflashupdate, stdplus_gtest_dep, gtest, gmock]) |
| test('flashupdate/config', flashupdate_config_test) |
| |
| flashupdate_flash_test = executable( |
| 'flashupdate_flash', |
| 'flash.cpp', |
| build_by_default: false, |
| implicit_include_directories: false, |
| dependencies: [libflashupdate, stdplus_gtest_dep, gtest, gmock]) |
| test('flashupdate/flash', flashupdate_flash_test) |
| |
| |
| flashupdate_version_test = executable( |
| 'flashupdate_version', |
| 'version.cpp', |
| build_by_default: false, |
| implicit_include_directories: false, |
| dependencies: [libflashupdate, stdplus_gtest_dep, gtest, gmock]) |
| test('flashupdate/version', flashupdate_version_test) |
| |
| if get_option('tests').enabled() |
| assert(not is_disabler(flashupdate_args_test), |
| 'Tests enabled but flashupdate_args_test cannot build') |
| assert(not is_disabler(flashupdate_config_test), |
| 'Tests enabled but flashupdate_config_test cannot build') |
| assert(not is_disabler(flashupdate_flash_test), |
| 'Tests enabled but flashupdate_flash_test cannot build') |
| assert(not is_disabler(flashupdate_version_test), |
| 'Tests enabled but flashupdate_version_test cannot build') |
| endif |
| |
| tests = { |
| 'info': 'ops/info.cpp', |
| 'invalidate': 'ops/invalidate.cpp', |
| 'update_state': 'ops/update_state.cpp', |
| 'update_version': 'ops/update_version.cpp', |
| 'hash_descriptor': 'ops/hash_descriptor.cpp', |
| 'read': 'ops/read.cpp', |
| 'write': 'ops/write.cpp', |
| 'verify_staging': 'ops/verify_staging.cpp', |
| 'fetch_version': 'ops/fetch_version.cpp', |
| 'erase': 'ops/erase.cpp', |
| 'key_rotate_helper': 'validator/key_rotate_helper.cpp', |
| 'cr51_validator': 'validator/cr51.cpp', |
| } |
| |
| foreach name, file : tests |
| test(name, executable(name.underscorify(), file, |
| build_by_default: false, |
| implicit_include_directories: false, |
| dependencies: [libflashupdate, stdplus_gtest_dep, gtest, gmock])) |
| endforeach |