]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/test/cmdline_test/cmdline_test_data.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / seastar / dpdk / test / cmdline_test / cmdline_test_data.py
1 # BSD LICENSE
2 #
3 # Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
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
8 # are met:
9 #
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in
14 # the documentation and/or other materials provided with the
15 # distribution.
16 # * Neither the name of Intel Corporation nor the names of its
17 # contributors may be used to endorse or promote products derived
18 # from this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 # collection of static data
33
34 # keycode constants
35 CTRL_A = chr(1)
36 CTRL_B = chr(2)
37 CTRL_C = chr(3)
38 CTRL_D = chr(4)
39 CTRL_E = chr(5)
40 CTRL_F = chr(6)
41 CTRL_K = chr(11)
42 CTRL_L = chr(12)
43 CTRL_N = chr(14)
44 CTRL_P = chr(16)
45 CTRL_W = chr(23)
46 CTRL_Y = chr(25)
47 ALT_B = chr(27) + chr(98)
48 ALT_D = chr(27) + chr(100)
49 ALT_F = chr(27) + chr(102)
50 ALT_BKSPACE = chr(27) + chr(127)
51 DEL = chr(27) + chr(91) + chr(51) + chr(126)
52 TAB = chr(9)
53 HELP = chr(63)
54 BKSPACE = chr(127)
55 RIGHT = chr(27) + chr(91) + chr(67)
56 DOWN = chr(27) + chr(91) + chr(66)
57 LEFT = chr(27) + chr(91) + chr(68)
58 UP = chr(27) + chr(91) + chr(65)
59 ENTER2 = '\r'
60 ENTER = '\n'
61
62 # expected result constants
63 NOT_FOUND = "Command not found"
64 BAD_ARG = "Bad arguments"
65 AMBIG = "Ambiguous command"
66 CMD1 = "Command 1 parsed!"
67 CMD2 = "Command 2 parsed!"
68 SINGLE = "Single word command parsed!"
69 SINGLE_LONG = "Single long word command parsed!"
70 AUTO1 = "Autocomplete command 1 parsed!"
71 AUTO2 = "Autocomplete command 2 parsed!"
72
73 # misc defines
74 CMD_QUIT = "quit"
75 CMD_GET_BUFSIZE = "get_history_bufsize"
76 BUFSIZE_TEMPLATE = "History buffer size: "
77 PROMPT = "CMDLINE_TEST>>"
78
79 # test defines
80 # each test tests progressively diverse set of keys. this way for example
81 # if we want to use some key sequence in the test, we first need to test
82 # that it itself does what it is expected to do. Most of the tests are
83 # designed that way.
84 #
85 # example: "arrows & delete test 1". we enter a partially valid command,
86 # then move 3 chars left and use delete three times. this way we get to
87 # know that "delete", "left" and "ctrl+B" all work (because if any of
88 # them fails, the whole test will fail and next tests won't be run).
89 #
90 # each test consists of name, character sequence to send to child,
91 # and expected output (if any).
92
93 tests = [
94 # test basic commands
95 {"Name": "command test 1",
96 "Sequence": "ambiguous first" + ENTER,
97 "Result": CMD1},
98 {"Name": "command test 2",
99 "Sequence": "ambiguous second" + ENTER,
100 "Result": CMD2},
101 {"Name": "command test 3",
102 "Sequence": "ambiguous ambiguous" + ENTER,
103 "Result": AMBIG},
104 {"Name": "command test 4",
105 "Sequence": "ambiguous ambiguous2" + ENTER,
106 "Result": AMBIG},
107
108 {"Name": "invalid command test 1",
109 "Sequence": "ambiguous invalid" + ENTER,
110 "Result": BAD_ARG},
111 # test invalid commands
112 {"Name": "invalid command test 2",
113 "Sequence": "invalid" + ENTER,
114 "Result": NOT_FOUND},
115 {"Name": "invalid command test 3",
116 "Sequence": "ambiguousinvalid" + ENTER2,
117 "Result": NOT_FOUND},
118
119 # test arrows and deletes
120 {"Name": "arrows & delete test 1",
121 "Sequence": "singlebad" + LEFT*2 + CTRL_B + DEL*3 + ENTER,
122 "Result": SINGLE},
123 {"Name": "arrows & delete test 2",
124 "Sequence": "singlebad" + LEFT*5 + RIGHT + CTRL_F + DEL*3 + ENTER,
125 "Result": SINGLE},
126
127 # test backspace
128 {"Name": "backspace test",
129 "Sequence": "singlebad" + BKSPACE*3 + ENTER,
130 "Result": SINGLE},
131
132 # test goto left and goto right
133 {"Name": "goto left test",
134 "Sequence": "biguous first" + CTRL_A + "am" + ENTER,
135 "Result": CMD1},
136 {"Name": "goto right test",
137 "Sequence": "biguous fir" + CTRL_A + "am" + CTRL_E + "st" + ENTER,
138 "Result": CMD1},
139
140 # test goto words
141 {"Name": "goto left word test",
142 "Sequence": "ambiguous st" + ALT_B + "fir" + ENTER,
143 "Result": CMD1},
144 {"Name": "goto right word test",
145 "Sequence": "ambig first" + CTRL_A + ALT_F + "uous" + ENTER,
146 "Result": CMD1},
147
148 # test removing words
149 {"Name": "remove left word 1",
150 "Sequence": "single invalid" + CTRL_W + ENTER,
151 "Result": SINGLE},
152 {"Name": "remove left word 2",
153 "Sequence": "single invalid" + ALT_BKSPACE + ENTER,
154 "Result": SINGLE},
155 {"Name": "remove right word",
156 "Sequence": "single invalid" + ALT_B + ALT_D + ENTER,
157 "Result": SINGLE},
158
159 # test kill buffer (copy and paste)
160 {"Name": "killbuffer test 1",
161 "Sequence": "ambiguous" + CTRL_A + CTRL_K + " first" + CTRL_A +
162 CTRL_Y + ENTER,
163 "Result": CMD1},
164 {"Name": "killbuffer test 2",
165 "Sequence": "ambiguous" + CTRL_A + CTRL_K + CTRL_Y*26 + ENTER,
166 "Result": NOT_FOUND},
167
168 # test newline
169 {"Name": "newline test",
170 "Sequence": "invalid" + CTRL_C + "single" + ENTER,
171 "Result": SINGLE},
172
173 # test redisplay (nothing should really happen)
174 {"Name": "redisplay test",
175 "Sequence": "single" + CTRL_L + ENTER,
176 "Result": SINGLE},
177
178 # test autocomplete
179 {"Name": "autocomplete test 1",
180 "Sequence": "si" + TAB + ENTER,
181 "Result": SINGLE},
182 {"Name": "autocomplete test 2",
183 "Sequence": "si" + TAB + "_" + TAB + ENTER,
184 "Result": SINGLE_LONG},
185 {"Name": "autocomplete test 3",
186 "Sequence": "in" + TAB + ENTER,
187 "Result": NOT_FOUND},
188 {"Name": "autocomplete test 4",
189 "Sequence": "am" + TAB + ENTER,
190 "Result": BAD_ARG},
191 {"Name": "autocomplete test 5",
192 "Sequence": "am" + TAB + "fir" + TAB + ENTER,
193 "Result": CMD1},
194 {"Name": "autocomplete test 6",
195 "Sequence": "am" + TAB + "fir" + TAB + TAB + ENTER,
196 "Result": CMD1},
197 {"Name": "autocomplete test 7",
198 "Sequence": "am" + TAB + "fir" + TAB + " " + TAB + ENTER,
199 "Result": CMD1},
200 {"Name": "autocomplete test 8",
201 "Sequence": "am" + TAB + " am" + TAB + " " + ENTER,
202 "Result": AMBIG},
203 {"Name": "autocomplete test 9",
204 "Sequence": "am" + TAB + "inv" + TAB + ENTER,
205 "Result": BAD_ARG},
206 {"Name": "autocomplete test 10",
207 "Sequence": "au" + TAB + ENTER,
208 "Result": NOT_FOUND},
209 {"Name": "autocomplete test 11",
210 "Sequence": "au" + TAB + "1" + ENTER,
211 "Result": AUTO1},
212 {"Name": "autocomplete test 12",
213 "Sequence": "au" + TAB + "2" + ENTER,
214 "Result": AUTO2},
215 {"Name": "autocomplete test 13",
216 "Sequence": "au" + TAB + "2" + TAB + ENTER,
217 "Result": AUTO2},
218 {"Name": "autocomplete test 14",
219 "Sequence": "au" + TAB + "2 " + TAB + ENTER,
220 "Result": AUTO2},
221 {"Name": "autocomplete test 15",
222 "Sequence": "24" + TAB + ENTER,
223 "Result": "24"},
224
225 # test history
226 {"Name": "history test 1",
227 "Sequence": "invalid" + ENTER + "single" + ENTER + "invalid" +
228 ENTER + UP + CTRL_P + ENTER,
229 "Result": SINGLE},
230 {"Name": "history test 2",
231 "Sequence": "invalid" + ENTER + "ambiguous first" + ENTER + "invalid" +
232 ENTER + "single" + ENTER + UP * 3 + CTRL_N + DOWN + ENTER,
233 "Result": SINGLE},
234
235 #
236 # tests that improve coverage
237 #
238
239 # empty space tests
240 {"Name": "empty space test 1",
241 "Sequence": RIGHT + LEFT + CTRL_B + CTRL_F + ENTER,
242 "Result": PROMPT},
243 {"Name": "empty space test 2",
244 "Sequence": BKSPACE + ENTER,
245 "Result": PROMPT},
246 {"Name": "empty space test 3",
247 "Sequence": CTRL_E*2 + CTRL_A*2 + ENTER,
248 "Result": PROMPT},
249 {"Name": "empty space test 4",
250 "Sequence": ALT_F*2 + ALT_B*2 + ENTER,
251 "Result": PROMPT},
252 {"Name": "empty space test 5",
253 "Sequence": " " + CTRL_E*2 + CTRL_A*2 + ENTER,
254 "Result": PROMPT},
255 {"Name": "empty space test 6",
256 "Sequence": " " + CTRL_A + ALT_F*2 + ALT_B*2 + ENTER,
257 "Result": PROMPT},
258 {"Name": "empty space test 7",
259 "Sequence": " " + CTRL_A + CTRL_D + CTRL_E + CTRL_D + ENTER,
260 "Result": PROMPT},
261 {"Name": "empty space test 8",
262 "Sequence": " space" + CTRL_W*2 + ENTER,
263 "Result": PROMPT},
264 {"Name": "empty space test 9",
265 "Sequence": " space" + ALT_BKSPACE*2 + ENTER,
266 "Result": PROMPT},
267 {"Name": "empty space test 10",
268 "Sequence": " space " + CTRL_A + ALT_D*3 + ENTER,
269 "Result": PROMPT},
270
271 # non-printable char tests
272 {"Name": "non-printable test 1",
273 "Sequence": chr(27) + chr(47) + ENTER,
274 "Result": PROMPT},
275 {"Name": "non-printable test 2",
276 "Sequence": chr(27) + chr(128) + ENTER*7,
277 "Result": PROMPT},
278 {"Name": "non-printable test 3",
279 "Sequence": chr(27) + chr(91) + chr(127) + ENTER*6,
280 "Result": PROMPT},
281
282 # miscellaneous tests
283 {"Name": "misc test 1",
284 "Sequence": ENTER,
285 "Result": PROMPT},
286 {"Name": "misc test 2",
287 "Sequence": "single #comment" + ENTER,
288 "Result": SINGLE},
289 {"Name": "misc test 3",
290 "Sequence": "#empty line" + ENTER,
291 "Result": PROMPT},
292 {"Name": "misc test 4",
293 "Sequence": " single " + ENTER,
294 "Result": SINGLE},
295 {"Name": "misc test 5",
296 "Sequence": "single#" + ENTER,
297 "Result": SINGLE},
298 {"Name": "misc test 6",
299 "Sequence": 'a' * 257 + ENTER,
300 "Result": NOT_FOUND},
301 {"Name": "misc test 7",
302 "Sequence": "clear_history" + UP*5 + DOWN*5 + ENTER,
303 "Result": PROMPT},
304 {"Name": "misc test 8",
305 "Sequence": "a" + HELP + CTRL_C,
306 "Result": PROMPT},
307 {"Name": "misc test 9",
308 "Sequence": CTRL_D*3,
309 "Result": None},
310 ]