From 2e66216b0c5bdb0de350b9c40269f932fb009e68 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 17 Sep 2020 15:52:54 +0200 Subject: [PATCH] test/librados: fix endian bugs in checksum test cases We're seeing test failures when running rados/test.sh in Teuthology on a big-endian platform (IBM Z). These are all related to calls to the checksum operations, which expect little-endian inputs and outputs, but are in many places called with native-endian types from the test code. One test case, LibRadosAio::RoundTrip3 in aio.cc, already uses ceph_le types to address this problem, and this test actually completes successfully on IBM Z. This patch changes the other test case performing checksum operations accordingly. With this patch in place, rados/test.sh now completed successfully. Fixes: https://tracker.ceph.com/issues/47516 Signed-off-by: Ulrich Weigand --- src/test/librados/c_read_operations.cc | 12 ++++++------ src/test/librados/io.cc | 4 ++-- src/test/librados/misc_cxx.cc | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/test/librados/c_read_operations.cc b/src/test/librados/c_read_operations.cc index d3d8e772cbcfe..a6cb3918bf45d 100644 --- a/src/test/librados/c_read_operations.cc +++ b/src/test/librados/c_read_operations.cc @@ -381,7 +381,7 @@ TEST_F(CReadOpsTest, Checksum) { { rados_read_op_t op = rados_create_read_op(); - uint64_t init_value = -1; + ceph_le64 init_value = init_le64(-1); rados_read_op_checksum(op, LIBRADOS_CHECKSUM_TYPE_XXHASH64, reinterpret_cast(&init_value), sizeof(init_value), 0, len, 0, NULL, 0, NULL); @@ -390,8 +390,8 @@ TEST_F(CReadOpsTest, Checksum) { } { - uint32_t init_value = -1; - uint32_t crc[2]; + ceph_le32 init_value = init_le32(-1); + ceph_le32 crc[2]; rados_read_op_t op = rados_create_read_op(); rados_read_op_checksum(op, LIBRADOS_CHECKSUM_TYPE_CRC32C, reinterpret_cast(&init_value), @@ -407,7 +407,7 @@ TEST_F(CReadOpsTest, Checksum) { } { - uint32_t init_value = -1; + ceph_le32 init_value = init_le32(-1); int rval; rados_read_op_t op = rados_create_read_op(); rados_read_op_checksum(op, LIBRADOS_CHECKSUM_TYPE_XXHASH32, @@ -419,8 +419,8 @@ TEST_F(CReadOpsTest, Checksum) { } { - uint32_t init_value = -1; - uint32_t crc[3]; + ceph_le32 init_value = init_le32(-1); + ceph_le32 crc[3]; int rval; rados_read_op_t op = rados_create_read_op(); rados_read_op_checksum(op, LIBRADOS_CHECKSUM_TYPE_CRC32C, diff --git a/src/test/librados/io.cc b/src/test/librados/io.cc index fce3de6212263..6683bd5a7226f 100644 --- a/src/test/librados/io.cc +++ b/src/test/librados/io.cc @@ -111,8 +111,8 @@ TEST_F(LibRadosIo, Checksum) { uint32_t expected_crc = ceph_crc32c(-1, reinterpret_cast(buf), sizeof(buf)); - uint32_t init_value = -1; - uint32_t crc[2]; + ceph_le32 init_value = init_le32(-1); + ceph_le32 crc[2]; ASSERT_EQ(0, rados_checksum(ioctx, "foo", LIBRADOS_CHECKSUM_TYPE_CRC32C, reinterpret_cast(&init_value), sizeof(init_value), sizeof(buf), 0, 0, diff --git a/src/test/librados/misc_cxx.cc b/src/test/librados/misc_cxx.cc index c74bde90b9b81..e7ad1ec59ef0b 100644 --- a/src/test/librados/misc_cxx.cc +++ b/src/test/librados/misc_cxx.cc @@ -707,11 +707,11 @@ public: typedef ::testing::Types< LibRadosChecksumParams, + Checksummer::xxhash32, ceph_le32>, LibRadosChecksumParams, + Checksummer::xxhash64, ceph_le64>, LibRadosChecksumParams + Checksummer::crc32c, ceph_le32> > LibRadosChecksumTypes; TYPED_TEST_SUITE(LibRadosChecksum, LibRadosChecksumTypes); -- 2.39.5