yanglint REFACTOR change error msg to warning msg
If an error message is printed, the return value of yanglint should
be non-zero. If a warning message is displayed, the return value can
be zero.
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 5afe578..3987e08 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -908,12 +908,12 @@
}
if (c->data_operational.path && !c->data_type) {
- YLMSG_E("Operational datastore takes effect only with RPCs/Actions/Replies/Notification input data types.\n");
+ YLMSG_W("Operational datastore takes effect only with RPCs/Actions/Replies/Notification input data types.\n");
c->data_operational.path = NULL;
}
if (c->reply_rpc.path && (c->data_type != LYD_TYPE_REPLY_NETCONF)) {
- YLMSG_E("Source RPC is needed only for NETCONF Reply input data type.\n");
+ YLMSG_W("Source RPC is needed only for NETCONF Reply input data type.\n");
c->data_operational.path = NULL;
} else if (!c->reply_rpc.path && (c->data_type == LYD_TYPE_REPLY_NETCONF)) {
YLMSG_E("Missing source RPC (-R) for NETCONF Reply input data type.\n");
@@ -921,7 +921,7 @@
}
if ((c->schema_out_format != LYS_OUT_TREE) && c->line_length) {
- YLMSG_E("--tree-line-length take effect only in case of the tree output format.\n");
+ YLMSG_W("--tree-line-length take effect only in case of the tree output format.\n");
}
/* default output stream */
diff --git a/tools/lint/tests/interactive/data_operational.test b/tools/lint/tests/interactive/data_operational.test
index 25bb130..011936a 100644
--- a/tools/lint/tests/interactive/data_operational.test
+++ b/tools/lint/tests/interactive/data_operational.test
@@ -21,6 +21,11 @@
ly_cmd_err "data $ddir/modoper_leafref_notif_err.xml" "Failed to parse input data file"
}}
+test data_operational_wrong_type {data are not defined as an operation} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd_wrn "data -t data -O $ddir/modconfig.xml $ddir/modleaf.xml" $err1
+}}
+
test data_operational_datastore_with_unknown_data {unknown data are ignored} {
-setup $ly_setup -cleanup $ly_cleanup -body {
ly_cmd "load modrpc"
diff --git a/tools/lint/tests/non-interactive/data_operational.test b/tools/lint/tests/non-interactive/data_operational.test
index 8205d17..d027ee9 100644
--- a/tools/lint/tests/non-interactive/data_operational.test
+++ b/tools/lint/tests/non-interactive/data_operational.test
@@ -16,6 +16,10 @@
ly_cmd_err "$mdir/modoper-leafref.yang $ddir/modoper_leafref_notif_err.xml" "Failed to parse input data file"
} {}
+test data_operational_wrong_type {data are not defined as an operation} {
+ ly_cmd_wrn "-t data -O $ddir/modconfig.xml $mdir/modleaf.yang $ddir/modleaf.xml" $err1
+} {}
+
test data_operational_datastore_with_unknown_data {unknown data are ignored} {
ly_cmd "-t rpc -O $ddir/modmandatory_invalid.xml $mdir/modrpc.yang $ddir/modrpc.xml"
} {}