xref: /aosp_15_r20/external/openthread/tests/scripts/expect/cli-diags.exp (revision cfb92d1480a9e65faed56933e9c12405f45898b4)
1*cfb92d14SAndroid Build Coastguard Worker#!/usr/bin/expect -f
2*cfb92d14SAndroid Build Coastguard Worker#
3*cfb92d14SAndroid Build Coastguard Worker#  Copyright (c) 2022, The OpenThread Authors.
4*cfb92d14SAndroid Build Coastguard Worker#  All rights reserved.
5*cfb92d14SAndroid Build Coastguard Worker#
6*cfb92d14SAndroid Build Coastguard Worker#  Redistribution and use in source and binary forms, with or without
7*cfb92d14SAndroid Build Coastguard Worker#  modification, are permitted provided that the following conditions are met:
8*cfb92d14SAndroid Build Coastguard Worker#  1. Redistributions of source code must retain the above copyright
9*cfb92d14SAndroid Build Coastguard Worker#     notice, this list of conditions and the following disclaimer.
10*cfb92d14SAndroid Build Coastguard Worker#  2. Redistributions in binary form must reproduce the above copyright
11*cfb92d14SAndroid Build Coastguard Worker#     notice, this list of conditions and the following disclaimer in the
12*cfb92d14SAndroid Build Coastguard Worker#     documentation and/or other materials provided with the distribution.
13*cfb92d14SAndroid Build Coastguard Worker#  3. Neither the name of the copyright holder nor the
14*cfb92d14SAndroid Build Coastguard Worker#     names of its contributors may be used to endorse or promote products
15*cfb92d14SAndroid Build Coastguard Worker#     derived from this software without specific prior written permission.
16*cfb92d14SAndroid Build Coastguard Worker#
17*cfb92d14SAndroid Build Coastguard Worker#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18*cfb92d14SAndroid Build Coastguard Worker#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*cfb92d14SAndroid Build Coastguard Worker#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*cfb92d14SAndroid Build Coastguard Worker#  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21*cfb92d14SAndroid Build Coastguard Worker#  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22*cfb92d14SAndroid Build Coastguard Worker#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23*cfb92d14SAndroid Build Coastguard Worker#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*cfb92d14SAndroid Build Coastguard Worker#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25*cfb92d14SAndroid Build Coastguard Worker#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26*cfb92d14SAndroid Build Coastguard Worker#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27*cfb92d14SAndroid Build Coastguard Worker#  POSSIBILITY OF SUCH DAMAGE.
28*cfb92d14SAndroid Build Coastguard Worker#
29*cfb92d14SAndroid Build Coastguard Worker
30*cfb92d14SAndroid Build Coastguard Workersource "tests/scripts/expect/_common.exp"
31*cfb92d14SAndroid Build Coastguard Workersource "tests/scripts/expect/_multinode.exp"
32*cfb92d14SAndroid Build Coastguard Worker
33*cfb92d14SAndroid Build Coastguard Workerspawn_node 1
34*cfb92d14SAndroid Build Coastguard Workerspawn_node 2
35*cfb92d14SAndroid Build Coastguard Worker
36*cfb92d14SAndroid Build Coastguard Workerswitch_node 1
37*cfb92d14SAndroid Build Coastguard Workersend "diag start\n"
38*cfb92d14SAndroid Build Coastguard Workerexpect "start diagnostics mode"
39*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
40*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
41*cfb92d14SAndroid Build Coastguard Worker
42*cfb92d14SAndroid Build Coastguard Workersend "diag channel 11\n"
43*cfb92d14SAndroid Build Coastguard Workerexpect "set channel to 11"
44*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
45*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
46*cfb92d14SAndroid Build Coastguard Worker
47*cfb92d14SAndroid Build Coastguard Workersend "diag stats clear\n"
48*cfb92d14SAndroid Build Coastguard Workerexpect "stats cleared"
49*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
50*cfb92d14SAndroid Build Coastguard Worker
51*cfb92d14SAndroid Build Coastguard Workerswitch_node 2
52*cfb92d14SAndroid Build Coastguard Worker
53*cfb92d14SAndroid Build Coastguard Workersend "diag start\n"
54*cfb92d14SAndroid Build Coastguard Workerexpect "start diagnostics mode"
55*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
56*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
57*cfb92d14SAndroid Build Coastguard Worker
58*cfb92d14SAndroid Build Coastguard Workersend "diag channel 11\n"
59*cfb92d14SAndroid Build Coastguard Workerexpect "set channel to 11"
60*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
61*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
62*cfb92d14SAndroid Build Coastguard Worker
63*cfb92d14SAndroid Build Coastguard Workersend "diag stats clear\n"
64*cfb92d14SAndroid Build Coastguard Workerexpect "stats cleared"
65*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
66*cfb92d14SAndroid Build Coastguard Worker
67*cfb92d14SAndroid Build Coastguard Workersend "diag send 10 100\n"
68*cfb92d14SAndroid Build Coastguard Workerexpect "sending 0xa packet(s), length 0x64"
69*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
70*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
71*cfb92d14SAndroid Build Coastguard Worker
72*cfb92d14SAndroid Build Coastguard Workersleep 2
73*cfb92d14SAndroid Build Coastguard Worker
74*cfb92d14SAndroid Build Coastguard Workersend "diag stats\n"
75*cfb92d14SAndroid Build Coastguard Workerexpect "received packets: 0"
76*cfb92d14SAndroid Build Coastguard Workerexpect "sent packets: 10"
77*cfb92d14SAndroid Build Coastguard Workerexpect "first received packet: rssi=0, lqi=0"
78*cfb92d14SAndroid Build Coastguard Workerexpect "last received packet: rssi=0, lqi=0"
79*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
80*cfb92d14SAndroid Build Coastguard Worker
81*cfb92d14SAndroid Build Coastguard Workerswitch_node 1
82*cfb92d14SAndroid Build Coastguard Worker
83*cfb92d14SAndroid Build Coastguard Workersend "diag stats\n"
84*cfb92d14SAndroid Build Coastguard Workerexpect "received packets: 10"
85*cfb92d14SAndroid Build Coastguard Workerexpect "sent packets: 0"
86*cfb92d14SAndroid Build Coastguard Workerexpect "first received packet: rssi=-20, lqi=0"
87*cfb92d14SAndroid Build Coastguard Workerexpect "last received packet: rssi=-20, lqi=0"
88*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
89*cfb92d14SAndroid Build Coastguard Worker
90*cfb92d14SAndroid Build Coastguard Workersend "diag stats clear\n"
91*cfb92d14SAndroid Build Coastguard Workerexpect "stats cleared"
92*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
93*cfb92d14SAndroid Build Coastguard Worker
94*cfb92d14SAndroid Build Coastguard Workerswitch_node 2
95*cfb92d14SAndroid Build Coastguard Worker
96*cfb92d14SAndroid Build Coastguard Workersend "diag repeat 20 100\n"
97*cfb92d14SAndroid Build Coastguard Workerexpect "sending packets of length 0x64 at the delay of 0x14 ms"
98*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
99*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
100*cfb92d14SAndroid Build Coastguard Workersleep 1
101*cfb92d14SAndroid Build Coastguard Workersend "diag repeat stop\n"
102*cfb92d14SAndroid Build Coastguard Workerexpect "repeated packet transmission is stopped"
103*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
104*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
105*cfb92d14SAndroid Build Coastguard Worker
106*cfb92d14SAndroid Build Coastguard Workerswitch_node 1
107*cfb92d14SAndroid Build Coastguard Worker
108*cfb92d14SAndroid Build Coastguard Workersend "diag stats\n"
109*cfb92d14SAndroid Build Coastguard Workerexpect -r {received packets: \d+}
110*cfb92d14SAndroid Build Coastguard Workerexpect "sent packets: 0"
111*cfb92d14SAndroid Build Coastguard Workerexpect "first received packet: rssi=-20, lqi=0"
112*cfb92d14SAndroid Build Coastguard Workerexpect "last received packet: rssi=-20, lqi=0"
113*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
114*cfb92d14SAndroid Build Coastguard Worker
115*cfb92d14SAndroid Build Coastguard Workersend "diag stats clear\n"
116*cfb92d14SAndroid Build Coastguard Workerexpect "stats cleared"
117*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
118*cfb92d14SAndroid Build Coastguard Worker
119*cfb92d14SAndroid Build Coastguard Workerdispose_all
120*cfb92d14SAndroid Build Coastguard Worker
121*cfb92d14SAndroid Build Coastguard Worker
122*cfb92d14SAndroid Build Coastguard Workerspawn_node 1
123*cfb92d14SAndroid Build Coastguard Worker
124*cfb92d14SAndroid Build Coastguard Workersend "diag start\n"
125*cfb92d14SAndroid Build Coastguard Workerexpect "start diagnostics mode"
126*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
127*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
128*cfb92d14SAndroid Build Coastguard Worker
129*cfb92d14SAndroid Build Coastguard Workersend_user "input too short test\n"
130*cfb92d14SAndroid Build Coastguard Workersend "diag frame 11\n"
131*cfb92d14SAndroid Build Coastguard Workerexpect "Error"
132*cfb92d14SAndroid Build Coastguard Worker
133*cfb92d14SAndroid Build Coastguard Workersend_user "input too long test\n"
134*cfb92d14SAndroid Build Coastguard Workersend "diag frame 11223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900\n"
135*cfb92d14SAndroid Build Coastguard Workerexpect "Error"
136*cfb92d14SAndroid Build Coastguard Worker
137*cfb92d14SAndroid Build Coastguard Workersend_user "input odd length test\n"
138*cfb92d14SAndroid Build Coastguard Workersend "diag frame 123\n"
139*cfb92d14SAndroid Build Coastguard Workerexpect "Error"
140*cfb92d14SAndroid Build Coastguard Worker
141*cfb92d14SAndroid Build Coastguard Workersend_user "shortest frame test\n"
142*cfb92d14SAndroid Build Coastguard Workersend "diag frame 112233\n"
143*cfb92d14SAndroid Build Coastguard Workerexpect "Done"
144*cfb92d14SAndroid Build Coastguard Workersend "diag send 1\n"
145*cfb92d14SAndroid Build Coastguard Workerexpect "length 0x3"
146*cfb92d14SAndroid Build Coastguard Workerexpect "Done"
147*cfb92d14SAndroid Build Coastguard Worker
148*cfb92d14SAndroid Build Coastguard Workersend_user "longest frame test\n"
149*cfb92d14SAndroid Build Coastguard Workersend "diag frame 11223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677\n"
150*cfb92d14SAndroid Build Coastguard Workerexpect "Done"
151*cfb92d14SAndroid Build Coastguard Workersend "diag repeat 1\n"
152*cfb92d14SAndroid Build Coastguard Workerexpect "length 0x7f"
153*cfb92d14SAndroid Build Coastguard Workerexpect "Done"
154*cfb92d14SAndroid Build Coastguard Worker
155*cfb92d14SAndroid Build Coastguard Workersend_user "send frame with security processed\n"
156*cfb92d14SAndroid Build Coastguard Workersend "diag frame -s 112233\n"
157*cfb92d14SAndroid Build Coastguard Workerexpect "Done"
158*cfb92d14SAndroid Build Coastguard Workersend "diag send 1\n"
159*cfb92d14SAndroid Build Coastguard Workerexpect "length 0x3"
160*cfb92d14SAndroid Build Coastguard Workerexpect "Done"
161*cfb92d14SAndroid Build Coastguard Worker
162*cfb92d14SAndroid Build Coastguard Workersend "diag repeat stop\n"
163*cfb92d14SAndroid Build Coastguard Workerexpect "Done"
164*cfb92d14SAndroid Build Coastguard Worker
165*cfb92d14SAndroid Build Coastguard Workersend "diag channel 11\n"
166*cfb92d14SAndroid Build Coastguard Workerexpect "set channel to 11"
167*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
168*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
169*cfb92d14SAndroid Build Coastguard Worker
170*cfb92d14SAndroid Build Coastguard Workersend "diag power 10\n"
171*cfb92d14SAndroid Build Coastguard Workerexpect "set tx power to 10 dBm"
172*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
173*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
174*cfb92d14SAndroid Build Coastguard Worker
175*cfb92d14SAndroid Build Coastguard Workersend "diag radio sleep\n"
176*cfb92d14SAndroid Build Coastguard Workerexpect "set radio from receive to sleep"
177*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
178*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
179*cfb92d14SAndroid Build Coastguard Worker
180*cfb92d14SAndroid Build Coastguard Workersend "diag radio state\n"
181*cfb92d14SAndroid Build Coastguard Workerexpect "sleep"
182*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
183*cfb92d14SAndroid Build Coastguard Worker
184*cfb92d14SAndroid Build Coastguard Workersend "diag radio receive\n"
185*cfb92d14SAndroid Build Coastguard Workerexpect "set radio from sleep to receive on channel 11"
186*cfb92d14SAndroid Build Coastguard Workerexpect "status 0x00"
187*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
188*cfb92d14SAndroid Build Coastguard Worker
189*cfb92d14SAndroid Build Coastguard Workersend "diag radio state\n"
190*cfb92d14SAndroid Build Coastguard Workerexpect "receive"
191*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
192*cfb92d14SAndroid Build Coastguard Worker
193*cfb92d14SAndroid Build Coastguard Workersend "diag gpio set 0 1\n"
194*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
195*cfb92d14SAndroid Build Coastguard Worker
196*cfb92d14SAndroid Build Coastguard Workersend "diag gpio get 0\n"
197*cfb92d14SAndroid Build Coastguard Workerexpect "1"
198*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
199*cfb92d14SAndroid Build Coastguard Worker
200*cfb92d14SAndroid Build Coastguard Workersend "diag gpio mode 0 in\n"
201*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
202*cfb92d14SAndroid Build Coastguard Worker
203*cfb92d14SAndroid Build Coastguard Workersend "diag gpio mode 0\n"
204*cfb92d14SAndroid Build Coastguard Workerexpect "in"
205*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
206*cfb92d14SAndroid Build Coastguard Worker
207*cfb92d14SAndroid Build Coastguard Workersend "diag gpio mode 0 out\n"
208*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
209*cfb92d14SAndroid Build Coastguard Worker
210*cfb92d14SAndroid Build Coastguard Workersend "diag gpio mode 0\n"
211*cfb92d14SAndroid Build Coastguard Workerexpect "out"
212*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
213*cfb92d14SAndroid Build Coastguard Worker
214*cfb92d14SAndroid Build Coastguard Workersend "diag cw start\n"
215*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
216*cfb92d14SAndroid Build Coastguard Worker
217*cfb92d14SAndroid Build Coastguard Workersend "diag cw stop\n"
218*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
219*cfb92d14SAndroid Build Coastguard Worker
220*cfb92d14SAndroid Build Coastguard Workersend "diag stream start\n"
221*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
222*cfb92d14SAndroid Build Coastguard Worker
223*cfb92d14SAndroid Build Coastguard Workersend "diag stream stop\n"
224*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
225*cfb92d14SAndroid Build Coastguard Worker
226*cfb92d14SAndroid Build Coastguard Workersend "diag rawpowersetting 112233\n"
227*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
228*cfb92d14SAndroid Build Coastguard Worker
229*cfb92d14SAndroid Build Coastguard Workersend "diag rawpowersetting\n"
230*cfb92d14SAndroid Build Coastguard Workerexpect "112233"
231*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
232*cfb92d14SAndroid Build Coastguard Worker
233*cfb92d14SAndroid Build Coastguard Workersend "diag rawpowersetting enable\n"
234*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
235*cfb92d14SAndroid Build Coastguard Worker
236*cfb92d14SAndroid Build Coastguard Workersend "diag rawpowersetting disable\n"
237*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
238*cfb92d14SAndroid Build Coastguard Worker
239*cfb92d14SAndroid Build Coastguard Workersend "diag invalid_commad\n"
240*cfb92d14SAndroid Build Coastguard Workerexpect "Error 35: InvalidCommand"
241*cfb92d14SAndroid Build Coastguard Worker
242*cfb92d14SAndroid Build Coastguard Workersend "diag stop\n"
243*cfb92d14SAndroid Build Coastguard Workerexpect_line "Done"
244*cfb92d14SAndroid Build Coastguard Worker
245*cfb92d14SAndroid Build Coastguard Workersend "diag channel\n"
246*cfb92d14SAndroid Build Coastguard Workerexpect "failed"
247*cfb92d14SAndroid Build Coastguard Workerexpect "status 0xd"
248*cfb92d14SAndroid Build Coastguard Workerexpect "Error 13: InvalidState"
249*cfb92d14SAndroid Build Coastguard Worker
250*cfb92d14SAndroid Build Coastguard Workerdispose_all
251