diff options
author | Jeff Layton <jlayton@redhat.com> | 2017-10-11 17:16:38 +0200 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2017-10-11 17:16:38 +0200 |
commit | f72ace0a5666db49bb390ff4ec6808e6e55a779f (patch) | |
tree | d1bde6f9ce673ad79c5b2462d0124f56c00e4010 /src/test/ceph_argparse.cc | |
parent | common: make it safe to call env_to_vec multiple times (diff) | |
download | ceph-f72ace0a5666db49bb390ff4ec6808e6e55a779f.tar.xz ceph-f72ace0a5666db49bb390ff4ec6808e6e55a779f.zip |
common: add a clear_g_str_vec() function to clear g_str_vec
Prefix str_vec and str_vec_lock with "g_" to make it clear that they are
truly global values. Add a new clear_g_str_vec function to allow it to
be explicitly cleaned out by callers that need that functionality
(mostly testcase for now).
Tracker: http://tracker.ceph.com/issues/21512
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'src/test/ceph_argparse.cc')
-rw-r--r-- | src/test/ceph_argparse.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/ceph_argparse.cc b/src/test/ceph_argparse.cc index c4f99c8ba11..7ff4e3ca005 100644 --- a/src/test/ceph_argparse.cc +++ b/src/test/ceph_argparse.cc @@ -373,17 +373,21 @@ TEST(CephArgParse, env_to_vec) { std::vector<const char*> args; unsetenv("CEPH_ARGS"); unsetenv("WHATEVER"); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(0u, args.size()); + clear_g_str_vec(); env_to_vec(args, "WHATEVER"); EXPECT_EQ(0u, args.size()); args.push_back("a"); setenv("CEPH_ARGS", "b c", 0); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(3u, args.size()); EXPECT_EQ(string("b"), args[1]); EXPECT_EQ(string("c"), args[2]); setenv("WHATEVER", "d e", 0); + clear_g_str_vec(); env_to_vec(args, "WHATEVER"); EXPECT_EQ(5u, args.size()); EXPECT_EQ(string("d"), args[3]); @@ -396,6 +400,7 @@ TEST(CephArgParse, env_to_vec) { args.push_back("--"); args.push_back("c"); setenv("CEPH_ARGS", "b -- d", 0); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(5u, args.size()); EXPECT_EQ(string("a"), args[0]); @@ -410,6 +415,7 @@ TEST(CephArgParse, env_to_vec) { args.push_back("a"); args.push_back("--"); setenv("CEPH_ARGS", "b -- c", 0); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(4u, args.size()); EXPECT_EQ(string("a"), args[0]); @@ -423,6 +429,7 @@ TEST(CephArgParse, env_to_vec) { args.push_back("--"); args.push_back("c"); setenv("CEPH_ARGS", "b -- d", 0); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(4u, args.size()); EXPECT_EQ(string("b"), args[0]); @@ -435,6 +442,7 @@ TEST(CephArgParse, env_to_vec) { unsetenv("CEPH_ARGS"); args.push_back("b"); setenv("CEPH_ARGS", "c -- d", 0); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(4u, args.size()); EXPECT_EQ(string("b"), args[0]); @@ -449,6 +457,7 @@ TEST(CephArgParse, env_to_vec) { args.push_back("--"); args.push_back("c"); setenv("CEPH_ARGS", "-- d", 0); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(4u, args.size()); EXPECT_EQ(string("a"), args[0]); @@ -463,6 +472,7 @@ TEST(CephArgParse, env_to_vec) { args.push_back("--"); args.push_back("c"); setenv("CEPH_ARGS", "d", 0); + clear_g_str_vec(); env_to_vec(args); EXPECT_EQ(4u, args.size()); EXPECT_EQ(string("a"), args[0]); |