diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c1c5a1e..a526af29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,9 @@ Expected: April
### Minor features
+* Made a separate Clixon datastore XML/JSON top-level symbol
+ * Replaces the hardcoded "config" keyword.
+ * Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h
* Introduced a delay before making process start/stop/restart processes for race conditions when configuring eg restconf
* For restconf `CLICON_BACKEND_RESTCONF_PROCESS`, restart restconf if restconf is edited.
@@ -39,7 +42,6 @@ Expected: April
* Reverted blocked signal behavior introduced in 5.0.
-
## 5.0.0
27 February 2021
diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c
index c12d41f2..41326a24 100644
--- a/apps/backend/backend_client.c
+++ b/apps/backend/backend_client.c
@@ -443,7 +443,7 @@ client_get_config_only(clicon_handle h,
if (xret==NULL)
cprintf(cbret, "");
else{
- if (xml_name_set(xret, "data") < 0)
+ if (xml_name_set(xret, NETCONF_OUTPUT_DATA) < 0)
goto done;
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
goto done;
@@ -638,10 +638,13 @@ from_client_edit_config(clicon_handle h,
}
}
/* Get config element */
- if ((xc = xpath_first(xn, nsc, "%s%sconfig", prefix?prefix:"", prefix?":":"")) == NULL){
+ if ((xc = xpath_first(xn, nsc, "%s%s%s",
+ prefix?prefix:"",
+ prefix?":":"",
+ NETCONF_INPUT_CONFIG)) == NULL){
cprintf(cbx, "Element not found, or mismatching prefix %s for namespace %s",
prefix?prefix:"null", NETCONF_BASE_NAMESPACE);
- if (netconf_missing_element(cbret, "protocol", "config", cbuf_get(cbx)) < 0)
+ if (netconf_missing_element(cbret, "protocol", NETCONF_INPUT_CONFIG, cbuf_get(cbx)) < 0)
goto done;
goto ok;
}
@@ -1215,7 +1218,7 @@ from_client_get(clicon_handle h,
if (xret==NULL)
cprintf(cbret, "");
else{
- if (xml_name_set(xret, "data") < 0)
+ if (xml_name_set(xret, NETCONF_OUTPUT_DATA) < 0)
goto done;
/* Top level is data, so add 1 to depth if significant */
if (clicon_xml2cbuf(cbret, xret, 0, 0, depth>0?depth+1:depth) < 0)
diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c
index 0f34cb34..0946ed39 100644
--- a/apps/backend/backend_commit.c
+++ b/apps/backend/backend_commit.c
@@ -399,32 +399,37 @@ startup_commit(clicon_handle h,
goto done;
if (ret == 0)
goto fail;
- /* 8. Call plugin transaction commit callbacks */
- if (plugin_transaction_commit_all(h, td) < 0)
- goto done;
- /* After commit, make a post-commit call (sure that all plugins have committed) */
- if (plugin_transaction_commit_done_all(h, td) < 0)
- goto done;
- /* Clear cached trees from default values and marking */
- if (xmldb_get0_clear(h, td->td_target) < 0)
- goto done;
+ /* 8. Call plugin transaction commit callbacks */
+ if (plugin_transaction_commit_all(h, td) < 0)
+ goto done;
+ /* After commit, make a post-commit call (sure that all plugins have committed) */
+ if (plugin_transaction_commit_done_all(h, td) < 0)
+ goto done;
+ /* Clear cached trees from default values and marking */
+ if (xmldb_get0_clear(h, td->td_target) < 0)
+ goto done;
- /* [Delete and] create running db */
- if (xmldb_exists(h, "running") == 1){
+ /* [Delete and] create running db */
+ if (xmldb_exists(h, "running") == 1){
if (xmldb_delete(h, "running") != 0 && errno != ENOENT)
goto done;;
}
if (xmldb_create(h, "running") < 0)
goto done;
- /* 9, write (potentially modified) tree to running
- * XXX note here startup is copied to candidate, which may confuse everything
- * XXX default values are overwritten
- */
- if ((ret = xmldb_put(h, "running", OP_REPLACE, td->td_target,
- clicon_username_get(h), cbret)) < 0)
- goto done;
- if (ret == 0)
- goto fail;
+ /* 9, write (potentially modified) tree to running
+ * XXX note here startup is copied to candidate, which may confuse everything
+ * XXX default values are overwritten
+ */
+ if (td->td_target)
+ /* target is datastore, but is here transformed to mimic an incoming
+ * edit-config
+ */
+ xml_name_set(td->td_target, NETCONF_INPUT_CONFIG);
+ if ((ret = xmldb_put(h, "running", OP_REPLACE, td->td_target,
+ clicon_username_get(h), cbret)) < 0)
+ goto done;
+ if (ret == 0)
+ goto fail;
/* 10. Call plugin transaction end callbacks */
plugin_transaction_end_all(h, td);
retval = 1;
@@ -432,8 +437,8 @@ startup_commit(clicon_handle h,
if (td){
if (retval < 1)
plugin_transaction_abort_all(h, td);
- xmldb_get0_free(h, &td->td_target);
- transaction_free(td);
+ xmldb_get0_free(h, &td->td_target);
+ transaction_free(td);
}
return retval;
fail: /* cbret should be set */
diff --git a/apps/backend/backend_plugin.c b/apps/backend/backend_plugin.c
index 37902a00..2f75fcdd 100644
--- a/apps/backend/backend_plugin.c
+++ b/apps/backend/backend_plugin.c
@@ -255,7 +255,7 @@ clixon_plugin_statedata_one(clixon_plugin *cp,
cxobj *x = NULL;
if ((fn = cp->cp_api.ca_statedata) != NULL){
- if ((x = xml_new("config", NULL, CX_ELMNT)) == NULL)
+ if ((x = xml_new(XML_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
goto done;
if (fn(h, nsc, xpath, x) < 0){
if (clicon_errno < 0)
diff --git a/apps/backend/backend_startup.c b/apps/backend/backend_startup.c
index 8ddf5a55..f7ff0b1d 100644
--- a/apps/backend/backend_startup.c
+++ b/apps/backend/backend_startup.c
@@ -88,6 +88,7 @@ db_merge(clicon_handle h,
/* Get data as xml from db1 */
if (xmldb_get0(h, (char*)db1, YB_MODULE, NULL, NULL, 0, &xt, NULL) < 0)
goto done;
+ xml_name_set(xt, NETCONF_INPUT_CONFIG);
/* Merge xml into db2. Without commit */
retval = xmldb_put(h, (char*)db2, OP_MERGE, xt, clicon_username_get(h), cbret);
done:
@@ -168,8 +169,10 @@ load_extraxml(clicon_handle h,
{
int retval = -1;
cxobj *xt = NULL;
+ cxobj *xerr = NULL;
FILE *fp = NULL;
yang_stmt *yspec = NULL;
+ int ret;
if (filename == NULL)
return 1;
@@ -178,11 +181,25 @@ load_extraxml(clicon_handle h,
goto done;
}
yspec = clicon_dbspec_yang(h);
- if (clixon_xml_parse_file(fp, YB_MODULE, yspec, NULL, &xt, NULL) < 0)
+ /* No yang check yet because it has as top symbol, do it later after that is removed */
+ if (clixon_xml_parse_file(fp, YB_NONE, yspec, NULL, &xt, &xerr) < 0)
goto done;
/* Replace parent w first child */
if (xml_rootchild(xt, 0, &xt) < 0)
+ goto done;
+ /* Ensure edit-config "config" statement */
+ if (xt)
+ xml_name_set(xt, NETCONF_INPUT_CONFIG);
+ /* Now we can yang bind */
+ if ((ret = xml_bind_yang(xt, YB_MODULE, yspec, &xerr)) < 0)
goto done;
+ if (ret == 0){
+ if (netconf_err2cb(xerr, cbret) < 0)
+ goto done;
+ retval = 0;
+ goto done;
+ }
+
/* Merge user reset state */
retval = xmldb_put(h, (char*)db, OP_MERGE, xt, clicon_username_get(h), cbret);
done:
diff --git a/apps/cli/cli_common.c b/apps/cli/cli_common.c
index d7e669fa..15346b16 100644
--- a/apps/cli/cli_common.c
+++ b/apps/cli/cli_common.c
@@ -269,7 +269,7 @@ cli_dbxml(clicon_handle h,
if (api_path_fmt2api_path(api_path_fmt, cvv, &api_path, &cvv_i) < 0)
goto done;
/* Create config top-of-tree */
- if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
+ if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
goto done;
xbot = xtop;
if (api_path){
@@ -834,8 +834,8 @@ load_config_file(clicon_handle h,
goto done;
x = NULL;
while ((x = xml_child_each(xt, x, -1)) != NULL) {
- /* Ensure top-level is "config", maybe this is too rough? */
- xml_name_set(x, "config");
+ /* Read as datastore-top but transformed into an edit-config "config" */
+ xml_name_set(x, NETCONF_INPUT_CONFIG);
if (clicon_xml2cbuf(cbxml, x, 0, 0, -1) < 0)
goto done;
}
@@ -919,7 +919,7 @@ save_config_file(clicon_handle h,
/* get-config returns a tree. Save as tree so it can be used
* as data-store.
*/
- if (xml_name_set(xt, "config") < 0)
+ if (xml_name_set(xt, DATASTORE_TOP_SYMBOL) < 0)
goto done;
if ((f = fopen(filename, "w")) == NULL){
clicon_err(OE_CFG, errno, "Creating file %s", filename);
@@ -1166,7 +1166,7 @@ cli_unlock(clicon_handle h,
/*! Copy one configuration object to antother
*
- * Works for objects that are items ina yang list with a keyname, eg as:
+ * Works for objects that are items in a yang list with a keyname, eg as:
* list sender{
* key name;
* leaf name{...
@@ -1270,11 +1270,11 @@ cli_copy_config(clicon_handle h,
}
toname = cv_string_get(tocv);
/* Create copy xml tree x2 */
- if ((x2 = xml_new("config", NULL, CX_ELMNT)) == NULL)
+ if ((x2 = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
goto done;
if (xml_copy(x1, x2) < 0)
goto done;
- xml_name_set(x2, "config");
+ xml_name_set(x2, NETCONF_INPUT_CONFIG);
cprintf(cb, "/%s", keyname);
if ((x = xpath_first(x2, nsc, "%s", cbuf_get(cb))) == NULL){
diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c
index 4d6a7f6c..d0d72473 100644
--- a/apps/cli/cli_show.c
+++ b/apps/cli/cli_show.c
@@ -166,7 +166,7 @@ expand_dbvar(void *h,
xcur = xt; /* default top-of-tree */
xpathcur = xpath;
/* Create config top-of-tree */
- if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
+ if ((xtop = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
goto done;
xbot = xtop;
/* This is primarily to get "y",
diff --git a/apps/restconf/restconf_main_evhtp.c b/apps/restconf/restconf_main_evhtp.c
index 474f363b..b74a805f 100644
--- a/apps/restconf/restconf_main_evhtp.c
+++ b/apps/restconf/restconf_main_evhtp.c
@@ -716,7 +716,7 @@ usage(clicon_handle h,
fprintf(stderr, "usage:%s [options]\n"
"where options are\n"
"\t-h \t\t Help\n"
- "\t-D \t Debug level _ overrides any config debug setting\n"
+ "\t-D \t Debug level, overrides any config debug setting\n"
"\t-f \t Configuration file (mandatory)\n"
"\t-E \t Extra configuration file directory\n"
"\t-l > \t Log on (s)yslog, (f)ile (syslog is default)\n"
diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c
index 5fd7dfdc..0f3bfdc2 100644
--- a/apps/restconf/restconf_methods.c
+++ b/apps/restconf/restconf_methods.c
@@ -305,7 +305,7 @@ api_data_write(clicon_handle h,
else
op = OP_REPLACE; /* OP_CREATE if it does not exist */
/* Create config top-of-tree */
- if ((xtop = xml_new("config", NULL, CX_ELMNT)) == NULL)
+ if ((xtop = xml_new(NETCONF_INPUT_CONFIG, NULL, CX_ELMNT)) == NULL)
goto done;
/* Translate api_path to xml in the form of xtop/xbot */
xbot = xtop;
@@ -480,7 +480,7 @@ api_data_write(clicon_handle h,
*/
dname = xml_name(xdata);
if (api_path==NULL) {
- if (strcmp(dname, "data")!=0){
+ if (strcmp(dname, NETCONF_OUTPUT_DATA)!=0){
if (netconf_bad_element_xml(&xerr, "application", dname,
"Data element does not match top-level data") < 0)
goto done;
@@ -497,7 +497,7 @@ api_data_write(clicon_handle h,
if (xtop) /* also xbot */
xml_free(xtop);
xtop = xdata;
- xml_name_set(xtop, "config");
+ xml_name_set(xtop, NETCONF_INPUT_CONFIG);
/* remove default namespace */
if ((xa = xml_find_type(xtop, NULL, "xmlns", CX_ATTR)) != NULL){
if (xml_rm(xa) < 0)
@@ -818,7 +818,7 @@ api_data_delete(clicon_handle h,
for (i=0; i...
*/
diff --git a/apps/restconf/restconf_root.c b/apps/restconf/restconf_root.c
index 33e8a0c6..9dfe652f 100644
--- a/apps/restconf/restconf_root.c
+++ b/apps/restconf/restconf_root.c
@@ -471,7 +471,7 @@ api_root_restconf(clicon_handle h,
if (api_yang_library_version(h, req, pretty, media_out) < 0)
goto done;
}
- else if (strcmp(api_resource, "data") == 0){ /* restconf, skip /api/data */
+ else if (strcmp(api_resource, NETCONF_OUTPUT_DATA) == 0){ /* restconf, skip /api/data */
if (api_data(h, req, path, pcvec, 2, qvec, indata,
pretty, media_out, IETF_DS_NONE) < 0)
goto done;
diff --git a/include/clixon_custom.h b/include/clixon_custom.h
index 931dc163..3ae8dcf2 100644
--- a/include/clixon_custom.h
+++ b/include/clixon_custom.h
@@ -92,3 +92,11 @@
* clixon-4.4
*/
#define STATE_ORDERED_BY_SYSTEM
+
+/* Top-symbol in clixon datastores
+ * This is traditionally same as NETCONF_INPUT_CONFIG ("config") but can be different
+ * If you change this, you need to change test shell variable in lib.sh: DATASTORE_TOP
+ * Consider making this an option or configure option
+ * see XMLDB_CONFIG_HACK
+ */
+#define DATASTORE_TOP_SYMBOL "config"
diff --git a/lib/clixon/clixon_plugin.h b/lib/clixon/clixon_plugin.h
index 8c932da3..302befab 100644
--- a/lib/clixon/clixon_plugin.h
+++ b/lib/clixon/clixon_plugin.h
@@ -363,7 +363,7 @@ int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *s
int upgrade_callback_delete_all(clicon_handle h);
int upgrade_callback_call(clicon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret);
-const clixon_auth_type_t clixon_auth_type_str2int(char *auth_type);
+const int clixon_auth_type_str2int(char *auth_type);
const char *clixon_auth_type_int2str(clixon_auth_type_t auth_type);
diff --git a/lib/clixon/clixon_xml.h b/lib/clixon/clixon_xml.h
index b3a9b435..a54d8eb1 100644
--- a/lib/clixon/clixon_xml.h
+++ b/lib/clixon/clixon_xml.h
@@ -57,6 +57,26 @@
* operations, content, and the element.
*/
#define YANG_XML_NAMESPACE "urn:ietf:params:xml:ns:yang:1"
+
+/* Input symbol for netconf edit-config (+validate)
+ * ietf-netconf.yang defines is as input:
+ * choice edit-content {
+ * anyxml config;
+ * See also DATASTORE_TOP_SYMBOL which is the clixon datastore top symbol. By default also config
+ */
+#define NETCONF_INPUT_CONFIG "config"
+
+/* Output symbol for netconf get/get-config
+ * ietf-netconf.yang defines it as output:
+ * output { anyxml data;
+ */
+#define NETCONF_OUTPUT_DATA "data"
+
+/* Name of xml top object created by xml parse functions
+ * This is a "neutral" symbol without any meaning as opposed to the previous symbols ^
+ */
+#define XML_TOP_SYMBOL "top"
+
/*
* Types
*/
@@ -147,6 +167,7 @@ typedef struct clixon_xml_vec clixon_xvec; /* struct defined in clicon_xml_vec.c
#define XML_FLAG_CHANGE 0x08 /* Node is changed (commits) or child changed rec */
#define XML_FLAG_NONE 0x10 /* Node is added as NONE */
#define XML_FLAG_DEFAULT 0x20 /* Added when a value is set as default @see xml_default */
+#define XML_FLAG_TOP 0x40 /* Top datastore symbol */
/*
* Prototypes
diff --git a/lib/src/clixon_client.c b/lib/src/clixon_client.c
index 06b51299..15b84d6d 100644
--- a/lib/src/clixon_client.c
+++ b/lib/src/clixon_client.c
@@ -407,7 +407,7 @@ clixon_client_get_xdata(int sock,
goto done; /* Not fatal */
}
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
- if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
+ if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
goto done;
}
else{
diff --git a/lib/src/clixon_datastore.c b/lib/src/clixon_datastore.c
index 31b6a29f..60dd9f74 100644
--- a/lib/src/clixon_datastore.c
+++ b/lib/src/clixon_datastore.c
@@ -217,6 +217,7 @@ xmldb_copy(clicon_handle h,
else if (x2 == NULL){ /* create x2 and copy from x1 */
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
goto done;
+ xml_flag_set(x2, XML_FLAG_TOP);
if (xml_copy(x1, x2) < 0)
goto done;
}
@@ -224,6 +225,7 @@ xmldb_copy(clicon_handle h,
xml_free(x2);
if ((x2 = xml_new(xml_name(x1), NULL, CX_ELMNT)) == NULL)
goto done;
+ xml_flag_set(x2, XML_FLAG_TOP);
if (xml_copy(x1, x2) < 0)
goto done;
}
@@ -372,7 +374,7 @@ xmldb_exists(clicon_handle h,
return retval;
}
-/*! Clear database cache if any for mem/size optimization only
+/*! Clear database cache if any for mem/size optimization only, not file itself
* @param[in] h Clicon handle
* @param[in] db Database
* @retval -1 Error
diff --git a/lib/src/clixon_datastore_read.c b/lib/src/clixon_datastore_read.c
index 64855434..bc8f9a84 100644
--- a/lib/src/clixon_datastore_read.c
+++ b/lib/src/clixon_datastore_read.c
@@ -102,9 +102,9 @@ singleconfigroot(cxobj *xt,
x = NULL;
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){
i++;
- if (strcmp(xml_name(x), "config")){
- clicon_err(OE_DB, ENOENT, "Wrong top-element %s expected config",
- xml_name(x));
+ if (strcmp(xml_name(x), DATASTORE_TOP_SYMBOL)){
+ clicon_err(OE_DB, ENOENT, "Wrong top-element %s expected %s",
+ xml_name(x), DATASTORE_TOP_SYMBOL);
goto done;
}
}
@@ -462,7 +462,7 @@ xmldb_readfile(clicon_handle h,
if ((ret = clixon_json_parse_file(fp, yb, yspec, &x0, NULL)) < 0) /* XXX: ret == 0*/
goto done;
}
- else if ((ret = clixon_xml_parse_file(fp, yb, yspec, "", &x0, NULL)) < 0)
+ else if ((ret = clixon_xml_parse_file(fp, yb, yspec, NULL /* "" XXX */, &x0, NULL)) < 0)
goto done;
#ifdef XMLDB_READFILE_FAIL /* The functions calling this function cannot handle a failed parse yet */
if (ret == 0)
@@ -473,7 +473,7 @@ xmldb_readfile(clicon_handle h,
* 1. File is empty -> rename top-level to "config"
*/
if (xml_child_nr(x0) == 0){
- if (xml_name_set(x0, "config") < 0)
+ if (xml_name_set(x0, DATASTORE_TOP_SYMBOL) < 0)
goto done;
}
/* 2. File is not empty ... -> replace root */
@@ -482,6 +482,7 @@ xmldb_readfile(clicon_handle h,
if (singleconfigroot(x0, &x0) < 0)
goto done;
}
+ xml_flag_set(x0, XML_FLAG_TOP);
if (xml_child_nr(x0) == 0 && de)
de->de_empty = 1;
@@ -695,6 +696,7 @@ xmldb_get_cache(clicon_handle h,
/* Make new tree by copying top-of-tree from x0t to x1t */
if ((x1t = xml_new(xml_name(x0t), NULL, CX_ELMNT)) == NULL)
goto done;
+ xml_flag_set(x1t, XML_FLAG_TOP);
xml_spec_set(x1t, xml_spec(x0t));
if (xlen < 1000){
@@ -996,7 +998,7 @@ xmldb_get0_clear(clicon_handle h,
/* clear mark and change */
xml_apply0(x, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset,
- (void*)(0xffff));
+ (void*)(XML_FLAG_MARK|XML_FLAG_ADD|XML_FLAG_CHANGE));
ok:
retval = 0;
done:
diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c
index 14c9262d..abecfbd9 100644
--- a/lib/src/clixon_datastore_write.c
+++ b/lib/src/clixon_datastore_write.c
@@ -154,7 +154,7 @@ check_body_namespace(cxobj *x0,
/* XXX: need to identify root better than hiereustics and strcmp,... */
isroot = xml_parent(x1p)==NULL &&
- strcmp(xml_name(x1p), "config") == 0 &&
+ strcmp(xml_name(x1p), DATASTORE_TOP_SYMBOL) == 0 &&
xml_prefix(x1p)==NULL;
if (nodeid_split(x1bstr, &prefix, NULL) < 0)
goto done;
@@ -935,14 +935,14 @@ xmldb_put(clicon_handle h,
clicon_err(OE_YANG, ENOENT, "No yang spec");
goto done;
}
- if (x1 && strcmp(xml_name(x1), "config") != 0){
- clicon_err(OE_XML, 0, "Top-level symbol of modification tree is %s, expected \"config\"",
- xml_name(x1));
+ if (x1 && strcmp(xml_name(x1), NETCONF_INPUT_CONFIG) != 0){
+ clicon_err(OE_XML, 0, "Top-level symbol of modification tree is %s, expected \"%s\"",
+ xml_name(x1), NETCONF_INPUT_CONFIG);
goto done;
}
if ((de = clicon_db_elmnt_get(h, db)) != NULL){
if (clicon_datastore_cache(h) != DATASTORE_NOCACHE)
- x0 = de->de_xml;
+ x0 = de->de_xml; /* XXX flag is not XML_FLAG_TOP */
}
/* If there is no xml x0 tree (in cache), then read it from file */
if (x0 == NULL){
@@ -952,9 +952,10 @@ xmldb_put(clicon_handle h,
if (ret == 0)
goto fail;
}
- if (strcmp(xml_name(x0), "config")!=0){
- clicon_err(OE_XML, 0, "Top-level symbol is %s, expected \"config\"",
- xml_name(x0));
+ if (strcmp(xml_name(x0), DATASTORE_TOP_SYMBOL) !=0 ||
+ xml_flag(x0, XML_FLAG_TOP) == 0){
+ clicon_err(OE_XML, 0, "Top-level symbol is %s, expected \"%s\"",
+ xml_name(x0), DATASTORE_TOP_SYMBOL);
goto done;
}
/* Here x0 looks like: ... */
diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c
index 7821d81c..46e9a433 100644
--- a/lib/src/clixon_json.c
+++ b/lib/src/clixon_json.c
@@ -1232,7 +1232,8 @@ _json_parse(char *str,
*/
if (yspec && xml_prefix(x) == NULL
#ifdef XMLDB_CONFIG_HACK
- && strcmp(xml_name(x), "config") != 0
+ // && !xml_flag(x, XML_FLAG_TOP)
+ && strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) != 0
#endif
){
if ((cberr = cbuf_new()) == NULL){
@@ -1261,8 +1262,11 @@ _json_parse(char *str,
break;
case YB_MODULE:
#ifdef XMLDB_CONFIG_HACK
- if (strcmp(xml_name(x),"config") == 0 ||
- strcmp(xml_name(x),"data") == 0){
+ if (
+ // xml_flag(x, XML_FLAG_TOP)
+ strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) == 0
+ || strcmp(xml_name(x), NETCONF_OUTPUT_DATA) == 0
+ ){
/* xt: nospec
* x:
* <-- populate from modules
diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c
index f3491145..7b11af5f 100644
--- a/lib/src/clixon_plugin.c
+++ b/lib/src/clixon_plugin.c
@@ -964,7 +964,7 @@ static const map_str2int clixon_auth_type[] = {
/*! Translate from string to auth-type
*/
-const clixon_auth_type_t
+const int
clixon_auth_type_str2int(char *auth_type)
{
return clicon_str2int(clixon_auth_type, auth_type);
diff --git a/lib/src/clixon_proto_client.c b/lib/src/clixon_proto_client.c
index 6479bcfa..c4c90dc1 100644
--- a/lib/src/clixon_proto_client.c
+++ b/lib/src/clixon_proto_client.c
@@ -469,7 +469,7 @@ clicon_rpc_get_config(clicon_handle h,
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
xd = xml_parent(xd); /* point to rpc-reply */
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
- if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
+ if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
goto done;
}
else{
@@ -831,7 +831,7 @@ clicon_rpc_get(clicon_handle h,
if ((xd = xpath_first(xret, NULL, "/rpc-reply/rpc-error")) != NULL)
xd = xml_parent(xd); /* point to rpc-reply */
else if ((xd = xpath_first(xret, NULL, "/rpc-reply/data")) == NULL){
- if ((xd = xml_new("data", NULL, CX_ELMNT)) == NULL)
+ if ((xd = xml_new(NETCONF_OUTPUT_DATA, NULL, CX_ELMNT)) == NULL)
goto done;
}
else{
diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c
index 2348513f..a5dcf796 100644
--- a/lib/src/clixon_xml.c
+++ b/lib/src/clixon_xml.c
@@ -1905,7 +1905,7 @@ xml_copy_one(cxobj *x0,
default:
break;
}
- xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT)); /* Maybe more flags */
+ xml_flag_set(x1, xml_flag(x0, XML_FLAG_DEFAULT | XML_FLAG_TOP)); /* Maybe more flags */
retval = 0;
done:
return retval;
diff --git a/lib/src/clixon_xml_io.c b/lib/src/clixon_xml_io.c
index 90dca606..4eba888d 100644
--- a/lib/src/clixon_xml_io.c
+++ b/lib/src/clixon_xml_io.c
@@ -82,9 +82,6 @@
#define BUFLEN 1024
/* Indentation for xml pretty-print. Consider option? */
#define XML_INDENT 3
-/* Name of xml top object created by xml parse functions */
-#define XML_TOP_SYMBOL "top"
-
/*------------------------------------------------------------------------
* XML printing functions. Output a parse tree to file, string cligen buf
@@ -516,8 +513,11 @@ _xml_parse(const char *str,
* x: <-- populate from modules
*/
#ifdef XMLDB_CONFIG_HACK
- if (strcmp(xml_name(x),"config") == 0 ||
- strcmp(xml_name(x),"data") == 0){
+ if (
+ // xml_flag(x, XML_FLAG_TOP)
+ strcmp(xml_name(x), DATASTORE_TOP_SYMBOL) == 0
+ || strcmp(xml_name(x), NETCONF_OUTPUT_DATA) == 0
+ ){
/* xt: nospec
* x:
* <-- populate from modules
diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c
index 4d167e1f..7e3f30d7 100644
--- a/lib/src/clixon_xml_map.c
+++ b/lib/src/clixon_xml_map.c
@@ -1329,7 +1329,7 @@ xml_global_defaults(clicon_handle h,
/* First get or compute global xml tree cache */
if ((de = clicon_db_elmnt_get(h, key)) == NULL){
/* Create it */
- if ((xcache = xml_new("config", NULL, CX_ELMNT)) == NULL)
+ if ((xcache = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
goto done;
if (xml_global_defaults_create(xcache, yspec, state) < 0)
goto done;
@@ -1353,7 +1353,7 @@ xml_global_defaults(clicon_handle h,
xml_apply_ancestor(x0, (xml_applyfn_t*)xml_flag_set, (void*)XML_FLAG_CHANGE);
}
/* Create a new tree and copy over the parts from the cache that matches xpath */
- if ((xpart = xml_new("config", NULL, CX_ELMNT)) == NULL)
+ if ((xpart = xml_new(DATASTORE_TOP_SYMBOL, NULL, CX_ELMNT)) == NULL)
goto done;
if (xml_copy_marked(xcache, xpart) < 0) /* config */
goto done;
@@ -1763,11 +1763,12 @@ assign_namespace_element(cxobj *x0, /* source */
char *prefix0 = NULL;;
int isroot;
- /* XXX: need to identify root better than hiereustics and strcmp,... */
+ /* XXX: need to identify root better than hiereustics and strcmp,...
+ * see XMLDB_CONFIG_HACK
+ */
isroot = xml_parent(x1p)==NULL &&
- (strcmp(xml_name(x1p), "config") == 0 || strcmp(xml_name(x1p), "top") == 0)&&
+ xml_flag(x1p, XML_FLAG_TOP) &&
xml_prefix(x1p)==NULL;
-
/* 1. Find N=namespace(x0) in x0 element */
prefix0 = xml_prefix(x0);
if (xml2ns(x0, prefix0, &namespace) < 0)
diff --git a/test/config.sh.in b/test/config.sh.in
index 8e538b4c..53b7b3e5 100755
--- a/test/config.sh.in
+++ b/test/config.sh.in
@@ -61,3 +61,8 @@ TOP_SRCDIR=@top_srcdir@
# Clixon version
CLIXON_VERSION=@CLIXON_VERSION@
+
+# Which XML symbol to add to top datastore config level
+# see also DATASTORE_TOP_SYMBOL
+DATASTORE_TOP="config"
+
diff --git a/test/lib.sh b/test/lib.sh
index 1029156d..1caeed48 100755
--- a/test/lib.sh
+++ b/test/lib.sh
@@ -361,6 +361,7 @@ function wait_restconf(){
fi
}
+# End of test, final tests before normal exit of test
function endtest()
{
if [ $valgrindtest -eq 1 ]; then
@@ -657,6 +658,10 @@ function expectmatch(){
r=$2
expret=$3
expect=$4
+# echo "ret:$ret"
+# echo "ret:$r"
+# echo "expret:$expret"
+# echo "expect:$expect"
if [ $r != $expret ]; then
echo -e "\e[31m\nError ($r != $retval) in Test$testnr [$testname]:"
echo -e "\e[0m:"
diff --git a/test/test_api.sh b/test/test_api.sh
index a0a53dea..62116784 100755
--- a/test/test_api.sh
+++ b/test/test_api.sh
@@ -277,3 +277,6 @@ unset format
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_api_path.sh b/test/test_api_path.sh
index fd76f32e..c9b9c1e3 100755
--- a/test/test_api_path.sh
+++ b/test/test_api_path.sh
@@ -260,3 +260,7 @@ unset nr
unset clixon_util_path
rm -rf $dir
+
+new "endtest"
+endtest
+
diff --git a/test/test_augment.sh b/test/test_augment.sh
index 2f5adb7b..c6020253 100755
--- a/test/test_augment.sh
+++ b/test/test_augment.sh
@@ -311,3 +311,6 @@ fi
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_augment_state.sh b/test/test_augment_state.sh
index fc175d83..756e8cb7 100755
--- a/test/test_augment_state.sh
+++ b/test/test_augment_state.sh
@@ -246,17 +246,18 @@ testrun "$CONFIG" "$EXPSTATE"
#-----------------------------
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_augment_trans.sh b/test/test_augment_trans.sh
index 9b77b647..517af842 100755
--- a/test/test_augment_trans.sh
+++ b/test/test_augment_trans.sh
@@ -135,3 +135,6 @@ fi
stop_backend -f $cfg
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_c++.sh b/test/test_c++.sh
index 799cfc26..446aa411 100755
--- a/test/test_c++.sh
+++ b/test/test_c++.sh
@@ -169,3 +169,5 @@ fi
rm -rf $dir
+new "endtest"
+endtest
diff --git a/test/test_choice.sh b/test/test_choice.sh
index 673d4623..81990a6d 100755
--- a/test/test_choice.sh
+++ b/test/test_choice.sh
@@ -287,20 +287,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli.sh b/test/test_cli.sh
index 77d4b78c..281d38d1 100755
--- a/test/test_cli.sh
+++ b/test/test_cli.sh
@@ -126,17 +126,18 @@ new "cli rpc"
# We dont know which message-id the cli app uses
expectpart "$($clixon_cli -1 -f $cfg -l o rpc ipv4)" 0 "ipv442"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli_auto.sh b/test/test_cli_auto.sh
index c872e3a6..56f83606 100755
--- a/test/test_cli_auto.sh
+++ b/test/test_cli_auto.sh
@@ -63,14 +63,14 @@ show("Show a particular state of the system"){
EOF
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
-
+${DATASTORE_TOP}>
EOF
# Add inline state
diff --git a/test/test_cli_auto_extension.sh b/test/test_cli_auto_extension.sh
index 6c906ed0..3afb12f5 100755
--- a/test/test_cli_auto_extension.sh
+++ b/test/test_cli_auto_extension.sh
@@ -291,3 +291,6 @@ fi
stop_backend -f $cfg
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli_auto_genmodel.sh b/test/test_cli_auto_genmodel.sh
index ecb2cf7e..d64ed9a3 100755
--- a/test/test_cli_auto_genmodel.sh
+++ b/test/test_cli_auto_genmodel.sh
@@ -215,3 +215,6 @@ fi
stop_backend -f $cfg
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli_auto_sub.sh b/test/test_cli_auto_sub.sh
index ef9599a7..bbfb9b1c 100755
--- a/test/test_cli_auto_sub.sh
+++ b/test/test_cli_auto_sub.sh
@@ -99,7 +99,7 @@ show("Show a particular state of the system"){
EOF
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
p1
@@ -110,7 +110,7 @@ cat < $dir/startup_db
-
+${DATASTORE_TOP}>
EOF
new "test params: -f $cfg"
@@ -162,3 +162,6 @@ fi
stop_backend -f $cfg
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli_history.sh b/test/test_cli_history.sh
index 8b6d17e1..da487fa1 100755
--- a/test/test_cli_history.sh
+++ b/test/test_cli_history.sh
@@ -136,3 +136,6 @@ fi
unset nr
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli_multikey.sh b/test/test_cli_multikey.sh
index ae03da63..f8b2b3bd 100755
--- a/test/test_cli_multikey.sh
+++ b/test/test_cli_multikey.sh
@@ -125,17 +125,18 @@ expectpart "$($clixon_cli -1 -f $cfg set ex y a 2 b v2)" 0 ""
new "show conf"
expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^1v11v21v32v12v22v31v12v11v21v32v2]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli_submodes.sh b/test/test_cli_submodes.sh
index 32cb1efc..5811f85f 100755
--- a/test/test_cli_submodes.sh
+++ b/test/test_cli_submodes.sh
@@ -109,17 +109,18 @@ for c in 2 4; do
expectpart "$($clixon_cli -1 -m $m -f $cfg cmd$c)" 255 "^$"
done
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_cli_translate.sh b/test/test_cli_translate.sh
index 78833fed..da977c6e 100755
--- a/test/test_cli_translate.sh
+++ b/test/test_cli_translate.sh
@@ -79,3 +79,6 @@ if [ $BE -ne 0 ]; then
fi
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_client.sh b/test/test_client.sh
index 32ed2f18..d2b30046 100755
--- a/test/test_client.sh
+++ b/test/test_client.sh
@@ -157,19 +157,17 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=`pgrep -u root -f clixon_backend`
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=`pgrep -u root -f clixon_backend`
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# unset conditional parameters
unset format
@@ -177,3 +175,6 @@ unset format
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_configdir.sh b/test/test_configdir.sh
index d17429a2..1f5ea896 100755
--- a/test/test_configdir.sh
+++ b/test/test_configdir.sh
@@ -126,3 +126,6 @@ new "Start with 2 extra configfiles + command-line"
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_MODULE_SET_ID=4 -o CLICON_FEATURE=test4 -l o show options)" 0 'CLICON_MODULE_SET_ID: "4"' 'CLICON_FEATURE: "test1"' 'CLICON_FEATURE: "test2"' 'CLICON_FEATURE: "test3"' 'CLICON_FEATURE: "test4"'
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_copy_config.sh b/test/test_copy_config.sh
index 24d518b5..b9ae23ea 100755
--- a/test/test_copy_config.sh
+++ b/test/test_copy_config.sh
@@ -56,7 +56,7 @@ EOF
# Create empty startup
cat < $dir/startup_db
-
+<${DATASTORE_TOP}/>
EOF
# rm candidate and running
diff --git a/test/test_datastore.sh b/test/test_datastore.sh
index f5913767..08fd8c42 100755
--- a/test/test_datastore.sh
+++ b/test/test_datastore.sh
@@ -47,7 +47,9 @@ module ietf-ip{
}
EOF
-xml='12first-entry13second-entry23third-entryabcastring'
+xml="12first-entry13second-entry23third-entryabcastring"
+
+xml2="<${DATASTORE_TOP}>12first-entry13second-entry23third-entryabcastring${DATASTORE_TOP}>"
name=text
@@ -68,13 +70,13 @@ ret=$($clixon_util_datastore $conf put replace "$xml")
expectmatch "$ret" $? "0" ""
new "datastore get"
-expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
+expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
new "datastore put all remove"
-expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
+expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
new "datastore get"
-expectpart "$($clixon_util_datastore $conf get /)" 0 "^$"
+expectpart "$($clixon_util_datastore $conf get /)" 0 "^<${DATASTORE_TOP}/>$"
new "datastore put all merge"
ret=$($clixon_util_datastore $conf put merge "$xml")
@@ -83,23 +85,23 @@ expectmatch "$ret" $? "0" ""
# expectpart "$($clixon_util_datastore $conf put merge $xml)" 0 ""
new "datastore get"
-expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
+expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
new "datastore put all delete"
-expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
+expectpart "$($clixon_util_datastore $conf put remove "")" 0 ""
new "datastore get"
-expectpart "$($clixon_util_datastore $conf get /)" 0 "^$"
+expectpart "$($clixon_util_datastore $conf get /)" 0 "^<${DATASTORE_TOP}/>$"
new "datastore put all create"
ret=$($clixon_util_datastore $conf put create "$xml")
expectmatch "$ret" $? "0" ""
new "datastore get"
-expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml$"
+expectpart "$($clixon_util_datastore $conf get /)" 0 "^$xml2$"
new "datastore put top create"
-expectpart "$($clixon_util_datastore $conf put create "")" 0 "" # error
+expectpart "$($clixon_util_datastore $conf put create '')" 0 "" # error
# Single key operations
# leaf
@@ -110,43 +112,43 @@ new "datastore init"
expectpart "$($clixon_util_datastore $conf init)" 0 ""
new "datastore create leaf"
-expectpart "$($clixon_util_datastore $conf put create "13newentry")" 0 ""
+expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 ""
new "datastore create leaf"
-expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 ""
+expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 ""
new "datastore delete leaf"
-expectpart "$($clixon_util_datastore $conf put delete '13')" 0 ""
+expectpart "$($clixon_util_datastore $conf put delete '13')" 0 ""
new "datastore replace leaf"
-expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 ""
+expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 ""
new "datastore remove leaf"
-expectpart "$($clixon_util_datastore $conf put remove '')" 0 ""
+expectpart "$($clixon_util_datastore $conf put remove '')" 0 ""
new "datastore remove leaf"
-expectpart "$($clixon_util_datastore $conf put remove '13')" 0 ""
+expectpart "$($clixon_util_datastore $conf put remove '13')" 0 ""
new "datastore delete leaf"
-expectpart "$($clixon_util_datastore $conf put delete '')" 0 ""
+expectpart "$($clixon_util_datastore $conf put delete '')" 0 ""
new "datastore merge leaf"
-expectpart "$($clixon_util_datastore $conf put merge 'nalle')" 0 ""
+expectpart "$($clixon_util_datastore $conf put merge 'nalle')" 0 ""
new "datastore replace leaf"
-expectpart "$($clixon_util_datastore $conf put replace 'nalle')" 0 ""
+expectpart "$($clixon_util_datastore $conf put replace 'nalle')" 0 ""
new "datastore merge leaf"
-expectpart "$($clixon_util_datastore $conf put merge '13newentry')" 0 ""
+expectpart "$($clixon_util_datastore $conf put merge '13newentry')" 0 ""
new "datastore replace leaf"
-expectpart "$($clixon_util_datastore $conf put replace '13newentry')" 0 ""
+expectpart "$($clixon_util_datastore $conf put replace '13newentry')" 0 ""
new "datastore create leaf"
-expectpart "$($clixon_util_datastore $conf put create 'aaa')" 0 ""
+expectpart "$($clixon_util_datastore $conf put create 'aaa')" 0 ""
new "datastore create leaf"
-expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 ""
+expectpart "$($clixon_util_datastore $conf put create '13newentry')" 0 ""
new "datastore other db init"
expectpart "$($clixon_util_datastore -d kalle -b $mydir -y $dir/ietf-ip.yang init)" 0 ""
@@ -166,3 +168,6 @@ rm -rf $mydir
rm -rf $dir
+new "endtest"
+endtest
+
diff --git a/test/test_datastore_repair.sh b/test/test_datastore_repair.sh
index c024a1f2..01db5f4c 100755
--- a/test/test_datastore_repair.sh
+++ b/test/test_datastore_repair.sh
@@ -81,7 +81,7 @@ EOF
)
function testrun(){
- new "test params: -f $cfg -- -U"
+ new "test params: -f $cfg -- -U" # -U : upgrade
# Bring your own backend
if [ $BE -ne 0 ]; then
# kill old backend (if any)
@@ -116,7 +116,7 @@ function testrun(){
# Create startup db of "old" db with incorrect augment namespace tagging
# without modstate
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
@@ -126,10 +126,13 @@ cat < $dir/startup_db
This node is obsolete
this too
-
+${DATASTORE_TOP}>
EOF
new "general-purpose upgrade without modstate"
testrun
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_identity.sh b/test/test_identity.sh
index a5fb9960..2d0ae5cf 100755
--- a/test/test_identity.sh
+++ b/test/test_identity.sh
@@ -323,7 +323,7 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
+if [ $BE -ne 0 ]; then
new "Kill backend"
# Check if premature kill
pid=$(pgrep -u root -f clixon_backend)
diff --git a/test/test_install.sh b/test/test_install.sh
index 5ee1e0f4..6f1ea39e 100755
--- a/test/test_install.sh
+++ b/test/test_install.sh
@@ -72,3 +72,6 @@ rm -rf $dir
# unset conditional parameters
unset make
+
+new "endtest"
+endtest
diff --git a/test/test_instance_id.sh b/test/test_instance_id.sh
index 842b30b3..9e6bbf38 100755
--- a/test/test_instance_id.sh
+++ b/test/test_instance_id.sh
@@ -328,4 +328,5 @@ rm -rf $dir
unset nr
unset clixon_util_path # for other script reusing it
-
+new "endtest"
+endtest
diff --git a/test/test_instance_id_multi.sh b/test/test_instance_id_multi.sh
index c668c186..f6da6587 100755
--- a/test/test_instance_id_multi.sh
+++ b/test/test_instance_id_multi.sh
@@ -99,4 +99,5 @@ expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /ex:table/ex:parameter/ex:n
rm -rf $dir
unset clixon_util_path # for other script reusing it
-
+new "endtest"
+endtest
diff --git a/test/test_json.sh b/test/test_json.sh
index 747c1a31..3cf33ca8 100755
--- a/test/test_json.sh
+++ b/test/test_json.sh
@@ -138,3 +138,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_json
unset clixon_util_xml
+
+new "endtest"
+endtest
diff --git a/test/test_json_null.sh b/test/test_json_null.sh
index 32afabb6..f6675107 100755
--- a/test/test_json_null.sh
+++ b/test/test_json_null.sh
@@ -197,3 +197,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_json
unset clixon_util_xml
+
+new "endtest"
+endtest
diff --git a/test/test_leaf_default.sh b/test/test_leaf_default.sh
index dcd1bf17..8fe1aabf 100755
--- a/test/test_leaf_default.sh
+++ b/test/test_leaf_default.sh
@@ -158,9 +158,9 @@ fi
# From startup 1, only r1, all else should be filled in
SXML='99'
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
$SXML
-
+${DATASTORE_TOP}>
EOF
XML='99223331'
@@ -186,11 +186,11 @@ sudo chmod 666 $dir/running_db
new "Check running no defaults: r1 only"
# Running should have only non-defaults, ie only r1 that is set to 99
-moreret=$(diff $dir/running_db <(echo "
+moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
$SXML
-"))
+${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
- err "$SXML" "$moreret"
+ err "<${DATASTORE_TOP}>$SXML${DATASTORE_TOP}>" "$moreret"
fi
new "Change default value r2"
@@ -201,12 +201,12 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "
new "Check running no defaults: r1 and r2"
# Again, running should have only non-defaults, ie only r1 and r2
-moreret=$(diff $dir/running_db <(echo "
+moreret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>
$SXML
88
-"))
+${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
- err "$SXML88" "$moreret"
+ err "<${DATASTORE_TOP}>$SXML88${DATASTORE_TOP}>" "$moreret"
fi
new "Kill backend"
@@ -218,9 +218,9 @@ fi
# From startup 2, only presence p4, s4/np5 should be filled in
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
-
+${DATASTORE_TOP}>
EOF
XML='112233314445'
if [ $BE -ne 0 ]; then
@@ -248,9 +248,9 @@ fi
# Only single x list element
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
a
-
+${DATASTORE_TOP}>
EOF
XML='11223331'
if [ $BE -ne 0 ]; then
@@ -277,3 +277,6 @@ if [ -z "$pid" ]; then
fi
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_leafref.sh b/test/test_leafref.sh
index 7668426b..fed72778 100755
--- a/test/test_leafref.sh
+++ b/test/test_leafref.sh
@@ -187,17 +187,18 @@ expectpart "$($clixon_cli -1f $cfg -l o set sender a)" 0 "^$"
new "cli sender template"
expectpart "$($clixon_cli -1f $cfg -l o set sender b template a)" 0 "^$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_leafref_augment.sh b/test/test_leafref_augment.sh
index dfb5e640..c6df69e2 100755
--- a/test/test_leafref_augment.sh
+++ b/test/test_leafref_augment.sh
@@ -264,17 +264,19 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
-fi
+if [ $BE -ne 0 ]; then
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-# kill backend
-stop_backend -f $cfg
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_leafref_state.sh b/test/test_leafref_state.sh
index 89f73811..327c7292 100755
--- a/test/test_leafref_state.sh
+++ b/test/test_leafref_state.sh
@@ -175,17 +175,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^y]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_minmax.sh b/test/test_minmax.sh
index 3a6da5e5..2f162183 100755
--- a/test/test_minmax.sh
+++ b/test/test_minmax.sh
@@ -245,17 +245,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "
new "minmax: validate should fail empty list"
expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^protocoloperation-failedtoo-few-elementserror/c/a1]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm.sh b/test/test_nacm.sh
index 9ecc6df8..e2c741ce 100755
--- a/test/test_nacm.sh
+++ b/test/test_nacm.sh
@@ -191,20 +191,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_credentials.sh b/test/test_nacm_credentials.sh
index 8afef8e5..10d16aea 100755
--- a/test/test_nacm_credentials.sh
+++ b/test/test_nacm_credentials.sh
@@ -231,3 +231,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_socket
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_datanode.sh b/test/test_nacm_datanode.sh
index 75485401..b49a36fc 100755
--- a/test/test_nacm_datanode.sh
+++ b/test/test_nacm_datanode.sh
@@ -321,20 +321,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_datanode_paths.sh b/test/test_nacm_datanode_paths.sh
index 1f5c4fe2..2dfd738c 100755
--- a/test/test_nacm_datanode_paths.sh
+++ b/test/test_nacm_datanode_paths.sh
@@ -68,7 +68,7 @@ EOF
# Set initial NACM rules in startup enabling admin and a single param config
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
@@ -86,7 +86,7 @@ cat < $dir/startup_db
$NGROUPS
$NADMIN
-
+${DATASTORE_TOP}>
EOF
new "test params: -f $cfg"
@@ -171,3 +171,6 @@ fi
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_datanode_read.sh b/test/test_nacm_datanode_read.sh
index d27e9205..9440f03f 100755
--- a/test/test_nacm_datanode_read.sh
+++ b/test/test_nacm_datanode_read.sh
@@ -303,3 +303,6 @@ fi
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_datanode_write.sh b/test/test_nacm_datanode_write.sh
index 4205193a..1f9798ba 100755
--- a/test/test_nacm_datanode_write.sh
+++ b/test/test_nacm_datanode_write.sh
@@ -301,3 +301,6 @@ fi
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_default.sh b/test/test_nacm_default.sh
index ce790862..ca3be682 100755
--- a/test/test_nacm_default.sh
+++ b/test/test_nacm_default.sh
@@ -91,7 +91,7 @@ EOF
# Use startup or set values with POST (below)
if [ $db = startup ]; then
- sudo echo "$NACM$XML" > $dir/startup_db
+ sudo echo "<${DATASTORE_TOP}>$NACM$XML${DATASTORE_TOP}>" > $dir/startup_db
fi
if [ $BE -ne 0 ]; then # Bring your own backend
diff --git a/test/test_nacm_ext.sh b/test/test_nacm_ext.sh
index 9debcbab..c80a9266 100755
--- a/test/test_nacm_ext.sh
+++ b/test/test_nacm_ext.sh
@@ -216,20 +216,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_module_read.sh b/test/test_nacm_module_read.sh
index 69e26931..deb64c50 100755
--- a/test/test_nacm_module_read.sh
+++ b/test/test_nacm_module_read.sh
@@ -259,20 +259,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_module_write.sh b/test/test_nacm_module_write.sh
index 62fe2a3f..e52fac9d 100755
--- a/test/test_nacm_module_write.sh
+++ b/test/test_nacm_module_write.sh
@@ -261,20 +261,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_nacm_protocol.sh b/test/test_nacm_protocol.sh
index f7d93cdc..9bcdc98b 100755
--- a/test/test_nacm_protocol.sh
+++ b/test/test_nacm_protocol.sh
@@ -227,20 +227,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_netconf.sh b/test/test_netconf.sh
index 60987b2d..9d6a97a9 100755
--- a/test/test_netconf.sh
+++ b/test/test_netconf.sh
@@ -304,17 +304,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "e0e1]]>]]>" "^applicationunknown-elementnameerrorFailed to find YANG spec of XML node: name with parent: name in namespace: urn:ietf:params:xml:ns:yang:ietf-interfaces]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_netconf_filter.sh b/test/test_netconf_filter.sh
index 16e8a51e..4243ed21 100755
--- a/test/test_netconf_filter.sh
+++ b/test/test_netconf_filter.sh
@@ -80,17 +80,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^11]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_netconf_notifications.sh b/test/test_netconf_notifications.sh
index 93ce7b1a..beceefc3 100755
--- a/test/test_netconf_notifications.sh
+++ b/test/test_netconf_notifications.sh
@@ -149,3 +149,5 @@ fi
rm -rf $dir
+new "endtest"
+endtest
diff --git a/test/test_netconf_whitespace.sh b/test/test_netconf_whitespace.sh
index f5fb9d82..fd6483ff 100755
--- a/test/test_netconf_whitespace.sh
+++ b/test/test_netconf_whitespace.sh
@@ -59,8 +59,9 @@ EOF
new "test params: -f $cfg -s startup"
-echo '
- foo\n ]]>]]>$start' > $dir/startup_db
+# Keep the following as is (whitespace)
+echo "<${DATASTORE_TOP}>
+ foo\n ${DATASTORE_TOP}>" > $dir/startup_db
if [ $BE -ne 0 ]; then
new "kill old backend"
@@ -137,17 +138,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_openconfig.sh b/test/test_openconfig.sh
index feb7c4fd..b47e0d30 100755
--- a/test/test_openconfig.sh
+++ b/test/test_openconfig.sh
@@ -161,3 +161,5 @@ fi
rm -rf $dir
+new "endtest"
+endtest
diff --git a/test/test_order.sh b/test/test_order.sh
index 65b4d5ae..d48bfac4 100755
--- a/test/test_order.sh
+++ b/test/test_order.sh
@@ -129,7 +129,7 @@ EOF
rm -f $dbdir/candidate_db
# alt
cat < $dbdir/running_db
-
+<${DATASTORE_TOP}>
d
d
dbar
@@ -148,7 +148,7 @@ cat < $dbdir/running_db
cbar
bbar
bbar
-
+${DATASTORE_TOP}>
EOF
new "test params: -s running -f $cfg -- -s"
@@ -391,20 +391,21 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^ebarafoo71fiebbar42fumcfoodfie]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
# unset conditional parameters
unset format
+
+new "endtest"
+endtest
diff --git a/test/test_pattern.sh b/test/test_pattern.sh
index da9af567..6cd3f84d 100755
--- a/test/test_pattern.sh
+++ b/test/test_pattern.sh
@@ -824,3 +824,6 @@ rm -rf $dir
# unset conditional parameters
unset regex
+
+new "endtest"
+endtest
diff --git a/test/test_perf_cli.sh b/test/test_perf_cli.sh
index e6518f97..e72e0a0f 100755
--- a/test/test_perf_cli.sh
+++ b/test/test_perf_cli.sh
@@ -149,22 +149,23 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^" > $dir/startup_db
+ echo -n "<${DATASTORE_TOP}>" > $dir/startup_db
for (( i=0; i<$nr; i++ )); do
echo -n "$i$i" >> $dir/startup_db
done
- echo "" >> $dir/startup_db
+ echo "${DATASTORE_TOP}>" >> $dir/startup_db
new "kill old backend"
sudo clixon_backend -zf $cfg
@@ -173,5 +173,7 @@ b:
childvec: 8
(ns-cache: 115) # only in startup?
-
fi
+
+new "endtest"
+endtest
diff --git a/test/test_perf_netconf.sh b/test/test_perf_netconf.sh
index 4238f16e..fc3fe284 100755
--- a/test/test_perf_netconf.sh
+++ b/test/test_perf_netconf.sh
@@ -191,22 +191,23 @@ expecteof "time -p $clixon_netconf -qf $cfg" 0 "]
new "netconf get large leaf-list config"
expecteof "time -p $clixon_netconf -qf $cfg" 0 "]]>]]>" "^01" 2>&1 | awk '/real/ {print $2}'
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
# unset conditional parameters
unset format
unset perfnr
unset perfreq
+
+new "endtest"
+endtest
diff --git a/test/test_perf_restconf.sh b/test/test_perf_restconf.sh
index 820fdade..427f2098 100755
--- a/test/test_perf_restconf.sh
+++ b/test/test_perf_restconf.sh
@@ -197,19 +197,17 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
# Set by restconf_config
@@ -219,3 +217,6 @@ unset RESTCONFIG
unset format
unset perfnr
unset perfreq
+
+new "endtest"
+endtest
diff --git a/test/test_perf_startup.sh b/test/test_perf_startup.sh
index 8d7cd3e2..6bc554d0 100755
--- a/test/test_perf_startup.sh
+++ b/test/test_perf_startup.sh
@@ -163,3 +163,6 @@ rm -rf $dir
# unset conditional parameters
unset perfnr
+
+new "endtest"
+endtest
diff --git a/test/test_perf_state.sh b/test/test_perf_state.sh
index 03d2b684..ff7a0f06 100755
--- a/test/test_perf_state.sh
+++ b/test/test_perf_state.sh
@@ -196,19 +196,17 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
# unset conditional parameters
@@ -219,3 +217,5 @@ unset perfreq
# Set by restconf_config
unset RESTCONFIG
+new "endtest"
+endtest
diff --git a/test/test_perf_state_only.sh b/test/test_perf_state_only.sh
index 747621a1..57042089 100755
--- a/test/test_perf_state_only.sh
+++ b/test/test_perf_state_only.sh
@@ -208,5 +208,5 @@ unset format
unset perfnr
unset perfreq
-
-
+new "endtest"
+endtest
diff --git a/test/test_perf_xml.sh b/test/test_perf_xml.sh
index c2f1ac3b..5375704a 100755
--- a/test/test_perf_xml.sh
+++ b/test/test_perf_xml.sh
@@ -30,3 +30,5 @@ rm -rf $dir
unset clixon_util_xml
unset perfnr
+new "endtest"
+endtest
diff --git a/test/test_privileges.sh b/test/test_privileges.sh
index 86d7dc89..8b2e4b35 100755
--- a/test/test_privileges.sh
+++ b/test/test_privileges.sh
@@ -134,3 +134,6 @@ new "Start as non-privileged, try to drop (but fail)"
testrun $(whoami) $BUSER $BUSER drop_perm 1
sudo rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf.sh b/test/test_restconf.sh
index e3819946..97b5a1b5 100755
--- a/test/test_restconf.sh
+++ b/test/test_restconf.sh
@@ -414,3 +414,6 @@ unset RESTCONFIG
unset RESTCONFIG1
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf2.sh b/test/test_restconf2.sh
index bc09eb2d..7e07f89f 100755
--- a/test/test_restconf2.sh
+++ b/test/test_restconf2.sh
@@ -208,20 +208,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf_basic_auth.sh b/test/test_restconf_basic_auth.sh
index 1f14120c..eb076c16 100755
--- a/test/test_restconf_basic_auth.sh
+++ b/test/test_restconf_basic_auth.sh
@@ -98,7 +98,7 @@ EOF
# NACM rules and top/ config
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
true
deny
@@ -163,7 +163,7 @@ cat < $dir/startup_db
42
71
-
+${DATASTORE_TOP}>
EOF
# Restconf auth test with arguments:
@@ -316,3 +316,6 @@ unset MSGERR1
unset MSGERR2
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf_err.sh b/test/test_restconf_err.sh
index 4210d231..ecb4255c 100755
--- a/test/test_restconf_err.sh
+++ b/test/test_restconf_err.sh
@@ -245,20 +245,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf_jukebox.sh b/test/test_restconf_jukebox.sh
index 21a4b768..898c9629 100755
--- a/test/test_restconf_jukebox.sh
+++ b/test/test_restconf_jukebox.sh
@@ -256,20 +256,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf_listkey.sh b/test/test_restconf_listkey.sh
index c1baa41b..a2bb068a 100755
--- a/test/test_restconf_listkey.sh
+++ b/test/test_restconf_listkey.sh
@@ -171,20 +171,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf_patch.sh b/test/test_restconf_patch.sh
index feef172f..0f4cd77b 100755
--- a/test/test_restconf_patch.sh
+++ b/test/test_restconf_patch.sh
@@ -74,9 +74,9 @@ NACM0="
"
cat< $startupdb
-
+<${DATASTORE_TOP}>
$NACM0
-
+${DATASTORE_TOP}>
EOF
# An extra testmodule that includes nacm
@@ -158,9 +158,9 @@ fi
# Restart
cat< $startupdb
-
+<${DATASTORE_TOP}>
$NACM0
-
+${DATASTORE_TOP}>
EOF
if [ $BE -ne 0 ]; then
new "kill old backend"
@@ -270,3 +270,6 @@ fi
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_restconf_rpc.sh b/test/test_restconf_rpc.sh
index c25448b9..2b0ca368 100755
--- a/test/test_restconf_rpc.sh
+++ b/test/test_restconf_rpc.sh
@@ -42,6 +42,17 @@ cat < $cfg
EOF
+cat < $dir/example.yang
+module example {
+ namespace "urn:example:clixon";
+ prefix ex;
+ revision 2021-03-05;
+ leaf val{
+ type string;
+ }
+}
+EOF
+
# Subroutine send a process control RPC and tricks to echo process-id returned
# Args:
# 1: operation
@@ -101,11 +112,11 @@ EOF
new "ENABLE true"
# First basic operation with restconf enable is true
cat< $startupdb
-
+<${DATASTORE_TOP}>
true
-
+${DATASTORE_TOP}>
EOF
new "kill old restconf"
@@ -273,11 +284,11 @@ fi
new "ENABLE false"
# Second basic operation with restconf enable is false
cat< $startupdb
-
+<${DATASTORE_TOP}>
false
-
+${DATASTORE_TOP}>
EOF
new "kill old restconf"
@@ -320,7 +331,7 @@ pid=$(testrpc status 1)
if [ $? -ne 0 ]; then echo "$pid";exit -1; fi
# Edit a field, eg debug
-new "Edit a field via restconf"
+new "Edit a restconf field via restconf"
expectpart "$(curl $CURLOPTS -X PUT -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/clixon-restconf:restconf/debug -d '{"clixon-restconf:debug":1}' )" 0 "HTTP/1.1 201 Created"
new "check status RPC new pid"
@@ -331,6 +342,18 @@ if [ $pid -eq $pid1 ]; then
err "A different pid" "Same pid: $pid"
fi
+new "Edit a non-restconf field via restconf"
+echo "curl $CURLOPTS -X POST -H \"Content-Type: application/yang-data+json\" $RCPROTO://localhost/restconf/data -d '{\"example:val\":\"xyz\"}'"
+
+expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data -d '{"example:val":"xyz"}' )" 0 "HTTP/1.1 201 Created"
+
+new "check status RPC same pid"
+pid2=$(testrpc status 1)
+if [ $? -ne 0 ]; then echo "$pid2";exit -1; fi
+if [ $pid1 -ne $pid2 ]; then
+ err "Same pid $pid1" "$pid2"
+fi
+
new "Disable restconf"
expecteof "$clixon_netconf -qf $cfg" 0 "mergefalse]]>]]>" "^]]>]]>$"
diff --git a/test/test_restconf_ssl_certs.sh b/test/test_restconf_ssl_certs.sh
index db12737f..38daa95c 100755
--- a/test/test_restconf_ssl_certs.sh
+++ b/test/test_restconf_ssl_certs.sh
@@ -166,9 +166,9 @@ EOF
function testrun()
{
cat < $dir/startup_db
-
+ <${DATASTORE_TOP}>
$RULES
-
+ ${DATASTORE_TOP}>
EOF
if [ $BE -ne 0 ]; then
new "kill old backend"
diff --git a/test/test_restconf_startup.sh b/test/test_restconf_startup.sh
index f866f16b..60e0a194 100755
--- a/test/test_restconf_startup.sh
+++ b/test/test_restconf_startup.sh
@@ -135,3 +135,6 @@ fi
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_rpc.sh b/test/test_rpc.sh
index 9e35fa25..7cfa7927 100755
--- a/test/test_rpc.sh
+++ b/test/test_rpc.sh
@@ -188,20 +188,21 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_search_index.sh b/test/test_search_index.sh
index 45b5c4cb..d8265eff 100755
--- a/test/test_search_index.sh
+++ b/test/test_search_index.sh
@@ -96,4 +96,5 @@ rm -rf $dir
unset nr
unset clixon_util_path # for other script reusing it
-
+new "endtest"
+endtest
diff --git a/test/test_sock.sh b/test/test_sock.sh
index db3a9854..8e303287 100755
--- a/test/test_sock.sh
+++ b/test/test_sock.sh
@@ -94,3 +94,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_socket
+
+new "endtest"
+endtest
diff --git a/test/test_startup.sh b/test/test_startup.sh
index e7a77a8e..5a59f979 100755
--- a/test/test_startup.sh
+++ b/test/test_startup.sh
@@ -69,9 +69,9 @@ function testrun(){
exprun=$5 # expected running_db after startup
sudo rm -f $dir/*_db
- echo "$rdb" > $dir/running_db
- echo "$sdb" > $dir/startup_db
- echo "$edb" > $dir/extra_db
+ echo "<${DATASTORE_TOP}>$rdb${DATASTORE_TOP}>" > $dir/running_db
+ echo "<${DATASTORE_TOP}>$sdb${DATASTORE_TOP}>" > $dir/startup_db
+ echo "<${DATASTORE_TOP}>$edb${DATASTORE_TOP}>" > $dir/extra_db
if [ $BE -ne 0 ]; then # Bring your own backend
# kill old backend (if any)
@@ -118,9 +118,9 @@ function testfail(){
sudo rm -f $dir/*_db
- echo "$rdb" > $dir/running_db
- echo "$sdb" > $dir/startup_db
- echo "$edb" > $dir/extra_db
+ echo "<${DATASTORE_TOP}>$rdb${DATASTORE_TOP}>" > $dir/running_db
+ echo "<${DATASTORE_TOP}>$sdb${DATASTORE_TOP}>" > $dir/startup_db
+ echo "<${DATASTORE_TOP}>$edb${DATASTORE_TOP}>" > $dir/extra_db
# kill old backend (if any)
new "kill old backend"
@@ -138,20 +138,20 @@ function testfail(){
sudo chmod 666 $dir/running_db
sudo chmod 666 $dir/startup_db
new "Checking running unchanged"
- ret=$(diff $dir/running_db <(echo "$rdb"))
+ ret=$(diff $dir/running_db <(echo "<${DATASTORE_TOP}>$rdb${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
- err "$rdb" "$ret"
+ err "<${DATASTORE_TOP}>$rdb${DATASTORE_TOP}>" "$ret"
fi
new "Checking startup unchanged"
- ret=$(diff $dir/startup_db <(echo "$sdb"))
+ ret=$(diff $dir/startup_db <(echo "<${DATASTORE_TOP}>$sdb${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
- err "$sdb" "$ret"
+ err "<${DATASTORE_TOP}>$sdb${DATASTORE_TOP}>" "$ret"
fi
new "Checking extra unchanged"
- ret=$(diff $dir/extra_db <(echo "$edb"))
+ ret=$(diff $dir/extra_db <(echo "<${DATASTORE_TOP}>$edb${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
- err "$edb" "$ret"
+ err "<${DATASTORE_TOP}>$edb${DATASTORE_TOP}>" "$ret"
fi
}
@@ -190,3 +190,6 @@ rm -rf $dir
# unset conditional parameters
unset format
+
+new "endtest"
+endtest
diff --git a/test/test_submodule.sh b/test/test_submodule.sh
index fd2e0969..b046ed8a 100755
--- a/test/test_submodule.sh
+++ b/test/test_submodule.sh
@@ -253,21 +253,22 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
+ sudo pkill -u root -f clixon_backend
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-sudo pkill -u root -f clixon_backend
-
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_transaction.sh b/test/test_transaction.sh
index 16a5dab2..6abf085a 100755
--- a/test/test_transaction.sh
+++ b/test/test_transaction.sh
@@ -305,19 +305,20 @@ for op in begin validate complete commit commit_done end; do
let line++
done
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
unset nr
+
+new "endtest"
+endtest
diff --git a/test/test_transaction_restart.sh b/test/test_transaction_restart.sh
index 11200ef0..b12eef03 100755
--- a/test/test_transaction_restart.sh
+++ b/test/test_transaction_restart.sh
@@ -131,19 +131,20 @@ done
new "Send restart to nonexistatn plugin expect fail"
expecteof "$clixon_netconf -qf $cfg" 0 "xxx]]>]]>" "^applicationbad-elementpluginerrorNo such plugin]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
unset nr
+
+new "endtest"
+endtest
diff --git a/test/test_type.sh b/test/test_type.sh
index a8c9ba16..257f14b9 100755
--- a/test/test_type.sh
+++ b/test/test_type.sh
@@ -679,3 +679,6 @@ testrun cache
testrun cache-zerocopy
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_type_range.sh b/test/test_type_range.sh
index e2fdb789..a74111f2 100755
--- a/test/test_type_range.sh
+++ b/test/test_type_range.sh
@@ -335,3 +335,6 @@ rm -rf $dir
# unset conditional parameters
unset format
+
+new "endtest"
+endtest
diff --git a/test/test_union.sh b/test/test_union.sh
index b1db3745..e1d21e40 100755
--- a/test/test_union.sh
+++ b/test/test_union.sh
@@ -100,17 +100,18 @@ expectpart "$($clixon_cli -1f $cfg -l o set c ulle 33)" 0 "^$"
new "cli set transitive union error"
expectpart "$($clixon_cli -1f $cfg -l o set c ulle kalle)" 255 "^CLI syntax error: \"set c ulle kalle\": 'kalle' is not a number$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_unique.sh b/test/test_unique.sh
index 6050633a..9d664edd 100755
--- a/test/test_unique.sh
+++ b/test/test_unique.sh
@@ -209,17 +209,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_upgrade_auto.sh b/test/test_upgrade_auto.sh
index a93266cd..efdcc317 100755
--- a/test/test_upgrade_auto.sh
+++ b/test/test_upgrade_auto.sh
@@ -126,17 +126,17 @@ EOF
# Create failsafe db
cat < $dir/failsafe_db
-
+<${DATASTORE_TOP}>
Failsafe
-
+${DATASTORE_TOP}>
EOF
# Create startup db revision example-a and example-b 2017-12-01
# this should be automatically upgraded to 2017-12-20
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
42
@@ -162,7 +162,7 @@ cat < $dir/startup_db
Obsolete
-
+${DATASTORE_TOP}>
EOF
# Wanted new XML
@@ -270,6 +270,9 @@ if [ $BE -ne 0 ]; then
fi
# kill backend
stop_backend -f $cfg
-
- rm -rf $dir
fi
+
+rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_upgrade_failsafe.sh b/test/test_upgrade_failsafe.sh
index 893283e6..0f58631d 100755
--- a/test/test_upgrade_failsafe.sh
+++ b/test/test_upgrade_failsafe.sh
@@ -112,15 +112,15 @@ EOF
# Create failsafe db
cat < $dir/failsafe_db
-
+<${DATASTORE_TOP}>
always work
-
+${DATASTORE_TOP}>
EOF
# Create compatible startup db
# startup config XML with following
cat < $dir/compat-valid.xml
-
+<${DATASTORE_TOP}>
42
@@ -136,13 +136,13 @@ cat < $dir/compat-valid.xml
always work
other text
-
+${DATASTORE_TOP}>
EOF
# Create compatible startup db
# startup config XML with following
cat < $dir/compat-invalid.xml
-
+<${DATASTORE_TOP}>
42
@@ -160,7 +160,7 @@ cat < $dir/compat-invalid.xml
always work
other text
bla bla
-
+${DATASTORE_TOP}>
EOF
@@ -168,7 +168,7 @@ EOF
# startup config XML with following (A obsolete, B OK, C lacking)
# But XML is OK
cat < $dir/non-compat-valid.xml
-
+<${DATASTORE_TOP}>
42
@@ -189,13 +189,13 @@ cat < $dir/non-compat-valid.xml
always work
other text
-
+${DATASTORE_TOP}>
EOF
# Create non-compat startup db
# startup config XML with following (A obsolete, B OK, C lacking)
cat < $dir/non-compat-invalid.xml
-
+<${DATASTORE_TOP}>
42
@@ -218,12 +218,12 @@ cat < $dir/non-compat-invalid.xml
always work
other text
bla bla
-
+${DATASTORE_TOP}>
EOF
# Compatible startup with syntax errors
cat < $dir/compat-err.xml
-
+<${DATASTORE_TOP}>
42
@@ -239,7 +239,7 @@ cat < $dir/compat-err.xml
<always work
other text
-
+${DATASTORE_TOP}>
EOF
#! Start system in given mode and check database contents
@@ -365,6 +365,8 @@ new "8. Load non-compat startup. Syntax fail, enter failsafe, startup invalid"
runtest true startup 'always work' 'applicationoperation-failederrorread registry'
fi # valgrindtest
-if [ $BE -ne 0 ]; then
- rm -rf $dir
-fi
+rm -rf $dir
+
+new "endtest"
+endtest
+
diff --git a/test/test_upgrade_interfaces.sh b/test/test_upgrade_interfaces.sh
index 3c7e70cd..49022ee4 100755
--- a/test/test_upgrade_interfaces.sh
+++ b/test/test_upgrade_interfaces.sh
@@ -188,7 +188,7 @@ EOF
# Create startup db revision from 2014-05-08 to be upgraded to 2018-02-20
# This is 2014 syntax
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
42
@@ -226,7 +226,7 @@ cat < $dir/startup_db
testing
-
+${DATASTORE_TOP}>
EOF
# Create configuration
@@ -292,7 +292,7 @@ testrun "$XML"
# This is "2016" syntax
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
42
@@ -336,7 +336,7 @@ cat < $dir/startup_db
testing
-
+${DATASTORE_TOP}>
EOF
# 2. Upgrade from intermediate 2016-01-01 to 2018-02-20
@@ -345,7 +345,7 @@ testrun "$XML"
# Again 2014 syntax
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
42
@@ -383,7 +383,7 @@ cat < $dir/startup_db
testing
-
+${DATASTORE_TOP}>
EOF
rm $if2018
@@ -397,7 +397,9 @@ testrun "$XML"
#new "4. No model at all"
#testrun "$XML"
-if [ $BE -ne 0 ]; then
- rm -rf $dir
-fi
+rm -rf $dir
+
+new "endtest"
+endtest
+
diff --git a/test/test_upgrade_module.sh b/test/test_upgrade_module.sh
index f550fdd5..66fe4802 100755
--- a/test/test_upgrade_module.sh
+++ b/test/test_upgrade_module.sh
@@ -81,26 +81,26 @@ function createstartups()
# no : there is no modstate in the file (1)
cat < $dir/startup1.xml
-
+<${DATASTORE_TOP}>
$payload
-
+${DATASTORE_TOP}>
EOF
# Create startup datastore:
# - : there is modstate but module is not present (2)
cat < $dir/startup2.xml
-
+<${DATASTORE_TOP}>
42
$payload
-
+${DATASTORE_TOP}>
EOF
# Create startup datastore:
# $dir/startup3.xml
-
+<${DATASTORE_TOP}>
42
@@ -110,13 +110,13 @@ EOF
$payload
-
+${DATASTORE_TOP}>
EOF
# Create startup datastore:
# =Y : there is modstate and revision is exactly Y (4)
cat < $dir/startup4.xml
-
+<${DATASTORE_TOP}>
42
@@ -126,13 +126,13 @@ EOF
$payload
-
+${DATASTORE_TOP}>
EOF
# Create startup datastore:
# >Y : there is modstate and revision is exactly Y (5)
cat < $dir/startup5.xml
-
+<${DATASTORE_TOP}>
42
@@ -142,7 +142,7 @@ EOF
$payload
-
+${DATASTORE_TOP}>
EOF
}
@@ -313,3 +313,5 @@ testall '' ''
rm -rf $dir
+new "endtest"
+endtest
diff --git a/test/test_upgrade_quit.sh b/test/test_upgrade_quit.sh
index b157f2a0..95524531 100755
--- a/test/test_upgrade_quit.sh
+++ b/test/test_upgrade_quit.sh
@@ -195,7 +195,7 @@ EOF
# Create startup db revision from 2014-05-08 to be upgraded to 2018-02-20
# This is 2014 syntax
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
42
@@ -233,7 +233,7 @@ cat < $dir/startup_db
testing
-
+${DATASTORE_TOP}>
EOF
# Create configuration
@@ -260,7 +260,7 @@ EOF
# This is 2014 syntax
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
42
@@ -298,7 +298,7 @@ cat < $dir/startup_db
testing
-
+${DATASTORE_TOP}>
EOF
MODSTATE1='0clixon-lib2020-12-30http://clicon.org/lib'
@@ -307,7 +307,7 @@ MODSTATE2='interfaces2018-02-20$MODSTATE$XML"
+ALL="<${DATASTORE_TOP}>$MODSTATE$XML${DATASTORE_TOP}>"
# -u means trigger example upgrade
@@ -341,4 +341,5 @@ fi
rm -rf $dir
-
+new "endtest"
+endtest
diff --git a/test/test_upgrade_repair.sh b/test/test_upgrade_repair.sh
index bb97ccbe..2a509b4d 100755
--- a/test/test_upgrade_repair.sh
+++ b/test/test_upgrade_repair.sh
@@ -73,15 +73,15 @@ EOF
# Create failsafe db
cat < $dir/failsafe_db
-
+<${DATASTORE_TOP}>
$SAMEXML
-
+${DATASTORE_TOP}>
EOF
# Create non-compat startup db
# startup config XML with following (A obsolete, B OK, C lacking)
cat < $dir/non-compat-invalid.xml
-
+<${DATASTORE_TOP}>
42
@@ -92,7 +92,7 @@ cat < $dir/non-compat-invalid.xml
$OLDXML
$SAMEXML
-
+${DATASTORE_TOP}>
EOF
(cd $dir; rm -f tmp_db candidate_db running_db startup_db) # remove databases
@@ -147,7 +147,9 @@ if [ $BE -ne 0 ]; then
fi
# kill backend
stop_backend -f $cfg
-
- rm -rf $dir
fi
+rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_upgrade_simple.sh b/test/test_upgrade_simple.sh
index fba067c1..d3f9feee 100755
--- a/test/test_upgrade_simple.sh
+++ b/test/test_upgrade_simple.sh
@@ -128,3 +128,5 @@ stop_backend -f $cfg
rm -rf $dir
+new "endtest"
+endtest
diff --git a/test/test_when_must.sh b/test/test_when_must.sh
index 354bd770..3b512ae5 100755
--- a/test/test_when_must.sh
+++ b/test/test_when_must.sh
@@ -140,17 +140,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^applicationoperation-failederrorAn Ethernet MTU must be 1500]]>]]>"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_with_default.sh b/test/test_with_default.sh
index 32517ca3..3f900dc8 100755
--- a/test/test_with_default.sh
+++ b/test/test_with_default.sh
@@ -101,17 +101,18 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^$EXPLICIT]]>]]>$"
-if [ $BE -eq 0 ]; then
- exit # BE
+if [ $BE -ne 0 ]; then
+ new "Kill backend"
+ # Check if premature kill
+ pid=$(pgrep -u root -f clixon_backend)
+ if [ -z "$pid" ]; then
+ err "backend already dead"
+ fi
+ # kill backend
+ stop_backend -f $cfg
fi
-new "Kill backend"
-# Check if premature kill
-pid=$(pgrep -u root -f clixon_backend)
-if [ -z "$pid" ]; then
- err "backend already dead"
-fi
-# kill backend
-stop_backend -f $cfg
-
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_xml.sh b/test/test_xml.sh
index a294c0d0..60dcff48 100755
--- a/test/test_xml.sh
+++ b/test/test_xml.sh
@@ -179,9 +179,10 @@ EOF
)
expecteof "$clixon_util_xml -o" 0 "$XML" '^Cheaper by the Dozen1568491379$'
-endtest
-
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml
+
+new "endtest"
+endtest
diff --git a/test/test_xml_trees.sh b/test/test_xml_trees.sh
index ca7ca5d6..ef3176f3 100755
--- a/test/test_xml_trees.sh
+++ b/test/test_xml_trees.sh
@@ -125,3 +125,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_xml_mod
+
+new "endtest"
+endtest
diff --git a/test/test_xml_validate.sh b/test/test_xml_validate.sh
index adf3fb81..f39b9758 100755
--- a/test/test_xml_validate.sh
+++ b/test/test_xml_validate.sh
@@ -49,3 +49,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_xml
+
+new "endtest"
+endtest
diff --git a/test/test_xpath.sh b/test/test_xpath.sh
index ecaaa47a..697895d6 100755
--- a/test/test_xpath.sh
+++ b/test/test_xpath.sh
@@ -230,3 +230,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_xpath
+
+new "endtest"
+endtest
diff --git a/test/test_xpath_canonical.sh b/test/test_xpath_canonical.sh
index 7f538a95..deb05fb0 100755
--- a/test/test_xpath_canonical.sh
+++ b/test/test_xpath_canonical.sh
@@ -66,3 +66,6 @@ rm -rf $dir
# unset conditional parameters
unset clixon_util_xpath
+
+new "endtest"
+endtest
diff --git a/test/test_xpath_functions.sh b/test/test_xpath_functions.sh
index 230d0f81..a12085e2 100755
--- a/test/test_xpath_functions.sh
+++ b/test/test_xpath_functions.sh
@@ -186,3 +186,6 @@ if [ $BE -ne 0 ]; then
fi
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_yang.sh b/test/test_yang.sh
index 46c23654..bad5bef2 100755
--- a/test/test_yang.sh
+++ b/test/test_yang.sh
@@ -293,3 +293,6 @@ fi
stop_backend -f "$cfg"
rm -rf "$dir"
+
+new "endtest"
+endtest
diff --git a/test/test_yang_anydata.sh b/test/test_yang_anydata.sh
index c2b88c6c..b7d34b2d 100755
--- a/test/test_yang_anydata.sh
+++ b/test/test_yang_anydata.sh
@@ -155,9 +155,9 @@ EOF
# Only positive startup test, ie dont add XMLU if unknown not treated as anyxml
# and check for errors
cat < $dir/startup_db
-
+<${DATASTORE_TOP}>
$XML
-
+${DATASTORE_TOP}>
EOF
fi
@@ -283,3 +283,6 @@ testrun true true
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_yang_bind.sh b/test/test_yang_bind.sh
index d5f8cd62..3fbaf6c2 100755
--- a/test/test_yang_bind.sh
+++ b/test/test_yang_bind.sh
@@ -156,3 +156,6 @@ new "JSON Add any on top"
expectpart "$($clixon_util_xml -Jvy $fyang -f $fjson)" 0 '^$'
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_yang_default.sh b/test/test_yang_default.sh
index d4590350..c4fea254 100755
--- a/test/test_yang_default.sh
+++ b/test/test_yang_default.sh
@@ -76,7 +76,7 @@ function testrun(){
db=startup
if [ $db = startup ]; then
- sudo echo "$XML" > $dir/startup_db
+ sudo echo "<${DATASTORE_TOP}>$XML${DATASTORE_TOP}>" > $dir/startup_db
fi
if [ $BE -ne 0 ]; then # Bring your own backend
new "kill old backend"
@@ -96,15 +96,15 @@ function testrun(){
sudo chmod 666 $dir/startup_db
new "Checking startup unchanged"
- ret=$(diff $dir/startup_db <(echo "$XML"))
+ ret=$(diff $dir/startup_db <(echo "<${DATASTORE_TOP}>$XML${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
- err "$XML" "$ret"
+ err "<${DATASTORE_TOP}>$XML${DATASTORE_TOP}>" "$ret"
fi
new "Checking running unchanged"
- ret=$(diff $dir/running_db <(echo -n "$XML"))
+ ret=$(diff $dir/running_db <(echo -n "<${DATASTORE_TOP}>$XML${DATASTORE_TOP}>"))
if [ $? -ne 0 ]; then
- err "$XML" "$ret"
+ err "<${DATASTORE_TOP}>$XML${DATASTORE_TOP}>" "$ret"
fi
new "check running defaults"
@@ -125,3 +125,6 @@ function testrun(){
testrun
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_yang_extension.sh b/test/test_yang_extension.sh
index 7df8404d..88f475aa 100755
--- a/test/test_yang_extension.sh
+++ b/test/test_yang_extension.sh
@@ -140,3 +140,6 @@ if [ $BE -ne 0 ]; then
fi
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_yang_load.sh b/test/test_yang_load.sh
index 2d3ec4ae..da0c2c29 100755
--- a/test/test_yang_load.sh
+++ b/test/test_yang_load.sh
@@ -427,4 +427,5 @@ if [ $BE -ne 0 ]; then
rm -rf $dir
fi
-
+new "endtest"
+endtest
diff --git a/test/test_yang_models_ieee.sh b/test/test_yang_models_ieee.sh
index db621e08..f8304b8c 100755
--- a/test/test_yang_models_ieee.sh
+++ b/test/test_yang_models_ieee.sh
@@ -78,3 +78,5 @@ expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/s
rm -rf $dir
+new "endtest"
+endtest
diff --git a/test/test_yang_models_ietf.sh b/test/test_yang_models_ietf.sh
index f0aa8e3f..1a8137ab 100755
--- a/test/test_yang_models_ietf.sh
+++ b/test/test_yang_models_ietf.sh
@@ -64,3 +64,6 @@ echo "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version)" 0 "${CLIXON_VERSION}"
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/test/test_yang_namespace.sh b/test/test_yang_namespace.sh
index 1d14d1cf..fbf01a07 100755
--- a/test/test_yang_namespace.sh
+++ b/test/test_yang_namespace.sh
@@ -147,3 +147,6 @@ fi
unset RESTCONFIG
rm -rf $dir
+
+new "endtest"
+endtest
diff --git a/util/clixon_util_datastore.c b/util/clixon_util_datastore.c
index b9ee4263..a1245202 100644
--- a/util/clixon_util_datastore.c
+++ b/util/clixon_util_datastore.c
@@ -102,6 +102,7 @@ usage(char *argv0)
int
main(int argc, char **argv)
{
+ int retval = -1;
int c;
clicon_handle h;
char *argv0;
@@ -119,6 +120,7 @@ main(int argc, char **argv)
char *xpath;
cbuf *cbret = NULL;
int dbg = 0;
+ cxobj *xerr = NULL;
/* In the startup, logs to stderr & debug flag set later */
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
@@ -259,16 +261,21 @@ main(int argc, char **argv)
goto done;
fclose(fp);
}
- else
- if (clixon_xml_parse_string(argv[2], YB_MODULE, yspec, &xt, NULL) < 0)
+ else{
+ if ((ret = clixon_xml_parse_string(argv[2], YB_MODULE, yspec, &xt, &xerr)) < 0)
goto done;
- if (xml_rootchild(xt, 0, &xt) < 0)
+ if (ret == 0){
+ xml_print(stderr, xerr);
+ goto done;
+ }
+ }
+ if (xml_name_set(xt, NETCONF_INPUT_CONFIG) < 0)
goto done;
if ((cbret = cbuf_new()) == NULL){
clicon_err(OE_UNIX, errno, "cbuf_new");
goto done;
}
- if (xmldb_put(h, db, op, xt, NULL, cbret) < 1)
+ if ((ret = xmldb_put(h, db, op, xt, NULL, cbret)) < 0)
goto done;
}
else if (strcmp(cmd, "copy")==0){
@@ -329,6 +336,7 @@ main(int argc, char **argv)
}
if (xmldb_disconnect(h) < 0)
goto done;
+ retval = 0;
done:
if (cbret)
cbuf_free(cbret);
@@ -338,6 +346,6 @@ main(int argc, char **argv)
clicon_handle_exit(h);
if (yspec)
yspec_free(yspec);
- return 0;
+ return retval;
}
diff --git a/util/clixon_util_ssl.c b/util/clixon_util_ssl.c
index fa3e9343..1d90045f 100644
--- a/util/clixon_util_ssl.c
+++ b/util/clixon_util_ssl.c
@@ -33,7 +33,10 @@
***** END LICENSE BLOCK *****
+ *
* HTTP2 + OPENSSL client integrated with clixon events
+ * Ubuntu package:
+ * apt install libnghttp2-dev
* Example run: clixon_util_ssl -H nghttp2.org
*/
@@ -122,9 +125,8 @@ send_callback(nghttp2_session *session,
{
session_data *sd = (session_data*)user_data;
int ret;
-
- clicon_debug(1, "%s %d:", __FUNCTION__, length);
+ clicon_debug(1, "%s %zu:", __FUNCTION__, length);
#if 0
{
int i;
@@ -475,6 +477,7 @@ main(int argc,
int ret;
nghttp2_session *session = NULL;
session_data *sd = NULL;
+ int dbg = 0;
/* In the startup, logs to stderr & debug flag set later */
clicon_log_init(__FILE__, LOG_INFO, CLICON_LOG_STDERR);
@@ -487,7 +490,7 @@ main(int argc,
usage(argv[0]);
break;
case 'D':
- if (sscanf(optarg, "%d", &debug) != 1)
+ if (sscanf(optarg, "%d", &dbg) != 1)
usage(argv[0]);
break;
case 'H': /* hostname */
@@ -501,6 +504,7 @@ main(int argc,
fprintf(stderr, "-H is mandatory\n");
usage(argv[0]);
}
+ clicon_debug_init(dbg, NULL);
SSL_library_init();
if ((ctx = InitCTX()) == NULL)
goto done;