mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 07:48:01 +02:00
test: log the buffers after reading from them
Should help debug some issues with the encoding
This commit is contained in:
parent
8e95c7d8a5
commit
8f911d5e41
1 changed files with 22 additions and 0 deletions
|
|
@ -571,6 +571,20 @@ bytes_to_int32(uint32_t count)
|
|||
return (uint32_t)(((uint64_t)count + 3)/4);
|
||||
}
|
||||
|
||||
static inline void
|
||||
buffer_debug(const void *buffer, size_t sz)
|
||||
{
|
||||
const size_t stride = 8;
|
||||
_cleanup_(strv_freep) char **strv = strv_from_mem(buffer, sz, stride);
|
||||
|
||||
munit_logf(MUNIT_LOG_DEBUG, "Logging buffer size %zu", sz);
|
||||
for (size_t offset = 0; offset < sz; offset += stride) {
|
||||
const char *s = strv[offset/stride];
|
||||
munit_assert_ptr_not_null(s);
|
||||
munit_logf(MUNIT_LOG_DEBUG, "%02zu: %s", offset, s);
|
||||
}
|
||||
}
|
||||
|
||||
MUNIT_TEST(test_brei_send_message)
|
||||
{
|
||||
int sv[2];
|
||||
|
|
@ -594,6 +608,8 @@ MUNIT_TEST(test_brei_send_message)
|
|||
int len = read(sock_read, buf, sizeof(buf));
|
||||
munit_assert_int(len, ==, msglen);
|
||||
|
||||
buffer_debug(buf, len);
|
||||
|
||||
const struct brei_header *header = (const struct brei_header*)buf;
|
||||
munit_assert_int(header->sender_id, ==, id);
|
||||
munit_assert_int(header->msglen, ==, msglen);
|
||||
|
|
@ -617,6 +633,8 @@ MUNIT_TEST(test_brei_send_message)
|
|||
} ufloat;
|
||||
munit_assert_int(len, ==, msglen);
|
||||
|
||||
buffer_debug(buf, len);
|
||||
|
||||
const struct brei_header *header = (const struct brei_header*)buf;
|
||||
munit_assert_int(header->sender_id, ==, id);
|
||||
munit_assert_int(header->msglen, ==, msglen);
|
||||
|
|
@ -645,6 +663,8 @@ MUNIT_TEST(test_brei_send_message)
|
|||
int len = read(sock_read, buf, sizeof(buf));
|
||||
munit_assert_int(len, ==, msglen);
|
||||
|
||||
buffer_debug(buf, len);
|
||||
|
||||
const struct brei_header *header = (const struct brei_header*)buf;
|
||||
munit_assert_int(header->sender_id, ==, id);
|
||||
munit_assert_int(header->msglen, ==, msglen);
|
||||
|
|
@ -676,6 +696,8 @@ MUNIT_TEST(test_brei_send_message)
|
|||
int len = read(sock_read, buf, sizeof(buf));
|
||||
munit_assert_int(len, ==, msglen);
|
||||
|
||||
buffer_debug(buf, len);
|
||||
|
||||
const struct brei_header *header = (const struct brei_header*)buf;
|
||||
munit_assert_int(header->sender_id, ==, id);
|
||||
munit_assert_int(header->msglen, ==, msglen);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue