Closed ygorelik closed 3 years ago
Initialize root schema by creating connection to the device, then use XmlSubtreeCodec to get the XML subtree:
TEST_CASE("xml_codec_augment_subtree")
{
ydk::path::Repository repo{TEST_HOME};
ydk::path::NetconfSession session{repo, "127.0.0.1", "admin", "admin", 12022};
XmlSubtreeCodec xml_codec{};
auto passive = make_unique<ydktest_sanity::Runner::Passive>();
passive->name = "xyz";
auto ifc = make_shared<ydktest_sanity::Runner::Passive::Interfac>();
ifc->test = "abc";
passive->interfac.append(ifc);
passive->testc->xyz = make_shared<ydktest_sanity::Runner::Passive::Testc::Xyz>();
passive->testc->xyz->parent = passive.get();
passive->testc->xyz->xyz = 25;
auto xml = xml_codec.encode(*passive, session.get_root_schema());
cout << xml << endl;
}
Run the test and observe correct results:
ygorelik@bionic:~/ydk-gen/sdk/cpp/tests/build$ ./ydk_bundle_test xml_codec_augment_subtree
<passive xmlns="http://cisco.com/ns/yang/ydktest-sanity">
<name>xyz</name>
<interfac>
<test>abc</test>
</interfac>
<testc xmlns="http://cisco.com/ns/yang/ydktest-sanity-augm">
<xyz>
<xyz>25</xyz>
</xyz>
</testc>
</passive>
===============================================================================
test cases: 1 | 1 passed
assertions: - none -
Resolved the issue in my fork. It will be included to the next patch release - 0.8.5.3.
Current Behavior
When tried to get XML subtree from non-top level entity the CodecService fails with segmentation violation.
Steps to Reproduce
Add the following unit test to the suite of bundle tests:
Run the unit test and observe the issue:
System Information
YDK-0.8.5