diff options
author | Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> | 2022-02-14 12:26:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-14 12:26:50 +0300 |
commit | 1fb7beae5e97aadf8471ae7b6e07f5c2e5f33c78 (patch) | |
tree | fc905cdb67494c5b7b59cb21465483f6d0464b31 /tests | |
parent | 6df74a76eeacc5240d36fa7e62717cd1cdd238a7 (diff) | |
download | virtual-media-1fb7beae5e97aadf8471ae7b6e07f5c2e5f33c78.tar.xz |
Switch the build system to meson
Due to requirements from community, new projects have to be built with
meson.
To unify with other projects some additional warnings has been enabled,
so appropriate code updates has been implemented.
This commit makes both meson and CMake available to simplyfy transition
in openbmc. CMake support will be removed after switching to meson in
openbmc will be accepted.
Tested:
Compiled and smoke tested.
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/meson.build | 48 | ||||
-rw-r--r-- | tests/src/main.cpp | 7 |
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..81c6b3b --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,48 @@ +gtest_dep = dependency('gtest', main: true, version: '>1.11.0', disabler: true, required: false) +gmock_dep = dependency('gmock', disabler: true, required: false) + +if not gtest_dep.found() or not gmock_dep.found() + cmake = import('cmake') + opt_var = cmake.subproject_options() + + opt_var.add_cmake_defines({'CMAKE_CXX_FLAGS': '-Wno-pedantic'}) + opt_var.set_override_option('warning_level', '3') + opt_var.set_override_option('werror', 'true') + + gtest_proj = cmake.subproject('gtest', + options: opt_var, + required: true) + if gtest_proj.found() + gtest_dep = declare_dependency( + dependencies: [ + dependency('threads'), + gtest_proj.dependency('gtest') + ] + ) + gmock_dep = gtest_proj.dependency('gmock') + else + assert( + not get_option('tests').enabled(), + 'Googletest is required if tests are enabled' + ) + endif +endif + +test( + 'virtual-media-ut', + executable( + 'virtual-media-ut', + [ + 'src/main.cpp', + ], + dependencies: [ + boost, + gmock_dep, + gtest_dep, + sdbusplus, + ], + include_directories: ['../src', 'src'], + cpp_args : '-DINJECT_MOCKS' + ), + timeout: 120, +) diff --git a/tests/src/main.cpp b/tests/src/main.cpp new file mode 100644 index 0000000..9bb465e --- /dev/null +++ b/tests/src/main.cpp @@ -0,0 +1,7 @@ +#include <gtest/gtest.h> + +int main(int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} |