From: Tomek Mrugalski Date: Wed, 24 Oct 2018 10:03:50 +0000 (+0200) Subject: [#65,!30] Unnecessary keaexample model removed. X-Git-Tag: 65-libyang-clean-keatext_base~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=570ec4387819d2c00707456673a4d328eb30c080;p=thirdparty%2Fkea.git [#65,!30] Unnecessary keaexample model removed. --- diff --git a/src/lib/yang/pretests/sysrepo_setup_tests.cc b/src/lib/yang/pretests/sysrepo_setup_tests.cc index 5a51bfe0ad..4a97127a78 100644 --- a/src/lib/yang/pretests/sysrepo_setup_tests.cc +++ b/src/lib/yang/pretests/sysrepo_setup_tests.cc @@ -14,7 +14,6 @@ using namespace std; /// Not using libyang headers, e.g. yang_models.h. const string TEST_MODULE = "keatest-module"; -const string EXAMPLE_MODULE = "keaexample-module"; const string IETF_TYPES = "ietf-inet-types"; const string YANG_TYPES = "ietf-yang-types"; const string IETF_MODULE = "ietf-dhcpv6-server"; @@ -75,7 +74,6 @@ int main() { } bool found_test = false; - bool found_example = false; bool found_ietf_types = false; bool found_yang_types =false; bool found_ietf = false; @@ -91,8 +89,6 @@ int main() { } if (module == TEST_MODULE) { found_test = true; - } else if (module == EXAMPLE_MODULE) { - found_example = true; } else if (module == IETF_TYPES) { found_ietf_types = true; } else if (module == YANG_TYPES) { @@ -112,7 +108,7 @@ int main() { int exit_code = 0; - if (!found_test || !found_example || + if (!found_test || !found_ietf_types || !found_yang_types || !found_ietf || !found_kea4 || !found_kea6 || !found_keaca || !found_kea2) { @@ -124,11 +120,6 @@ int main() { --exit_code; } - if (!found_example) { - cerr << missingModuleText(EXAMPLE_MODULE); - --exit_code; - } - if (!found_ietf_types) { cerr << missingModuleText(IETF_TYPES); --exit_code; diff --git a/src/lib/yang/tests/Makefile.am b/src/lib/yang/tests/Makefile.am index e76a8b9a8d..4a8f091ece 100644 --- a/src/lib/yang/tests/Makefile.am +++ b/src/lib/yang/tests/Makefile.am @@ -12,7 +12,7 @@ CLEANFILES = *.gcno *.gcda TESTS_ENVIRONMENT = \ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) -EXTRA_DIST = keatest-module.yang keaexample-module.yang +EXTRA_DIST = keatest-module.yang TESTS = if HAVE_GTEST diff --git a/src/lib/yang/tests/keaexample-module.yang b/src/lib/yang/tests/keaexample-module.yang deleted file mode 100644 index 6e0eb84f32..0000000000 --- a/src/lib/yang/tests/keaexample-module.yang +++ /dev/null @@ -1,32 +0,0 @@ -module keaexample-module { - yang-version 1.1; - namespace "urn:ietf:params:xml:ns:yang:keaexample-module"; - prefix tm; - - import ietf-inet-types { - prefix inet; - } - - organization "Sysrepo and ISC"; - description - "ISC imported an example module from Sysrepo tests and adapted it - to kea testing regime."; - contact - "kea-dev@lists.isc.org"; - - container container { - config true; - list list { - leaf leaf { - type string; - } - leaf key1 { - type string; - } - leaf key2 { - type string; - } - key "key1 key2"; - } - } -} diff --git a/src/lib/yang/tests/keatest-module.yang b/src/lib/yang/tests/keatest-module.yang index 4a0bb74938..0d09a667ef 100644 --- a/src/lib/yang/tests/keatest-module.yang +++ b/src/lib/yang/tests/keatest-module.yang @@ -28,6 +28,22 @@ module keatest-module { description "Power in dBm"; } + container container { + config true; + list list { + leaf leaf { + type string; + } + leaf key1 { + type string; + } + leaf key2 { + type string; + } + key "key1 key2"; + } + } + container main { leaf enum { type enumeration { diff --git a/src/lib/yang/tests/translator_unittests.cc b/src/lib/yang/tests/translator_unittests.cc index 08ed2666f7..7639b129db 100644 --- a/src/lib/yang/tests/translator_unittests.cc +++ b/src/lib/yang/tests/translator_unittests.cc @@ -150,11 +150,11 @@ TEST(TranslatorBasicTest, getItem) { ASSERT_NO_THROW(t_obj.reset(new TranslatorBasic(sess))); // Container. - string xpath = "/keaexample-module:container/list"; + string xpath = "/keatest-module:container/list"; S_Val s_val; EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); ConstElementPtr elem; - EXPECT_NO_THROW(elem = t_obj->getItem("/keaexample-module:containe")); + EXPECT_NO_THROW(elem = t_obj->getItem("/keatest-module:containe")); EXPECT_FALSE(elem); elem.reset(); @@ -452,14 +452,14 @@ TEST(TranslatorBasicTest, setItem) { ASSERT_NO_THROW(t_obj.reset(new TranslatorBasic(sess))); // Container. - string xpath = "/keaexample-module:containe"; + string xpath = "/keatest-module:containe"; ConstElementPtr elem = Element::createMap(); EXPECT_THROW(t_obj->setItem(xpath, elem, SR_CONTAINER_T), NotImplemented); EXPECT_THROW(t_obj->setItem(xpath, elem, SR_CONTAINER_PRESENCE_T), NotImplemented); // List. - xpath = "/keaexample-module:container/list"; + xpath = "/keatest-module:container/list"; elem = Element::createList(); EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_LIST_T)); S_Val s_val; @@ -657,20 +657,20 @@ TEST(TranslatorBasicTest, list) { // Empty list. S_Iter_Value iter; - EXPECT_NO_THROW(iter = t_obj->getIter("/keaexample-module:container/list")); + EXPECT_NO_THROW(iter = t_obj->getIter("/keatest-module:container/list")); ASSERT_TRUE(iter); string xpath; EXPECT_NO_THROW(xpath = t_obj->getNext(iter)); EXPECT_TRUE(xpath.empty()); // Retried with a filled list. - xpath = "/keaexample-module:container/list[key1='key1'][key2='key2']/leaf"; + xpath = "/keatest-module:container/list[key1='key1'][key2='key2']/leaf"; S_Val s_val(new Val("Leaf value")); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - EXPECT_NO_THROW(iter = t_obj->getIter("/keaexample-module:container/list")); + EXPECT_NO_THROW(iter = t_obj->getIter("/keatest-module:container/list")); ASSERT_TRUE(iter); EXPECT_NO_THROW(xpath = t_obj->getNext(iter)); - EXPECT_EQ("/keaexample-module:container/list[key1='key1'][key2='key2']", + EXPECT_EQ("/keatest-module:container/list[key1='key1'][key2='key2']", xpath); EXPECT_NO_THROW(xpath = t_obj->getNext(iter)); EXPECT_TRUE(xpath.empty()); diff --git a/src/lib/yang/tests/translator_utils_unittests.cc b/src/lib/yang/tests/translator_utils_unittests.cc index cea5081d12..bf5d4525b4 100644 --- a/src/lib/yang/tests/translator_utils_unittests.cc +++ b/src/lib/yang/tests/translator_utils_unittests.cc @@ -56,26 +56,6 @@ TEST(YangReprTest, item) { EXPECT_EQ(item2, item1); } -// Test get with example module. -TEST(YangReprTest, getExample) { - // Get a translator object to play with. - S_Connection conn(new Connection("utils unittests")); - S_Session sess(new Session(conn, SR_DS_CANDIDATE)); - - // Create a list. - string xpath = "/keaexample-module:container/list"; - S_Val s_val; - EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); - - // Get it. - YangRepr repr(exampleModel); - YRTree tree; - EXPECT_NO_THROW(tree = repr.get(sess)); - - // Verify. - EXPECT_TRUE(repr.verify(exampleTree, sess, cerr)); -} - // Test get with test module. TEST(YangReprTest, getTest) { // Get a translator object to play with. @@ -86,6 +66,10 @@ TEST(YangReprTest, getTest) { string xpath; S_Val s_val; + // Create a list. + xpath = "/keatest-module:container/list"; + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + xpath = "/keatest-module:main/string"; s_val.reset(new Val("str", SR_STRING_T)); EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); @@ -174,20 +158,6 @@ TEST(YangReprTest, getTest) { EXPECT_FALSE(repr.verify(badextra, sess, cerr)); } -// Test set with example module. -TEST(YangReprTest, setExample) { - // Get a translator object to play with. - S_Connection conn(new Connection("utils unittests")); - S_Session sess(new Session(conn, SR_DS_CANDIDATE)); - - // Set the module content. - YangRepr repr(exampleModel); - EXPECT_NO_THROW(repr.set(exampleTree, sess)); - - // Verify it. - EXPECT_TRUE(repr.verify(exampleTree, sess, cerr)); -} - // Test set with test module. TEST(YangReprTest, setTest) { // Get a translator object to play with. diff --git a/src/lib/yang/tests/yang_configs.h b/src/lib/yang/tests/yang_configs.h index 0720077b8b..afdd98a815 100644 --- a/src/lib/yang/tests/yang_configs.h +++ b/src/lib/yang/tests/yang_configs.h @@ -14,16 +14,11 @@ namespace isc { namespace yang { namespace test { -/// @brief The example module from sysrepo tests. -const std::string exampleModel = "keaexample-module"; -const YRTree exampleTree = { - { "/keaexample-module:container", "", SR_CONTAINER_T, false }, - { "/keaexample-module:container/list", "", SR_LIST_T, true } -}; - /// @brief The test module from sysrepo tests. const std::string testModel = "keatest-module"; const YRTree testTree = { + { "/keatest-module:container", "", SR_CONTAINER_T, false }, + { "/keatest-module:container/list", "", SR_LIST_T, true }, { "/keatest-module:main", "", SR_CONTAINER_T, false }, { "/keatest-module:main/string", "str", SR_STRING_T, true }, { "/keatest-module:main/boolean", "true", SR_BOOL_T, true }, @@ -445,7 +440,6 @@ const YRTree designExampleTree = { /// @brief Set of example configurations. const std::vector > test_configs = { - { exampleModel, exampleTree }, { testModel, testTree }, { subnetTwoPoolsModelIetf6, subnetTwoPoolsTreeIetf6 }, { subnetTimersModel, subnetTimersIetf6 },