From 7e92f67f4f9ce46fbfe7d189d43cfc8457d5984c Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 20 Dec 2022 20:09:18 +0100 Subject: [PATCH] RFC6022 montoring fix: submodules should report main module's namespace --- lib/src/clixon_netconf_monitoring.c | 4 +--- test/test_netconf_monitoring.sh | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/src/clixon_netconf_monitoring.c b/lib/src/clixon_netconf_monitoring.c index b556d3ee..138a7dc4 100644 --- a/lib/src/clixon_netconf_monitoring.c +++ b/lib/src/clixon_netconf_monitoring.c @@ -94,9 +94,7 @@ yang_modules(clicon_handle h, } cprintf(cb, ""); cprintf(cb, "yang"); - if ((y1 = yang_find(ym, Y_NAMESPACE, NULL)) != NULL){ - cprintf(cb, "%s", yang_argument_get(y1)); - } + cprintf(cb, "%s", yang_find_mynamespace(ym)); /* A local implementation may have other locations, how to configure? */ cprintf(cb, "NETCONF"); if ((dir = clicon_option_str(h,"CLICON_NETCONF_MONITORING_LOCATION")) != NULL){ diff --git a/test/test_netconf_monitoring.sh b/test/test_netconf_monitoring.sh index 186fc57e..350d3535 100755 --- a/test/test_netconf_monitoring.sh +++ b/test/test_netconf_monitoring.sh @@ -12,12 +12,14 @@ APPNAME=example cfg=$dir/conf_yang.xml fyang=$dir/clixon-example@2022-01-01.yang +fyangsub=$dir/clixon-sub@2022-01-01.yang cat < $cfg $cfg ${YANG_INSTALLDIR} + ${dir} $fyang false /usr/local/lib/$APPNAME/clispec @@ -36,6 +38,17 @@ module clixon-example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; + include clixon-sub; + revision 2022-01-01; +} +EOF + +cat < $fyangsub +submodule clixon-sub{ + yang-version 1.1; + belongs-to clixon-example { + prefix ex; + } revision 2022-01-01; } EOF @@ -59,8 +72,9 @@ new "Retrieving all state via operation" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "urn:ietf:params:netconf:base:1.0urn:ietf:params:netconf:base:1.1.*urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring.*.*" # 4.1. Retrieving Schema List via Operation +# match bith module and sub-module new "Retrieving Schema List via Operation" -expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "clixon-example2022-01-01yangurn:example:clixonNETCONF.*" +expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "clixon-example2022-01-01yangurn:example:clixonNETCONF.*clixon-sub2022-01-01yangurn:example:clixonNETCONF.*" # 4.2. Retrieving Schema Instances # From 2b. bar, version 2008-06-1 in YANG format, via get-schema @@ -100,11 +114,14 @@ if [ $BE -ne 0 ]; then stop_backend -f $cfg fi +# for some reason valgrind tests fail below? +if [ ${valgrindtest} -eq 0 ]; then # Error dont cleanup mem OK + YANGDIR=$YANG_INSTALLDIR if [ $BE -ne 0 ]; then - new "start backend -s init -f $cfg -o CLICON_YANG_MAIN_DIR=$YANGDIR" - start_backend -s init -f $cfg -o CLICON_YANG_MAIN_DIR=$YANGDIR + new "start backend -s init -f $cfg -o CLICON_YANG_MAIN_DIR=$YANGDIR -o CLICON_YANG_MAIN_FILE=$fyang" + start_backend -s init -f $cfg -o CLICON_YANG_MAIN_DIR=$YANGDIR fi new "wait backend" wait_backend @@ -140,6 +157,7 @@ EOF continue fi done +fi # valgrind rm -rf $dir