From 965cce5e5dc2be00e0d49a38cadfbda119e114fb Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 27 May 2021 14:55:04 +0200 Subject: [PATCH] * Added SM_RUNNING_STARTUP to translation table * Fixed https://github.com/clicon/clixon/issues/224 yet again by addressing a mixed xml and yang namespace xpath case --- lib/src/clixon_options.c | 5 +++-- lib/src/clixon_validate.c | 7 +++++-- lib/src/clixon_xpath_eval.c | 7 +++++++ test/test_leafref_augment.sh | 21 --------------------- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index 097bc505..0e8361a6 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -96,9 +96,10 @@ static const map_str2int cli_genmodel_map[] = { see clixon-config.yang type startup_mode */ static const map_str2int startup_mode_map[] = { {"none", SM_NONE}, - {"running", SM_RUNNING}, - {"startup", SM_STARTUP}, {"init", SM_INIT}, + {"running", SM_RUNNING}, + {"startup", SM_STARTUP}, + {"startup", SM_RUNNING_STARTUP}, {NULL, -1} }; diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c index 57a67e0a..d611f198 100644 --- a/lib/src/clixon_validate.c +++ b/lib/src/clixon_validate.c @@ -1212,8 +1212,11 @@ xml_yang_validate_all(clicon_handle h, continue; xpath = yang_argument_get(yc); /* "must" has xpath argument */ /* the context node is the node in the accessible tree for - * which the "must" statement is defined. */ - nsc = NULL; + * which the "must" statement is defined. + * The set of namespace declarations is the set of all "import" statements' + */ + if (xml_nsctx_yang(yc, &nsc) < 0) + goto done; if ((nr = xpath_vec_bool(xt, nsc, "%s", xpath)) < 0) goto done; if (!nr){ diff --git a/lib/src/clixon_xpath_eval.c b/lib/src/clixon_xpath_eval.c index 7c75ad1c..b67976a2 100644 --- a/lib/src/clixon_xpath_eval.c +++ b/lib/src/clixon_xpath_eval.c @@ -151,6 +151,13 @@ nodetest_eval_node(cxobj *x, nsxpath = xml_nsctx_get(nsc, prefix2); if (nsxml != NULL && nsxpath != NULL) retval = (strcmp(nsxml, nsxpath) == 0); + else if (nsxpath == NULL){ + /* We have a namespace from xml, but none in yang. + * This can happen in eg augments and ../foo, where foo is + * augmented from another namespace + */ + retval = 1; + } else retval = (nsxml == nsxpath); /* True only if both are NULL */ } diff --git a/test/test_leafref_augment.sh b/test/test_leafref_augment.sh index 8e165db2..2a8e3c22 100755 --- a/test/test_leafref_augment.sh +++ b/test/test_leafref_augment.sh @@ -144,27 +144,6 @@ if [ $BE -ne 0 ]; then wait_backend fi -# Test top-level, default prefix, wring leafref prefix and typedef path -XML=$(cat < - x - - - y - x - -EOF -) - -new "leafref augment+leafref config top-level" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$XML]]>]]>" "^]]>]]>$" - -new "leafref augment+leafref validate top-level wrong prefix" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^applicationbad-elementxerrorLeafref validation failed: No leaf x matching path /ex:sender/ex:name]]>]]>$" - -new "netconf discard-changes" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" - # Test top-level, default prefix, correct leafref and typedef path XML=$(cat <