mirror of
https://github.com/ceph/ceph
synced 2025-01-03 17:42:36 +00:00
common/config: fix get_val for booleans
md_config_t::get_val should return true/false for booleans, not 0/1. This is for consistency with the setter. Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
This commit is contained in:
parent
9c498e0f1e
commit
3432729397
@ -862,8 +862,10 @@ get_val(const char *key, char **buf, int len) const
|
||||
case OPT_DOUBLE:
|
||||
oss << *(double*)opt->conf_ptr(this);
|
||||
break;
|
||||
case OPT_BOOL:
|
||||
oss << *(bool*)opt->conf_ptr(this);
|
||||
case OPT_BOOL: {
|
||||
bool b = *(bool*)opt->conf_ptr(this);
|
||||
oss << (b ? "true" : "false");
|
||||
}
|
||||
break;
|
||||
case OPT_U32:
|
||||
oss << *(uint32_t*)opt->conf_ptr(this);
|
||||
|
@ -131,6 +131,38 @@ TEST(DaemonConfig, InjectArgsReject) {
|
||||
ASSERT_EQ(string(buf), string(buf2));
|
||||
}
|
||||
|
||||
TEST(DaemonConfig, InjectArgsBooleans) {
|
||||
int ret;
|
||||
char buf[128];
|
||||
char *tmp = buf;
|
||||
char buf2[128];
|
||||
char *tmp2 = buf2;
|
||||
|
||||
// Change log_to_syslog
|
||||
std::ostringstream chat;
|
||||
std::string injection("--log_to_syslog --debug 28");
|
||||
ret = g_ceph_context->_conf->injectargs(injection, &chat);
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
||||
// log_to_syslog should be set...
|
||||
memset(buf, 0, sizeof(buf));
|
||||
ret = g_ceph_context->_conf->get_val("log_to_syslog", &tmp, sizeof(buf));
|
||||
ASSERT_EQ(ret, 0);
|
||||
ASSERT_EQ(string("true"), string(buf));
|
||||
|
||||
// Turn off log_to_syslog
|
||||
std::ostringstream chat2;
|
||||
injection = "--log_to_syslog=false --debug 28";
|
||||
ret = g_ceph_context->_conf->injectargs(injection, &chat2);
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
||||
// log_to_syslog should be cleared...
|
||||
memset(buf, 0, sizeof(buf));
|
||||
ret = g_ceph_context->_conf->get_val("log_to_syslog", &tmp, sizeof(buf));
|
||||
ASSERT_EQ(ret, 0);
|
||||
ASSERT_EQ(string("false"), string(buf));
|
||||
}
|
||||
|
||||
TEST(DaemonConfig, InjectArgsLogfile) {
|
||||
int ret;
|
||||
std::ostringstream chat;
|
||||
|
Loading…
Reference in New Issue
Block a user