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