/// 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";
}
bool found_test = false;
- bool found_example = false;
bool found_ietf_types = false;
bool found_yang_types =false;
bool found_ietf = false;
}
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) {
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) {
--exit_code;
}
- if (!found_example) {
- cerr << missingModuleText(EXAMPLE_MODULE);
- --exit_code;
- }
-
if (!found_ietf_types) {
cerr << missingModuleText(IETF_TYPES);
--exit_code;
TESTS_ENVIRONMENT = \
$(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
-EXTRA_DIST = keatest-module.yang keaexample-module.yang
+EXTRA_DIST = keatest-module.yang
TESTS =
if HAVE_GTEST
+++ /dev/null
-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";
- }
- }
-}
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 {
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();
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;
// 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());
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.
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));
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.
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 },
/// @brief Set of example configurations.
const std::vector<std::pair<std::string, YRTree> > test_configs =
{
- { exampleModel, exampleTree },
{ testModel, testTree },
{ subnetTwoPoolsModelIetf6, subnetTwoPoolsTreeIetf6 },
{ subnetTimersModel, subnetTimersIetf6 },