yanglint TEST option --xpath in interactive mode
diff --git a/tools/lint/tests/data/moddatanodes.xml b/tools/lint/tests/data/moddatanodes.xml
new file mode 100644
index 0000000..8ae6e97
--- /dev/null
+++ b/tools/lint/tests/data/moddatanodes.xml
@@ -0,0 +1,17 @@
+<dnc xmlns="urn:yanglint:moddatanodes">
+ <lf>x</lf>
+ <lfl>1</lfl>
+ <lfl>2</lfl>
+ <con>
+ <lt>
+ <kalf>ka1</kalf>
+ <kblf>kb1</kblf>
+ <vlf>v1</vlf>
+ </lt>
+ <lt>
+ <kalf>ka2</kalf>
+ <kblf>kb2</kblf>
+ <vlf>v2</vlf>
+ </lt>
+ </con>
+</dnc>
diff --git a/tools/lint/tests/interactive/data_xpath.test b/tools/lint/tests/interactive/data_xpath.test
new file mode 100644
index 0000000..6edb095
--- /dev/null
+++ b/tools/lint/tests/interactive/data_xpath.test
@@ -0,0 +1,39 @@
+source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
+
+set data "$::env(TESTS_DIR)/data/moddatanodes.xml"
+
+test data_xpath_empty {--xpath to missing node} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load moddatanodes"
+ ly_cmd "data -x /moddatanodes:dnc/mis $data" "Empty"
+}}
+
+test data_xpath_leaf {--xpath to leaf node} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load moddatanodes"
+ ly_cmd "data -x /moddatanodes:dnc/lf $data" "leaf \"lf\" \\(value: \"x\"\\)"
+}}
+
+test data_xpath_leaflist {--xpath to leaf-list node} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load moddatanodes"
+ set r1 "leaf-list \"lfl\" \\(value: \"1\"\\)"
+ set r2 "leaf-list \"lfl\" \\(value: \"2\"\\)"
+ ly_cmd "data -x /moddatanodes:dnc/lfl $data" "$r1\r\n $r2"
+}}
+
+test data_xpath_list {--xpath to list} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load moddatanodes"
+ set r1 "list \"lt\" \\(\"kalf\": \"ka1\"; \"kblf\": \"kb1\";\\)"
+ set r2 "list \"lt\" \\(\"kalf\": \"ka2\"; \"kblf\": \"kb2\";\\)"
+ ly_cmd "data -x /moddatanodes:dnc/con/lt $data" "$r1\r\n $r2"
+}}
+
+test data_xpath_err_default {--xpath cannot be combined with --default} {
+-setup $ly_setup -cleanup $ly_cleanup -body {
+ ly_cmd "load moddatanodes ietf-netconf-with-defaults"
+ ly_cmd_err "data -d all -x /moddatanodes:dnc/lf $data" "option cannot be combined"
+}}
+
+cleanupTests
diff --git a/tools/lint/tests/modules/moddatanodes.yang b/tools/lint/tests/modules/moddatanodes.yang
new file mode 100644
index 0000000..ae4ab20
--- /dev/null
+++ b/tools/lint/tests/modules/moddatanodes.yang
@@ -0,0 +1,31 @@
+module moddatanodes {
+ yang-version 1.1;
+ namespace "urn:yanglint:moddatanodes";
+ prefix mdn;
+
+ container dnc {
+ leaf lf {
+ type string;
+ }
+ leaf-list lfl {
+ type string;
+ }
+ leaf mis {
+ type string;
+ }
+ container con {
+ list lt {
+ key "kalf kblf";
+ leaf kalf {
+ type string;
+ }
+ leaf kblf {
+ type string;
+ }
+ leaf vlf {
+ type string;
+ }
+ }
+ }
+ }
+}