]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librados: fix endian bugs in checksum test cases 37605/head
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 17 Sep 2020 13:52:54 +0000 (15:52 +0200)
committerNathan Cutler <ncutler@suse.com>
Thu, 8 Oct 2020 18:06:41 +0000 (20:06 +0200)
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 <ulrich.weigand@de.ibm.com>
(cherry picked from commit 2e66216b0c5bdb0de350b9c40269f932fb009e68)

src/test/librados/c_read_operations.cc
src/test/librados/io.cc
src/test/librados/misc_cxx.cc

index d3d8e772cbcfe96e213b81b6cc0bae44c366758b..a6cb3918bf45dfa3a571596b313189c6ca0ffe2c 100644 (file)
@@ -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<char *>(&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<char *>(&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,
index fce3de621226339db93ccd686f6439e46be759c8..6683bd5a7226f4fe935194e3f21c978da47ad8b8 100644 (file)
@@ -111,8 +111,8 @@ TEST_F(LibRadosIo, Checksum) {
 
   uint32_t expected_crc = ceph_crc32c(-1, reinterpret_cast<const uint8_t*>(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<char*>(&init_value),
                              sizeof(init_value), sizeof(buf), 0, 0,
index 6e0eb2543af3868fe2d436a7091fe30aa1742ddd..f5871cf9b7b8b841d0cfddad2559934759c41646 100644 (file)
@@ -707,11 +707,11 @@ public:
 
 typedef ::testing::Types<
     LibRadosChecksumParams<LIBRADOS_CHECKSUM_TYPE_XXHASH32,
-                          Checksummer::xxhash32, uint32_t>,
+                          Checksummer::xxhash32, ceph_le32>,
     LibRadosChecksumParams<LIBRADOS_CHECKSUM_TYPE_XXHASH64,
-                          Checksummer::xxhash64, uint64_t>,
+                          Checksummer::xxhash64, ceph_le64>,
     LibRadosChecksumParams<LIBRADOS_CHECKSUM_TYPE_CRC32C,
-                          Checksummer::crc32c, uint32_t>
+                          Checksummer::crc32c, ceph_le32>
   > LibRadosChecksumTypes;
 
 TYPED_TEST_CASE(LibRadosChecksum, LibRadosChecksumTypes);