]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | #include "gtest/gtest.h" | |
f67539c2 | 16 | #include "include/compat.h" |
7c673cae FG |
17 | #include "include/cephfs/libcephfs.h" |
18 | ||
19 | #include <sstream> | |
20 | #include <string> | |
21 | #include <string.h> | |
22 | ||
23 | using std::string; | |
24 | ||
25 | TEST(LibCephConfig, SimpleSet) { | |
26 | struct ceph_mount_info *cmount; | |
27 | int ret = ceph_create(&cmount, NULL); | |
28 | ASSERT_EQ(ret, 0); | |
29 | ||
c07f9fc5 | 30 | ret = ceph_conf_set(cmount, "leveldb_max_open_files", "21"); |
7c673cae FG |
31 | ASSERT_EQ(ret, 0); |
32 | ||
33 | char buf[128]; | |
34 | memset(buf, 0, sizeof(buf)); | |
c07f9fc5 | 35 | ret = ceph_conf_get(cmount, "leveldb_max_open_files", buf, sizeof(buf)); |
7c673cae FG |
36 | ASSERT_EQ(ret, 0); |
37 | ASSERT_EQ(string("21"), string(buf)); | |
38 | ||
39 | ceph_shutdown(cmount); | |
40 | } | |
41 | ||
42 | TEST(LibCephConfig, ArgV) { | |
43 | struct ceph_mount_info *cmount; | |
44 | int ret = ceph_create(&cmount, NULL); | |
45 | ASSERT_EQ(ret, 0); | |
46 | ||
c07f9fc5 | 47 | const char *argv[] = { "foo", "--leveldb-max-open-files", "2", |
11fdf7f2 | 48 | "--key", "my-key", NULL }; |
7c673cae FG |
49 | size_t argc = (sizeof(argv) / sizeof(argv[0])) - 1; |
50 | ceph_conf_parse_argv(cmount, argc, argv); | |
51 | ||
52 | char buf[128]; | |
53 | memset(buf, 0, sizeof(buf)); | |
11fdf7f2 | 54 | ret = ceph_conf_get(cmount, "key", buf, sizeof(buf)); |
7c673cae | 55 | ASSERT_EQ(ret, 0); |
11fdf7f2 | 56 | ASSERT_EQ(string("my-key"), string(buf)); |
7c673cae FG |
57 | |
58 | memset(buf, 0, sizeof(buf)); | |
c07f9fc5 | 59 | ret = ceph_conf_get(cmount, "leveldb_max_open_files", buf, sizeof(buf)); |
7c673cae FG |
60 | ASSERT_EQ(ret, 0); |
61 | ASSERT_EQ(string("2"), string(buf)); | |
62 | ||
63 | ceph_shutdown(cmount); | |
64 | } |