]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_objectstore: dump actual vs expected on read data mismatch
authorSage Weil <sage@redhat.com>
Thu, 17 Dec 2015 19:17:35 +0000 (14:17 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:07:23 +0000 (13:07 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/test/objectstore/store_test.cc

index c94e6096f39bb421551dbee05975acef5e6a8565..6c5aeb175b939191ea2d13eaa63d80e29106f00d 100644 (file)
@@ -1485,6 +1485,20 @@ public:
   }
 };
 
+static void dump_bl_mismatch(bufferlist& expected, bufferlist& actual)
+{
+  cout << __func__ << std::endl;
+  unsigned offset = 0;
+  while (expected[offset] == actual[offset])
+    ++offset;
+  cout << "--- buffer mismatch at offset 0x" << std::hex << offset << std::dec
+       << std::endl;
+  cout << "--- expected:\n";
+  expected.hexdump(cout);
+  cout << "--- actual:\n";
+  actual.hexdump(cout);
+}
+
 class SyntheticWorkloadState {
   struct Object {
     bufferlist data;
@@ -1575,7 +1589,8 @@ public:
       bufferlist r2;
       r = state->store->read(state->cid, noid, 0, state->contents[noid].data.length(), r2);
       if (!state->contents[noid].data.contents_equal(r2)) {
-        assert(state->contents[noid].data.contents_equal(r2));
+       dump_bl_mismatch(state->contents[noid].data, r2);
+       assert(0 == " mismatch after clone");
         ASSERT_TRUE(state->contents[noid].data.contents_equal(r2));
       }
       state->cond.Signal();
@@ -1933,19 +1948,14 @@ public:
       expected.copy(offset, len, bl);
       ASSERT_EQ(r, (int)len);
       if (!result.contents_equal(bl)) {
-       cout << "result:\n";
-       result.hexdump(cout);
-       cout << "expected:\n";
-       bl.hexdump(cout);
-       for (unsigned i=0; i<result.length(); ++i) {
-         if (result[i] != bl[i]) {
-           cout << "first difference at offset " << i << std::endl;
-           break;
-         }
-       }
-       assert(0);
+       cout << " obj " << obj
+        << " size " << expected.length()
+        << " offset " << offset
+        << " len " << len << std::endl;
+       dump_bl_mismatch(bl, result);
+       assert(0 == "mismatch after read");
+       ASSERT_TRUE(result.contents_equal(bl));
       }
-      ASSERT_TRUE(result.contents_equal(bl));
     }
   }