Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] support/testing: boost: new runtime tests
@ 2026-10-06  8:03 Michael Nosthoff via buildroot
  0 siblings, 0 replies; only message in thread
From: Michael Nosthoff via buildroot @ 2026-10-06  8:03 UTC (permalink / raw)
  To: buildroot

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
Signed-off-by: Michael Nosthoff <buildroot@heine.tech>

---

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

diff --git a/DEVELOPERS b/DEVELOPERS
index 32ac338dc8..e8d76dad90 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -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 <michael@amarulasolutions.com>
 F:	board/bsh/
diff --git a/support/testing/tests/package/br2-external/boost/Config.in b/support/testing/tests/package/br2-external/boost/Config.in
new file mode 100644
index 0000000000..4a49617767
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/Config.in
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_BOOST_RUNTIME_TEST_PATH/package/boost-runtime-test/Config.in"
diff --git a/support/testing/tests/package/br2-external/boost/external.desc b/support/testing/tests/package/br2-external/boost/external.desc
new file mode 100644
index 0000000000..2b88912b82
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/external.desc
@@ -0,0 +1 @@
+name: BOOST_RUNTIME_TEST
diff --git a/support/testing/tests/package/br2-external/boost/external.mk b/support/testing/tests/package/br2-external/boost/external.mk
new file mode 100644
index 0000000000..295235ba4b
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/external.mk
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_BOOST_RUNTIME_TEST_PATH)/package/*/*.mk))
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/CMakeLists.txt b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/CMakeLists.txt
new file mode 100644
index 0000000000..69edd6e7b9
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/CMakeLists.txt
@@ -0,0 +1,137 @@
+cmake_minimum_required(VERSION 3.10)
+project(boost-runtime-test CXX)
+
+set(CMAKE_CXX_STANDARD 14)
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+
+# Names of the boost libraries to test
+set(BOOST_RUNTIME_TEST_LIBS "" CACHE STRING "Boost libraries to test")
+# Boost source tree, the upstream tests are built straight from it
+set(BOOST_SOURCE_DIR "" CACHE PATH "Boost source tree")
+# Set to build a boost-python extension module
+set(BOOST_RUNTIME_TEST_PYTHON_INCLUDE_DIR "" CACHE PATH "Python include directory")
+set(BOOST_RUNTIME_TEST_PYTHON_SITE_DIR "" CACHE STRING "Python module install directory")
+
+# Upstream test of each library, relative to the boost source tree.
+# Libraries without an entry are built from src/boost-<lib>-test.cpp.
+set(upstream_atomic libs/atomic/test/atomic_api.cpp)
+
+set(upstream_chrono libs/chrono/test/test_11012.cpp)
+
+set(upstream_container libs/container/test/synchronized_pool_resource_test.cpp)
+
+set(upstream_context libs/context/test/test_fcontext.cpp)
+
+set(upstream_contract libs/contract/test/check/audit_disabled.cpp)
+
+set(upstream_date_time libs/date_time/test/testgregorian_calendar.cpp)
+
+set(upstream_exception libs/exception/test/exception_test.cpp)
+set(definitions_exception BOOST_TEST_DYN_LINK)
+
+set(upstream_filesystem libs/filesystem/test/quick.cpp)
+
+set(upstream_graph libs/graph/test/copy.cpp)
+
+set(upstream_json libs/json/test/string.cpp libs/json/test/main.cpp)
+set(includes_json libs/json/test)
+
+set(upstream_log libs/log/test/run/attr_attribute_set.cpp)
+set(component_log log_setup)
+set(components_log unit_test_framework)
+set(definitions_log BOOST_TEST_DYN_LINK BOOST_LOG_DYN_LINK BOOST_LOG_SETUP_DYN_LINK)
+set(includes_log libs/log/test/common)
+
+set(upstream_math libs/math/test/test_tr1.cpp)
+set(component_math math_c99 math_c99f math_tr1 math_tr1f)
+set(components_math unit_test_framework)
+set(definitions_math BOOST_TEST_DYN_LINK)
+
+set(upstream_nowide libs/nowide/test/test_convert.cpp)
+
+set(upstream_program_options libs/program_options/test/variable_map_test.cpp)
+
+set(upstream_random libs/random/test/test_ranlux24.cpp)
+set(components_random unit_test_framework)
+set(definitions_random BOOST_TEST_DYN_LINK)
+
+set(upstream_regex libs/regex/test/quick.cpp)
+
+set(upstream_serialization libs/serialization/test/test_inclusion2.cpp)
+
+set(upstream_stacktrace libs/stacktrace/test/test_trivial.cpp)
+set(component_stacktrace stacktrace_basic)
+
+set(upstream_system libs/system/test/error_condition_test.cpp)
+
+set(upstream_test libs/test/test/framework-ts/decorators-datatestcase-test.cpp)
+set(component_test unit_test_framework)
+set(definitions_test BOOST_TEST_DYN_LINK)
+set(includes_test libs/test/test/framework-ts)
+
+set(upstream_thread libs/thread/test/test_2501.cpp)
+
+set(upstream_timer libs/timer/test/cpu_timer_test.cpp)
+
+set(upstream_type_erasure libs/type_erasure/test/test_dynamic_any_cast.cpp)
+set(components_type_erasure unit_test_framework)
+set(definitions_type_erasure BOOST_TEST_DYN_LINK)
+
+function(boost_components out)
+  set(components)
+  foreach(lib IN LISTS ARGN)
+    if(DEFINED component_${lib})
+      list(APPEND components ${component_${lib}})
+    else()
+      list(APPEND components ${lib})
+    endif()
+    list(APPEND components ${components_${lib}})
+  endforeach()
+  list(REMOVE_DUPLICATES components)
+  set(${out} ${components} PARENT_SCOPE)
+endfunction()
+
+boost_components(all_components ${BOOST_RUNTIME_TEST_LIBS})
+if(BOOST_RUNTIME_TEST_PYTHON_INCLUDE_DIR)
+  list(APPEND all_components python)
+endif()
+
+find_package(Boost REQUIRED CONFIG COMPONENTS ${all_components})
+
+foreach(lib IN LISTS BOOST_RUNTIME_TEST_LIBS)
+  string(REPLACE "_" "-" name ${lib})
+  set(target boost-${name}-test)
+
+  boost_components(components ${lib})
+  set(boost_targets)
+  foreach(component IN LISTS components)
+    list(APPEND boost_targets Boost::${component})
+  endforeach()
+
+  if(DEFINED upstream_${lib})
+    set(sources)
+    foreach(source IN LISTS upstream_${lib})
+      list(APPEND sources ${BOOST_SOURCE_DIR}/${source})
+    endforeach()
+  else()
+    set(sources src/${target}.cpp)
+  endif()
+
+  add_executable(${target} ${sources})
+  target_link_libraries(${target} Boost::headers ${boost_targets}
+                        Threads::Threads ${CMAKE_DL_LIBS})
+  target_compile_definitions(${target} PRIVATE ${definitions_${lib}})
+  foreach(include IN LISTS includes_${lib})
+    target_include_directories(${target} PRIVATE ${BOOST_SOURCE_DIR}/${include})
+  endforeach()
+  install(TARGETS ${target} RUNTIME DESTINATION bin)
+endforeach()
+
+if(BOOST_RUNTIME_TEST_PYTHON_INCLUDE_DIR)
+  add_library(boost_python_test MODULE src/boost-python-test.cpp)
+  set_target_properties(boost_python_test PROPERTIES PREFIX "")
+  target_include_directories(boost_python_test PRIVATE ${BOOST_RUNTIME_TEST_PYTHON_INCLUDE_DIR})
+  target_link_libraries(boost_python_test Boost::headers Boost::python)
+  install(TARGETS boost_python_test LIBRARY DESTINATION ${BOOST_RUNTIME_TEST_PYTHON_SITE_DIR})
+endif()
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/Config.in b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/Config.in
new file mode 100644
index 0000000000..a7bdafd7ee
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/Config.in
@@ -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.
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/boost-runtime-test.mk b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/boost-runtime-test.mk
new file mode 100644
index 0000000000..f2489339c5
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/boost-runtime-test.mk
@@ -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))
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-coroutine-test.cpp b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-coroutine-test.cpp
new file mode 100644
index 0000000000..c5911bbe67
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-coroutine-test.cpp
@@ -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;
+}
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-fiber-test.cpp b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-fiber-test.cpp
new file mode 100644
index 0000000000..14856b566f
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-fiber-test.cpp
@@ -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;
+}
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-iostreams-test.cpp b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-iostreams-test.cpp
new file mode 100644
index 0000000000..0a163d748a
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-iostreams-test.cpp
@@ -0,0 +1,47 @@
+#include <boost/iostreams/copy.hpp>
+#include <boost/iostreams/filter/bzip2.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
+
+#include <iostream>
+#include <sstream>
+#include <string>
+
+namespace io = boost::iostreams;
+
+template <typename Compressor, typename Decompressor>
+static bool round_trip(const std::string &input)
+{
+    std::stringstream compressed;
+    {
+        io::filtering_ostream out;
+        out.push(Compressor());
+        out.push(compressed);
+        out << input;
+    }
+    if (compressed.str().size() >= input.size())
+        return false;
+
+    std::stringstream output;
+    {
+        io::filtering_istream in;
+        in.push(Decompressor());
+        in.push(compressed);
+        io::copy(in, output);
+    }
+    return output.str() == input;
+}
+
+int main()
+{
+    std::string input(1000, 'x');
+    input += "boost";
+
+    if (!round_trip<io::gzip_compressor, io::gzip_decompressor>(input))
+        return 1;
+    if (!round_trip<io::bzip2_compressor, io::bzip2_decompressor>(input))
+        return 1;
+
+    std::cout << "iostreams: gzip and bzip2 round trip OK" << std::endl;
+    return 0;
+}
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-locale-test.cpp b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-locale-test.cpp
new file mode 100644
index 0000000000..ba1583e48a
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-locale-test.cpp
@@ -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;
+}
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-python-test.cpp b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-python-test.cpp
new file mode 100644
index 0000000000..1401b9c10f
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-python-test.cpp
@@ -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);
+}
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-url-test.cpp b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-url-test.cpp
new file mode 100644
index 0000000000..979644a921
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-url-test.cpp
@@ -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;
+}
diff --git a/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-wave-test.cpp b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-wave-test.cpp
new file mode 100644
index 0000000000..15eff29847
--- /dev/null
+++ b/support/testing/tests/package/br2-external/boost/package/boost-runtime-test/src/boost-wave-test.cpp
@@ -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;
+}
diff --git a/support/testing/tests/package/test_boost.py b/support/testing/tests/package/test_boost.py
new file mode 100644
index 0000000000..3954aa5dec
--- /dev/null
+++ b/support/testing/tests/package/test_boost.py
@@ -0,0 +1,249 @@
+import os
+
+import infra.basetest
+
+# The ARMv5 basic toolchain lacks always lock-free atomics, which most
+# boost libraries depend on.
+BOOST_CONFIG = \
+    """
+    BR2_arm=y
+    BR2_cortex_a9=y
+    BR2_ARM_ENABLE_VFP=y
+    BR2_TOOLCHAIN_EXTERNAL=y
+    BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+    BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV7_EABIHF_GLIBC_STABLE=y
+    BR2_PACKAGE_BOOST=y
+    BR2_PACKAGE_BOOST_RUNTIME_TEST=y
+    BR2_TARGET_ROOTFS_CPIO=y
+    # BR2_TARGET_ROOTFS_TAR is not set
+    """
+
+
+def boost_config(lib, extra=""):
+    return BOOST_CONFIG + f"BR2_PACKAGE_BOOST_{lib.upper()}=y\n" + extra
+
+
+# boost-mpi and boost-graph_parallel are not tested yet.
+#
+# Most tests are upstream tests built from the boost source tree and only
+# checked for a zero exit code. Libraries without a suitable upstream test
+# set expected_output and are built from the programs in boost-runtime-test/src.
+class TestBoostBase(infra.basetest.BRTest):
+    __test__ = False
+    br2_external = [infra.filepath("tests/package/br2-external/boost")]
+    config = BOOST_CONFIG
+    lib = None
+    expected_output = None
+
+    def program(self):
+        return "/usr/bin/boost-{}-test".format(self.lib.replace("_", "-"))
+
+    def run_ok(self, cmd):
+        output, exit_code = self.emulator.run(cmd)
+        self.assertEqual(exit_code, 0, output)
+        return output
+
+    def check(self):
+        output = self.run_ok(self.program())
+        if self.expected_output is not None:
+            self.assertEqual(output, self.expected_output)
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        self.emulator.boot(arch="armv7",
+                           kernel="builtin",
+                           options=["-initrd", cpio_file])
+        self.emulator.login()
+        self.check()
+
+
+class TestBoostAtomic(TestBoostBase):
+    __test__ = True
+    lib = "atomic"
+    config = boost_config(lib)
+
+
+class TestBoostChrono(TestBoostBase):
+    __test__ = True
+    lib = "chrono"
+    config = boost_config(lib)
+
+
+class TestBoostContainer(TestBoostBase):
+    __test__ = True
+    lib = "container"
+    config = boost_config(lib)
+
+
+class TestBoostContext(TestBoostBase):
+    __test__ = True
+    lib = "context"
+    config = boost_config(lib)
+
+
+class TestBoostContract(TestBoostBase):
+    __test__ = True
+    lib = "contract"
+    config = boost_config(lib)
+
+
+class TestBoostCoroutine(TestBoostBase):
+    __test__ = True
+    lib = "coroutine"
+    config = boost_config(lib)
+    expected_output = ["coroutine: fib(9)=34"]
+
+
+class TestBoostDateTime(TestBoostBase):
+    __test__ = True
+    lib = "date_time"
+    config = boost_config(lib)
+
+
+class TestBoostException(TestBoostBase):
+    __test__ = True
+    lib = "exception"
+    config = boost_config(lib)
+
+
+class TestBoostFiber(TestBoostBase):
+    __test__ = True
+    lib = "fiber"
+    config = boost_config(lib)
+    expected_output = ["fiber: sum=15"]
+
+
+class TestBoostFilesystem(TestBoostBase):
+    __test__ = True
+    lib = "filesystem"
+    config = boost_config(lib)
+
+
+class TestBoostGraph(TestBoostBase):
+    __test__ = True
+    lib = "graph"
+    config = boost_config(lib)
+
+
+class TestBoostIostreams(TestBoostBase):
+    __test__ = True
+    lib = "iostreams"
+    config = boost_config(lib)
+    expected_output = ["iostreams: gzip and bzip2 round trip OK"]
+
+
+class TestBoostJson(TestBoostBase):
+    __test__ = True
+    lib = "json"
+    config = boost_config(lib)
+
+
+class TestBoostLocale(TestBoostBase):
+    __test__ = True
+    lib = "locale"
+    config = boost_config(lib, 'BR2_GENERATE_LOCALE="en_US.UTF-8"\n'
+                               "BR2_TOOLCHAIN_GLIBC_GCONV_LIBS_COPY=y\n")
+    expected_output = ["locale: 5 characters"]
+
+
+class TestBoostLog(TestBoostBase):
+    __test__ = True
+    lib = "log"
+    config = boost_config(lib, "BR2_PACKAGE_BOOST_TEST=y\n")
+
+
+class TestBoostMath(TestBoostBase):
+    __test__ = True
+    lib = "math"
+    config = boost_config(lib, "BR2_PACKAGE_BOOST_TEST=y\n")
+
+
+class TestBoostNowide(TestBoostBase):
+    __test__ = True
+    lib = "nowide"
+    config = boost_config(lib)
+
+
+class TestBoostProgramOptions(TestBoostBase):
+    __test__ = True
+    lib = "program_options"
+    config = boost_config(lib)
+
+
+class TestBoostPython(TestBoostBase):
+    __test__ = True
+    lib = "python"
+    config = boost_config(lib, "BR2_PACKAGE_PYTHON3=y\n")
+
+    def check(self):
+        cmd = "python3 -c 'import boost_python_test as m; c = m.Counter(); " \
+              "c.add(3); c.add(4); print(m.greet(\"buildroot\"), c.value)'"
+        self.assertEqual(self.run_ok(cmd), ["hello buildroot 7"])
+
+
+class TestBoostRandom(TestBoostBase):
+    __test__ = True
+    lib = "random"
+    config = boost_config(lib, "BR2_PACKAGE_BOOST_TEST=y\n")
+
+
+class TestBoostRegex(TestBoostBase):
+    __test__ = True
+    lib = "regex"
+    config = boost_config(lib)
+
+
+class TestBoostSerialization(TestBoostBase):
+    __test__ = True
+    lib = "serialization"
+    config = boost_config(lib)
+
+
+class TestBoostStacktrace(TestBoostBase):
+    __test__ = True
+    lib = "stacktrace"
+    config = boost_config(lib)
+
+
+class TestBoostSystem(TestBoostBase):
+    __test__ = True
+    lib = "system"
+    config = boost_config(lib)
+
+
+class TestBoostTest(TestBoostBase):
+    __test__ = True
+    lib = "test"
+    config = boost_config(lib)
+
+
+class TestBoostThread(TestBoostBase):
+    __test__ = True
+    lib = "thread"
+    config = boost_config(lib)
+
+
+class TestBoostTimer(TestBoostBase):
+    __test__ = True
+    lib = "timer"
+    config = boost_config(lib)
+
+
+class TestBoostTypeErasure(TestBoostBase):
+    __test__ = True
+    lib = "type_erasure"
+    config = boost_config(lib, "BR2_PACKAGE_BOOST_TEST=y\n")
+
+
+class TestBoostUrl(TestBoostBase):
+    __test__ = True
+    lib = "url"
+    config = boost_config(lib)
+    expected_output = ["url: https://buildroot.org:8080/downloads/index.html?ver=2026.11&arch=aarch64"]
+
+
+class TestBoostWave(TestBoostBase):
+    __test__ = True
+    lib = "wave"
+    config = boost_config(lib)
+    expected_output = ["wave: hello buildroot"]
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-06  8:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-06  8:03 [Buildroot] [PATCH v2] support/testing: boost: new runtime tests Michael Nosthoff via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox