diff options
author | Josh Durgin <josh.durgin@inktank.com> | 2013-10-22 10:04:25 -0700 |
---|---|---|
committer | Josh Durgin <josh.durgin@inktank.com> | 2013-10-22 10:04:25 -0700 |
commit | 3445810f1f2254b707879f32842a40d279888c49 (patch) | |
tree | e384d851dbbe959f308da1b1cdc73291a2c2c513 | |
parent | ad4553a4fddfa01129d84da1f9e166a93260bd3e (diff) | |
parent | dff41cd768687c0be0ebd274c7bd6425209f9d45 (diff) | |
download | ceph-3445810f1f2254b707879f32842a40d279888c49.tar.gz |
Merge pull request #754 from ceph/wip-test-librbd
fix ceph_test_lirbd crash
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r-- | src/test/Makefile.am | 2 | ||||
-rw-r--r-- | src/test/librbd/test_librbd.cc | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 84a228f1d4b..572d5d57dc4 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -615,7 +615,7 @@ endif # WITH_RADOSGW ceph_test_librbd_SOURCES = \ test/librbd/test_librbd.cc \ test/librados/test.cc -ceph_test_librbd_LDADD = $(LIBRBD) $(LIBRADOS) $(UNITTEST_LDADD) +ceph_test_librbd_LDADD = $(LIBRBD) $(LIBRADOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL) ceph_test_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) bin_DEBUGPROGRAMS += ceph_test_librbd diff --git a/src/test/librbd/test_librbd.cc b/src/test/librbd/test_librbd.cc index 84bf3477aff..5169a14e3b7 100644 --- a/src/test/librbd/test_librbd.cc +++ b/src/test/librbd/test_librbd.cc @@ -18,6 +18,10 @@ #include "include/rbd/librbd.h" #include "include/rbd/librbd.hpp" +#include "global/global_context.h" +#include "global/global_init.h" +#include "common/ceph_argparse.h" + #include "gtest/gtest.h" #include <errno.h> @@ -428,10 +432,9 @@ TEST(LibRBD, TestCopyPP) int test_ls_snaps(rbd_image_t image, int num_expected, ...) { - rbd_snap_info_t *snaps; int num_snaps, i, j, max_size = 10; va_list ap; - snaps = (rbd_snap_info_t *) malloc(sizeof(rbd_snap_info_t *) * max_size); + rbd_snap_info_t snaps[max_size]; num_snaps = rbd_snap_list(image, snaps, &max_size); printf("num snaps is: %d\nexpected: %d\n", num_snaps, num_expected); @@ -463,7 +466,6 @@ int test_ls_snaps(rbd_image_t image, int num_expected, ...) for (i = 0; i < num_snaps; i++) { assert(snaps[i].name == NULL); } - free(snaps); return num_snaps; } @@ -1772,3 +1774,16 @@ TEST(LibRBD, DiffIterateStress) ioctx.close(); ASSERT_EQ(0, destroy_one_pool_pp(pool_name, rados)); } + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + + vector<const char*> args; + argv_to_vec(argc, (const char **)argv, args); + + global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + common_init_finish(g_ceph_context); + + return RUN_ALL_TESTS(); +} |