#!/bin/bash

ib_devices=`ibdev2netdev |wc -l`

if [ $ib_devices -ne 4 -a $ib_devices -ne 8 ]; then
    echo "failure"
    exit 1
fi

eth_devices=`ifconfig -a |grep -v bond |grep 9100 |grep UP |grep RUNNING |wc -l`
bond_act=`cat /proc/net/bonding/bond* |grep -i "Slave active: 1" |wc -l`

expect_eth_device=$((2*$ib_devices))

if [ $expect_eth_device -ne $eth_devices ]; then
    echo "failure: link issue"
    exit 1
else
    echo "pass"
fi

if [ $expect_eth_device -ne $bond_act ]; then
    echo "failure: bonding issue"
    exit 1
else
    echo "pass"
fi
