From 596718595a8c07798caa90853186812ab0b56d13 Mon Sep 17 00:00:00 2001 From: Ioannis Kavvadias Date: Wed, 20 Nov 2024 13:26:01 +0000 Subject: [PATCH] serde: bazelize serde_test --- src/v/serde/test/BUILD | 42 ++++++++++++++++++++++++++++++++++ src/v/serde/test/serde_test.cc | 17 ++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/v/serde/test/BUILD diff --git a/src/v/serde/test/BUILD b/src/v/serde/test/BUILD new file mode 100644 index 0000000000000..df1c7a007b8fd --- /dev/null +++ b/src/v/serde/test/BUILD @@ -0,0 +1,42 @@ +load("//bazel:test.bzl", "redpanda_cc_btest") + +redpanda_cc_btest( + name = "serde_test", + timeout = "short", + srcs = [ + "serde_test.cc", + ], + defines = [ + "SERDE_TEST", + ], + deps = [ + "//src/v/bytes:random", + "//src/v/container:fragmented_vector", + "//src/v/hashing:crc32c", + "//src/v/model", + "//src/v/random:generators", + "//src/v/serde", + "//src/v/serde:array", + "//src/v/serde:bool_class", + "//src/v/serde:bytes", + "//src/v/serde:chrono", + "//src/v/serde:enum", + "//src/v/serde:inet_address", + "//src/v/serde:iobuf", + "//src/v/serde:map", + "//src/v/serde:set", + "//src/v/serde:sstring", + "//src/v/serde:variant", + "//src/v/test_utils:random", + "//src/v/test_utils:seastar_boost", + "//src/v/utils:tristate", + "@abseil-cpp//absl/container:btree", + "@abseil-cpp//absl/container:flat_hash_map", + "@abseil-cpp//absl/container:node_hash_map", + "@abseil-cpp//absl/container:node_hash_set", + "@boost//:container_hash", + "@boost//:test", + "@seastar", + "@seastar//:testing", + ], +) diff --git a/src/v/serde/test/serde_test.cc b/src/v/serde/test/serde_test.cc index dd2a9628519fe..a7578e9373694 100644 --- a/src/v/serde/test/serde_test.cc +++ b/src/v/serde/test/serde_test.cc @@ -13,9 +13,21 @@ #include "model/fundamental.h" #include "model/metadata.h" #include "random/generators.h" +#include "serde/async.h" +#include "serde/peek.h" +#include "serde/rw/array.h" +#include "serde/rw/bool_class.h" +#include "serde/rw/bytes.h" +#include "serde/rw/chrono.h" +#include "serde/rw/enum.h" +#include "serde/rw/envelope.h" +#include "serde/rw/inet_address.h" +#include "serde/rw/iobuf.h" +#include "serde/rw/map.h" #include "serde/rw/rw.h" +#include "serde/rw/set.h" +#include "serde/rw/sstring.h" #include "serde/rw/variant.h" -#include "serde/serde.h" #include "test_utils/randoms.h" #include "utils/tristate.h" @@ -36,6 +48,7 @@ #include #include #include +#include struct custom_read_write { friend inline void read_nested( @@ -468,7 +481,7 @@ ss::future<> test_snapshot_header::serde_async_read( crc.extend(ss::cpu_to_le(version)); crc.extend(ss::cpu_to_le(metadata_size)); - if (header_crc != crc.value()) { + if (std::cmp_not_equal(header_crc, crc.value())) { throw std::runtime_error(fmt::format( "Corrupt snapshot. Failed to verify header crc: {} != " "{}: path?",