From: Ulrich Weigand Date: Thu, 17 Sep 2020 13:52:54 +0000 (+0200) Subject: test/librados: fix endian bugs in checksum test cases X-Git-Tag: v14.2.17~28^2~27^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=68f82de0d273b4dcadda44c377689a6b96c5be39;p=ceph.git 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 (cherry picked from commit 2e66216b0c5bdb0de350b9c40269f932fb009e68) --- diff --git a/src/test/librados/c_read_operations.cc b/src/test/librados/c_read_operations.cc index d3d8e772cbcf..a6cb3918bf45 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 fce3de621226..6683bd5a7226 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 6e0eb2543af3..f5871cf9b7b8 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_CASE(LibRadosChecksum, LibRadosChecksumTypes);