1 AT_BANNER([appctl bashcomp unit tests])
3 m4_define([GET_FORMAT], [
4 echo "$@" | grep -A 1 -- "Command format" | tail -n+2
7 m4_define([GET_EXPAN], [
8 echo "$@" | grep -- "available completions for keyword" \
9 | sed -e 's/^[ ]*//g;s/[ ]*$//g'
12 m4_define([GET_AVAIL], [
13 echo "$@" | sed -e '1,/Available/d' | tail -n+2
16 m4_define([GET_COMP_STR], [
17 echo "available completions for keyword \"$1\": $2" \
21 AT_SETUP([appctl-bashcomp - basic verification])
22 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
25 # complete ovs-appctl [TAB]
26 # complete ovs-dpctl [TAB]
27 # complete ovs-ofctl [TAB]
28 # complete ovsdb-tool [TAB]
36 INPUT="$(bash ovs-appctl-bashcomp.bash debug test_command TAB 2>&1)"
37 MATCH="$(test_command --option | sort | sed -n '/^--.*/p' | cut -d '=' -f1)
38 $(test_command list-commands | tail -n +2 | cut -c3- | cut -d ' ' -f1 | sort)"
39 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
45 # complete ovs-appctl --tar[TAB]
46 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl --tar 2>&1)"
47 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
53 # complete ovs-appctl --target [TAB]
54 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl --target TAB 2>&1)"
55 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
63 # complete ovs-appctl --target ovs-vswitchd [TAB]
64 # complete ovs-appctl --target ovsdb-server [TAB]
65 # complete ovs-appctl --target ovs-ofctl [TAB]
66 AT_CHECK([ovs-ofctl monitor br0 --detach --no-chdir --pidfile])
73 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl --target target_daemon TAB 2>&1)"
74 MATCH="$(ovs-appctl --option | sort | sed -n '/^--.*/p' | cut -d '=' -f1)
75 $(ovs-appctl --target target_daemon list-commands | tail -n +2 | cut -c3- | cut -d ' ' -f1 | sort)"
76 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
80 OVS_APP_EXIT_AND_WAIT([ovs-ofctl])
85 # complex completion check - bfd/set-forwarding
86 # bfd/set-forwarding [interface] normal|false|true
87 # test expansion of 'interface'
88 AT_SETUP([appctl-bashcomp - complex completion check 1])
89 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
90 OVS_VSWITCHD_START(add-port br0 p0 -- set Interface p0 type=dummy)
92 # check the top level completion.
93 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl bfd/set-forwarding TAB 2>&1)"
94 MATCH="$(GET_COMP_STR([normal], [])
95 GET_COMP_STR([false], [])
96 GET_COMP_STR([true], [])
97 GET_COMP_STR([interface], [p0]))"
98 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
102 # check the available completions.
103 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
109 # set argument to 'true', there should be no more completions.
110 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl bfd/set-forwarding true TAB 2>&1)"
111 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e '/./,$!d'],
116 # set argument to 'p1', there should still be the completion for booleans.
117 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl bfd/set-forwarding p1 TAB 2>&1)"
118 MATCH="$(GET_COMP_STR([normal], [])
119 GET_COMP_STR([false], [])
120 GET_COMP_STR([true], []))"
121 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
125 # check the available completions.
126 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})], [0])
129 # set argument to 'p1 false', there should still no more completions.
130 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl bfd/set-forwarding p1 false TAB 2>&1)"
131 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e '/./,$!d'],
139 # complex completion check - lacp/show
141 # test expansion on 'port'
142 AT_SETUP([appctl-bashcomp - complex completion check 2])
143 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
144 OVS_VSWITCHD_START(add-port br0 p0 -- set Interface p0 type=dummy \
145 -- add-port br0 p1 -- set Interface p1 type=dummy)
147 # check the top level completion.
148 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl lacp/show TAB 2>&1)"
149 MATCH="$(GET_COMP_STR([port], [br0 p0 p1]))"
150 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
154 # check the available completions.
155 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
163 # set argument to 'p1', there should be no more completions.
164 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl lacp/show p1 TAB 2>&1)"
165 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e '/./,$!d'],
173 # complex completion check - ofproto/trace
174 # ofproto/trace {[dp_name] odp_flow | bridge br_flow} [-generate|packet]
175 # test expansion on 'dp|dp_name' and 'bridge'
176 AT_SETUP([appctl-bashcomp - complex completion check 3])
177 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
178 OVS_VSWITCHD_START(add-port br0 p0 -- set Interface p0 type=dummy \
179 -- add-port br0 p1 -- set Interface p1 type=dummy)
181 # check the top level completion.
182 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ofproto/trace TAB 2>&1)"
183 MATCH="$(GET_COMP_STR([bridge], [br0])
184 GET_COMP_STR([odp_flow], [])
185 GET_COMP_STR([dp_name], [ovs-dummy]))"
186 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
190 # check the available completions.
191 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
198 # set argument to 'ovs-dummy', should go to the dp-name path.
199 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ofproto/trace ovs-dummy TAB 2>&1)"
200 MATCH="$(GET_COMP_STR([odp_flow], []))"
201 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
205 # check the available completions.
206 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})], [0])
209 # set odp_flow to some random string, should go to the next level.
210 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ofproto/trace ovs-dummy "in_port(123),mac(),ip,tcp" TAB 2>&1)"
211 MATCH="$(GET_COMP_STR([-generate], [-generate])
212 GET_COMP_STR([packet], []))"
213 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
217 # check the available completions.
218 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
224 # set packet to some random string, there should be no more completions.
225 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ofproto/trace ovs-dummy "in_port(123),mac(),ip,tcp" "ABSJDFLSDJFOIWEQR" TAB 2>&1)"
226 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e '/./,$!d'],
231 # set argument to 'br0', should go to the bridge path.
232 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ofproto/trace br0 TAB 2>&1)"
233 MATCH="$(GET_COMP_STR([br_flow], []))"
234 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
238 # check the available completions.
239 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})], [0])
242 # set argument to some random string, should go to the odp_flow path.
243 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ofproto/trace "in_port(123),mac(),ip,tcp" TAB 2>&1)"
244 MATCH="$(GET_COMP_STR([-generate], [-generate])
245 GET_COMP_STR([packet], []))"
246 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
250 # check the available completions.
251 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
260 # complex completion check - vlog/set
261 # vlog/set {spec | PATTERN:destination:pattern}
262 # test non expandable arguments
263 AT_SETUP([appctl-bashcomp - complex completion check 4])
264 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
267 # check the top level completion.
268 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl vlog/set TAB 2>&1)"
269 MATCH="$(GET_COMP_STR([PATTERN:destination:pattern], [])
270 GET_COMP_STR([spec], []))"
271 AT_CHECK_UNQUOTED([GET_EXPAN(${INPUT})],
275 # check the available completions.
276 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})], [0])
279 # set argument to random 'abcd', there should be no more completions.
280 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl vlog/set abcd TAB 2>&1)"
281 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e '/./,$!d'],
289 AT_SETUP([appctl-bashcomp - negative test])
290 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
291 OVS_VSWITCHD_START(add-port br0 p0 -- set Interface p0 type=dummy)
293 # negative test - incorrect subcommand
294 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ERROR 2>&1)"
295 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e 's/[ \t]*$//' | sed -e '/./,$!d'], [0])
296 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl ERROR TAB 2>&1)"
297 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e 's/[ \t]*$//' | sed -e '/./!d'],
302 # negative test - no ovs-vswitchd
303 # negative test - no ovsdb-server
304 # negative test - no ovs-ofctl
305 # should not see any error.
313 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl --target target_daemon TAB 2>&1)"
314 MATCH="$(ovs-appctl --option | sort | sed -n '/^--.*/p' | cut -d '=' -f1)"
315 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})],
319 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovs-appctl --target target_daemon ERROR SUBCMD TAB 2>&1)"
320 AT_CHECK_UNQUOTED([echo "$INPUT" | sed -e 's/[ \t]*$//' | sed -e '/./!d'],
325 # negative test - do not match on nested option
326 INPUT="$(bash ovs-appctl-bashcomp.bash debug ovsdb-tool create TAB 2>&1)"
327 AT_CHECK_UNQUOTED([GET_AVAIL(${INPUT})], [0])
332 dnl ----------------------------------------------------------------------
333 AT_BANNER([vsctl bashcomp unit tests])
335 m4_define([PREPARE_MATCH_NOSPACE], [
336 echo "$@" | tr ' ' '\n' | sed -e '/^$/d' | sort -u
339 m4_define([PREPARE_MATCH_SPACE], [
340 echo "$@" | tr ' ' '\n' | sed -e '/^$/d' | sed -e 's/$/ /g' | sort -u
343 AT_SETUP([vsctl-bashcomp - basic verification])
344 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
345 AT_SKIP_IF([eval 'test ${BASH_VERSINFO[[0]]} -lt 4'])
348 # complete ovs-vsctl --db=* [TAB]
349 TMP="$(ovs-vsctl --commands | cut -d',' -f1-2 | tr -d ',[[]]' | tr -s ' ' '\n')
350 $(ovs-vsctl --options | grep -- '--' | sed -e 's/=.*$/=/g')"
351 MATCH="$(PREPARE_MATCH_NOSPACE(${TMP}))"
352 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "--db=unix:$OVS_RUNDIR/db.sock "],
356 # complete ovs-vsctl [TAB]
357 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test ""],
362 # complete on global options.
363 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "--dry-run "],
367 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "--dry-run --pretty "],
372 # complete on local options.
373 TMP="$(ovs-vsctl --commands | grep -- '--may-exist' | cut -d',' -f1-2 | tr -d ',[[]]' | tr -s ' ' '\n' | grep -v -- '--may-exist')"
374 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
375 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "--may-exist "],
383 # test !. no following arguments are expanded.
384 TMP="$(ovsdb-client --no-heading list-tables)"
385 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
386 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set "],
390 # test ?. will show completions for both current and following arguments.
391 ovs-vsctl br-set-external-id br0 bridge-id br0
392 MATCH="$(PREPARE_MATCH_SPACE(bridge-id --))"
393 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-get-external-id br0 "],
397 # test *. argument with this prefix could be completed for zero or more times.
398 TMP="$(ovs-vsctl --no-heading --columns=_uuid,name list Bridge | tr -d '\"')"
399 MATCH="$(PREPARE_MATCH_SPACE(${TMP} --))"
400 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "destroy Bridge "],
404 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "destroy Bridge br0 "],
408 # test +. the first time, an argument is required, after that, it becomes '*'.
409 TMP="$(ovsdb-client --no-heading list-columns Open_vSwitch Bridge | awk '/key.*value/ { print $1":"; next } { print $1; next }')"
410 MATCH="$(PREPARE_MATCH_NOSPACE(${TMP}))"
411 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Bridge br0 "],
415 MATCH="$(PREPARE_MATCH_NOSPACE(${TMP} --))"
416 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Bridge br0 other_config:random_key=123 "],
425 AT_SETUP([vsctl-bashcomp - argument completion])
426 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
427 AT_SKIP_IF([eval 'test ${BASH_VERSINFO[[0]]} -lt 4'])
430 set bridge br1 datapath-type=dummy -- \
432 set bridge foo datapath-type=dummy -- \
433 add-br --weird-br_name -- \
434 set bridge --weird-br_name datapath-type=dummy -- \
435 add-port br0 br0p0 -- set Interface br0p0 type=dummy -- \
436 add-port br0 br0p1 -- set Interface br0p1 type=dummy -- \
437 add-port br1 br1p0 -- set Interface br1p0 type=dummy -- \
438 add-port br1 br1p1 -- set Interface br1p1 type=dummy -- \
439 add-port foo bar -- set Interface bar type=dummy ])
441 # test completion functions defined in '_OVS_VSCTL_ARG_COMPLETION_FUNCS'.
442 # therein, the different argument prefixes are also tested at the same time.
444 # A space is appended to each output if completion is configured without
450 # test: _ovs_vsctl_complete_table
452 TMP="$(ovsdb-client --no-heading list-tables)"
453 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
454 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set "],
458 MATCH="$(PREPARE_MATCH_SPACE(Open_vSwitch))"
459 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Open"],
466 # test: _ovs_vsctl_complete_record
468 TMP="$(ovs-vsctl --no-heading --columns=_uuid list Open_vSwitch | tr -d '\"')"
469 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
470 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Open_vSwitch "],
474 TMP="$(ovs-vsctl --no-heading --columns=_uuid,name list Bridge | tr -d '\"')"
475 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
476 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Bridge "],
483 # test: _ovs_vsctl_complete_bridge
485 TMP="$(ovs-vsctl list-br)"
486 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
487 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-to-vlan "],
491 # this also helps check the '_ovs_vsctl_check_startswith_string'.
492 MATCH="$(PREPARE_MATCH_SPACE(--weird-br_name))"
493 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-to-vlan --"],
500 # test: _ovs_vsctl_complete_port
502 TMP="$(ovs-vsctl --no-heading --columns=name list Port | tr -d '\"')"
503 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
504 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "port-to-br "],
508 # complete on ports in particular bridge.
509 TMP="$(ovs-vsctl list-ports br0)"
510 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
511 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "del-port br0 "],
518 # test: _ovs_vsctl_complete_iface
520 for br in `ovs-vsctl list-br`; do
521 TMP="${TMP} $(ovs-vsctl list-ifaces $br)"
523 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
524 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "iface-to-br "],
531 # test: _ovs_vsctl_complete_bridge_fail_mode
533 MATCH="$(PREPARE_MATCH_SPACE(standalone secure))"
534 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set-fail-mode br0 "],
541 # test: _ovs_vsctl_complete_key
543 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-set-external-id br0 "],
547 # since there is no key added yet, we will only get our own input.
548 MATCH="$(PREPARE_MATCH_SPACE(test_key))"
549 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-set-external-id br0 test_key"],
553 # now add a key, as we should see it.
554 ovs-vsctl br-set-external-id br0 bridge-id br0
555 MATCH="$(PREPARE_MATCH_SPACE(bridge-id))"
556 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-set-external-id br0 "],
560 MATCH="$(PREPARE_MATCH_SPACE(bridge-id --))"
561 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-get-external-id br0 "],
568 # test: _ovs_vsctl_complete_value
570 # should just return the user input.
571 MATCH="$(PREPARE_MATCH_SPACE(test_value --))"
572 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "br-set-external-id br0 bridge-id test_value"],
579 # test: _ovs_vsctl_complete_column
581 TMP="$(ovsdb-client --no-heading list-columns Open_vSwitch Open_vSwitch | tr -d ':' | cut -d' ' -f1)"
582 UUID="$(ovs-vsctl --no-heading --columns=_uuid list Open_vSwitch | tr -d ' ')"
583 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
584 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "clear Open_vSwitch $UUID "],
588 TMP="$(ovsdb-client --no-heading list-columns Open_vSwitch Bridge | tr -d ':' | cut -d' ' -f1)"
589 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
590 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "clear Bridge br0 "],
594 # the 'clear' command requires one or more (+) COLUMN.
595 # so, with one specified COLUMN 'other_config', it should still complete on
596 # COLUMNs, plus '--'.
597 MATCH="$(PREPARE_MATCH_SPACE(${TMP} --))"
598 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "clear Bridge br0 other_config "],
605 # test: _ovs_vsctl_complete_key_value
607 # with no key available, should always get user input.
608 MATCH="$(PREPARE_MATCH_NOSPACE(random_key))"
609 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add Bridge br0 other_config random_key"],
613 MATCH="$(PREPARE_MATCH_NOSPACE(abc))"
614 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add Bridge br0 other_config random_key=abc"],
618 # now add two random keys.
619 ovs-vsctl set Bridge br0 other_config:random_key1=abc other_config:random_val1=xyz
620 MATCH="$(PREPARE_MATCH_NOSPACE(random_key1= random_val1=))"
621 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add Bridge br0 other_config ran"],
628 # test: _ovs_vsctl_complete_column_optkey_value
630 # at first, we should complete on column.
631 TMP="$(ovsdb-client --no-heading list-columns Open_vSwitch Bridge | awk '/key.*value/ { print $1":"; next } { print $1; next }')"
632 MATCH="$(PREPARE_MATCH_NOSPACE(${TMP}))"
633 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Bridge br0 "],
637 MATCH="$(PREPARE_MATCH_NOSPACE(other_config:))"
638 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Bridge br0 other"],
642 # then, with the ':' we should complete on key.
643 TMP="$(ovs-vsctl --no-heading --columns=other_config list Bridge br0 | tr -d '{\"}' | tr -s ', ' '\n' | cut -d'=' -f1)"
644 MATCH="$(PREPARE_MATCH_NOSPACE(${TMP}))"
645 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Bridge br0 other_config:"],
649 # finally, if user fill in some value, we should just complete on user input.
650 MATCH="$(PREPARE_MATCH_NOSPACE(random_val1))"
651 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set Bridge br0 other_config:random_val1=12345"],
658 # test: _ovs_vsctl_complete_filename
660 touch private_key certificate
661 MATCH="$(PREPARE_MATCH_SPACE(private_key))"
662 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set-ssl priva"],
666 MATCH="$(PREPARE_MATCH_SPACE(certificate))"
667 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set-ssl private_key cer"],
674 # test: _ovs_vsctl_complete_target
676 MATCH="$(PREPARE_MATCH_NOSPACE(pssl: ptcp: punix: ssl: tcp: unix:))"
677 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set-manager "],
681 # filename completion on unix, punix.
682 MATCH="$(PREPARE_MATCH_NOSPACE(testsuite.log))"
683 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set-manager unix:test"],
687 # no completion on other type, just return available types.
688 # in real environment, bash will not complete on anything.
689 MATCH="$(PREPARE_MATCH_NOSPACE(pssl: ptcp: punix: tcp: unix:))"
690 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set-manager ssl:something"],
697 # test: _ovs_vsctl_complete_new
700 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add-br "],
704 > ovs-vsctl add-br --- END MESSAGE
706 # user input does not change the output.
707 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add-br new-br"],
711 > ovs-vsctl add-br new-br--- END MESSAGE
713 # after specifying the new bridge name, we should complete on parent bridge.
714 TMP="$(ovs-vsctl list-br)"
715 MATCH="$(PREPARE_MATCH_SPACE(${TMP}))"
716 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add-br new-br "],
721 # after specifying the new port name, we should complete on the column part
722 # of '*COLUMN?:KEY=VALUE'.
723 TMP="$(ovsdb-client --no-heading list-columns Open_vSwitch Port | awk '/key.*value/ { print $1":"; next } { print $1; next }')"
724 MATCH="$(PREPARE_MATCH_NOSPACE(${TMP} --))"
725 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add-port br0 new-port "],
732 # test: _ovs_vsctl_complete_dashdash
734 # after '--', there should be no global options available for completion.
735 TMP="$(ovs-vsctl --commands | cut -d',' -f1-2 | tr -d ',[[]]' | tr -s ' ' '\n')"
736 MATCH="$(PREPARE_MATCH_NOSPACE(${TMP}))"
737 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "init -- "],
741 TMP="$(ovs-vsctl --no-heading --columns=name,_uuid list Port | tr -d '\"')"
742 MATCH="$(PREPARE_MATCH_SPACE(${TMP} newp1 newp2))"
743 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "add-port br0 newp1 -- add-port br1 newp2 -- set Port "],
752 AT_SETUP([vsctl-bashcomp - negative test])
753 AT_SKIP_IF([test -z ${BASH_VERSION+x}])
754 AT_SKIP_IF([eval 'test ${BASH_VERSINFO[[0]]} -lt 4'])
757 # complete non-matching command.
758 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "invalid"],
763 # complete after invalid command.
764 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "invalid argu"],
769 # complete non-matching end argument.
770 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set INVALID_"],
775 # complete after invalid intermediate argument.
776 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "set INVALID_TBL "],
779 Cannot complete 'INVALID_TBL' at index 3:
780 > ovs-vsctl set INVALID_TBL --- END MESSAGE])
782 # complete ovs-vsctl --db=wrongdb [TAB]
783 # should return 1 and show nothing.
784 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test "--db=wrongdb"],
788 # delete ovsdb-server and try again.
789 AT_CHECK_UNQUOTED([ovs-vsctl-bashcomp.bash test ""],