]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: fix nfsns unit test when !created and !create
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 12 Apr 2016 18:39:40 +0000 (14:39 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 12 Apr 2016 20:13:00 +0000 (16:13 -0400)
Avoid dereferencing unitialized top-level objects when !found and the
create option not present (when means we cannot create them).

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

index 7f52c80a179541ef315a9f0d1276c67932a1645f..de8aa5fc7b07d1ee5818333855e54e93521806e9 100644 (file)
@@ -262,6 +262,9 @@ TEST(LibRGW, SETUP_DIRS1) {
        rc = rgw_mkdir(fs, dirs1_b.parent_fh, dirs1_b.name.c_str(), &st,
                      create_mask, &dirs1_b.fh, RGW_MKDIR_FLAG_NONE);
        ASSERT_EQ(rc, 0);
+      } else {
+       /* no top-level dir and can't create it--skip remaining tests */
+       return;
       }
     }
     dirs1_b.sync();
@@ -487,6 +490,12 @@ TEST(LibRGW, RGW_CROSSBUCKET_RENAME1) {
 TEST(LibRGW, BAD_DELETES_DIRS1) {
   if (do_dirs1) {
     int rc;
+
+    if (dirs_vec.size() == 0) {
+      /* skip */
+      return;
+    }
+
     if (do_delete) {
       /* try to unlink a non-empty directory (bucket) */
       rc = rgw_unlink(fs, dirs1_b.parent_fh, dirs1_b.name.c_str(),
@@ -494,7 +503,8 @@ TEST(LibRGW, BAD_DELETES_DIRS1) {
       ASSERT_NE(rc, 0);
     }
     /* try to unlink a non-empty directory (non-bucket) */
-    obj_rec& sdir_0 = get<1>(dirs_vec[0])[0];    ASSERT_EQ(sdir_0.name, "sdir_0");
+    obj_rec& sdir_0 = get<1>(dirs_vec[0])[0];
+    ASSERT_EQ(sdir_0.name, "sdir_0");
     ASSERT_TRUE(sdir_0.rgw_fh->is_dir());
     /* XXX we can't enforce this currently */
 #if 0