#!/bin/bash
#
# Test case for LLDPAD VDP testing according to IEEE 802.1Qbg ratified standard
#
# Copyright (c) International Business Machines Corp., 2014
#
# Author(s): Thomas Richter <tmricht at linux.vnet.ibm.com>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
#

# 
# Thomas Richter, IBM Research & Development, Boeblingen, Germany, 20-Apr-2013
#
# Execute a simple assoc input using vdptool. Expect success.
#

sleep 30	# Must: Wait some time for lldpad to start up and initialize
outfile=$(basename $0)
dirfile=$(dirname $0)
cd $dirfile

vsi1="assoc,hello,1,2,00112233-4455-6677-8899-aabbccddeeff"
vsi2="22222-0a:0b:0c:00:00:00"
vsi_cmd="$vsi1,none,$vsi2"
vsi_ok="vsi=$vsi1,0,$vsi2;"

../../../vdptool -i veth0 -T -V assoc -c vsi=$vsi_cmd
rc=$?
if [ "$rc" -ne 0 ]
then
	echo "vdptool failure (step 1)"
	exit $rc
fi

sleep 30
reply="$(../../../vdptool -i veth0 -t -V assoc -c vsi)"
rc=$?
if [ "$rc" -ne 0 ]
then
	echo "vdptool failure (step 2)"
	exit $rc
fi

if [ "$reply" != "$vsi_ok" ]
then
	echo "vdptool reply mismatch"
	echo "expected reply:$vsi_ok"
	echo "returned reply:$reply"
	let rc=1
fi

sleep 5
exit $rc
