]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: add list bucket test
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 8 Sep 2015 23:46:33 +0000 (19:46 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 16:57:56 +0000 (11:57 -0500)
The operation on store is missing, but interface works.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/test/librgw_file.cc

index 0fc48a9e6691466ff57cfba516b1ad7f04145194..ab88eec98f4b4edd9e237d714d077e9a06c69557 100644 (file)
@@ -13,6 +13,8 @@
  */
 
 #include <stdint.h>
+#include <tuple>
+#include <iostream>
 
 #include "include/rados/librgw.h"
 #include "include/rados/rgw_file.h"
@@ -28,6 +30,8 @@ namespace {
   string access_key("C4B4D3E4H355VTDTQXRF");
   string secret_key("NRBkhM2rUZNUbydD86HpNJ110VpQjVroumCOHJXw");
   struct rgw_fs *fs = nullptr;
+  typedef std::tuple<string,uint64_t> fid_type; //in c++2014 can alias...
+  std::vector<fid_type> fids1;
 }
 
 TEST(LibRGW, INIT) {
@@ -43,6 +47,27 @@ TEST(LibRGW, MOUNT) {
   ASSERT_NE(fs, nullptr);
 }
 
+extern "C" {
+  static bool r1_cb(const char* name, void *arg, uint64_t offset) {
+    // don't need arg--it would point to fids1
+    fids1.push_back(fid_type(name, offset));
+    return true; /* XXX ? */
+  }
+}
+
+TEST(LibRGW, LIST_BUCKETS) {
+  /* list buckets via readdir in fs root */
+  using std::get;
+
+  bool eof = false;
+  int ret = rgw_readdir(fs, &fs->root_fh, 0 /* offset */, r1_cb, &fids1, &eof);
+  for (auto& fid : fids1) {
+    std::cout << "fname: " << get<0>(fid) << " fid: " << get<1>(fid)
+             << std::endl;
+  }
+  ASSERT_EQ(ret, 0);
+}
+
 TEST(LibRGW, UMOUNT) {
   int ret = rgw_umount(fs);
   ASSERT_EQ(ret, 0);