From 2df986746b4010a24def7369f356b50e52bda50d Mon Sep 17 00:00:00 2001 From: Adrian Freihofer Date: Thu, 7 Dec 2023 21:52:49 +0100 Subject: oe-selftest: add a cpp-example recipe This simple C++ project supports compilation with CMake and Meson. (Autotool support could be added later on.) It's supposed to be used with oe-selftest. An artificial project has several advantages over compiling a normal CMake or Meson based project for testing purposes: - It is much faster because it can be kept minimalistic - It can cover multiple odd corner cases - No one will change it in an unpredictable way - It can support multiple build tools with only one C++ codebase (From OE-Core rev: 4904e772470b0d6e5d98ef0344b3f2bf54214661) Signed-off-by: Adrian Freihofer Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- .../recipes-test/cpp/files/test-cpp-example.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 meta-selftest/recipes-test/cpp/files/test-cpp-example.cpp (limited to 'meta-selftest/recipes-test/cpp/files/test-cpp-example.cpp') diff --git a/meta-selftest/recipes-test/cpp/files/test-cpp-example.cpp b/meta-selftest/recipes-test/cpp/files/test-cpp-example.cpp new file mode 100644 index 0000000000..83c9bfa844 --- /dev/null +++ b/meta-selftest/recipes-test/cpp/files/test-cpp-example.cpp @@ -0,0 +1,25 @@ +/* +* Copyright OpenEmbedded Contributors +* +* SPDX-License-Identifier: MIT +*/ + +#include "cpp-example-lib.hpp" + +#include + +/* This is for creating a failing test for testing the test infrastructure */ +#ifndef FAIL_COMPARISON_STR +#define FAIL_COMPARISON_STR "" +#endif + +int main() { + auto cpp_example = CppExample(); + auto ret_string = cpp_example.get_string(); + if(0 == ret_string.compare(CppExample::test_string + FAIL_COMPARISON_STR)) { + std::cout << "PASS: " << ret_string << " = " << CppExample::test_string << std::endl; + } else { + std::cout << "FAIL: " << ret_string << " != " << CppExample::test_string << std::endl; + return 1; + } +} -- cgit v1.2.3-54-g00ecf