/** * @file test_lyb.c * @author Michal Vasko * @brief Cmocka tests for LYB binary data format. * * Copyright (c) 2020 CESNET, z.s.p.o. * * This source code is licensed under BSD 3-Clause License (the "License"). * You may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://opensource.org/licenses/BSD-3-Clause */ #define _UTEST_MAIN_ #include "utests.h" #include "hash_table.h" #include "libyang.h" #define CHECK_PARSE_LYD(INPUT, OUT_NODE) \ CHECK_PARSE_LYD_PARAM(INPUT, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, LY_SUCCESS, OUT_NODE) #define CHECK_LYD_STRING(MODEL, TEXT) \ CHECK_LYD_STRING_PARAM(MODEL, TEXT, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK) static void check_print_parse(void **state, const char *data_xml) { struct lyd_node *tree_1; struct lyd_node *tree_2; char *lyb_out; CHECK_PARSE_LYD(data_xml, tree_1); assert_int_equal(lyd_print_mem(&lyb_out, tree_1, LYD_LYB, LYD_PRINT_WITHSIBLINGS), 0); assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, lyb_out, LYD_LYB, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, &tree_2)); assert_non_null(tree_2); CHECK_LYD(tree_1, tree_2); free(lyb_out); lyd_free_all(tree_1); lyd_free_all(tree_2); } static int setup(void **state) { UTEST_SETUP; assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG)); return 0; } static void tests_leaflist(void **state) { const char *mod; const char *data_xml; mod = "module mod { namespace \"urn:test-leaflist\"; prefix m;" " container cont {" " presence \"\";" " leaf-list ll {" " type uint8;" " }" " }" "}"; UTEST_ADD_MODULE(mod, LYS_IN_YANG, NULL, NULL); data_xml = "\n" "\n"; check_print_parse(state, data_xml); data_xml = "\n" " 1\n" "\n"; check_print_parse(state, data_xml); data_xml = "\n" " 1\n" " 2\n" "\n"; check_print_parse(state, data_xml); } static void tests_list(void **state) { const char *mod; const char *data_xml; mod = "module mod { namespace \"urn:test-list\"; prefix m;" " container cont {" " presence \"\";" " list lst {" " key \"lf\";" " leaf lf {" " type uint8;" " }" " }" " }" "}"; UTEST_ADD_MODULE(mod, LYS_IN_YANG, NULL, NULL); data_xml = "\n" " " " 1" " " "\n"; check_print_parse(state, data_xml); data_xml = "\n" " " " 1" " 2" " " "\n"; check_print_parse(state, data_xml); } static void tests_any(void **state) { const char *mod; const char *data_xml; mod = "module mod { namespace \"urn:test-any\"; prefix m;" " container cont {" " presence \"\";" " anyxml anxml;\n" " }" "}"; UTEST_ADD_MODULE(mod, LYS_IN_YANG, NULL, NULL); data_xml = "\n" "\n"; check_print_parse(state, data_xml); data_xml = "\n" " value\n" "\n"; check_print_parse(state, data_xml); data_xml = "\n" " value\n" " value\n" "\n"; check_print_parse(state, data_xml); } static void test_ietf_interfaces(void **state) { const char *data_xml = "\n" " \n" " eth0\n" " Ethernet 0\n" " ianaift:ethernetCsmacd\n" " true\n" " \n" " true\n" " 1500\n" "
\n" " 192.168.2.100\n" " 24\n" "
\n" "
\n" "
\n" " \n" " eth1\n" " Ethernet 1\n" " ianaift:ethernetCsmacd\n" " true\n" " \n" " true\n" " 1500\n" "
\n" " 10.10.1.5\n" " 16\n" "
\n" "
\n" "
\n" " \n" " gigaeth0\n" " GigabitEthernet 0\n" " ianaift:ethernetCsmacd\n" " false\n" " \n" "
\n"; assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "ietf-ip", NULL, NULL)); assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "iana-if-type", NULL, NULL)); check_print_parse(state, data_xml); } static void test_origin(void **state) { const char *origin_yang = "module test-origin {" " namespace \"urn:test-origin\";" " prefix to;" " import ietf-origin {" " prefix or;" " }" "" " container cont {" " leaf leaf1 {" " type string;" " }" " leaf leaf2 {" " type string;" " }" " leaf leaf3 {" " type uint8;" " }" " }" "}"; const char *data_xml = "\n" " value1\n" " value2\n" " 125\n" "\n"; UTEST_ADD_MODULE(origin_yang, LYS_IN_YANG, NULL, NULL); assert_int_equal(LY_SUCCESS, lys_set_implemented(ly_ctx_get_module_latest(UTEST_LYCTX, "ietf-origin"), NULL)); check_print_parse(state, data_xml); } static void test_statements(void **state) { const char *links_yang = "module links {\n" " yang-version 1.1;\n" " namespace \"urn:module2\";\n" " prefix mod2;\n" "\n" " identity just-another-identity;\n" "\n" " leaf one-leaf {\n" " type string;\n" " }\n" "\n" " list list-for-augment {\n" " key keyleaf;\n" "\n" " leaf keyleaf {\n" " type string;\n" " }\n" "\n" " leaf just-leaf {\n" " type int32;\n" " }\n" " }\n" "\n" " leaf rleaf {\n" " type string;\n" " }\n" "\n" " leaf-list llist {\n" " type string;\n" " min-elements 0;\n" " max-elements 100;\n" " ordered-by user;\n" " }\n" "\n" " grouping rgroup {\n" " leaf rg1 {\n" " type string;\n" " }\n" "\n" " leaf rg2 {\n" " type string;\n" " }\n" " }\n" "}\n"; const char *statements_yang = "module statements {\n" " namespace \"urn:module\";\n" " prefix mod;\n" " yang-version 1.1;\n" "\n" " import links {\n" " prefix mod2;\n" " }\n" "\n" " identity random-identity {\n" " base \"mod2:just-another-identity\";\n" " base \"another-identity\";\n" " }\n" "\n" " identity another-identity {\n" " base \"mod2:just-another-identity\";\n" " }\n" "\n" " typedef percent {\n" " type uint8 {\n" " range \"0 .. 100\";\n" " }\n" " units percent;\n" " }\n" "\n" " container ice-cream-shop {\n" " container employees {\n" " list employee {\n" " config true;\n" " key id;\n" " unique name;\n" " min-elements 0;\n" " max-elements 100;\n" "\n" " leaf id {\n" " type uint64;\n" " mandatory true;\n" " }\n" "\n" " leaf name {\n" " type string;\n" " }\n" "\n" " leaf age {\n" " type uint32;\n" " }\n" " }\n" " }\n" " }\n" "\n" " container random {\n" " choice switch {\n" " case a {\n" " leaf aleaf {\n" " type string;\n" " default aaa;\n" " }\n" " }\n" "\n" " case c {\n" " leaf cleaf {\n" " type string;\n" " }\n" " }\n" " }\n" "\n" " anyxml xml-data;\n" " anydata any-data;\n" " leaf-list leaflist {\n" " type string;\n" " min-elements 0;\n" " max-elements 20;\n" " ordered-by system;\n" " }\n" "\n" " grouping group {\n" " leaf g1 {\n" " mandatory false;\n" " type percent;\n" " }\n" "\n" " leaf g2 {\n" " type string;\n" " }\n" " }\n" "\n" " uses group;\n" " uses mod2:rgroup;\n" "\n" " leaf lref {\n" " type leafref {\n" " path \"/mod2:one-leaf\";\n" " }\n" " }\n" "\n" " leaf iref {\n" " type identityref {\n" " base \"mod2:just-another-identity\";\n" " }\n" " }\n" " }\n" "\n" " notification notif;\n" "\n" " augment \"/random\" {\n" " leaf aug-leaf {\n" " type string;\n" " }\n" " }\n" "}\n"; const char *data_xml = "reference leaf\n" "\n" " \n" " \n" " 0\n" " John Doe\n" " 28\n" " \n" " \n" " 1\n" " Dohn Joe\n" " 20\n" " \n" " \n" "\n" "\n" " string\n" " data\n" " \n" " l0\n" " l1\n" " l2\n" " 40\n" " string\n" " string\n" " string\n" " string\n" " reference leaf\n" " random-identity\n" "\n"; UTEST_ADD_MODULE(links_yang, LYS_IN_YANG, NULL, NULL); UTEST_ADD_MODULE(statements_yang, LYS_IN_YANG, NULL, NULL); check_print_parse(state, data_xml); } static void test_opaq(void **state) { const char *nc_feats[] = {"writable-running", NULL}; const char *data_xml = "\n" " \n" " \n" " \n" " \n" " \n" " TestFirst\n" " \n" " \n" "\n"; struct ly_in *in; struct lyd_node *tree_1; struct lyd_node *tree_2; char *xml_out; /* tree_2 */ LY_ERR rc; assert_non_null(ly_ctx_load_module(UTEST_LYCTX, "ietf-netconf", NULL, nc_feats)); ly_in_new_memory(data_xml, &in); rc = lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_RPC_YANG, &tree_1, NULL); ly_in_free(in, 0); assert_int_equal(rc, LY_SUCCESS); assert_int_equal(lyd_print_mem(&xml_out, tree_1, LYD_LYB, LYD_PRINT_WITHSIBLINGS), 0); ly_in_new_memory(xml_out, &in); rc = lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_LYB, LYD_TYPE_RPC_YANG, &tree_2, NULL); ly_in_free(in, 0); assert_int_equal(rc, LY_SUCCESS); /* compare models */ CHECK_LYD(tree_1, tree_2); /* clean */ free(xml_out); lyd_free_all(tree_1); lyd_free_all(tree_2); } static void test_collisions(void **state) { char *counters_yang, *data_xml; counters_yang = malloc(32768); strcpy(counters_yang, "module counters {\n" " namespace \"urn:counters\";\n" " prefix c;\n" "\n" " container stats {\n"); strcat(counters_yang, " leaf counter1 {\n" " type uint64;\n" " }\n" " leaf counter2 {\n" " type uint64;\n" " }\n" " leaf counter3 {\n" " type uint64;\n" " }\n" " leaf counter4 {\n" " type uint64;\n" " }\n" " leaf counter5 {\n" " type uint64;\n" " }\n" " leaf counter6 {\n" " type uint64;\n" " }\n" " leaf counter7 {\n" " type uint64;\n" " }\n" " leaf counter8 {\n" " type uint64;\n" " }\n" " leaf counter9 {\n" " type uint64;\n" " }\n" " leaf counter10 {\n" " type uint64;\n" " }\n" " leaf counter11 {\n" " type uint64;\n" " }\n" " leaf counter12 {\n" " type uint64;\n" " }\n" " leaf counter13 {\n" " type uint64;\n" " }\n" " leaf counter14 {\n" " type uint64;\n" " }\n" " leaf counter15 {\n" " type uint64;\n" " }\n" " leaf counter16 {\n" " type uint64;\n" " }\n" " leaf counter17 {\n" " type uint64;\n" " }\n" " leaf counter18 {\n" " type uint64;\n" " }\n" " leaf counter19 {\n" " type uint64;\n" " }\n" " leaf counter20 {\n" " type uint64;\n" " }\n" " leaf counter21 {\n" " type uint64;\n" " }\n" " leaf counter22 {\n" " type uint64;\n" " }\n" " leaf counter23 {\n" " type uint64;\n" " }\n" " leaf counter24 {\n" " type uint64;\n" " }\n" " leaf counter25 {\n" " type uint64;\n" " }\n" " leaf counter26 {\n" " type uint64;\n" " }\n" " leaf counter27 {\n" " type uint64;\n" " }\n" " leaf counter28 {\n" " type uint64;\n" " }\n" " leaf counter29 {\n" " type uint64;\n" " }\n" " leaf counter30 {\n" " type uint64;\n" " }\n" " leaf counter31 {\n" " type uint64;\n" " }\n" " leaf counter32 {\n" " type uint64;\n" " }\n" " leaf counter33 {\n" " type uint64;\n" " }\n" " leaf counter34 {\n" " type uint64;\n" " }\n" " leaf counter35 {\n" " type uint64;\n" " }\n" " leaf counter36 {\n" " type uint64;\n" " }\n" " leaf counter37 {\n" " type uint64;\n" " }\n" " leaf counter38 {\n" " type uint64;\n" " }\n" " leaf counter39 {\n" " type uint64;\n" " }\n" " leaf counter40 {\n" " type uint64;\n" " }\n" " leaf counter41 {\n" " type uint64;\n" " }\n" " leaf counter42 {\n" " type uint64;\n" " }\n" " leaf counter43 {\n" " type uint64;\n" " }\n" " leaf counter44 {\n" " type uint64;\n" " }\n" " leaf counter45 {\n" " type uint64;\n" " }\n" " leaf counter46 {\n" " type uint64;\n" " }\n" " leaf counter47 {\n" " type uint64;\n" " }\n" " leaf counter48 {\n" " type uint64;\n" " }\n" " leaf counter49 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter50 {\n" " type uint64;\n" " }\n" " leaf counter51 {\n" " type uint64;\n" " }\n" " leaf counter52 {\n" " type uint64;\n" " }\n" " leaf counter53 {\n" " type uint64;\n" " }\n" " leaf counter54 {\n" " type uint64;\n" " }\n" " leaf counter55 {\n" " type uint64;\n" " }\n" " leaf counter56 {\n" " type uint64;\n" " }\n" " leaf counter57 {\n" " type uint64;\n" " }\n" " leaf counter58 {\n" " type uint64;\n" " }\n" " leaf counter59 {\n" " type uint64;\n" " }\n" " leaf counter60 {\n" " type uint64;\n" " }\n" " leaf counter61 {\n" " type uint64;\n" " }\n" " leaf counter62 {\n" " type uint64;\n" " }\n" " leaf counter63 {\n" " type uint64;\n" " }\n" " leaf counter64 {\n" " type uint64;\n" " }\n" " leaf counter65 {\n" " type uint64;\n" " }\n" " leaf counter66 {\n" " type uint64;\n" " }\n" " leaf counter67 {\n" " type uint64;\n" " }\n" " leaf counter68 {\n" " type uint64;\n" " }\n" " leaf counter69 {\n" " type uint64;\n" " }\n" " leaf counter70 {\n" " type uint64;\n" " }\n" " leaf counter71 {\n" " type uint64;\n" " }\n" " leaf counter72 {\n" " type uint64;\n" " }\n" " leaf counter73 {\n" " type uint64;\n" " }\n" " leaf counter74 {\n" " type uint64;\n" " }\n" " leaf counter75 {\n" " type uint64;\n" " }\n" " leaf counter76 {\n" " type uint64;\n" " }\n" " leaf counter77 {\n" " type uint64;\n" " }\n" " leaf counter78 {\n" " type uint64;\n" " }\n" " leaf counter79 {\n" " type uint64;\n" " }\n" " leaf counter80 {\n" " type uint64;\n" " }\n" " leaf counter81 {\n" " type uint64;\n" " }\n" " leaf counter82 {\n" " type uint64;\n" " }\n" " leaf counter83 {\n" " type uint64;\n" " }\n" " leaf counter84 {\n" " type uint64;\n" " }\n" " leaf counter85 {\n" " type uint64;\n" " }\n" " leaf counter86 {\n" " type uint64;\n" " }\n" " leaf counter87 {\n" " type uint64;\n" " }\n" " leaf counter88 {\n" " type uint64;\n" " }\n" " leaf counter89 {\n" " type uint64;\n" " }\n" " leaf counter90 {\n" " type uint64;\n" " }\n" " leaf counter91 {\n" " type uint64;\n" " }\n" " leaf counter92 {\n" " type uint64;\n" " }\n" " leaf counter93 {\n" " type uint64;\n" " }\n" " leaf counter94 {\n" " type uint64;\n" " }\n" " leaf counter95 {\n" " type uint64;\n" " }\n" " leaf counter96 {\n" " type uint64;\n" " }\n" " leaf counter97 {\n" " type uint64;\n" " }\n" " leaf counter98 {\n" " type uint64;\n" " }\n" " leaf counter99 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter100 {\n" " type uint64;\n" " }\n" " leaf counter101 {\n" " type uint64;\n" " }\n" " leaf counter102 {\n" " type uint64;\n" " }\n" " leaf counter103 {\n" " type uint64;\n" " }\n" " leaf counter104 {\n" " type uint64;\n" " }\n" " leaf counter105 {\n" " type uint64;\n" " }\n" " leaf counter106 {\n" " type uint64;\n" " }\n" " leaf counter107 {\n" " type uint64;\n" " }\n" " leaf counter108 {\n" " type uint64;\n" " }\n" " leaf counter109 {\n" " type uint64;\n" " }\n" " leaf counter110 {\n" " type uint64;\n" " }\n" " leaf counter111 {\n" " type uint64;\n" " }\n" " leaf counter112 {\n" " type uint64;\n" " }\n" " leaf counter113 {\n" " type uint64;\n" " }\n" " leaf counter114 {\n" " type uint64;\n" " }\n" " leaf counter115 {\n" " type uint64;\n" " }\n" " leaf counter116 {\n" " type uint64;\n" " }\n" " leaf counter117 {\n" " type uint64;\n" " }\n" " leaf counter118 {\n" " type uint64;\n" " }\n" " leaf counter119 {\n" " type uint64;\n" " }\n" " leaf counter120 {\n" " type uint64;\n" " }\n" " leaf counter121 {\n" " type uint64;\n" " }\n" " leaf counter122 {\n" " type uint64;\n" " }\n" " leaf counter123 {\n" " type uint64;\n" " }\n" " leaf counter124 {\n" " type uint64;\n" " }\n" " leaf counter125 {\n" " type uint64;\n" " }\n" " leaf counter126 {\n" " type uint64;\n" " }\n" " leaf counter127 {\n" " type uint64;\n" " }\n" " leaf counter128 {\n" " type uint64;\n" " }\n" " leaf counter129 {\n" " type uint64;\n" " }\n" " leaf counter130 {\n" " type uint64;\n" " }\n" " leaf counter131 {\n" " type uint64;\n" " }\n" " leaf counter132 {\n" " type uint64;\n" " }\n" " leaf counter133 {\n" " type uint64;\n" " }\n" " leaf counter134 {\n" " type uint64;\n" " }\n" " leaf counter135 {\n" " type uint64;\n" " }\n" " leaf counter136 {\n" " type uint64;\n" " }\n" " leaf counter137 {\n" " type uint64;\n" " }\n" " leaf counter138 {\n" " type uint64;\n" " }\n" " leaf counter139 {\n" " type uint64;\n" " }\n" " leaf counter140 {\n" " type uint64;\n" " }\n" " leaf counter141 {\n" " type uint64;\n" " }\n" " leaf counter142 {\n" " type uint64;\n" " }\n" " leaf counter143 {\n" " type uint64;\n" " }\n" " leaf counter144 {\n" " type uint64;\n" " }\n" " leaf counter145 {\n" " type uint64;\n" " }\n" " leaf counter146 {\n" " type uint64;\n" " }\n" " leaf counter147 {\n" " type uint64;\n" " }\n" " leaf counter148 {\n" " type uint64;\n" " }\n" " leaf counter149 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter150 {\n" " type uint64;\n" " }\n" " leaf counter151 {\n" " type uint64;\n" " }\n" " leaf counter152 {\n" " type uint64;\n" " }\n" " leaf counter153 {\n" " type uint64;\n" " }\n" " leaf counter154 {\n" " type uint64;\n" " }\n" " leaf counter155 {\n" " type uint64;\n" " }\n" " leaf counter156 {\n" " type uint64;\n" " }\n" " leaf counter157 {\n" " type uint64;\n" " }\n" " leaf counter158 {\n" " type uint64;\n" " }\n" " leaf counter159 {\n" " type uint64;\n" " }\n" " leaf counter160 {\n" " type uint64;\n" " }\n" " leaf counter161 {\n" " type uint64;\n" " }\n" " leaf counter162 {\n" " type uint64;\n" " }\n" " leaf counter163 {\n" " type uint64;\n" " }\n" " leaf counter164 {\n" " type uint64;\n" " }\n" " leaf counter165 {\n" " type uint64;\n" " }\n" " leaf counter166 {\n" " type uint64;\n" " }\n" " leaf counter167 {\n" " type uint64;\n" " }\n" " leaf counter168 {\n" " type uint64;\n" " }\n" " leaf counter169 {\n" " type uint64;\n" " }\n" " leaf counter170 {\n" " type uint64;\n" " }\n" " leaf counter171 {\n" " type uint64;\n" " }\n" " leaf counter172 {\n" " type uint64;\n" " }\n" " leaf counter173 {\n" " type uint64;\n" " }\n" " leaf counter174 {\n" " type uint64;\n" " }\n" " leaf counter175 {\n" " type uint64;\n" " }\n" " leaf counter176 {\n" " type uint64;\n" " }\n" " leaf counter177 {\n" " type uint64;\n" " }\n" " leaf counter178 {\n" " type uint64;\n" " }\n" " leaf counter179 {\n" " type uint64;\n" " }\n" " leaf counter180 {\n" " type uint64;\n" " }\n" " leaf counter181 {\n" " type uint64;\n" " }\n" " leaf counter182 {\n" " type uint64;\n" " }\n" " leaf counter183 {\n" " type uint64;\n" " }\n" " leaf counter184 {\n" " type uint64;\n" " }\n" " leaf counter185 {\n" " type uint64;\n" " }\n" " leaf counter186 {\n" " type uint64;\n" " }\n" " leaf counter187 {\n" " type uint64;\n" " }\n" " leaf counter188 {\n" " type uint64;\n" " }\n" " leaf counter189 {\n" " type uint64;\n" " }\n" " leaf counter190 {\n" " type uint64;\n" " }\n" " leaf counter191 {\n" " type uint64;\n" " }\n" " leaf counter192 {\n" " type uint64;\n" " }\n" " leaf counter193 {\n" " type uint64;\n" " }\n" " leaf counter194 {\n" " type uint64;\n" " }\n" " leaf counter195 {\n" " type uint64;\n" " }\n" " leaf counter196 {\n" " type uint64;\n" " }\n" " leaf counter197 {\n" " type uint64;\n" " }\n" " leaf counter198 {\n" " type uint64;\n" " }\n" " leaf counter199 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter200 {\n" " type uint64;\n" " }\n" " leaf counter201 {\n" " type uint64;\n" " }\n" " leaf counter202 {\n" " type uint64;\n" " }\n" " leaf counter203 {\n" " type uint64;\n" " }\n" " leaf counter204 {\n" " type uint64;\n" " }\n" " leaf counter205 {\n" " type uint64;\n" " }\n" " leaf counter206 {\n" " type uint64;\n" " }\n" " leaf counter207 {\n" " type uint64;\n" " }\n" " leaf counter208 {\n" " type uint64;\n" " }\n" " leaf counter209 {\n" " type uint64;\n" " }\n" " leaf counter210 {\n" " type uint64;\n" " }\n" " leaf counter211 {\n" " type uint64;\n" " }\n" " leaf counter212 {\n" " type uint64;\n" " }\n" " leaf counter213 {\n" " type uint64;\n" " }\n" " leaf counter214 {\n" " type uint64;\n" " }\n" " leaf counter215 {\n" " type uint64;\n" " }\n" " leaf counter216 {\n" " type uint64;\n" " }\n" " leaf counter217 {\n" " type uint64;\n" " }\n" " leaf counter218 {\n" " type uint64;\n" " }\n" " leaf counter219 {\n" " type uint64;\n" " }\n" " leaf counter220 {\n" " type uint64;\n" " }\n" " leaf counter221 {\n" " type uint64;\n" " }\n" " leaf counter222 {\n" " type uint64;\n" " }\n" " leaf counter223 {\n" " type uint64;\n" " }\n" " leaf counter224 {\n" " type uint64;\n" " }\n" " leaf counter225 {\n" " type uint64;\n" " }\n" " leaf counter226 {\n" " type uint64;\n" " }\n" " leaf counter227 {\n" " type uint64;\n" " }\n" " leaf counter228 {\n" " type uint64;\n" " }\n" " leaf counter229 {\n" " type uint64;\n" " }\n" " leaf counter230 {\n" " type uint64;\n" " }\n" " leaf counter231 {\n" " type uint64;\n" " }\n" " leaf counter232 {\n" " type uint64;\n" " }\n" " leaf counter233 {\n" " type uint64;\n" " }\n" " leaf counter234 {\n" " type uint64;\n" " }\n" " leaf counter235 {\n" " type uint64;\n" " }\n" " leaf counter236 {\n" " type uint64;\n" " }\n" " leaf counter237 {\n" " type uint64;\n" " }\n" " leaf counter238 {\n" " type uint64;\n" " }\n" " leaf counter239 {\n" " type uint64;\n" " }\n" " leaf counter240 {\n" " type uint64;\n" " }\n" " leaf counter241 {\n" " type uint64;\n" " }\n" " leaf counter242 {\n" " type uint64;\n" " }\n" " leaf counter243 {\n" " type uint64;\n" " }\n" " leaf counter244 {\n" " type uint64;\n" " }\n" " leaf counter245 {\n" " type uint64;\n" " }\n" " leaf counter246 {\n" " type uint64;\n" " }\n" " leaf counter247 {\n" " type uint64;\n" " }\n" " leaf counter248 {\n" " type uint64;\n" " }\n" " leaf counter249 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter250 {\n" " type uint64;\n" " }\n" " leaf counter251 {\n" " type uint64;\n" " }\n" " leaf counter252 {\n" " type uint64;\n" " }\n" " leaf counter253 {\n" " type uint64;\n" " }\n" " leaf counter254 {\n" " type uint64;\n" " }\n" " leaf counter255 {\n" " type uint64;\n" " }\n" " leaf counter256 {\n" " type uint64;\n" " }\n" " leaf counter257 {\n" " type uint64;\n" " }\n" " leaf counter258 {\n" " type uint64;\n" " }\n" " leaf counter259 {\n" " type uint64;\n" " }\n" " leaf counter260 {\n" " type uint64;\n" " }\n" " leaf counter261 {\n" " type uint64;\n" " }\n" " leaf counter262 {\n" " type uint64;\n" " }\n" " leaf counter263 {\n" " type uint64;\n" " }\n" " leaf counter264 {\n" " type uint64;\n" " }\n" " leaf counter265 {\n" " type uint64;\n" " }\n" " leaf counter266 {\n" " type uint64;\n" " }\n" " leaf counter267 {\n" " type uint64;\n" " }\n" " leaf counter268 {\n" " type uint64;\n" " }\n" " leaf counter269 {\n" " type uint64;\n" " }\n" " leaf counter270 {\n" " type uint64;\n" " }\n" " leaf counter271 {\n" " type uint64;\n" " }\n" " leaf counter272 {\n" " type uint64;\n" " }\n" " leaf counter273 {\n" " type uint64;\n" " }\n" " leaf counter274 {\n" " type uint64;\n" " }\n" " leaf counter275 {\n" " type uint64;\n" " }\n" " leaf counter276 {\n" " type uint64;\n" " }\n" " leaf counter277 {\n" " type uint64;\n" " }\n" " leaf counter278 {\n" " type uint64;\n" " }\n" " leaf counter279 {\n" " type uint64;\n" " }\n" " leaf counter280 {\n" " type uint64;\n" " }\n" " leaf counter281 {\n" " type uint64;\n" " }\n" " leaf counter282 {\n" " type uint64;\n" " }\n" " leaf counter283 {\n" " type uint64;\n" " }\n" " leaf counter284 {\n" " type uint64;\n" " }\n" " leaf counter285 {\n" " type uint64;\n" " }\n" " leaf counter286 {\n" " type uint64;\n" " }\n" " leaf counter287 {\n" " type uint64;\n" " }\n" " leaf counter288 {\n" " type uint64;\n" " }\n" " leaf counter289 {\n" " type uint64;\n" " }\n" " leaf counter290 {\n" " type uint64;\n" " }\n" " leaf counter291 {\n" " type uint64;\n" " }\n" " leaf counter292 {\n" " type uint64;\n" " }\n" " leaf counter293 {\n" " type uint64;\n" " }\n" " leaf counter294 {\n" " type uint64;\n" " }\n" " leaf counter295 {\n" " type uint64;\n" " }\n" " leaf counter296 {\n" " type uint64;\n" " }\n" " leaf counter297 {\n" " type uint64;\n" " }\n" " leaf counter298 {\n" " type uint64;\n" " }\n" " leaf counter299 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter300 {\n" " type uint64;\n" " }\n" " leaf counter301 {\n" " type uint64;\n" " }\n" " leaf counter302 {\n" " type uint64;\n" " }\n" " leaf counter303 {\n" " type uint64;\n" " }\n" " leaf counter304 {\n" " type uint64;\n" " }\n" " leaf counter305 {\n" " type uint64;\n" " }\n" " leaf counter306 {\n" " type uint64;\n" " }\n" " leaf counter307 {\n" " type uint64;\n" " }\n" " leaf counter308 {\n" " type uint64;\n" " }\n" " leaf counter309 {\n" " type uint64;\n" " }\n" " leaf counter310 {\n" " type uint64;\n" " }\n" " leaf counter311 {\n" " type uint64;\n" " }\n" " leaf counter312 {\n" " type uint64;\n" " }\n" " leaf counter313 {\n" " type uint64;\n" " }\n" " leaf counter314 {\n" " type uint64;\n" " }\n" " leaf counter315 {\n" " type uint64;\n" " }\n" " leaf counter316 {\n" " type uint64;\n" " }\n" " leaf counter317 {\n" " type uint64;\n" " }\n" " leaf counter318 {\n" " type uint64;\n" " }\n" " leaf counter319 {\n" " type uint64;\n" " }\n" " leaf counter320 {\n" " type uint64;\n" " }\n" " leaf counter321 {\n" " type uint64;\n" " }\n" " leaf counter322 {\n" " type uint64;\n" " }\n" " leaf counter323 {\n" " type uint64;\n" " }\n" " leaf counter324 {\n" " type uint64;\n" " }\n" " leaf counter325 {\n" " type uint64;\n" " }\n" " leaf counter326 {\n" " type uint64;\n" " }\n" " leaf counter327 {\n" " type uint64;\n" " }\n" " leaf counter328 {\n" " type uint64;\n" " }\n" " leaf counter329 {\n" " type uint64;\n" " }\n" " leaf counter330 {\n" " type uint64;\n" " }\n" " leaf counter331 {\n" " type uint64;\n" " }\n" " leaf counter332 {\n" " type uint64;\n" " }\n" " leaf counter333 {\n" " type uint64;\n" " }\n" " leaf counter334 {\n" " type uint64;\n" " }\n" " leaf counter335 {\n" " type uint64;\n" " }\n" " leaf counter336 {\n" " type uint64;\n" " }\n" " leaf counter337 {\n" " type uint64;\n" " }\n" " leaf counter338 {\n" " type uint64;\n" " }\n" " leaf counter339 {\n" " type uint64;\n" " }\n" " leaf counter340 {\n" " type uint64;\n" " }\n" " leaf counter341 {\n" " type uint64;\n" " }\n" " leaf counter342 {\n" " type uint64;\n" " }\n" " leaf counter343 {\n" " type uint64;\n" " }\n" " leaf counter344 {\n" " type uint64;\n" " }\n" " leaf counter345 {\n" " type uint64;\n" " }\n" " leaf counter346 {\n" " type uint64;\n" " }\n" " leaf counter347 {\n" " type uint64;\n" " }\n" " leaf counter348 {\n" " type uint64;\n" " }\n" " leaf counter349 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter350 {\n" " type uint64;\n" " }\n" " leaf counter351 {\n" " type uint64;\n" " }\n" " leaf counter352 {\n" " type uint64;\n" " }\n" " leaf counter353 {\n" " type uint64;\n" " }\n" " leaf counter354 {\n" " type uint64;\n" " }\n" " leaf counter355 {\n" " type uint64;\n" " }\n" " leaf counter356 {\n" " type uint64;\n" " }\n" " leaf counter357 {\n" " type uint64;\n" " }\n" " leaf counter358 {\n" " type uint64;\n" " }\n" " leaf counter359 {\n" " type uint64;\n" " }\n" " leaf counter360 {\n" " type uint64;\n" " }\n" " leaf counter361 {\n" " type uint64;\n" " }\n" " leaf counter362 {\n" " type uint64;\n" " }\n" " leaf counter363 {\n" " type uint64;\n" " }\n" " leaf counter364 {\n" " type uint64;\n" " }\n" " leaf counter365 {\n" " type uint64;\n" " }\n" " leaf counter366 {\n" " type uint64;\n" " }\n" " leaf counter367 {\n" " type uint64;\n" " }\n" " leaf counter368 {\n" " type uint64;\n" " }\n" " leaf counter369 {\n" " type uint64;\n" " }\n" " leaf counter370 {\n" " type uint64;\n" " }\n" " leaf counter371 {\n" " type uint64;\n" " }\n" " leaf counter372 {\n" " type uint64;\n" " }\n" " leaf counter373 {\n" " type uint64;\n" " }\n" " leaf counter374 {\n" " type uint64;\n" " }\n" " leaf counter375 {\n" " type uint64;\n" " }\n" " leaf counter376 {\n" " type uint64;\n" " }\n" " leaf counter377 {\n" " type uint64;\n" " }\n" " leaf counter378 {\n" " type uint64;\n" " }\n" " leaf counter379 {\n" " type uint64;\n" " }\n" " leaf counter380 {\n" " type uint64;\n" " }\n" " leaf counter381 {\n" " type uint64;\n" " }\n" " leaf counter382 {\n" " type uint64;\n" " }\n" " leaf counter383 {\n" " type uint64;\n" " }\n" " leaf counter384 {\n" " type uint64;\n" " }\n" " leaf counter385 {\n" " type uint64;\n" " }\n" " leaf counter386 {\n" " type uint64;\n" " }\n" " leaf counter387 {\n" " type uint64;\n" " }\n" " leaf counter388 {\n" " type uint64;\n" " }\n" " leaf counter389 {\n" " type uint64;\n" " }\n" " leaf counter390 {\n" " type uint64;\n" " }\n" " leaf counter391 {\n" " type uint64;\n" " }\n" " leaf counter392 {\n" " type uint64;\n" " }\n" " leaf counter393 {\n" " type uint64;\n" " }\n" " leaf counter394 {\n" " type uint64;\n" " }\n" " leaf counter395 {\n" " type uint64;\n" " }\n" " leaf counter396 {\n" " type uint64;\n" " }\n" " leaf counter397 {\n" " type uint64;\n" " }\n" " leaf counter398 {\n" " type uint64;\n" " }\n" " leaf counter399 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter400 {\n" " type uint64;\n" " }\n" " leaf counter401 {\n" " type uint64;\n" " }\n" " leaf counter402 {\n" " type uint64;\n" " }\n" " leaf counter403 {\n" " type uint64;\n" " }\n" " leaf counter404 {\n" " type uint64;\n" " }\n" " leaf counter405 {\n" " type uint64;\n" " }\n" " leaf counter406 {\n" " type uint64;\n" " }\n" " leaf counter407 {\n" " type uint64;\n" " }\n" " leaf counter408 {\n" " type uint64;\n" " }\n" " leaf counter409 {\n" " type uint64;\n" " }\n" " leaf counter410 {\n" " type uint64;\n" " }\n" " leaf counter411 {\n" " type uint64;\n" " }\n" " leaf counter412 {\n" " type uint64;\n" " }\n" " leaf counter413 {\n" " type uint64;\n" " }\n" " leaf counter414 {\n" " type uint64;\n" " }\n" " leaf counter415 {\n" " type uint64;\n" " }\n" " leaf counter416 {\n" " type uint64;\n" " }\n" " leaf counter417 {\n" " type uint64;\n" " }\n" " leaf counter418 {\n" " type uint64;\n" " }\n" " leaf counter419 {\n" " type uint64;\n" " }\n" " leaf counter420 {\n" " type uint64;\n" " }\n" " leaf counter421 {\n" " type uint64;\n" " }\n" " leaf counter422 {\n" " type uint64;\n" " }\n" " leaf counter423 {\n" " type uint64;\n" " }\n" " leaf counter424 {\n" " type uint64;\n" " }\n" " leaf counter425 {\n" " type uint64;\n" " }\n" " leaf counter426 {\n" " type uint64;\n" " }\n" " leaf counter427 {\n" " type uint64;\n" " }\n" " leaf counter428 {\n" " type uint64;\n" " }\n" " leaf counter429 {\n" " type uint64;\n" " }\n" " leaf counter430 {\n" " type uint64;\n" " }\n" " leaf counter431 {\n" " type uint64;\n" " }\n" " leaf counter432 {\n" " type uint64;\n" " }\n" " leaf counter433 {\n" " type uint64;\n" " }\n" " leaf counter434 {\n" " type uint64;\n" " }\n" " leaf counter435 {\n" " type uint64;\n" " }\n" " leaf counter436 {\n" " type uint64;\n" " }\n" " leaf counter437 {\n" " type uint64;\n" " }\n" " leaf counter438 {\n" " type uint64;\n" " }\n" " leaf counter439 {\n" " type uint64;\n" " }\n" " leaf counter440 {\n" " type uint64;\n" " }\n" " leaf counter441 {\n" " type uint64;\n" " }\n" " leaf counter442 {\n" " type uint64;\n" " }\n" " leaf counter443 {\n" " type uint64;\n" " }\n" " leaf counter444 {\n" " type uint64;\n" " }\n" " leaf counter445 {\n" " type uint64;\n" " }\n" " leaf counter446 {\n" " type uint64;\n" " }\n" " leaf counter447 {\n" " type uint64;\n" " }\n" " leaf counter448 {\n" " type uint64;\n" " }\n" " leaf counter449 {\n" " type uint64;\n" " }\n"); strcat(counters_yang, " leaf counter450 {\n" " type uint64;\n" " }\n" " leaf counter451 {\n" " type uint64;\n" " }\n" " leaf counter452 {\n" " type uint64;\n" " }\n" " leaf counter453 {\n" " type uint64;\n" " }\n" " leaf counter454 {\n" " type uint64;\n" " }\n" " leaf counter455 {\n" " type uint64;\n" " }\n" " leaf counter456 {\n" " type uint64;\n" " }\n" " leaf counter457 {\n" " type uint64;\n" " }\n" " leaf counter458 {\n" " type uint64;\n" " }\n" " leaf counter459 {\n" " type uint64;\n" " }\n" " leaf counter460 {\n" " type uint64;\n" " }\n" " leaf counter461 {\n" " type uint64;\n" " }\n" " leaf counter462 {\n" " type uint64;\n" " }\n" " leaf counter463 {\n" " type uint64;\n" " }\n" " leaf counter464 {\n" " type uint64;\n" " }\n" " leaf counter465 {\n" " type uint64;\n" " }\n" " leaf counter466 {\n" " type uint64;\n" " }\n" " leaf counter467 {\n" " type uint64;\n" " }\n" " leaf counter468 {\n" " type uint64;\n" " }\n" " leaf counter469 {\n" " type uint64;\n" " }\n" " leaf counter470 {\n" " type uint64;\n" " }\n" " leaf counter471 {\n" " type uint64;\n" " }\n" " leaf counter472 {\n" " type uint64;\n" " }\n" " leaf counter473 {\n" " type uint64;\n" " }\n" " leaf counter474 {\n" " type uint64;\n" " }\n" " leaf counter475 {\n" " type uint64;\n" " }\n" " leaf counter476 {\n" " type uint64;\n" " }\n" " leaf counter477 {\n" " type uint64;\n" " }\n" " leaf counter478 {\n" " type uint64;\n" " }\n" " leaf counter479 {\n" " type uint64;\n" " }\n" " leaf counter480 {\n" " type uint64;\n" " }\n" " leaf counter481 {\n" " type uint64;\n" " }\n" " leaf counter482 {\n" " type uint64;\n" " }\n" " leaf counter483 {\n" " type uint64;\n" " }\n" " leaf counter484 {\n" " type uint64;\n" " }\n" " leaf counter485 {\n" " type uint64;\n" " }\n" " leaf counter486 {\n" " type uint64;\n" " }\n" " leaf counter487 {\n" " type uint64;\n" " }\n" " leaf counter488 {\n" " type uint64;\n" " }\n" " leaf counter489 {\n" " type uint64;\n" " }\n" " leaf counter490 {\n" " type uint64;\n" " }\n" " leaf counter491 {\n" " type uint64;\n" " }\n" " leaf counter492 {\n" " type uint64;\n" " }\n" " leaf counter493 {\n" " type uint64;\n" " }\n" " leaf counter494 {\n" " type uint64;\n" " }\n" " leaf counter495 {\n" " type uint64;\n" " }\n" " leaf counter496 {\n" " type uint64;\n" " }\n" " leaf counter497 {\n" " type uint64;\n" " }\n" " leaf counter498 {\n" " type uint64;\n" " }\n" " leaf counter499 {\n" " type uint64;\n" " }\n" " }\n" "}\n"); data_xml = malloc(16384); strcpy(data_xml, "\n"); strcat(data_xml, " 1\n" " 2\n" " 3\n" " 4\n" " 5\n" " 6\n" " 7\n" " 8\n" " 9\n" " 10\n" " 11\n" " 12\n" " 13\n" " 14\n" " 15\n" " 16\n" " 17\n" " 18\n" " 19\n" " 20\n" " 21\n" " 22\n" " 23\n" " 24\n" " 25\n" " 26\n" " 27\n" " 28\n" " 29\n" " 30\n" " 31\n" " 32\n" " 33\n" " 34\n" " 35\n" " 36\n" " 37\n" " 38\n" " 39\n" " 40\n" " 41\n" " 42\n" " 43\n" " 44\n" " 45\n" " 46\n" " 47\n" " 48\n" " 49\n" " 50\n" " 51\n" " 52\n" " 53\n" " 54\n" " 55\n" " 56\n" " 57\n" " 58\n" " 59\n" " 60\n" " 61\n" " 62\n" " 63\n" " 64\n" " 65\n" " 66\n" " 67\n" " 68\n" " 69\n" " 70\n" " 71\n" " 72\n" " 73\n" " 74\n" " 75\n" " 76\n" " 77\n" " 78\n" " 79\n" " 80\n" " 81\n" " 82\n" " 83\n" " 84\n" " 85\n" " 86\n" " 87\n" " 88\n" " 89\n" " 90\n" " 91\n" " 92\n" " 93\n" " 94\n" " 95\n" " 96\n" " 97\n" " 98\n" " 99\n"); strcat(data_xml, " 100\n" " 101\n" " 102\n" " 103\n" " 104\n" " 105\n" " 106\n" " 107\n" " 108\n" " 109\n" " 110\n" " 111\n" " 112\n" " 113\n" " 114\n" " 115\n" " 116\n" " 117\n" " 118\n" " 119\n" " 120\n" " 121\n" " 122\n" " 123\n" " 124\n" " 125\n" " 126\n" " 127\n" " 128\n" " 129\n" " 130\n" " 131\n" " 132\n" " 133\n" " 134\n" " 135\n" " 136\n" " 137\n" " 138\n" " 139\n" " 140\n" " 141\n" " 142\n" " 143\n" " 144\n" " 145\n" " 146\n" " 147\n" " 148\n" " 149\n" " 150\n" " 151\n" " 152\n" " 153\n" " 154\n" " 155\n" " 156\n" " 157\n" " 158\n" " 159\n" " 160\n" " 161\n" " 162\n" " 163\n" " 164\n" " 165\n" " 166\n" " 167\n" " 168\n" " 169\n" " 170\n" " 171\n" " 172\n" " 173\n" " 174\n" " 175\n" " 176\n" " 177\n" " 178\n" " 179\n" " 180\n" " 181\n" " 182\n" " 183\n" " 184\n" " 185\n" " 186\n" " 187\n" " 188\n" " 189\n" " 190\n" " 191\n" " 192\n" " 193\n" " 194\n" " 195\n" " 196\n" " 197\n" " 198\n" " 199\n"); strcat(data_xml, " 200\n" " 201\n" " 202\n" " 203\n" " 204\n" " 205\n" " 206\n" " 207\n" " 208\n" " 209\n" " 210\n" " 211\n" " 212\n" " 213\n" " 214\n" " 215\n" " 216\n" " 217\n" " 218\n" " 219\n" " 220\n" " 221\n" " 222\n" " 223\n" " 224\n" " 225\n" " 226\n" " 227\n" " 228\n" " 229\n" " 230\n" " 231\n" " 232\n" " 233\n" " 234\n" " 235\n" " 236\n" " 237\n" " 238\n" " 239\n" " 240\n" " 241\n" " 242\n" " 243\n" " 244\n" " 245\n" " 246\n" " 247\n" " 248\n" " 249\n" " 250\n" " 251\n" " 252\n" " 253\n" " 254\n" " 255\n" " 256\n" " 257\n" " 258\n" " 259\n" " 260\n" " 261\n" " 262\n" " 263\n" " 264\n" " 265\n" " 266\n" " 267\n" " 268\n" " 269\n" " 270\n" " 271\n" " 272\n" " 273\n" " 274\n" " 275\n" " 276\n" " 277\n" " 278\n" " 279\n" " 280\n" " 281\n" " 282\n" " 283\n" " 284\n" " 285\n" " 286\n" " 287\n" " 288\n" " 289\n" " 290\n" " 291\n" " 292\n" " 293\n" " 294\n" " 295\n" " 296\n" " 297\n" " 298\n" " 299\n"); strcat(data_xml, " 300\n" " 301\n" " 302\n" " 303\n" " 304\n" " 305\n" " 306\n" " 307\n" " 308\n" " 309\n" " 310\n" " 311\n" " 312\n" " 313\n" " 314\n" " 315\n" " 316\n" " 317\n" " 318\n" " 319\n" " 320\n" " 321\n" " 322\n" " 323\n" " 324\n" " 325\n" " 326\n" " 327\n" " 328\n" " 329\n" " 330\n" " 331\n" " 332\n" " 333\n" " 334\n" " 335\n" " 336\n" " 337\n" " 338\n" " 339\n" " 340\n" " 341\n" " 342\n" " 343\n" " 344\n" " 345\n" " 346\n" " 347\n" " 348\n" " 349\n" " 350\n" " 351\n" " 352\n" " 353\n" " 354\n" " 355\n" " 356\n" " 357\n" " 358\n" " 359\n" " 360\n" " 361\n" " 362\n" " 363\n" " 364\n" " 365\n" " 366\n" " 367\n" " 368\n" " 369\n" " 370\n" " 371\n" " 372\n" " 373\n" " 374\n" " 375\n" " 376\n" " 377\n" " 378\n" " 379\n" " 380\n" " 381\n" " 382\n" " 383\n" " 384\n" " 385\n" " 386\n" " 387\n" " 388\n" " 389\n" " 390\n" " 391\n" " 392\n" " 393\n" " 394\n" " 395\n" " 396\n" " 397\n" " 398\n" " 399\n"); strcat(data_xml, " 400\n" " 401\n" " 402\n" " 403\n" " 404\n" " 405\n" " 406\n" " 407\n" " 408\n" " 409\n" " 410\n" " 411\n" " 412\n" " 413\n" " 414\n" " 415\n" " 416\n" " 417\n" " 418\n" " 419\n" " 420\n" " 421\n" " 422\n" " 423\n" " 424\n" " 425\n" " 426\n" " 427\n" " 428\n" " 429\n" " 430\n" " 431\n" " 432\n" " 433\n" " 434\n" " 435\n" " 436\n" " 437\n" " 438\n" " 439\n" " 440\n" " 441\n" " 442\n" " 443\n" " 444\n" " 445\n" " 446\n" " 447\n" " 448\n" " 449\n" " 450\n" " 451\n" " 452\n" " 453\n" " 454\n" " 455\n" " 456\n" " 457\n" " 458\n" " 459\n" " 460\n" " 461\n" " 462\n" " 463\n" " 464\n" " 465\n" " 466\n" " 467\n" " 468\n" " 469\n" " 470\n" " 471\n" " 472\n" " 473\n" " 474\n" " 475\n" " 476\n" " 477\n" " 478\n" " 479\n" " 480\n" " 481\n" " 482\n" " 483\n" " 484\n" " 485\n" " 486\n" " 487\n" " 488\n" " 489\n" " 490\n" " 491\n" " 492\n" " 493\n" " 494\n" " 495\n" " 496\n" " 497\n" " 498\n" " 499\n" "\n"); UTEST_ADD_MODULE(counters_yang, LYS_IN_YANG, NULL, NULL); check_print_parse(state, data_xml); free(counters_yang); free(data_xml); } #if 0 static void test_types(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "types", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/types.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_annotations(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/annotations.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_similar_annot_names(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/similar-annot-names.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_many_child_annot(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/many-childs-annot.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_union(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "union", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/union.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_union2(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "statements", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/union2.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_collisions(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/collisions.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_anydata(void **state) { struct state *st = (*state); const struct lys_module *mod; int ret; const char *test_anydata = "module test-anydata {" " namespace \"urn:test-anydata\";" " prefix ya;" "" " container cont {" " anydata ntf;" " }" "}"; assert_non_null(ly_ctx_load_module(st->ctx, "ietf-netconf-notifications", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/ietf-netconf-notifications.json", LYD_JSON, LYD_OPT_NOTIF | LYD_OPT_TRUSTED, NULL); assert_ptr_not_equal(st->dt1, NULL); / *get notification in LYB format to set as anydata content * / ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); lyd_free_withsiblings(st->dt1); st->dt1 = NULL; / *now comes the real test, test anydata * / mod = lys_parse_mem(st->ctx, test_anydata, LYS_YANG); assert_non_null(mod); st->dt1 = lyd_new(NULL, mod, "cont"); assert_non_null(st->dt1); assert_non_null(lyd_new_anydata(st->dt1, NULL, "ntf", st->mem, LYD_ANYDATA_LYBD)); st->mem = NULL; ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); ret = lyd_validate(&st->dt1, LYD_OPT_CONFIG, NULL); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); /* and also test the embedded notification itself */ free(st->mem); ret = lyd_lyb_data_length(((struct lyd_node_anydata *)st->dt1->child)->value.mem); st->mem = malloc(ret); memcpy(st->mem, ((struct lyd_node_anydata *)st->dt1->child)->value.mem, ret); lyd_free_withsiblings(st->dt2); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_NOTIF | LYD_OPT_STRICT | LYD_OPT_NOEXTDEPS, NULL); assert_ptr_not_equal(st->dt2, NULL); /* parse the JSON again for this comparison */ lyd_free_withsiblings(st->dt1); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/ietf-netconf-notifications.json", LYD_JSON, LYD_OPT_NOTIF | LYD_OPT_TRUSTED, NULL); assert_ptr_not_equal(st->dt1, NULL); check_data_tree(st->dt1, st->dt2); } static void test_submodule_feature(void **state) { struct state *st = (*state); const struct lys_module *mod; int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); mod = ly_ctx_load_module(st->ctx, "feature-submodule-main", NULL); assert_non_null(mod); assert_int_equal(lys_features_enable(mod, "test-submodule-feature"), 0); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/test-submodule-feature.json", LYD_JSON, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_coliding_augments(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "augment-target", NULL)); assert_non_null(ly_ctx_load_module(st->ctx, "augment0", NULL)); assert_non_null(ly_ctx_load_module(st->ctx, "augment1", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/augment.xml", LYD_XML, LYD_OPT_CONFIG); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } static void test_leafrefs(void **state) { struct state *st = (*state); int ret; ly_ctx_set_searchdir(st->ctx, TESTS_DIR "/data/files"); assert_non_null(ly_ctx_load_module(st->ctx, "leafrefs2", NULL)); st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR "/data/files/leafrefs2.json", LYD_JSON, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt1, NULL); ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS); assert_int_equal(ret, 0); st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT); assert_ptr_not_equal(st->dt2, NULL); check_data_tree(st->dt1, st->dt2); } #endif int main(void) { const struct CMUnitTest tests[] = { UTEST(tests_leaflist), UTEST(tests_list), UTEST(tests_any), UTEST(test_ietf_interfaces, setup), UTEST(test_origin, setup), UTEST(test_statements, setup), UTEST(test_opaq, setup), UTEST(test_collisions, setup), #if 0 cmocka_unit_test_setup_teardown(test_types, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_annotations, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_similar_annot_names, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_many_child_annot, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_union, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_union2, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_collisions, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_anydata, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_submodule_feature, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_coliding_augments, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_leafrefs, setup_f, teardown_f), #endif }; return cmocka_run_group_tests(tests, NULL, NULL); }