Skip to content

Commit 3644dba

Browse files
authored
Merge pull request #729 from elbeno/fix-mipi-buf
🐛 Fix MIPI catalog builder using buffer
2 parents 456f51e + 4728965 commit 3644dba

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

include/log/catalog/mipi_builder.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ template <> struct builder<defn::catalog_msg_t> {
103103
} else {
104104
constexpr auto header_size =
105105
defn::catalog_msg_t::size<std::uint8_t>::value;
106-
constexpr auto payload_size = (sizeof(id) + ... + sizeof(Ts));
106+
constexpr auto payload_size =
107+
(sizeof(id) + ... + sizeof(pack_as_t<Ts>));
107108
using storage_t =
108109
std::array<std::uint8_t, header_size + payload_size>;
109110
return catalog_builder<storage_t>{}.template build<Level>(id, m,

test/log/encoder.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ constexpr auto check_at = [](auto span, auto dw_idx, std::uint32_t expected) {
8383

8484
template <std::uint32_t... Expected>
8585
constexpr auto check_buffer = [](auto data) {
86-
REQUIRE(data.size() > (sizeof...(Expected) - 1) * sizeof(std::uint32_t));
8786
auto idx = std::size_t{};
8887
(check_at(data, idx++, Expected), ...);
8988
};
@@ -102,8 +101,9 @@ struct test_log_args_destination {
102101

103102
template <logging::level Level, typename ModuleId, auto... ExpectedArgs>
104103
struct test_log_buf_destination {
105-
template <std::size_t N>
106-
auto log_by_buf(stdx::span<std::uint8_t const, N> data) const {
104+
auto log_by_buf(stdx::span<std::uint8_t const> data) const {
105+
REQUIRE(data.size() ==
106+
(sizeof...(ExpectedArgs) + 1) * sizeof(std::uint32_t));
107107
constexpr auto Header =
108108
expected_msg_header(Level, test_module_id, sizeof...(ExpectedArgs));
109109
check_buffer<Header, ExpectedArgs...>(data);
@@ -120,8 +120,7 @@ struct test_log_version_destination {
120120
++num_log_args_calls;
121121
}
122122

123-
template <std::size_t N>
124-
auto log_by_buf(stdx::span<std::uint8_t const, N> data) const {
123+
auto log_by_buf(stdx::span<std::uint8_t const> data) const {
125124
check_buffer<Header, ExpectedArgs...>(data);
126125
++num_log_args_calls;
127126
}
@@ -212,9 +211,9 @@ TEST_CASE("log more than two arguments", "[mipi]") {
212211
test_critical_section::count = 0;
213212
auto cfg = logging::binary::config{
214213
test_log_buf_destination<logging::level::TRACE, log_env, 42u, 17u,
215-
18u, 19u, 20u>{}};
214+
18u, 97u, 98u>{}};
216215
cfg.logger.log_msg<log_env>(
217-
stdx::ct_format<"{} {} {} {}">(17u, 18u, 19u, 20u));
216+
stdx::ct_format<"{} {} {} {}">(17u, 18u, 'a', 'b'));
218217
CHECK(test_critical_section::count == 2);
219218
}
220219
}

0 commit comments

Comments
 (0)