forked from TimidRobot/cmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cmc
executable file
·110 lines (96 loc) · 2.77 KB
/
test_cmc
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
set -o errexit
set -o errtrace
set -o nounset
trap '_es=${?};
printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\"";
printf " exited with a status of ${_es}\n";
exit ${_es}' ERR
TESTHOST=${1}
echo 'Show Debug information'
echo '======================'
./cmc -d
echo
echo
echo 'Verify syntax'
echo '============='
shellcheck cmc
echo
echo
HEAD="Verify \`-c ${TESTHOST}\` check HOST ControlMaster connection status"
echo "${HEAD}"
echo "${HEAD//?/=}"
echo "1. Establish a connection to ${TESTHOST}"
ssh -o ClearAllForwardings=yes -o ControlPersist=5m -o VisualHostKey=no \
${TESTHOST} exit 0
echo
echo "2. Check ${TESTHOST} with active socket"
./cmc -c ${TESTHOST}
echo
PID=$(./cmc -c ${TESTHOST} | awk '/pid:/ {print $2}')
echo "3. Send ALRM signal to PID ${PID} leave a stale socket"
kill -14 ${PID}
echo
echo "4. Check ${TESTHOST} with stale socket"
./cmc -c ${TESTHOST} || true
echo
echo
echo 'Verify `-l` list all active ControlMaster connection sockets'
echo '============================================================'
echo "1. Establish a connection to ${TESTHOST}"
ssh -o ClearAllForwardings=yes -o ControlPersist=5m -o VisualHostKey=no \
${TESTHOST} exit 0
echo
echo '2. List all with active socket'
./cmc -l
echo
PID=$(./cmc -c ${TESTHOST} | awk '/pid:/ {print $2}')
echo "3. Send ALRM signal to PID ${PID} leave a stale socket"
kill -14 ${PID}
echo
echo '4. List all with stale socket'
./cmc -l || true
echo
echo
HEAD="Verify \`-x ${TESTHOST}\` exit ControlMaster session"
echo "${HEAD}"
echo "${HEAD//?/=}"
echo "1. Establish a connection to ${TESTHOST}"
ssh -o ClearAllForwardings=yes -o ControlPersist=5m -o VisualHostKey=no \
${TESTHOST} exit 0
echo
echo "2. Exit ${TESTHOST} with active socket"
./cmc -x ${TESTHOST}
echo
echo "3. Establish a connection to ${TESTHOST}"
ssh -o ClearAllForwardings=yes -o ControlPersist=5m -o VisualHostKey=no \
${TESTHOST} exit 0
echo
PID=$(./cmc -c ${TESTHOST} | awk '/pid:/ {print $2}')
echo "4. Send ALRM signal to PID ${PID} leave a stale socket"
kill -14 ${PID}
echo
echo "5. Exit ${TESTHOST} with stale socket"
./cmc -x ${TESTHOST} || true
echo
echo
echo 'Verify `-X` exit all ControlMaster connections with sockets'
echo '==========================================================='
echo "1. Establish a connection to ${TESTHOST}"
ssh -o ClearAllForwardings=yes -o ControlPersist=5m -o VisualHostKey=no \
${TESTHOST} exit 0
echo
echo '2. Exit all with active socket'
./cmc -X
echo
echo "3. Establish a connection to ${TESTHOST}"
ssh -o ClearAllForwardings=yes -o ControlPersist=5m -o VisualHostKey=no \
${TESTHOST} exit 0
echo
PID=$(./cmc -c ${TESTHOST} | awk '/pid:/ {print $2}')
echo "4. Send ALRM signal to PID ${PID} leave a stale socket"
kill -14 ${PID}
echo
echo '5. Exit all with stale socket'
./cmc -X || true
echo