aPiecek | 05c7595 | 2023-03-29 09:09:44 +0200 | [diff] [blame] | 1 | source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/non-interactive/ly.tcl" : "ly.tcl"}] |
| 2 | |
| 3 | set mdir $::env(YANG_MODULES_DIR) |
aPiecek | f1f4efe | 2023-05-11 14:26:39 +0200 | [diff] [blame] | 4 | set ddir $::env(TESTS_DIR)/data |
aPiecek | 768ee47 | 2023-03-30 11:19:42 +0200 | [diff] [blame] | 5 | set ipv6_path "/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address" |
aPiecek | 05c7595 | 2023-03-29 09:09:44 +0200 | [diff] [blame] | 6 | |
| 7 | test format_yang {} { |
| 8 | ly_cmd "-f yang $mdir/modleaf.yang" "leaf lfl" |
| 9 | } {} |
| 10 | |
aPiecek | 60a517a | 2023-03-31 11:06:42 +0200 | [diff] [blame] | 11 | test format_yang_submodule {Print submodule in yang format} { |
| 12 | ly_cmd "-s modsub -f yang $mdir/modinclude.yang" "submodule modsub" |
| 13 | } {} |
| 14 | |
aPiecek | 05c7595 | 2023-03-29 09:09:44 +0200 | [diff] [blame] | 15 | test format_yin {} { |
| 16 | ly_cmd "-f yin $mdir/modleaf.yang" "<leaf name=\"lfl\">" |
| 17 | } {} |
| 18 | |
aPiecek | 60a517a | 2023-03-31 11:06:42 +0200 | [diff] [blame] | 19 | test format_yin_submodule {Print submodule in yin format} { |
| 20 | ly_cmd "-s modsub -f yin $mdir/modinclude.yang" "<submodule name=\"modsub\"" |
| 21 | } {} |
| 22 | |
aPiecek | 05c7595 | 2023-03-29 09:09:44 +0200 | [diff] [blame] | 23 | test format_info {} { |
| 24 | ly_cmd "-f info $mdir/modleaf.yang" "status current" |
| 25 | } {} |
| 26 | |
| 27 | test format_tree {} { |
| 28 | ly_cmd "-f tree $mdir/modleaf.yang" "\\+--rw lfl" |
| 29 | } {} |
| 30 | |
aPiecek | f1f4efe | 2023-05-11 14:26:39 +0200 | [diff] [blame] | 31 | test format_data_xml {Print data in xml format} { |
| 32 | ly_cmd "-f xml $mdir/modleaf.yang $ddir/modleaf.xml" "<lfl xmlns=\"urn:yanglint:modleaf\">7</lfl>" |
| 33 | } {} |
| 34 | |
| 35 | test format_data_json {Print data in json format} { |
| 36 | ly_cmd "-f json $mdir/modleaf.yang $ddir/modleaf.xml" "{\n \"modleaf:lfl\": 7\n}" |
| 37 | } {} |
| 38 | |
aPiecek | a472348 | 2023-05-11 14:31:02 +0200 | [diff] [blame] | 39 | test format_data_lyb_err {Printing in LYB format: expect error due to missing parameter} { |
| 40 | ly_cmd_err "-f lyb $mdir/modleaf.yang $ddir/modleaf.xml" "The LYB format requires the -o" |
| 41 | } {} |
| 42 | |
aPiecek | 60a517a | 2023-03-31 11:06:42 +0200 | [diff] [blame] | 43 | test format_tree_submodule {Print submodule in tree format} { |
| 44 | ly_cmd "-s modsub -f tree $mdir/modinclude.yang" "submodule: modsub" |
| 45 | } {} |
| 46 | |
aPiecek | 768ee47 | 2023-03-30 11:19:42 +0200 | [diff] [blame] | 47 | test format_tree_path {Print subtree in tree format} { |
| 48 | ly_cmd "-f tree -P $ipv6_path $mdir/ietf-ip.yang" "\\+--rw address.*\\+--rw prefix-length" |
| 49 | } {} |
| 50 | |
| 51 | test format_tree_path_single_node {Print node in tree format} { |
| 52 | ly_cmd "-f tree -q -P $ipv6_path $mdir/ietf-ip.yang" "\\+--rw address\\* \\\[ip\\\]$" |
| 53 | } {} |
| 54 | |
aPiecek | 146fd19 | 2023-03-30 11:22:16 +0200 | [diff] [blame] | 55 | test format_tree_path_single_node_line_length {Print node in the tree format and limit row size} { |
| 56 | ly_cmd "-f tree -L 20 -q -P $ipv6_path $mdir/ietf-ip.yang" "\\+--rw address\\*\n *\\\[ip\\\]$" |
| 57 | } {} |
| 58 | |
aPiecek | 05c7595 | 2023-03-29 09:09:44 +0200 | [diff] [blame] | 59 | test format_feature_param_one_module {Show features for one module} { |
| 60 | ly_cmd "-f feature-param $mdir/ietf-ip.yang" " -F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf" -ex |
| 61 | } {} |
| 62 | |
| 63 | test format_feature_param_more_modules {Show a mix of modules with and without features} { |
| 64 | |
| 65 | set features " -F modfeature:ftr1,ftr2\ |
| 66 | -F modleaf:\ |
| 67 | -F ietf-ip:ipv4-non-contiguous-netmasks,ipv6-privacy-autoconf" |
| 68 | |
| 69 | ly_cmd "-f feature-param $mdir/modfeature.yang $mdir/modleaf.yang $mdir/ietf-ip.yang" $features -ex |
| 70 | } {} |
| 71 | |
| 72 | cleanupTests |