From 5abaec499275bc47fb596e6bf2fa9fe98a891e79 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 17 Aug 2022 11:37:56 +1000 Subject: [PATCH] ctdb-tests: Implement "ip -brief link show" in ip stub Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/tests/UNIT/eventscripts/stubs/ip | 34 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/ctdb/tests/UNIT/eventscripts/stubs/ip b/ctdb/tests/UNIT/eventscripts/stubs/ip index 2856aff00a6..090afae253a 100755 --- a/ctdb/tests/UNIT/eventscripts/stubs/ip +++ b/ctdb/tests/UNIT/eventscripts/stubs/ip @@ -130,17 +130,26 @@ ip_link_show() _mac="00:00:00:00:00:00" _brd="00:00:00:00:00:00" _type="loopback" - _opts=" mtu 65536 qdisc noqueue state UNKNOWN" + _state="UNKNOWN" + _status="" + _opts="mtu 65536 qdisc noqueue state ${_state}" ;; *) _mac=$(echo "$dev" | cksum | sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@') _brd="ff:ff:ff:ff:ff:ff" _type="ether" - _opts=" mtu 1500 qdisc pfifo_fast state ${_state} qlen 1000" + _status="" + _opts="mtu 1500 qdisc pfifo_fast state ${_state} qlen 1000" ;; esac - echo "${n:-42}: ${dev}: ${_opts}" - echo " link/${_type} ${_mac} brd ${_brd}" + + if $brief; then + printf '%-16s %-14s %-17s %s\n' \ + "$dev" "$_status" "$_mac" "$_status" + else + echo "${n:-42}: ${dev}: ${_status} ${_opts}" + echo " link/${_type} ${_mac} brd ${_brd}" + fi } # This is incomplete because it doesn't actually look up table ids in @@ -209,6 +218,11 @@ ip_addr_show() primary=true secondary=true _to="" + + if $brief; then + not_implemented "ip -br addr show in \"$orig_args\"" + fi + while [ -n "$1" ]; do case "$1" in dev) @@ -466,6 +480,10 @@ ip_rule() ip_rule_show() { + if $brief; then + not_implemented "ip -br rule show in \"$orig_args\"" + fi + ip_rule_show_1() { _pre="$1" @@ -784,6 +802,14 @@ ip_route_del() orig_args="$*" +brief=false +case "$1" in +-br*) + brief=true + shift + ;; +esac + case "$1" in link) shift