Fixed: Search function checked only own not for config false statement, should have checked all ancestors.

This commit is contained in:
Olof hagsand 2020-02-28 14:05:56 +01:00
parent 451adfaf1f
commit 760cdda49a
7 changed files with 142 additions and 100 deletions

View file

@ -76,6 +76,7 @@ Expected: February 2020
### Corrected Bugs ### Corrected Bugs
* Fixed: Search function checked only own not for config false statement, should have checked all ancestors.
* Fixed: Some restconf errors were wrongly formatted such as: `{"ietf-restconf:errors":{"error":{"rpc-error":` . There should be no `"rpc-error"` level. * Fixed: Some restconf errors were wrongly formatted such as: `{"ietf-restconf:errors":{"error":{"rpc-error":` . There should be no `"rpc-error"` level.
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt) * Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
* Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set * Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set

View file

@ -216,6 +216,7 @@ int yang_desc_schema_nodeid(yang_stmt *yn, char *schema_nodeid,
enum rfc_6020 keyword, yang_stmt **yres); enum rfc_6020 keyword, yang_stmt **yres);
int yang_mandatory(yang_stmt *ys); int yang_mandatory(yang_stmt *ys);
int yang_config(yang_stmt *ys); int yang_config(yang_stmt *ys);
int yang_config_ancestor(yang_stmt *ys);
int yang_features(clicon_handle h, yang_stmt *yt); int yang_features(clicon_handle h, yang_stmt *yt);
cvec *yang_arg2cvec(yang_stmt *ys, char *delimi); cvec *yang_arg2cvec(yang_stmt *ys, char *delimi);
int yang_key_match(yang_stmt *yn, char *name); int yang_key_match(yang_stmt *yn, char *name);

View file

