Commit 1b86fa3b authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

selftests: forwarding: multipath_eval(): Improve style

- Change the indentation of the function body from 7 spaces to one tab.
- Move initialization of weights_ratio up so that it can be referenced
  from the error message about packet difference being zero.
- Move |'s consistently to continuation line, which reindent.
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b2c47872
...@@ -559,41 +559,45 @@ tests_run() ...@@ -559,41 +559,45 @@ tests_run()
multipath_eval() multipath_eval()
{ {
local desc="$1" local desc="$1"
local weight_rp12=$2 local weight_rp12=$2
local weight_rp13=$3 local weight_rp13=$3
local packets_rp12=$4 local packets_rp12=$4
local packets_rp13=$5 local packets_rp13=$5
local weights_ratio packets_ratio diff local weights_ratio packets_ratio diff
RET=0 RET=0
if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
check_err 1 "Packet difference is 0" weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \
log_test "Multipath" | bc -l)
log_info "Expected ratio $weights_ratio" else
return weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" \
fi | bc -l)
fi
if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \ if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then
| bc -l) check_err 1 "Packet difference is 0"
packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \ log_test "Multipath"
| bc -l) log_info "Expected ratio $weights_ratio"
else return
weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" | \ fi
bc -l)
packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" | \ if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then
bc -l) packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \
fi | bc -l)
else
diff=$(echo $weights_ratio - $packets_ratio | bc -l) packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" \
diff=${diff#-} | bc -l)
fi
test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0
check_err $? "Too large discrepancy between expected and measured ratios" diff=$(echo $weights_ratio - $packets_ratio | bc -l)
log_test "$desc" diff=${diff#-}
log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio"
test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0
check_err $? "Too large discrepancy between expected and measured ratios"
log_test "$desc"
log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio"
} }
############################################################################## ##############################################################################
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment