Skip to contentSkip to conversation

support/testing: boost: new runtime tests

PATCH New Michael Nosthoff via buildroot 1 participant 1 message Oct 6

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 support/testing: boost: new runtime tests

Each symbol in boost.mk got its own testcase.
Where possible reuse the testcases comming with the library. Where this is not the case a simple testcase was created.

it's currently based on boost 1.83 and should be extended when new libraries are added.

MPI and Graph-Parallel currently have a build issue which needs to be fixed before test-cases can be added.

Assisted-by Github Copilot:Claude Sonnet 5.5

---

V2: switch to boost internal testcases where available.

Successful Pipeline: https://gitlab.com/heinemml/buildroot/-/pipelines/2916654881

---
 DEVELOPERS                                    |   2 +
 .../package/br2-external/boost/Config.in      |   1 +
 .../package/br2-external/boost/external.desc  |   1 +
 .../package/br2-external/boost/external.mk    |   1 +
 .../package/boost-runtime-test/CMakeLists.txt | 137 ++++++++++
 .../package/boost-runtime-test/Config.in      |   6 +
 .../boost-runtime-test/boost-runtime-test.mk  |  34 +++
 .../src/boost-coroutine-test.cpp              |  32 +++
 .../src/boost-fiber-test.cpp                  |  29 ++
 .../src/boost-iostreams-test.cpp              |  47 ++++
 .../src/boost-locale-test.cpp                 |  21 ++
 .../src/boost-python-test.cpp                 |  26 ++
 .../boost-runtime-test/src/boost-url-test.cpp |  26 ++
 .../src/boost-wave-test.cpp                   |  33 +++
 support/testing/tests/package/test_boost.py   | 249 ++++++++++++++++++
 15 files changed, 645 insertions(+)
 create mode 100644 support/testing/tests/package/br2-external/boost/Config.in
 create mode 100644 support/testing/tests/package/br2-external/boost/external.desc
 create mode 100644 support/testing/tests/package/br2-external/boost/external.mk
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/CMakeLists.txt
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/Config.in
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/boost-runtime-test.mk
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-coroutine-test.cpp
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-fiber-test.cpp
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-iostreams-test.cpp
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-locale-test.cpp
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-python-test.cpp
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-url-test.cpp
 create mode 100644 support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-wave-test.cpp
 create mode 100644 support/testing/tests/package/test_boost.py
DEVELOPERS +2 -0
index 32ac338dc8..e8d76dad90 100644
@@ -2465,6 +2465,8 @@ F:	package/protobuf/
 F:	package/sdbus-cpp/
 F:	package/spdlog/
 F:	package/sqlitecpp/
+F:	support/testing/tests/package/br2-external/boost/
+F:	support/testing/tests/package/test_boost.py
 
 N:	Michael Trimarchi <[email protected]>
 F:	board/bsh/
support/testing/tests/package/br2-external/boost/Config.in new file +1 -0
new file mode 100644
index 0000000000..4a49617767
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_BOOST_RUNTIME_TEST_PATH/package/boost-runtime-test/Config.in"
support/testing/tests/package/br2-external/boost/external.desc new file +1 -0
new file mode 100644
index 0000000000..2b88912b82
@@ -0,0 +1 @@
+name: BOOST_RUNTIME_TEST
support/testing/tests/package/br2-external/boost/external.mk new file +1 -0
new file mode 100644
index 0000000000..295235ba4b
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_BOOST_RUNTIME_TEST_PATH)/package/*/*.mk))
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/CMakeLists.txt new file +137 -0

137 lines not on this page · raw message

support/testing/tests/package/br2-external/boost/package/boost-runtime-test/Config.in new file +6 -0
new file mode 100644
index 0000000000..a7bdafd7ee
@@ -0,0 +1,6 @@
+config BR2_PACKAGE_BOOST_RUNTIME_TEST
+	bool "boost-runtime-test"
+	depends on BR2_PACKAGE_BOOST
+	help
+	  Test programs for the Boost libraries. A test program is
+	  built for each enabled Boost library.
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/boost-runtime-test.mk new file +34 -0
new file mode 100644
index 0000000000..f2489339c5
@@ -0,0 +1,34 @@
+################################################################################
+#
+# boost-runtime-test
+#
+################################################################################
+
+BOOST_RUNTIME_TEST_SITE = $(BOOST_RUNTIME_TEST_PKGDIR)
+BOOST_RUNTIME_TEST_SITE_METHOD = local
+BOOST_RUNTIME_TEST_DEPENDENCIES = boost
+
+BOOST_RUNTIME_TEST_ALL_LIBS = \
+	atomic chrono container context contract coroutine date_time \
+	exception fiber filesystem graph iostreams json locale log math \
+	nowide program_options random regex serialization stacktrace \
+	system test thread timer type_erasure url wave
+
+BOOST_RUNTIME_TEST_LIBS = \
+	$(foreach lib,$(BOOST_RUNTIME_TEST_ALL_LIBS), \
+		$(if $(BR2_PACKAGE_BOOST_$(call UPPERCASE,$(lib))),$(lib)))
+
+# Link flags come from the cmake config files installed by boost, the
+# upstream tests are built from the boost source tree
+BOOST_RUNTIME_TEST_CONF_OPTS = \
+	-DBOOST_SOURCE_DIR=$(BOOST_DIR) \
+	-DBOOST_RUNTIME_TEST_LIBS="$(subst $(space),;,$(strip $(BOOST_RUNTIME_TEST_LIBS)))"
+
+ifeq ($(BR2_PACKAGE_BOOST_PYTHON),y)
+BOOST_RUNTIME_TEST_DEPENDENCIES += python3
+BOOST_RUNTIME_TEST_CONF_OPTS += \
+	-DBOOST_RUNTIME_TEST_PYTHON_INCLUDE_DIR=$(STAGING_DIR)/usr/include/python$(PYTHON3_VERSION_MAJOR) \
+	-DBOOST_RUNTIME_TEST_PYTHON_SITE_DIR=lib/python$(PYTHON3_VERSION_MAJOR)/site-packages
+endif
+
+$(eval $(cmake-package))
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-coroutine-test.cpp new file +32 -0
new file mode 100644
index 0000000000..c5911bbe67
@@ -0,0 +1,32 @@
+#define BOOST_COROUTINES_NO_DEPRECATION_WARNING
+#include <boost/coroutine/asymmetric_coroutine.hpp>
+
+#include <iostream>
+
+typedef boost::coroutines::asymmetric_coroutine<int> coro_t;
+
+int main()
+{
+    coro_t::pull_type fibonacci([](coro_t::push_type &sink) {
+        int a = 0, b = 1;
+        for (int i = 0; i < 10; i++) {
+            sink(a);
+            int next = a + b;
+            a = b;
+            b = next;
+        }
+    });
+
+    int count = 0, last = 0;
+    while (fibonacci) {
+        last = fibonacci.get();
+        count++;
+        fibonacci();
+    }
+
+    if (count != 10 || last != 34)
+        return 1;
+
+    std::cout << "coroutine: fib(9)=" << last << std::endl;
+    return 0;
+}
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-fiber-test.cpp new file +29 -0
new file mode 100644
index 0000000000..14856b566f
@@ -0,0 +1,29 @@
+#include <boost/fiber/all.hpp>
+
+#include <iostream>
+
+int main()
+{
+    boost::fibers::buffered_channel<int> channel(8);
+    int sum = 0;
+
+    boost::fibers::fiber producer([&channel] {
+        for (int i = 1; i <= 5; i++)
+            channel.push(i);
+        channel.close();
+    });
+    boost::fibers::fiber consumer([&channel, &sum] {
+        int value;
+        while (channel.pop(value) == boost::fibers::channel_op_status::success)
+            sum += value;
+    });
+
+    producer.join();
+    consumer.join();
+
+    if (sum != 15)
+        return 1;
+
+    std::cout << "fiber: sum=" << sum << std::endl;
+    return 0;
+}
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-iostreams-test.cpp new file +47 -0

47 lines not on this page · raw message

support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-locale-test.cpp new file +21 -0
new file mode 100644
index 0000000000..ba1583e48a
@@ -0,0 +1,21 @@
+#include <boost/locale.hpp>
+
+#include <iostream>
+#include <string>
+
+int main()
+{
+    // "grüße" in UTF-8
+    const std::string utf8 = "gr\xc3\xbc\xc3\x9f" "e";
+
+    std::wstring wide = boost::locale::conv::utf_to_utf<wchar_t>(utf8);
+    if (wide.size() != 5)
+        return 1;
+    if (boost::locale::conv::utf_to_utf<char>(wide) != utf8)
+        return 1;
+
+    boost::locale::generator gen;
+    std::cout.imbue(gen("en_US.UTF-8"));
+    std::cout << boost::locale::format("locale: {1} characters") % wide.size() << std::endl;
+    return 0;
+}
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-python-test.cpp new file +26 -0
new file mode 100644
index 0000000000..1401b9c10f
@@ -0,0 +1,26 @@
+#include <boost/python.hpp>
+
+#include <string>
+
+static std::string greet(const std::string &name)
+{
+    return "hello " + name;
+}
+
+struct counter {
+    int value = 0;
+    void add(int n)
+    {
+        value += n;
+    }
+};
+
+BOOST_PYTHON_MODULE(boost_python_test)
+{
+    namespace bp = boost::python;
+
+    bp::def("greet", greet);
+    bp::class_<counter>("Counter")
+        .def("add", &counter::add)
+        .def_readonly("value", &counter::value);
+}
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-url-test.cpp new file +26 -0
new file mode 100644
index 0000000000..979644a921
@@ -0,0 +1,26 @@
+#include <boost/url.hpp>
+
+#include <iostream>
+
+namespace urls = boost::urls;
+
+int main()
+{
+    auto parsed = urls::parse_uri(
+        "https://buildroot.org:8080/downloads/index.html?ver=2026.11&arch=arm#top");
+    if (!parsed)
+        return 1;
+
+    urls::url url = *parsed;
+    if (url.host() != "buildroot.org" || url.port_number() != 8080)
+        return 1;
+
+    url.params().set("arch", "aarch64");
+    url.remove_fragment();
+
+    if (urls::parse_uri("not a uri"))
+        return 1;
+
+    std::cout << "url: " << url.buffer() << std::endl;
+    return 0;
+}
support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-wave-test.cpp new file +33 -0
new file mode 100644
index 0000000000..15eff29847
@@ -0,0 +1,33 @@
+#include <boost/wave.hpp>
+#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
+#include <boost/wave/cpplexer/cpp_lex_token.hpp>
+
+#include <iostream>
+#include <string>
+
+typedef boost::wave::cpplexer::lex_token<> token_type;
+typedef boost::wave::cpplexer::lex_iterator<token_type> lex_iterator_type;
+typedef boost::wave::context<std::string::iterator, lex_iterator_type> context_type;
+
+int main()
+{
+    std::string input =
+        "#define GREETING(x) hello x\n"
+        "#if 1 + 1 == 2\n"
+        "GREETING(buildroot)\n"
+        "#else\n"
+        "wrong\n"
+        "#endif\n";
+
+    context_type ctx(input.begin(), input.end(), "test.cpp");
+    std::string output;
+    for (context_type::iterator_type it = ctx.begin(); it != ctx.end(); ++it)
+        output += (*it).get_value().c_str();
+
+    if (output.find("hello buildroot") == std::string::npos ||
+        output.find("wrong") != std::string::npos)
+        return 1;
+
+    std::cout << "wave: hello buildroot" << std::endl;
+    return 0;
+}
support/testing/tests/package/test_boost.py new file +249 -0

249 lines not on this page · raw message

Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot