Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / erasure-code / TestErasureCodePluginJerasure.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 distributed storage system
5  *
6  * Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
7  * Copyright (C) 2014 Red Hat <contact@redhat.com>
8  *
9  * Author: Loic Dachary <loic@dachary.org>
10  *
11  *  This library is free software; you can redistribute it and/or
12  *  modify it under the terms of the GNU Lesser General Public
13  *  License as published by the Free Software Foundation; either
14  *  version 2.1 of the License, or (at your option) any later version.
15  *
16  */
17
18 #include <errno.h>
19 #include <stdlib.h>
20 #include "erasure-code/ErasureCodePlugin.h"
21 #include "log/Log.h"
22 #include "global/global_context.h"
23 #include "common/config.h"
24 #include "gtest/gtest.h"
25
26 TEST(ErasureCodePlugin, factory)
27 {
28   ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
29   ErasureCodeProfile profile;
30   {
31     ErasureCodeInterfaceRef erasure_code;
32     EXPECT_FALSE(erasure_code);
33     EXPECT_EQ(-ENOENT, instance.factory("jerasure",
34                                         g_conf->get_val<std::string>("erasure_code_dir"),
35                                         profile,
36                                         &erasure_code, &cerr));
37     EXPECT_FALSE(erasure_code);
38   }
39   const char *techniques[] = {
40     "reed_sol_van",
41     "reed_sol_r6_op",
42     "cauchy_orig",
43     "cauchy_good",
44     "liberation",
45     "blaum_roth",
46     "liber8tion",
47     0
48   };
49   for(const char **technique = techniques; *technique; technique++) {
50     ErasureCodeInterfaceRef erasure_code;
51     ErasureCodeProfile profile;
52     profile["technique"] = *technique;
53     EXPECT_FALSE(erasure_code);
54     EXPECT_EQ(0, instance.factory("jerasure",
55                                   g_conf->get_val<std::string>("erasure_code_dir"),
56                                   profile,
57                                   &erasure_code, &cerr));
58     EXPECT_TRUE(erasure_code.get());
59   }
60 }
61
62 /*
63  * Local Variables:
64  * compile-command: "cd ../.. ; make -j4 &&
65  *   make unittest_erasure_code_plugin_jerasure &&
66  *   valgrind --tool=memcheck ./unittest_erasure_code_plugin_jerasure \
67  *      --gtest_filter=*.* --log-to-stderr=true --debug-osd=20"
68  * End:
69  */