@ -611,6 +611,46 @@ xml_search_indexvar_binary_pos(cxobj *x1,
done: done:
return retval; return retval;
} }
static int
xml_search_indexvar(cxobj *xp,
cxobj *x1,
int yangi,
int low,
int upper,
char *indexvar,
cxobj ***xvec,
size_t *xlen)
{
int retval = -1;
clixon_xvec *ivec = NULL;
int ilen;
int pos;
int eq = 0;
/* Check if (exactly one) explicit indexes in cvk */
if (xml_search_vector_get(xp, indexvar, &ivec) < 0)
goto done;
if (ivec){
ilen = clixon_xvec_len(ivec);
if ((pos = xml_search_indexvar_binary_pos(x1, indexvar,
ivec, 0,
ilen, ilen, &eq)) < 0)
goto done;
if (eq){ /* Found */
if (cxvec_append(clixon_xvec_i(ivec,pos), xvec, xlen) < 0)
goto done;
/* there may be more? */
if (search_multi_equals_xvec(ivec, x1, yangi, pos,
0, xvec, xlen) < 0)
goto done;
}
}
retval = 0;
done:
return retval;
}
#endif /* XML_EXPLICIT_INDEX */ #endif /* XML_EXPLICIT_INDEX */
/*! Find XML child under xp matching x1 using binary search /*! Find XML child under xp matching x1 using binary search
@ -657,40 +697,13 @@ xml_search_binary(cxobj *xp,
/* Here is right yang order == same yang? */ /* Here is right yang order == same yang? */
if (cmp == 0){ if (cmp == 0){
#ifdef XML_EXPLICIT_INDEX #ifdef XML_EXPLICIT_INDEX
if (indexvar != NULL){ if (indexvar){
clixon_xvec *ivec = NULL; if (xml_search_indexvar(xp, x1, yangi, low, upper, indexvar, xvec, xlen) < 0)
int ilen;
int pos;
int eq = 0;
/* Check if (exactly one) explicit indexes in cvk */
if (xml_search_vector_get(xp, indexvar, &ivec) < 0)
goto done; goto done;
if (ivec){
ilen = clixon_xvec_len(ivec);
#if 1 /* XXX This needs some heavy testing */
if ((pos = xml_search_indexvar_binary_pos(x1, indexvar,
ivec, 0,
ilen, ilen, &eq)) < 0)
goto done;
if (eq){ /* Found */
if (cxvec_append(clixon_xvec_i(ivec,pos), xvec, xlen) < 0)
goto done;
/* there may be more? */
if (search_multi_equals_xvec(ivec, x1, yangi, pos,
0, xvec, xlen) < 0)
goto done;
}
#else
if (xml_search_indexvar_binary(x1, indexvar,
ivec, 0,
ilen, ilen,
xvec, xlen) < 0)
goto done;
#endif
}
goto ok; goto ok;
} }
#endif #endif
/* >0 means search upper interval, <0 lower interval, = 0 is equal */
cmp = xml_cmp(x1, xc, 0, skip1, NULL); cmp = xml_cmp(x1, xc, 0, skip1, NULL);
if (cmp && !sorted){ /* Ordered by user (if not equal) */ if (cmp && !sorted){ /* Ordered by user (if not equal) */
retval = xml_find_keys_notsorted(xp, x1, yangi, mid, skip1, xvec, xlen); retval = xml_find_keys_notsorted(xp, x1, yangi, mid, skip1, xvec, xlen);
@ -753,7 +766,7 @@ xml_search_yang(cxobj *xp,
if ((xa = xml_child_i(xp, low)) == NULL || xml_type(xa) != CX_ATTR) if ((xa = xml_child_i(xp, low)) == NULL || xml_type(xa) != CX_ATTR)
break; break;
/* Find if non-config and if ordered-by-user */ /* Find if non-config and if ordered-by-user */
if (yang_config(yc)==0) if (yang_config_ancestor(yc)==0)
sorted = 0; sorted = 0;
else if (yang_keyword_get(yc) == Y_LIST || yang_keyword_get(yc) == Y_LEAF_LIST) else if (yang_keyword_get(yc) == Y_LIST || yang_keyword_get(yc) == Y_LEAF_LIST)
sorted = (yang_find(yc, Y_ORDERED_BY, "user") == NULL); sorted = (yang_find(yc, Y_ORDERED_BY, "user") == NULL);
@ -989,7 +1002,7 @@ xml_insert(cxobj *xp,
if ((xa = xml_child_i(xp, low)) == NULL || xml_type(xa)!=CX_ATTR) if ((xa = xml_child_i(xp, low)) == NULL || xml_type(xa)!=CX_ATTR)
break; break;
/* Find if non-config and if ordered-by-user */ /* Find if non-config and if ordered-by-user */
if (yang_config(y)==0) if (yang_config_ancestor(y)==0)
userorder = 1; userorder = 1;
else if (yang_keyword_get(y) == Y_LIST || yang_keyword_get(y) == Y_LEAF_LIST) else if (yang_keyword_get(y) == Y_LIST || yang_keyword_get(y) == Y_LEAF_LIST)
userorder = (yang_find(y, Y_ORDERED_BY, "user") != NULL); userorder = (yang_find(y, Y_ORDERED_BY, "user") != NULL);
@ -1026,7 +1039,7 @@ xml_sort_verify(cxobj *x0,
yang_stmt *ys; yang_stmt *ys;
/* Abort sort if non-config (=state) data */ /* Abort sort if non-config (=state) data */
if ((ys = xml_spec(x0)) != 0 && yang_config(ys)==0){ if ((ys = xml_spec(x0)) != 0 && yang_config_ancestor(ys)==0){
retval = 1; retval = 1;
goto done; goto done;
} }

View file

@ -249,7 +249,7 @@ xpath_list_optimize_fn(xpath_tree *xt,
if ((yp = xml_spec(xv)) == NULL) if ((yp = xml_spec(xv)) == NULL)
goto ok; goto ok;
/* or if not config data (state data should not be ordered) */ /* or if not config data (state data should not be ordered) */
if (yang_config(yp) == 0) if (yang_config_ancestor(yp) == 0)
goto ok; goto ok;
/* Check yang and that only a list with key as index is a special case can do bin search /* Check yang and that only a list with key as index is a special case can do bin search
* That is, ONLY check optimize cases of this type:_x[_y='_z'] * That is, ONLY check optimize cases of this type:_x[_y='_z']

View file

@ -2346,11 +2346,10 @@ yang_mandatory(yang_stmt *ys)
} }
/*! Return config state of this node /*! Return config state of this node
* config statement is default true. * @param[in] ys Yang statement
* @note a node with config=false may not have a sub statement where * @retval 0 If node has a config sub-statement and it is false
* config=true. And this function does not check the status of a parent. * @retval 1 If node has not config sub-statement or it is true
* @retval 0 if node has a config sub-statement and it is false * @see yang_config_ancestor which also takes ancestors into account, which you should normally do.
* @retval 1 node has not config sub-statement or it is true
*/ */
int int
yang_config(yang_stmt *ys) yang_config(yang_stmt *ys)
@ -2365,6 +2364,26 @@ yang_config(yang_stmt *ys)
return 1; return 1;
} }
/*! Return config state of this node taking parent into account
*
* config statement is default true.
* @param[in] ys Yang statement
* @retval 0 Node or one of its ancestor has config false
* @retval 1 Neither node nor any of its ancestors has config false
*/
int
yang_config_ancestor(yang_stmt *ys)
{
yang_stmt *yp;
yp = ys;
do {
if (yang_config(yp) == 0)
return 0;
} while((yp = yang_parent_get(yp)) != NULL);
return 1;
}
/*! Given a yang node, translate the argument string to a cv vector /*! Given a yang node, translate the argument string to a cv vector
* *
* @param[in] ys Yang statement * @param[in] ys Yang statement

View file

@ -12,6 +12,9 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Number of tests to generate XML for # Number of tests to generate XML for
max=9 max=9
# How many times to run ech test (go through some random numbers)
rep=10
# XML file (alt provide it in stdin after xpath) # XML file (alt provide it in stdin after xpath)
for (( i=1; i<$max; i++ )); do for (( i=1; i<$max; i++ )); do
eval xml$i=$dir/xml$i.xml eval xml$i=$dir/xml$i.xml
@ -155,6 +158,7 @@ module modb{
} }
EOF EOF
# This make it non-deterministic, some numbers may not work,...
rnd=$(( ( RANDOM % $nr ) )) rnd=$(( ( RANDOM % $nr ) ))
# Single string key # Single string key
@ -165,45 +169,42 @@ for (( i=0; i<$nr; i++ )); do
done done
echo -n '</x1>' >> $xml1 echo -n '</x1>' >> $xml1
new "instance-id single string key k1=a$rnd" for (( ii=0; ii<$rep; ii++ )); do
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"]" new "instance-id single string key k1=a$rnd"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$" expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string key /x1" new "instance-id single string key /x1"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1" expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1)" 0 "0: <x1 xmlns=\"urn:example:a\"><y><k1>a0</k1><z>foo0</z></y><y><k1>a1</k1><z>foo1</z></y>" # Assume at least two elements
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1)" 0 "0: <x1 xmlns=\"urn:example:a\"><y><k1>a0</k1><z>foo0</z></y><y><k1>a1</k1><z>foo1</z></y>" # Assume at least two elements
new "instance-id position specific position 5" new "instance-id position specific position 5"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[5]" # expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[5])" 0 "0: <y><k1>a13</k1><z>foo13</z>" # sort alphanumerivc wrong 1,10,2
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[5])" 0 "0: <y><k1>a13</k1><z>foo13</z>" # sort alphanumerivc wrong 1,10,2
new "instance-id single string key omit key" new "instance-id single string key omit key"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y)" 0 '^0: <y><k1>a0</k1><z>foo0</z></y> expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y)" 0 '^0: <y><k1>a0</k1><z>foo0</z></y>
1: <y><k1>a0</k1><z>foo0</z></y>' 1: <y><k1>a0</k1><z>foo0</z></y>'
# Fails and error handling # Fails and error handling
new "instance-id single string search non-index" new "instance-id single string search non-index"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"]" expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string search non-index (two variables, index first)" new "instance-id single string search non-index (two variables, index first)"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"][a:z=\"foo$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$" expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=\"a$rnd\"][a:z=\"foo$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string search non-index (two variables, index last)" new "instance-id single string search non-index (two variables, index last)"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"][a:k1=\"a$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$" expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:z=\"foo$rnd\"][a:k1=\"a$rnd\"] )" 0 "<y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
new "instance-id single string wrong module, notfound" new "instance-id single string wrong module, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /xxx:x1/a:y[a:k1=\"a$rnd\"] 2> /dev/null)" 255 '^$' expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /xxx:x1/a:y[a:k1=\"a$rnd\"] 2> /dev/null)" 255 '^$'
new "instance-id single string no module, notfound" new "instance-id single string no module, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /x1/a:y[a:k1=\"a$rnd\"] 2> /dev/null)" 255 '^$' expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /x1/a:y[a:k1=\"a$rnd\"] 2> /dev/null)" 255 '^$'
new "instance-id single string no sub-prefixes, notfound" new "instance-id single string no sub-prefixes, notfound"
echo "$clixon_util_path -f $xml1 -y $ydir -p /a:x1/y[k1=\"a$rnd\"]" expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/y[k1=\"a$rnd\"] 2> /dev/null)" 255 '^$'
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/y[k1=\"a$rnd\"] 2> /dev/null)" 255 '^$'
new "instance-id single string two keys, notfound" new "instance-id single string two keys, notfound"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=a$rnd][a:k2=a$rnd] 2> /dev/null)" 255 '^$' expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /a:x1/a:y[a:k1=a$rnd][a:k2=a$rnd] 2> /dev/null)" 255 '^$'
done
# Single int key # Single int key
new "generate list with $nr single int key to $xml2" new "generate list with $nr single int key to $xml2"
@ -213,9 +214,10 @@ for (( i=0; i<$nr; i++ )); do
done done
echo -n '</x2>' >> $xml2 echo -n '</x2>' >> $xml2
new "instance-id single int key k1=$rnd" for (( ii=0; ii<$rep; ii++ )); do
echo "$clixon_util_path -f $xml2 -y $ydir -p /a:x2/a:y[a:k1=\"$rnd\"]" new "instance-id single int key k1=$rnd"
expectpart "$($clixon_util_path -f $xml2 -y $ydir -p /a:x2/a:y[a:k1=\"$rnd\"])" 0 "^0: <y><k1>$rnd</k1><z>foo$rnd</z></y>$" expectpart "$($clixon_util_path -f $xml2 -y $ydir -p /a:x2/a:y[a:k1=\"$rnd\"])" 0 "^0: <y><k1>$rnd</k1><z>foo$rnd</z></y>$"
done
# Double string key # Double string key
new "generate list with $nr double string keys to $xml3 (two k2 entries per k1 key)" new "generate list with $nr double string keys to $xml3 (two k2 entries per k1 key)"
@ -229,23 +231,21 @@ echo -n "<y><k1>a0</k1><k2></k2><z>foo0</z></y>" >> $xml3
echo -n "<y><k1>a1</k1><k2></k2><z>foo1</z></y>" >> $xml3 echo -n "<y><k1>a1</k1><k2></k2><z>foo1</z></y>" >> $xml3
echo -n '</x3>' >> $xml3 echo -n '</x3>' >> $xml3
new "instance-id double string key k1=a$rnd k2=b$rnd" for (( ii=0; ii<$rep; ii++ )); do
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a$rnd\"][k2=\"b$rnd\"]" new "instance-id double string key k1=a$rnd k2=b$rnd"
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a$rnd\"][k2=\"b$rnd\"])" 0 "0: <y><k1>a$rnd</k1><k2>b$rnd</k2><z>foob$rnd</z></y>" expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a$rnd\"][k2=\"b$rnd\"])" 0 "0: <y><k1>a$rnd</k1><k2>b$rnd</k2><z>foob$rnd</z></y>"
new "instance-id double string key k1=a$rnd, - empty k2 string" new "instance-id double string key k1=a$rnd, - empty k2 string"
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"][k2=\"\"]" expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"][k2=\"\"])" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>"
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"][k2=\"\"])" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>"
new "instance-id double string key k1=a$rnd, - no k2 string - three matches" new "instance-id double string key k1=a$rnd, - no k2 string - three matches"
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"]" expecteq "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"])" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>
expecteq "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[k1=\"a1\"])" 0 "0: <y><k1>a1</k1><k2/><z>foo1</z></y>
1: <y><k1>a1</k1><k2>a1</k2><z>foo1</z></y> 1: <y><k1>a1</k1><k2>a1</k2><z>foo1</z></y>
2: <y><k1>a1</k1><k2>b1</k2><z>foob1</z></y>" 2: <y><k1>a1</k1><k2>b1</k2><z>foob1</z></y>"
new "instance-id double string specific position 5" new "instance-id double string specific position 5"
echo "$clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[5]" expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[5])" 0 "0: <y><k1>a1</k1><k2>b1</k2><z>foob1</z></y>" # sort alphanumerivc wrong 1,10,2
expectpart "$($clixon_util_path -f $xml3 -y $ydir -p /a:x3/a:y[5])" 0 "0: <y><k1>a1</k1><k2>b1</k2><z>foob1</z></y>" # sort alphanumerivc wrong 1,10,2 done
# Leaf-list # Leaf-list
new "generate leaf-list int keys to $xml4" new "generate leaf-list int keys to $xml4"
@ -255,9 +255,10 @@ for (( i=0; i<$nr; i++ )); do
done done
echo -n '</x4>' >> $xml4 echo -n '</x4>' >> $xml4
new "instance-id leaf-list k1=a$rnd" for (( ii=0; ii<$rep; ii++ )); do
echo "$clixon_util_path -f $xml4 -y $ydir -p /a:x4/a:y[.=\"a$rnd\"]" new "instance-id leaf-list k1=a$rnd"
expectpart "$($clixon_util_path -f $xml4 -y $ydir -p /a:x4/a:y[.=\"a$rnd\"])" 0 "^0: <y>a$rnd</y>$" expectpart "$($clixon_util_path -f $xml4 -y $ydir -p /a:x4/a:y[.=\"a$rnd\"])" 0 "^0: <y>a$rnd</y>$"
done
# Single string key direct under root # Single string key direct under root
new "generate list with $nr single string key to $xml5" new "generate list with $nr single string key to $xml5"
@ -266,8 +267,10 @@ for (( i=0; i<$nr; i++ )); do
echo -n "<x5 xmlns=\"urn:example:a\"><k1>a$i</k1><z>foo$i</z></x5>" >> $xml5 echo -n "<x5 xmlns=\"urn:example:a\"><k1>a$i</k1><z>foo$i</z></x5>" >> $xml5
done done
new "instance-id direct under root single string key k1=a$rnd" for (( ii=0; ii<$rep; ii++ )); do
expectpart "$($clixon_util_path -f $xml5 -y $ydir -p /a:x5[k1=\"a$rnd\"])" 0 "^0: <x5 xmlns=\"urn:example:a\"><k1>a$rnd</k1><z>foo$rnd</z></x5>$" new "instance-id direct under root single string key k1=a$rnd"
expectpart "$($clixon_util_path -f $xml5 -y $ydir -p /a:x5[k1=\"a$rnd\"])" 0 "^0: <x5 xmlns=\"urn:example:a\"><k1>a$rnd</k1><z>foo$rnd</z></x5>$"
done
# Depth and augment # Depth and augment
# Deep augmented xml path # Deep augmented xml path
@ -282,12 +285,13 @@ for (( i=0; i<$nr; i++ )); do
done done
echo -n '</x6>' >> $xml6 echo -n '</x6>' >> $xml6
new "instance-id double string key b$rnd,b$rnd in mod b" for (( ii=0; ii<$rep; ii++ )); do
echo "$clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"]" new "instance-id double string key b$rnd,b$rnd in mod b"
expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"])" 0 "0: <yy><kk1>b$rnd</kk1><kk2>b$rnd</kk2><zz>foo$rnd</zz><y xmlns=\"urn:example:a\"><k1>a0</k1><k2>a0</k2><z>foo0</z></y><y xmlns=\"urn:example:a\"><k1>a1</k1><k2>a1</k2><z>foo1</z></y><y xmlns=\"urn:example:a\"><k1>a2</k1><k2>a2</k2><z>foo2</z></y></yy>" expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"])" 0 "0: <yy><kk1>b$rnd</kk1><kk2>b$rnd</kk2><zz>foo$rnd</zz><y xmlns=\"urn:example:a\"><k1>a0</k1><k2>a0</k2><z>foo0</z></y><y xmlns=\"urn:example:a\"><k1>a1</k1><k2>a1</k2><z>foo1</z></y><y xmlns=\"urn:example:a\"><k1>a2</k1><k2>a2</k2><z>foo2</z></y></yy>"
new "instance-id double string key a$rnd,b$rnd in modb + augmented in moda" new "instance-id double string key a$rnd,b$rnd in modb + augmented in moda"
expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"]/a:y[k1=\"a1\"][k2=\"a1\"]/a:z[.=\"foo1\"])" 0 "0: <z>foo1</z>" expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /b:x6/b:yy[kk1=\"b$rnd\"][kk2=\"b$rnd\"]/a:y[k1=\"a1\"][k2=\"a1\"]/a:z[.=\"foo1\"])" 0 "0: <z>foo1</z>"
done
# Single list ordered by user # Single list ordered by user
new "generate list with $nr single string key to $xml7" new "generate list with $nr single string key to $xml7"
@ -297,9 +301,10 @@ for (( i=0; i<$nr; i++ )); do
done done
echo -n '</x7>' >> $xml7 echo -n '</x7>' >> $xml7
new "instance-id single string key k1=a$rnd ordered by user" for (( ii=0; ii<$rep; ii++ )); do
echo "$clixon_util_path -f $xml7 -y $ydir -p /a:x7/a:y[a:k1=\"a$rnd\"]" new "instance-id single string key k1=a$rnd ordered by user"
expectpart "$($clixon_util_path -f $xml7 -y $ydir -p /a:x7/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$" expectpart "$($clixon_util_path -f $xml7 -y $ydir -p /a:x7/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
done
# Single list state data (non-config) # Single list state data (non-config)
new "generate list with $nr single string key to $xml8" new "generate list with $nr single string key to $xml8"
@ -309,8 +314,11 @@ for (( i=0; i<$nr; i++ )); do
done done
echo -n '</x8>' >> $xml8 echo -n '</x8>' >> $xml8
new "instance-id single string key k1=a$rnd ordered by user" for (( ii=0; ii<$rep; ii++ )); do
expectpart "$($clixon_util_path -f $xml8 -y $ydir -p /a:x8/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$" rnd=$(( ( RANDOM % $nr ) ))
new "instance-id single string key k1=a$rnd ordered by user"
expectpart "$($clixon_util_path -f $xml8 -y $ydir -p /a:x8/a:y[a:k1=\"a$rnd\"])" 0 "^0: <y><k1>a$rnd</k1><z>foo$rnd</z></y>$"
done
rm -rf $dir rm -rf $dir