blob: d1cacc10526ac65cf6bac73935e3ca1dcc367eea [file] [log] [blame]
aPiecek6d41a522023-03-27 14:20:38 +02001source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
2
3set mdir $::env(YANG_MODULES_DIR)
4
aPiecek080c2bf2023-03-28 14:27:52 +02005test add_basic {} {
6-setup $ly_setup -cleanup $ly_cleanup -body {
7 ly_cmd "add $mdir/modleafref.yang"
8 ly_cmd "list" "I modleafref\r.*I modleaf"
9}}
10
aPiecek6d41a522023-03-27 14:20:38 +020011test add_disable_searchdir_once {add --disable-searchdir} {
12-setup $ly_setup -cleanup $ly_cleanup -constraints {!ctest} -body {
13 ly_cmd "add $mdir/modimp-cwd.yang"
14 ly_cmd "clear"
15 ly_cmd_err "add -D $mdir/modimp-cwd.yang" "not found in local searchdirs"
16}}
17
18test add_disable_searchdir_twice {add -D -D} {
19-setup $ly_setup -cleanup $ly_cleanup -constraints {!ctest} -body {
20 ly_cmd "add $mdir/ietf-ip.yang"
21 ly_cmd "clear"
22 ly_cmd_err "add -D -D $mdir/ietf-ip.yang" "Loading \"ietf-interfaces\" module failed."
23}}
24
aPieceka96d4432023-03-27 15:49:06 +020025test add_with_feature {Add module with feature} {
26-setup $ly_setup -cleanup $ly_cleanup -body {
27 ly_cmd "add --feature modfeature:ftr2 $mdir/modfeature.yang"
28 ly_cmd "feature -a" "modfeature:\r\n\tftr1 \\(off\\)\r\n\tftr2 \\(on\\)"
29}}
30
aPiecek080c2bf2023-03-28 14:27:52 +020031test add_make_implemented_once {add --make-implemented} {
32-setup $ly_setup -cleanup $ly_cleanup -body {
33 ly_ignore "add $mdir/modmust.yang"
34 ly_cmd "list" "I modmust\r.*i modleaf"
35 ly_cmd "clear"
36 ly_ignore "add -i $mdir/modmust.yang"
37 ly_cmd "list" "I modmust\r.*I modleaf"
38}}
39
40test add_make_implemented_twice {add -i -i} {
41-setup $ly_setup -cleanup $ly_cleanup -body {
42 ly_cmd "add $mdir/modimp-type.yang"
43 ly_cmd "list" "I modimp-type\r.*i modtypedef"
44 ly_cmd "clear"
45 ly_cmd "add -i -i $mdir/modimp-type.yang"
46 ly_cmd "list" "I modimp-type\r.*I modtypedef"
47}}
48
aPiecek88030e52023-06-02 11:03:57 +020049test add_extended_leafref_enabled {Valid module with --extended-leafref option} {
50-setup $ly_setup -cleanup $ly_cleanup -body {
51 ly_cmd "add -X $mdir/modextleafref.yang"
52}}
53
54test add_extended_leafref_disabled {Expected error if --extended-leafref is not set} {
55-setup $ly_setup -cleanup $ly_cleanup -body {
56 ly_cmd_err "add $mdir/modextleafref.yang" "Unexpected XPath token \"FunctionName\""
57}}
58
aPiecek6d41a522023-03-27 14:20:38 +020059cleanupTests