&& cd cxxopts && mkdir build && cd build && cmake .. && make install && ldconfig \
&& cd /opt/e2/RIC-E2-TERMINATION/3rdparty \
&& git clone https://github.com/Tencent/rapidjson.git && cd rapidjson \
- && cd build && cmake .. && make install && ldconfig \
+ && mkdir build && cd build && cmake .. && make install && ldconfig \
&& cd /opt/e2/RIC-E2-TERMINATION/3rdparty \
&& wget --content-disposition https://github.com/cgreen-devs/cgreen/releases/download/1.2.0/cgreen_1.2.0_amd64.deb \
&& dpkg -i cgreen_1.2.0_amd64.deb \
#include <cstdlib>
#include <boost/algorithm/string.hpp>
+#include <mdclog/mdclog.h>
using namespace std;
int openConfigFile(std::string const& configFile) {
std::ifstream file(configFile.c_str());
if (!file) { // file not found
- //perror(configFile.c_str());
- //mdclog_write(MDCLOG_ERR, "File: %s, failed to open", configFile.c_str());
+ mdclog_write(MDCLOG_ERR, "File: %s, failed to open", configFile.c_str());
return -1;
}
std::string line;
}
auto leftHand = line.find('=');
+ if (leftHand == std::string::npos) {
+ mdclog_write(MDCLOG_ERR, "problematic entry: %s ", line.c_str());
+ continue;
+ }
auto name = line.substr(0,leftHand);
trim(name);
auto value = line.substr(leftHand+1);
+ if (value.length() == 0) {
+ mdclog_write(MDCLOG_ERR, "problematic entry: %s no value ", line.c_str());
+ continue;
+
+ }
trim(value);
//cout << "entry = " << name << " value = " << value << endl;
entries[name] = value;
Ensure(Cgreen, fileExists) {
ReadConfigFile conf {};
- assert_that(conf.openConfigFile("config") == 0);
+ assert_that(conf.openConfigFile("config/config.conf") == 0);
}
Ensure(Cgreen, goodparams) {
ReadConfigFile conf {};
- assert_that(conf.openConfigFile("config") == 0);
+ assert_that(conf.openConfigFile("config/config.conf") == 0);
assert_that(conf.getIntValue("nano") == 38000);
assert_that(conf.getStringValue("loglevel") == "info");
- assert_that(conf.getStringValue("volume") == ".");
+ assert_that(conf.getStringValue("volume") == "log");
}
Ensure(Cgreen, badParams) {
ReadConfigFile conf {};
- assert_that(conf.openConfigFile("config") == 0);
+ assert_that(conf.openConfigFile("config/config.conf") == 0);
assert_that(conf.getIntValue("nano") != 38002);
assert_that(conf.getStringValue("loglevel") != "");
assert_that(conf.getStringValue("volume") != "bob");
Ensure(Cgreen, wrongType) {
ReadConfigFile conf {};
- assert_that(conf.openConfigFile("config") == 0);
+ assert_that(conf.openConfigFile("config/config.conf") == 0);
assert_that(conf.getStringValue("nano") != "debug");
assert_that(conf.getIntValue("loglevel") != 3);
assert_that(conf.getDoubleValue("loglevel") != 3.0);
}
+Ensure(Cgreen, badValues) {
+ ReadConfigFile conf {};
+ assert_that(conf.openConfigFile("config/config.bad") == 0);
+}
+
int main(const int argc, char **argv) {
mdclog_severity_t loglevel = MDCLOG_INFO;
add_test_with_context(suite, Cgreen, goodparams);
add_test_with_context(suite, Cgreen, badParams);
add_test_with_context(suite, Cgreen, wrongType);
+ add_test_with_context(suite, Cgreen, badValues);
return cgreen::run_test_suite(suite, create_text_reporter());