From 3a628ca1fcc1799c55de2635024ac178961cf702 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 23 Nov 2026 12:19:54 +0100 Subject: tests: let ecam_builder set bridge bus numbers This change extends the ecam_builder to support additional configuration data for PCI bridges, namely the secondary and subordinate bus numbers. This extension is required to support upcoming PCI bridge walk tests by allowing the tests to configure PCI bridge topologies. The builder test reads both of the new bus numbers to verify they are set correctly. Additionally, this change introduces a new test support function in kstd, called require_ok. require_ok asserts that a kstd::result contains a success value and moves that value out of the result. In the case of a failed result, the source location of the require_ok call as well as the error message are reported and the test case is aborted. Both ecam_builder::window_for and the ecam_builder tests use this new function. --- libs/kstd/kstd/test_support/result.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libs/kstd/kstd/test_support/result.hpp (limited to 'libs/kstd') diff --git a/libs/kstd/kstd/test_support/result.hpp b/libs/kstd/kstd/test_support/result.hpp new file mode 100644 index 00000000..7b6d765c --- /dev/null +++ b/libs/kstd/kstd/test_support/result.hpp @@ -0,0 +1,33 @@ +#ifndef KSTD_TEST_SUPPORT_RESULT_HPP +#define KSTD_TEST_SUPPORT_RESULT_HPP + +#include +#include + +#include + +#include +#include + +namespace kstd::tests +{ + + //! Require for a result to be successful. + //! + //! @param result The result to check. + //! @param where The source location to report in case of failure. + //! @return The successful value contained in the result. + template + auto require_ok(result result, std::source_location where = std::source_location::current()) -> ResultType + { + if (!result) + { + FAIL("expected success at " << where.file_name() << ':' << where.line() << ", got " + << error_to_string(result.error())); + } + return std::move(*result); + } + +} // namespace kstd::tests + +#endif -- cgit v1.2.3