From 8910a3b3432fe33151ae240aaabd5f8ae4969e17 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 27 Sep 2016 15:20:43 -0400 Subject: [PATCH] unittest_bluefs: use append(const char*, size_t) The bufferlist one is for internal use only. Signed-off-by: Sage Weil --- src/test/objectstore/test_bluefs.cc | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/test/objectstore/test_bluefs.cc b/src/test/objectstore/test_bluefs.cc index 2cad598f654ac..d189eeac71219 100644 --- a/src/test/objectstore/test_bluefs.cc +++ b/src/test/objectstore/test_bluefs.cc @@ -82,13 +82,9 @@ TEST(BlueFS, write_read) { BlueFS::FileWriter *h; ASSERT_EQ(0, fs.mkdir("dir")); ASSERT_EQ(0, fs.open_for_write("dir", "file", &h, false)); - bufferlist bl; - bl.append("foo"); - h->append(bl); - bl.append("bar"); - h->append(bl); - bl.append("baz"); - h->append(bl); + h->append("foo", 3); + h->append("bar", 3); + h->append("baz", 3); fs.fsync(h); fs.close_writer(h); } @@ -119,9 +115,7 @@ TEST(BlueFS, small_appends) { ASSERT_EQ(0, fs.mkdir("dir")); ASSERT_EQ(0, fs.open_for_write("dir", "file", &h, false)); for (unsigned i = 0; i < 10000; ++i) { - bufferlist bl; - bl.append("fddjdjdjdjdjdjdjdjdjdjjddjoo"); - h->append(bl); + h->append("abcdeabcdeabcdeabcdeabcdeabc", 23); } fs.fsync(h); fs.close_writer(h); @@ -130,9 +124,7 @@ TEST(BlueFS, small_appends) { BlueFS::FileWriter *h; ASSERT_EQ(0, fs.open_for_write("dir", "file_sync", &h, false)); for (unsigned i = 0; i < 1000; ++i) { - bufferlist bl; - bl.append("fddjdjdjdjdjdjdjdjdjdjjddjoo"); - h->append(bl); + h->append("abcdeabcdeabcdeabcdeabcdeabc", 23); fs.fsync(h); } fs.close_writer(h); @@ -164,7 +156,7 @@ void write_data(BlueFS &fs, uint64_t rationed_bytes) char *buf = gen_buffer(ALLOC_SIZE); bufferptr bp = buffer::claim_char(ALLOC_SIZE, buf); bl.push_back(bp); - h->append(bl); + h->append(bl.c_str(), bl.length()); r = fs.fsync(h); if (r < 0) { fs.close_writer(h); @@ -191,7 +183,7 @@ void create_single_file(BlueFS &fs) char *buf = gen_buffer(ALLOC_SIZE); bufferptr bp = buffer::claim_char(ALLOC_SIZE, buf); bl.push_back(bp); - h->append(bl); + h->append(bl.c_str(), bl.length()); fs.fsync(h); fs.close_writer(h); } @@ -211,7 +203,7 @@ void write_single_file(BlueFS &fs, uint64_t rationed_bytes) char *buf = gen_buffer(ALLOC_SIZE); bufferptr bp = buffer::claim_char(ALLOC_SIZE, buf); bl.push_back(bp); - h->append(bl); + h->append(bl.c_str(), bl.length()); r = fs.fsync(h); if (r < 0) { fs.close_writer(h); @@ -380,7 +372,7 @@ TEST(BlueFS, test_simple_compaction_sync) { char *buf = gen_buffer(4096); bufferptr bp = buffer::claim_char(4096, buf); bl.push_back(bp); - h->append(bl); + h->append(bl.c_str(), bl.length()); fs.fsync(h); fs.close_writer(h); } @@ -433,7 +425,7 @@ TEST(BlueFS, test_simple_compaction_async) { char *buf = gen_buffer(4096); bufferptr bp = buffer::claim_char(4096, buf); bl.push_back(bp); - h->append(bl); + h->append(bl.c_str(), bl.length()); fs.fsync(h); fs.close_writer(h); } -- 2.39.5