summaryrefslogtreecommitdiffstats
path: root/test/imode/cd_test.exp
blob: c241c89139745f5130d6d8cab062ee9e50d612fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/expect -f
# Test :cd and :pwd built-in commands.
#
# Environment variables:
#   LMI     - path to lmi meta-command executable with optional argumenta.
#
# Last change dir is unsuccessful.
# Exits with the exit code os spawned lmi shell.

set timeout 1

expect_after {
    timeout { exit -1 }
}

proc send1l {in out} {
    send   "$in\r"
    expect "$out"
}

proc send2l {in out1 out2} {
    send   "$in\r"
    expect "$out1"
    expect "$out2"
}

set LMI lmi
if {[info exists env(LMI)]} {
    set LMI $env(LMI)
}
spawn {*}$LMI
expect "lmi> "
send2l ": pwd"        "/lmi"        "lmi> "
send1l ": cd ."       "lmi> "
send2l " : pwd "      "/lmi"        "lmi> "
send1l ":cd .."       "lmi> "
send1l ":cd /"        "lmi> "
send1l " : cd // "    "lmi> "
send1l ": cd test"    ">test> "
send2l ": pwd"        "/lmi/test"   ">test> "
send1l ":cd ."        ">test> "
send1l ": .."         "lmi> "
send2l ":pwd"         "/lmi"        "lmi> "
send1l ":cd test"     ">test> "
send1l ":cd / "       "lmi> "
send1l ":cd test/"    ">test> "
send1l ":cd ../test"  ">test> "
send1l ":cd .././test/.././test/../"    "lmi> "
send1l ":cd test/./"  ">test> "
send1l ":cd list"     ">>list> "
send2l ":pwd"         "/lmi/test/list"  ">>list> "
send1l ":cd .."       ">test> "
send1l ":cd /lmi/test/list"     "list> "
send1l ":cd /lmi"     "lmi> "
send1l ":cd /test/list"         "list> "
send1l ":cd"          "list> "
send1l ":cd /./test/../test/./list"     ">>list> "
send2l ":cd /foo"     "No such subcommand \"foo\"."  ">>list> "
send2l ":cd pkgs"     "Can not nest to subcommand \"pkgs\" which is not a multiplexer." ">>list> "
send2l ":cd ../show"  "Can not nest to subcommand \"../show\" which lacks any help message." ">>list> "
send2l ":cd foo"      "No such subcommand \"foo\"." ">>list> "
send   ""
expect ">test> "
send   ""
expect "lmi> "
send   ""
expect ""
catch wait result
exit [lindex $result 3]