criu/test/zdtm/static/route_rules
Vitaly Ostrosablin b82fc5e07c test: fix shell script tests (conntracks & route_rules)
Test seem to assume that zdtm lib directory is on PATH, but if it's not
- calling for parseargs.sh would fail (if cwd is static). Therefore,
this patch changes this to ../lib/parseargs.sh which should be fine both
for zdtm and vzt-cpt.

travis-ci: success for test: fix shell script tests (conntracks & route_rules)
Signed-off-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-01-12 18:28:43 +03:00

73 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
# $Id: route_rules,v 1.1 2007/06/04 12:11:30 agladkov Exp $
#
# Copyright (c) 2007 by SWsoft.
# All rights reserved.
#
# Description:
# check that routes saved after migration
export PATH=$PATH:${0%/*}/../../lib
die()
{
echo "$0:${BASH_LINENO[0]}: $*" >&2
exit 1
}
fail()
{
echo "FAIL: $0:${BASH_LINENO[0]}: $*" > "$outfile"
exit 1
}
do_or_fail()
{
local failmsg="$1" output
shift
output="$(eval $@ 2>&1)" ||
fail "$failmsg: $output"
}
do_start()
{
[ -f "$statefile" ] && die "state file $statefile aleady exists"
# Get default route
dev_name=`ip route list match 0.0.0.0/0 | sed 's/.*dev \([^ ]*\).*/\1/'`
[ -n "$dev_name" ] || fail "dev_name is zero: " \
"\$dev_name=\`ip route list match 0.0.0.0/0 | " \
"sed 's/.*dev \([^ ]*\).*/\1/'"
do_or_fail "can't add routes" \
ip r a 1.2.3.4/32 dev $dev_name && ip r a 1.2.0.0/16 via 1.2.3.4
do_or_fail "can't list created routes" \
ip r \| grep "1.2.3.4" \> "$statefile"
}
do_stop()
{
do_or_fail "can't compare the routes" \
ip r \| grep "1.2.3.4" \| diff -u "$statefile" -
rm -f "$statefile"
IFS="
";
for line in `ip r | grep "1.2.3.4"`; do
eval ip r del $line
done
echo "PASS" > $outfile
}
tmpargs="$(../lib/parseargs.sh --name=$0 \
--flags-req=statefile,outfile \
-- "$@")" ||
die "can't parse command line"
eval "$tmpargs"
[ -f "$outfile" ] && die "out file $outfile aleady exists"
# expect "start" or "stop"
action=${1:?Specify action$(die 'Specify action')}
do_$action