Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / erasure-code / TestErasureCodePluginIsa.cc
1 /*
2  * Ceph - scalable distributed file system
3  *
4  * Copyright (C) 2014 CERN (Switzerland)
5  *
6  * Author: Andreas-Joachim Peters <Andreas.Joachim.Peters@cern.ch>
7  *
8  *  This library is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU Lesser General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2.1 of the License, or (at your option) any later version.
12  *
13  */
14
15 #include <errno.h>
16 #include <stdlib.h>
17 #include "arch/probe.h"
18 #include "arch/intel.h"
19 #include "erasure-code/ErasureCodePlugin.h"
20 #include "global/global_context.h"
21 #include "common/config.h"
22 #include "gtest/gtest.h"
23
24 TEST(ErasureCodePlugin, factory)
25 {
26   ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
27   ErasureCodeProfile profile;
28   {
29     ErasureCodeInterfaceRef erasure_code;
30     EXPECT_FALSE(erasure_code);
31     EXPECT_EQ(-EIO, instance.factory("no-isa",
32                                      g_conf->get_val<std::string>("erasure_code_dir"),
33                                      profile,
34                                      &erasure_code, &cerr));
35     EXPECT_FALSE(erasure_code);
36   }
37   const char *techniques[] = {
38     "reed_sol_van",
39     0
40   };
41   for(const char **technique = techniques; *technique; technique++) {
42     ErasureCodeInterfaceRef erasure_code;
43     profile["technique"] = *technique;
44     EXPECT_FALSE(erasure_code);
45     EXPECT_EQ(0, instance.factory("isa",
46                                   g_conf->get_val<std::string>("erasure_code_dir"),
47                                   profile,
48                                   &erasure_code, &cerr));
49     EXPECT_TRUE(erasure_code.get());
50   }
51 }
52
53 /*
54  * Local Variables:
55  * compile-command: "cd ../.. ; make -j4 &&
56  *   make unittest_erasure_code_plugin_isa &&
57  *   valgrind --tool=memcheck ./unittest_erasure_code_plugin_isa \
58  *      --gtest_filter=*.* --log-to-stderr=true --debug-osd=20"
59  * End:
60  */