From: Matt Benjamin Date: Tue, 12 Apr 2016 18:39:40 +0000 (-0400) Subject: rgw_file: fix nfsns unit test when !created and !create X-Git-Tag: v10.2.0~8^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=917a25d047be5384038a0099a80995e17aaec8c6;p=ceph.git rgw_file: fix nfsns unit test when !created and !create 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 --- diff --git a/src/test/librgw_file_nfsns.cc b/src/test/librgw_file_nfsns.cc index 7f52c80a1795..de8aa5fc7b07 100644 --- a/src/test/librgw_file_nfsns.cc +++ b/src/test/librgw_file_nfsns.cc @@ -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