Commit 2fec3c3c authored by Francis Dupont's avatar Francis Dupont

[65-libyang-option-data] Reviewed changes

parent 717c9a27
......@@ -12,11 +12,15 @@
using namespace std;
const string TEST_MODULE = "keatest-module";
const string IETF_TYPES = "ietf-inet-types";
const string YANG_TYPES = "ietf-yang-types";
const string IETF_MODULE = "ietf-dhcpv6-server";
const string KEA_DHCP4_MODULE = "kea-dhcp4-server";
const string KEA_DHCP6_MODULE = "kea-dhcp6-server";
const string KEA_CTRL_AGENT_MODULE = "kea-ctrl-agent";
const string KEA_D2_MODULE = "kea-dhcp-ddns";
// const string REPOSITORY = SYSREPO_REPO;
const string REPOSITORY = "<sysrepo repository>";
/// @brief Returns nicely formed error message if module is missing
///
......@@ -26,15 +30,11 @@ string missingModuleText(const string& name) {
stringstream tmp;
tmp << "ERROR: YANG model " << name << " is not installed." << endl
<< "The environment is not suitable for running unit-tests." << endl
<< "Please locate " << name << ".yang and issue the following command:" << endl
<< endl
<< "# sysrepoctl -i -g " << name << ".yang" << endl
<< endl
<< "If sysrepoctl complains about missing data model, you may need to specify " << endl
<< "the default Sysrepo schema directory with -s PATH. You can check it with:" << endl
<< endl
<< "$ sysrepoctl -l" << endl
<< endl;
<< "Please locate " << name << ".yang, change to its directory and "
<< "issue the following command:" << endl << endl
<< "# sysrepoctl -i -s " << REPOSITORY << "/yang "
<< "-s . -g " << name << ".yang" << endl
<< endl << endl;
return (tmp.str());
}
......@@ -43,6 +43,7 @@ string missingModuleText(const string& name) {
/// - daemon required
/// - session establishment
/// - test module
/// - type modules
/// - IETF module
/// - Kea modules.
int main() {
......@@ -67,7 +68,8 @@ int main() {
try {
sess.reset(new Session(conn, SR_DS_CANDIDATE));
} catch (const sysrepo_exception& ex) {
cerr << "ERROR: Can't establish a sysrepo session: " << ex.what() << endl;
cerr << "ERROR: Can't establish a sysrepo session: "
<< ex.what() << endl;
exit(-3);
}
S_Yang_Schemas schemas;
......@@ -78,6 +80,8 @@ int main() {
exit(-4);
}
bool found_test = false;
bool found_ietf_types = false;
bool found_yang_types =false;
bool found_ietf = false;
bool found_kea4 = false;
bool found_kea6 = false;
......@@ -91,6 +95,10 @@ int main() {
}
if (module == TEST_MODULE) {
found_test = true;
} else if (module == IETF_TYPES) {
found_ietf_types = true;
} else if (module == YANG_TYPES) {
found_yang_types = true;
} else if (module == IETF_MODULE) {
found_ietf = true;
} else if (module == KEA_DHCP4_MODULE) {
......@@ -107,34 +115,50 @@ int main() {
int exit_code = 0;
if (!found_test || !found_ietf_types || !found_yang_types ||
!found_ietf || !found_kea4 || !found_kea6 || !found_keaca ||
!found_kea2) {
exit_code = 4;
}
if (!found_test) {
cerr << missingModuleText(TEST_MODULE);
exit_code = -5;
--exit_code;
}
if (!found_ietf_types) {
cerr << missingModuleText(IETF_TYPES);
--exit_code;
}
if (!found_yang_types) {
cerr << missingModuleText(YANG_TYPES);
--exit_code;
}
if (!found_ietf) {
cerr << missingModuleText(IETF_MODULE);
exit_code = -6;
--exit_code;
}
if (!found_kea4) {
cerr << missingModuleText(KEA_DHCP4_MODULE);
exit_code = -7;
--exit_code;
}
if (!found_kea6) {
cerr << missingModuleText(KEA_DHCP6_MODULE);
exit_code = -8;
--exit_code;
}
if (!found_keaca) {
cerr << missingModuleText(KEA_CTRL_AGENT_MODULE);
exit_code = -9;
--exit_code;
}
if (!found_kea2) {
cerr << missingModuleText(KEA_D2_MODULE);
exit_code = -10;
--exit_code;
}
exit(exit_code);
......
......@@ -70,8 +70,13 @@ TEST_F(TranslatorOptionDataListTest, get) {
ConstElementPtr option;
EXPECT_NO_THROW(option = t_obj_->getOptionData(xoption));
ASSERT_TRUE(option);
EXPECT_EQ("{ \"always-send\": false, \"code\": 100, \"csv-format\": false, "
"\"data\": \"12121212\", \"space\": \"dns\" }",
EXPECT_EQ("{"
" \"always-send\": false,"
" \"code\": 100,"
" \"csv-format\": false,"
" \"data\": \"12121212\","
" \"space\": \"dns\""
" }",
option->str());
// Get the option data list.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment