Commit 93bf94ed authored by Francis Dupont's avatar Francis Dupont

[65-libyang-testutils_rebased] Updated

parent 1b7963c1
......@@ -14,6 +14,7 @@ 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";
......@@ -74,6 +75,7 @@ int main() {
}
bool found_test = false;
bool found_example = false;
bool found_ietf_types = false;
bool found_yang_types =false;
bool found_ietf = false;
......@@ -89,6 +91,8 @@ 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) {
......@@ -108,7 +112,8 @@ int main() {
int exit_code = 0;
if (!found_test || !found_ietf_types || !found_yang_types ||
if (!found_test || !found_example ||
!found_ietf_types || !found_yang_types ||
!found_ietf || !found_kea4 || !found_kea6 || !found_keaca ||
!found_kea2) {
exit_code = -4;
......@@ -119,6 +124,11 @@ int main() {
--exit_code;
}
if (!found_example) {
cerr << missingModuleText(EXAMPLE_MODULE);
--exit_code;
}
if (!found_ietf_types) {
cerr << missingModuleText(IETF_TYPES);
--exit_code;
......
......@@ -12,7 +12,7 @@ CLEANFILES = *.gcno *.gcda
TESTS_ENVIRONMENT = \
$(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
EXTRA_DIST = keatest-module.yang
EXTRA_DIST = keatest-module.yang keaexample-module.yang
TESTS =
if HAVE_GTEST
......
......@@ -9,27 +9,11 @@ module keatest-module {
organization "Sysrepo and ISC";
description
"ISC imported an example module from Sysrepo tests and adapted it
"ISC imported a test 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";
}
}
typedef threshold-power-dBm {
type union {
type decimal64 {
......
......@@ -150,11 +150,11 @@ TEST(TranslatorBasicTest, getItem) {
ASSERT_NO_THROW(t_obj.reset(new TranslatorBasic(sess)));
// Container.
string xpath = "/keatest-module:container/list";
string xpath = "/keaexample-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("/keatest-module:container"));
EXPECT_NO_THROW(elem = t_obj->getItem("/keaexample-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 = "/keatest-module:container";
string xpath = "/keaexample-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 = "/keatest-module:container/list";
xpath = "/keaexample-module:container/list";
elem = Element::createList();
EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_LIST_T));
S_Val s_val;
......@@ -657,20 +657,21 @@ TEST(TranslatorBasicTest, list) {
// Empty list.
S_Iter_Value iter;
EXPECT_NO_THROW(iter = t_obj->getIter("/keatest-module:container/list"));
EXPECT_NO_THROW(iter = t_obj->getIter("/keaexample-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 = "/keatest-module:container/list[key1='key1'][key2='key2']/leaf";
xpath = "/keaexample-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("/keatest-module:container/list"));
EXPECT_NO_THROW(iter = t_obj->getIter("/keaexample-module:container/list"));
ASSERT_TRUE(iter);
EXPECT_NO_THROW(xpath = t_obj->getNext(iter));
EXPECT_EQ("/keatest-module:container/list[key1='key1'][key2='key2']", xpath);
EXPECT_EQ("/keaexample-module:container/list[key1='key1'][key2='key2']",
xpath);
EXPECT_NO_THROW(xpath = t_obj->getNext(iter));
EXPECT_TRUE(xpath.empty());
......
......@@ -8,7 +8,6 @@
#include <yang/tests/yang_configs.h>
#include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h>
#include <sstream>
......@@ -64,7 +63,7 @@ TEST(YangReprTest, getExample) {
S_Session sess(new Session(conn, SR_DS_CANDIDATE));
// Create a list.
string xpath = "/example-module:container/list";
string xpath = "/keaexample-module:container/list";
S_Val s_val;
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
......@@ -87,54 +86,54 @@ TEST(YangReprTest, getTest) {
string xpath;
S_Val s_val;
xpath = "/test-module:main/string";
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));
xpath = "/test-module:main/boolean";
xpath = "/keatest-module:main/boolean";
s_val.reset(new Val(true, SR_BOOL_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/ui8";
xpath = "/keatest-module:main/ui8";
uint8_t u8(8);
s_val.reset(new Val(u8, SR_UINT8_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/ui16";
xpath = "/keatest-module:main/ui16";
uint16_t u16(16);
s_val.reset(new Val(u16, SR_UINT16_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/ui32";
xpath = "/keatest-module:main/ui32";
uint32_t u32(32);
s_val.reset(new Val(u32, SR_UINT32_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/i8";
xpath = "/keatest-module:main/i8";
int8_t s8(8);
s_val.reset(new Val(s8, SR_INT8_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/i16";
xpath = "/keatest-module:main/i16";
int16_t s16(16);
s_val.reset(new Val(s16, SR_INT16_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/i32";
xpath = "/keatest-module:main/i32";
int32_t s32(32);
s_val.reset(new Val(s32, SR_INT32_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/id_ref";
s_val.reset(new Val("test-module:id_1", SR_IDENTITYREF_T));
xpath = "/keatest-module:main/id_ref";
s_val.reset(new Val("keatest-module:id_1", SR_IDENTITYREF_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
xpath = "/test-module:main/enum";
xpath = "/keatest-module:main/enum";
s_val.reset(new Val("maybe", SR_ENUM_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
// Binary.
xpath = "/test-module:main/raw";
xpath = "/keatest-module:main/raw";
s_val.reset(new Val("Zm9vYmFy", SR_BINARY_T));
EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val));
......@@ -150,7 +149,7 @@ TEST(YangReprTest, getTest) {
// Change a path.
YRTree badpath = testTree;
badpath[20].xpath_ = "/test-module:kernel-module"; // removed final 's'
badpath[20].xpath_ = "/keatest-module:kernel-module"; // removed final 's'
EXPECT_FALSE(repr.verify(badpath, sess, cerr));
// Change a value.
......@@ -165,7 +164,7 @@ TEST(YangReprTest, getTest) {
// Add a record at the end.
YRTree badmissing = testTree;
const string& xpathpc = "/test-module:presence-container";
const string& xpathpc = "/keatest-module:presence-container";
badmissing.push_back(YRItem(xpathpc, "", SR_CONTAINER_PRESENCE_T, false));
EXPECT_FALSE(repr.verify(badmissing, sess, cerr));
......
This diff is collapsed.
......@@ -114,8 +114,9 @@ For details, see Section 20 "YANG/NETCONF support" in the Kea User's Guide.
You also need to install YANG schemas, so the unit-tests are able to
retrieve, add, update and generally interact with the sysrepo information.
There are several production Kea models (src/lib/yang/models) and one test
specific model (src/lib/yang/tests/keatest-module.yang).
There are several production Kea models (src/lib/yang/models) and two test
specific models (src/lib/yang/tests/keatest-module.yang and
src/lib/yang/tests/keaexample-module.yang).
To install the test module, issue the following command:
......@@ -123,11 +124,18 @@ To install the test module, issue the following command:
sudo sysrepoctl --install --yang=src/lib/yang/tests/keatest-module.yang
@endverbatim
To install the example module, issue the following command:
@verbatim
sudo sysrepoctl --install --yang=src/lib/yang/tests/keaexample-module.yang
@endverbatim
To verify that you have the schemas installed, do this:
@verbatim
sysrepoctl -l
@endverbatim
Make sure that keatest-module and other necessary modules are on the list.
Make sure that keatest-module, keaexample-module and other necessary
modules are on the list.
Note as DHCP modules are still being developed it can be useful to
deinstall them before reinstalling a more recent version:
......@@ -136,7 +144,7 @@ sudo sysrepoctl --uninstall --module=<module-name>
@endverbatim
Tests use these modules you can find in src/lib/yang/models in addition
of keatest-module:
of keatest-module and keaexample-module:
- ietf-dhcpv6-server
- kea-ctrl-agent
- kea-dhcp-ddns
......
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