Blame tests/p_vconfig/10_test_vconfig.sh

Christoph Galuschka 7d92e8
#!/bin/sh
Christoph Galuschka 7d92e8
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka 7d92e8
#         Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
t_Log "Running $0 - create VLAN IF, assign IP on VLAN IF and tear down VLAN IF test"
Christoph Galuschka 7d92e8
ret_val=0
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
# create VLAN-IF 10 on eth0
Christoph Galuschka 7d92e8
vconfig add eth0 10
Christoph Galuschka 7d92e8
ip addr list | grep -q eth0.10
Christoph Galuschka 7d92e8
if [ $? == 1 ]
Christoph Galuschka 7d92e8
  then
Christoph Galuschka 7d92e8
  t_Log "VLAN-IF creation failed"
Christoph Galuschka 7d92e8
  ret_val=1
Christoph Galuschka 7d92e8
else
Christoph Galuschka 7d92e8
  t_Log "VLAN-IF successfully created"
Christoph Galuschka 7d92e8
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
#assign IP address on VLAN-IF
Christoph Galuschka 7d92e8
ifconfig eth0.10 172.16.30.1 netmask 255.255.255.255
Christoph Galuschka 7d92e8
ip addr list | grep -q 172.16.30.1
Christoph Galuschka 7d92e8
if [ $? == 1 ]
Christoph Galuschka 7d92e8
  then
Christoph Galuschka 7d92e8
  t_Log "IP address assignment on eth0.10 failed"
Christoph Galuschka 7d92e8
  ret_val=1
Christoph Galuschka 7d92e8
else
Christoph Galuschka 7d92e8
  t_Log "IP address successfully assigned on eth1.10"
Christoph Galuschka 7d92e8
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
#testing address with ping
Christoph Galuschka 7d92e8
ping -c 4 -q 172.16.30.1 | grep -q '4 received'
Christoph Galuschka 7d92e8
if [ $? == 1 ]
Christoph Galuschka 7d92e8
  then
Christoph Galuschka 7d92e8
  t_Log "pinging on eth0.10 failed"
Christoph Galuschka 7d92e8
  ret_val=1
Christoph Galuschka 7d92e8
else
Christoph Galuschka 7d92e8
  t_Log "local ping on VLAN IF worked"
Christoph Galuschka 7d92e8
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
# delete VLAN-IF 10 on eth0
Christoph Galuschka 7d92e8
vconfig rem eth0.10
Christoph Galuschka 7d92e8
ip addr list | grep -q eth0.10
Christoph Galuschka 7d92e8
if [ $? == 0 ]
Christoph Galuschka 7d92e8
  then
Christoph Galuschka 7d92e8
  t_Log "Removing VLAN IF failed"
Christoph Galuschka 7d92e8
  ret_val=1
Christoph Galuschka 7d92e8
else
Christoph Galuschka 7d92e8
  t_Log "Removing of VLAN IF worked"
Christoph Galuschka 7d92e8
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
t_CheckExitStatus $ret_val