blob: 5ebd841ad78520b41063bc701372d581f3bbfab3 [file] [log] [blame]
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
gtests = [
'info',
'invalidate',
'update_state',
'update_version',
'hash_descriptor',
'read',
'write',
'verify_staging',
'fetch_version',
'erase',
]
foreach t : gtests
test(t, executable(t.underscorify(), 'ops/' + t + '.cpp',
build_by_default: false,
implicit_include_directories: false,
dependencies: [libflashupdate, stdplus_gtest_dep, gtest, gmock]))
endforeach