aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-11-23 12:19:54 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-11-23 12:19:54 +0100
commit3a628ca1fcc1799c55de2635024ac178961cf702 (patch)
tree13805cea0dfa726c3e1b21109f34ab1d6d1152aa /libs/kstd
parent2f9972781b66fd350f1975b2975f8998d5d07f13 (diff)
downloadkernel-3a628ca1fcc1799c55de2635024ac178961cf702.tar.xz
kernel-3a628ca1fcc1799c55de2635024ac178961cf702.zip
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.
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/kstd/test_support/result.hpp33
1 files changed, 33 insertions, 0 deletions
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 <kstd/result.hpp>
+#include <kstd/test_support/string_makers.hpp>
+
+#include <catch2/catch_test_macros.hpp>
+
+#include <source_location>
+#include <utility>
+
+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<typename ResultType>
+ auto require_ok(result<ResultType> 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