clixon_util_path did not sort XML properly

This commit is contained in:
Olof hagsand 2020-02-08 17:00:47 +01:00
parent a674af6f2c
commit 5831c053fa
6 changed files with 24 additions and 10 deletions

View file

@ -12,6 +12,11 @@ The directory contains the following files:
start.sh Start containers
startsystem.sh Internal start script copied to inside the container (dont run from shell)
How to run the tests:
```
$ make test
```
How to build and start the container (called clixon-system):
```
$ make docker
@ -60,4 +65,4 @@ You trigger the test scripts inside the container using `make test`.
If you want to edit clixon code so it runs in the container?
You either
(1) "persistent": make your changes in the actual clixon code and commit; make clean to remove the local clone; make test again
(2) "volatile" edit the local clone; make test.
(2) "volatile" edit the local clone, (in the subdir); `make test`.

View file

@ -696,8 +696,8 @@ clixon_trim(char *str)
* @param[in] s1 String 1
* @param[in] s2 String 2
* @retval 0 Equal
* @retval -1 Not equal
* @retval 1 Not equal
* @retval <0 s1 is less than s2
* @retval >0 s1 is greater than s2
*/
int
clicon_strcmp(char *s1,

View file

@ -972,7 +972,9 @@ xml_spec_populate(cxobj *x,
if (xml2ns(x, xml_prefix(x), &ns) < 0)
goto done;
if (xp && (yparent = xml_spec(xp)) != NULL){
#ifdef DEBUG
clicon_debug(1, "%s yang parent:%s", __FUNCTION__, yang_argument_get(yparent));
#endif
y = yang_find_datanode(yparent, name);
}
else if (yspec){ /* XXX this gives false positives */

View file

@ -219,14 +219,9 @@ main(int argc,
/* Populate */
if (xml_apply0(x1, CX_ELMNT, xml_spec_populate, yspec) < 0)
goto done;
/* Sort */
if (xml_apply0(x1, CX_ELMNT, xml_sort, h) < 0)
goto done;
/* Add default values */
if (xml_apply(x1, CX_ELMNT, xml_default, h) < 0)
goto done;
if (xml_apply0(x1, -1, xml_sort_verify, h) < 0)
clicon_log(LOG_NOTICE, "%s: sort verify failed", __FUNCTION__);
if ((ret = xml_yang_validate_all_top(h, x1, &xerr)) < 0)
goto done;
if (ret > 0 && (ret = xml_yang_validate_add(h, x1, &xerr)) < 0)
@ -242,6 +237,10 @@ main(int argc,
goto done;
}
}
if (xml_apply0(x, CX_ELMNT, xml_sort, h) < 0)
goto done;
if (xml_apply0(x, -1, xml_sort_verify, h) < 0)
clicon_log(LOG_NOTICE, "%s: sort verify failed", __FUNCTION__);
}
if (api_path_p){
if ((ret = clixon_xml_find_api_path(x, yspec, &xvec, &xlen, "%s", path)) < 0)
@ -264,6 +263,8 @@ main(int argc,
}
retval = 0;
done:
if (yspec != NULL)
yspec_free(yspec);
if (cb)
cbuf_free(cb);
if (xvec)
@ -272,7 +273,11 @@ main(int argc,
free(buf);
if (x)
xml_free(x);
if (xcfg)
xml_free(xcfg);
if (fd > 0)
close(fd);
if (h)
clicon_handle_exit(h);
return retval;
}

View file

@ -120,8 +120,6 @@ main(int argc,
goto done;
if (clicon_conf_xml_set(h, xcfg) < 0)
goto done;
xcfg = xml_new("clixon-config", NULL, NULL);
clicon_conf_xml_set(h, xcfg);
optind = 1;
@ -264,6 +262,8 @@ main(int argc,
done:
if (cbret)
cbuf_free(cbret);
if (xcfg)
xml_free(xcfg);
if (xt)
xml_free(xt);
if (cb)

View file

@ -355,6 +355,8 @@ main(int argc,
xml_nsctx_free(nsc);
if (xc)
ctx_free(xc);
if (xcfg)
xml_free(xcfg);
if (xv)
free(xv);
if (buf)