From: Francis Dupont Date: Mon, 24 Sep 2018 19:18:36 +0000 (+0200) Subject: [65-libyang-option-data] Reviewed changes X-Git-Tag: 65-libyang-option-data_before_rebased X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fec3c3c2a092c82b6b466f74eb28f4ef0bbb9df;p=thirdparty%2Fkea.git [65-libyang-option-data] Reviewed changes --- diff --git a/src/lib/yang/pretests/sysrepo_setup_tests.cc b/src/lib/yang/pretests/sysrepo_setup_tests.cc index c9c64411cc..defb9d289c 100644 --- a/src/lib/yang/pretests/sysrepo_setup_tests.cc +++ b/src/lib/yang/pretests/sysrepo_setup_tests.cc @@ -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 = ""; /// @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); diff --git a/src/lib/yang/tests/translator_option_data_unittests.cc b/src/lib/yang/tests/translator_option_data_unittests.cc index a26293499a..8365f60f5d 100644 --- a/src/lib/yang/tests/translator_option_data_unittests.cc +++ b/src/lib/yang/tests/translator_option_data_unittests.cc @@ -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.