Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / unit.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2011 New Dream Network
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #ifndef CEPH_UNIT_TEST_H
16 #define CEPH_UNIT_TEST_H
17
18 #include "include/types.h" // FIXME: ordering shouldn't be important, but right 
19                            // now, this include has to come before the others.
20
21 #include "common/ceph_argparse.h"
22 #include "common/code_environment.h"
23 #include "common/config.h"
24 #include "global/global_context.h"
25 #include "global/global_init.h"
26 #include "include/msgr.h" // for CEPH_ENTITY_TYPE_CLIENT
27 #include "gtest/gtest.h"
28
29 #include <vector>
30
31 /*
32  * You only need to include this file if you are testing Ceph internal code. If
33  * you are testing library code, the library init() interfaces will handle
34  * initialization for you.
35  */
36 int main(int argc, char **argv) {
37   std::vector<const char*> args(argv, argv + argc);
38   env_to_vec(args);
39   auto cct = global_init(NULL, args,
40                          CEPH_ENTITY_TYPE_CLIENT,
41                          CODE_ENVIRONMENT_UTILITY, 0);
42   common_init_finish(g_ceph_context);
43
44   const char* env = getenv("CEPH_LIB");
45   if (env) {
46     g_conf->set_val_or_die("erasure_code_dir", env, false);
47     g_conf->set_val_or_die("plugin_dir", env, false);
48   }
49
50   ::testing::InitGoogleTest(&argc, argv);
51   return RUN_ALL_TESTS();
52 }
53
54 #endif