From: aa7133@att.com Date: Sun, 1 Dec 2019 16:21:20 +0000 (+0200) Subject: version 3.0.3 fix Docker file error and add logging to config file and updated testing X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=79e21d3a86f8f86c8c041652e623f394358f4191;p=ric-plt%2Fe2.git version 3.0.3 fix Docker file error and add logging to config file and updated testing Change-Id: Ic7b01c12a56cbbced19e386ef19460512d6dfa13 Signed-off-by: aa7133@att.com --- diff --git a/RIC-E2-TERMINATION/Dockerfile b/RIC-E2-TERMINATION/Dockerfile index 6b65c7c..ad9eb3c 100644 --- a/RIC-E2-TERMINATION/Dockerfile +++ b/RIC-E2-TERMINATION/Dockerfile @@ -41,7 +41,7 @@ RUN apt-get install -y autoconf gawk libtool automake pkg-config autoconf-archiv && 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 \ diff --git a/RIC-E2-TERMINATION/ReadConfigFile.h b/RIC-E2-TERMINATION/ReadConfigFile.h index 941be6e..3f45e8c 100644 --- a/RIC-E2-TERMINATION/ReadConfigFile.h +++ b/RIC-E2-TERMINATION/ReadConfigFile.h @@ -30,6 +30,7 @@ #include #include +#include using namespace std; @@ -41,8 +42,7 @@ public: 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; @@ -57,9 +57,18 @@ public: } 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; diff --git a/RIC-E2-TERMINATION/TEST/ConfigurationFileTest/testConfigFile.cpp b/RIC-E2-TERMINATION/TEST/ConfigurationFileTest/testConfigFile.cpp index dc211d5..296cc94 100644 --- a/RIC-E2-TERMINATION/TEST/ConfigurationFileTest/testConfigFile.cpp +++ b/RIC-E2-TERMINATION/TEST/ConfigurationFileTest/testConfigFile.cpp @@ -44,21 +44,21 @@ Ensure(Cgreen, fileNotExist) { 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"); @@ -67,12 +67,17 @@ Ensure(Cgreen, badParams) { 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; @@ -87,6 +92,7 @@ int main(const int argc, char **argv) { 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());