2015-01-13 14:57:14 -08:00
|
|
|
AT_TESTED([ovs-vswitchd])
|
|
|
|
AT_TESTED([ovs-vsctl])
|
|
|
|
|
2016-02-22 09:58:54 -08:00
|
|
|
m4_include([m4/compat.m4])
|
2015-01-13 14:57:14 -08:00
|
|
|
|
2015-09-09 10:20:14 -07:00
|
|
|
dnl Make AT_SETUP automatically run the ovs_init() shell function
|
|
|
|
dnl as the first step in every test.
|
|
|
|
m4_rename([AT_SETUP], [OVS_AT_SETUP])
|
|
|
|
m4_define([AT_SETUP], [OVS_AT_SETUP($@)
|
|
|
|
ovs_init
|
|
|
|
])
|
2017-12-31 21:15:58 -08:00
|
|
|
|
2018-11-14 21:55:55 -08:00
|
|
|
dnl Make AT_CLEANUP check for Address Sanitizer errors as the last step
|
|
|
|
dnl in every test.
|
|
|
|
m4_rename([AT_CLEANUP], [OVS_AT_CLEANUP])
|
|
|
|
m4_define([AT_CLEANUP], [ovs_cleanup
|
|
|
|
OVS_AT_CLEANUP($@)
|
|
|
|
])
|
|
|
|
|
2017-12-31 21:15:58 -08:00
|
|
|
dnl OVS_START_SHELL_HELPERS...OVS_END_SHELL_HELPERS may bracket shell
|
|
|
|
dnl function definitions that invoke AT_CHECK and other Autotest macros
|
|
|
|
dnl that can ordinarily be run only within AT_SETUP...AT_CLEANUP.
|
|
|
|
m4_define([OVS_START_SHELL_HELPERS],
|
|
|
|
[m4_ifdef([AT_ingroup], [m4_fatal([$0: AT_SETUP and OVS_DEFINE_SHELL_HELPERS may not nest])])
|
|
|
|
m4_define([AT_ingroup])
|
|
|
|
m4_divert_push([PREPARE_TESTS])])
|
|
|
|
m4_define([OVS_END_SHELL_HELPERS], [
|
|
|
|
m4_divert_pop([PREPARE_TESTS])
|
|
|
|
m4_undefine([AT_ingroup])])
|
|
|
|
|
2015-01-13 14:57:14 -08:00
|
|
|
m4_divert_push([PREPARE_TESTS])
|
|
|
|
[
|
2015-09-09 10:20:14 -07:00
|
|
|
# Set ovs_base to the base directory in which the test is running and
|
|
|
|
# initialize the OVS_*DIR environment variables to point to this
|
|
|
|
# directory.
|
|
|
|
ovs_init() {
|
|
|
|
ovs_base=`pwd`
|
ovs-macros: An option to suspend test execution on error
Origins for this patch are captured at
https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html.
Summarizing here, when a test fails, it would be good to pause test execution
and let the developer poke around the system to see current status of system.
As part of this patch, made a small tweaks to ovs-macros.at, so that when test
suite fails, ovs_on_exit() function will be called. And in this function, a check
is made to see if an environment variable to OVS_PAUSE_TEST is set. If it is
set, then test suite is paused and will continue to wait for user input
Ctrl-D. Meanwhile user can poke around the system to see why test case has
failed. Once done with investigation, user can press ctrl-d to cleanup the
test suite.
For example, to re-run test case 139:
export OVS_PAUSE_TEST=1
cd tests/system-userspace-testsuite.dir/139
sudo -E ./run
When error occurs, above command would display something like this:
=====================================================
Set environment variable to use various ovs utilities
export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139
Press ENTER to continue:
=====================================================
And from another window, one can execute ovs-xxx commands like:
export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139
$ ovs-ofctl dump-ports br0
.
.
To be able to pause while performing `make check`, one can do:
$ OVS_PAUSE_TEST=1 make check TESTSUITEFLAGS='-v'
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Vasu Dasari <vdasari@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-07-15 17:15:01 -04:00
|
|
|
trap ovs_on_exit 0
|
2015-09-09 10:26:11 -07:00
|
|
|
: > cleanup
|
2015-09-29 15:40:22 -07:00
|
|
|
ovs_setenv
|
|
|
|
}
|
|
|
|
|
ovs-macros: An option to suspend test execution on error
Origins for this patch are captured at
https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html.
Summarizing here, when a test fails, it would be good to pause test execution
and let the developer poke around the system to see current status of system.
As part of this patch, made a small tweaks to ovs-macros.at, so that when test
suite fails, ovs_on_exit() function will be called. And in this function, a check
is made to see if an environment variable to OVS_PAUSE_TEST is set. If it is
set, then test suite is paused and will continue to wait for user input
Ctrl-D. Meanwhile user can poke around the system to see why test case has
failed. Once done with investigation, user can press ctrl-d to cleanup the
test suite.
For example, to re-run test case 139:
export OVS_PAUSE_TEST=1
cd tests/system-userspace-testsuite.dir/139
sudo -E ./run
When error occurs, above command would display something like this:
=====================================================
Set environment variable to use various ovs utilities
export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139
Press ENTER to continue:
=====================================================
And from another window, one can execute ovs-xxx commands like:
export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139
$ ovs-ofctl dump-ports br0
.
.
To be able to pause while performing `make check`, one can do:
$ OVS_PAUSE_TEST=1 make check TESTSUITEFLAGS='-v'
Acked-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Vasu Dasari <vdasari@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2019-07-15 17:15:01 -04:00
|
|
|
# Catch testsuite error condition and cleanup test environment by tearing down
|
|
|
|
# all interfaces and processes spawned.
|
|
|
|
# User has an option to leave the test environment in error state so that system
|
|
|
|
# can be poked around to get more information. User can enable this option by setting
|
|
|
|
# environment variable OVS_PAUSE_TEST=1. User needs to press CTRL-D to resume the
|
|
|
|
# cleanup operation.
|
|
|
|
ovs_pause() {
|
|
|
|
echo "====================================================="
|
|
|
|
echo "Set following environment variable to use various ovs utilities"
|
|
|
|
echo "export OVS_RUNDIR=$ovs_base"
|
|
|
|
echo "Press ENTER to continue: "
|
|
|
|
read
|
|
|
|
}
|
|
|
|
|
|
|
|
ovs_on_exit () {
|
|
|
|
if [ ! -z "${OVS_PAUSE_TEST}" ] && [ -z $at_verbose ]; then
|
|
|
|
trap '' INT
|
|
|
|
ovs_pause
|
|
|
|
fi
|
|
|
|
. "$ovs_base/cleanup"
|
|
|
|
}
|
|
|
|
|
2015-09-29 15:40:22 -07:00
|
|
|
# With no parameter or an empty parameter, sets the OVS_*DIR
|
|
|
|
# environment variables to point to $ovs_base, the base directory in
|
|
|
|
# which the test is running.
|
|
|
|
#
|
|
|
|
# With a parameter, sets them to $ovs_base/$1.
|
|
|
|
ovs_setenv() {
|
|
|
|
sandbox=$1
|
|
|
|
ovs_dir=$ovs_base${1:+/$1}
|
|
|
|
OVS_RUNDIR=$ovs_dir; export OVS_RUNDIR
|
|
|
|
OVS_LOGDIR=$ovs_dir; export OVS_LOGDIR
|
|
|
|
OVS_DBDIR=$ovs_dir; export OVS_DBDIR
|
|
|
|
OVS_SYSCONFDIR=$ovs_dir; export OVS_SYSCONFDIR
|
|
|
|
OVS_PKGDATADIR=$ovs_dir; export OVS_PKGDATADIR
|
2015-09-09 10:20:14 -07:00
|
|
|
}
|
|
|
|
|
2015-01-13 14:57:14 -08:00
|
|
|
# Prints the integers from $1 to $2, increasing by $3 (default 1) on stdout.
|
|
|
|
seq () {
|
2017-09-27 13:50:26 -07:00
|
|
|
if test $# = 1; then
|
|
|
|
set 1 $1
|
|
|
|
fi
|
2015-01-13 14:57:14 -08:00
|
|
|
while test $1 -le $2; do
|
|
|
|
echo $1
|
|
|
|
set `expr $1 + ${3-1}` $2 $3
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
if test "$IS_WIN32" = "yes"; then
|
|
|
|
pwd () {
|
|
|
|
command pwd -W "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
diff () {
|
|
|
|
command diff --strip-trailing-cr "$@"
|
|
|
|
}
|
|
|
|
|
2015-06-25 08:34:39 -07:00
|
|
|
# tskill is more effective than taskkill but it isn't always installed.
|
|
|
|
if (tskill //?) >/dev/null 2>&1; then :; else
|
|
|
|
tskill () { taskkill //F //PID $1 >/dev/null; }
|
|
|
|
fi
|
|
|
|
|
2015-01-13 14:57:14 -08:00
|
|
|
kill () {
|
2015-06-25 08:34:39 -07:00
|
|
|
signal=
|
|
|
|
retval=0
|
|
|
|
for arg; do
|
2020-09-23 13:39:55 +03:00
|
|
|
arg=$(echo $arg | tr -d '\n\r')
|
2015-06-25 08:34:39 -07:00
|
|
|
case $arg in
|
|
|
|
-*) signal=$arg ;;
|
2015-01-13 14:57:14 -08:00
|
|
|
[1-9][0-9]*)
|
2015-06-25 08:34:39 -07:00
|
|
|
# tasklist always returns 0.
|
|
|
|
# If pid does exist, there will be a line with the pid.
|
|
|
|
if tasklist //fi "PID eq $arg" | grep $arg >/dev/null; then
|
|
|
|
if test "X$signal" != "X-0"; then
|
|
|
|
tskill $arg
|
2015-04-07 17:17:39 -07:00
|
|
|
fi
|
2015-06-25 08:34:39 -07:00
|
|
|
else
|
|
|
|
retval=1
|
|
|
|
fi
|
2015-01-13 14:57:14 -08:00
|
|
|
;;
|
2015-06-25 08:34:39 -07:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
return $retval
|
2015-01-13 14:57:14 -08:00
|
|
|
}
|
|
|
|
fi
|
2016-09-29 14:41:50 -07:00
|
|
|
|
|
|
|
# parent_pid PID
|
|
|
|
#
|
|
|
|
# Prints the PID of the parent of process PID.
|
|
|
|
parent_pid () {
|
|
|
|
# Using "ps" is portable to any POSIX system, but busybox "ps" (used in
|
|
|
|
# e.g. Alpine Linux) is noncompliant, so we use a Linux-specific approach
|
2016-10-13 16:42:27 +09:00
|
|
|
# when it's available. We check the format of the status file to avoid
|
|
|
|
# the NetBSD file with the same name but different contents.
|
2022-09-12 21:38:46 +02:00
|
|
|
if grep -E '^PPid:[[:space:]]*[0-9]*$' /proc/$1/status > /dev/null 2>&1; then
|
2016-09-29 14:41:50 -07:00
|
|
|
sed -n 's/^PPid: \([0-9]*\)/\1/p' /proc/$1/status
|
2016-10-13 16:42:27 +09:00
|
|
|
else
|
|
|
|
ps -o ppid= -p $1
|
2016-09-29 14:41:50 -07:00
|
|
|
fi
|
|
|
|
}
|
2017-05-01 13:19:43 -07:00
|
|
|
|
2017-06-09 12:58:57 -03:00
|
|
|
# kill_ovs_vswitchd [PID]
|
|
|
|
#
|
|
|
|
# Signal the ovs-vswitchd daemon to exit gracefully and wait for it to
|
|
|
|
# terminate or kill it if that takes too long.
|
|
|
|
#
|
|
|
|
# It is used to cleanup all sorts of tests and results. It can't assume
|
|
|
|
# any state, including the availability of PID file which can be provided.
|
|
|
|
kill_ovs_vswitchd () {
|
|
|
|
# Use provided PID or save the current PID if available.
|
|
|
|
TMPPID=$1
|
|
|
|
if test -z "$TMPPID"; then
|
|
|
|
TMPPID=$(cat $OVS_RUNDIR/ovs-vswitchd.pid 2>/dev/null)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Tell the daemon to terminate gracefully
|
2019-10-10 16:23:57 +02:00
|
|
|
ovs-appctl -t ovs-vswitchd exit --cleanup 2>/dev/null
|
2017-06-09 12:58:57 -03:00
|
|
|
|
|
|
|
# Nothing else to be done if there is no PID
|
|
|
|
test -z "$TMPPID" && return
|
|
|
|
|
|
|
|
for i in 1 2 3 4 5 6 7 8 9; do
|
|
|
|
# Check if the daemon is alive.
|
|
|
|
kill -0 $TMPPID 2>/dev/null || return
|
|
|
|
|
|
|
|
# Fallback to whole number since POSIX doesn't require
|
|
|
|
# fractional times to work.
|
|
|
|
sleep 0.1 || sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make sure it is terminated.
|
|
|
|
kill $TMPPID
|
|
|
|
}
|
|
|
|
|
2017-05-01 13:19:43 -07:00
|
|
|
# Normalize the output of 'wc' to match POSIX.
|
|
|
|
# POSIX says 'wc' should print "%d %d %d", but GNU prints "%7d %7d %7d".
|
|
|
|
# POSIX says 'wc -l' should print "%d %s", but BSD prints "%8d".
|
|
|
|
#
|
|
|
|
# This fixes all of those (it will screw up filenames that contain
|
|
|
|
# multiple sequential spaces, but that doesn't really matter).
|
|
|
|
wc () {
|
|
|
|
command wc "$@" | tr -s ' ' ' ' | sed 's/^ *//'
|
|
|
|
}
|
2017-11-26 16:07:39 -08:00
|
|
|
|
|
|
|
uuidfilt () {
|
2019-09-20 08:30:42 -07:00
|
|
|
$PYTHON3 "$top_srcdir"/tests/uuidfilt.py "$@"
|
2017-11-26 16:07:39 -08:00
|
|
|
}
|
2017-12-31 21:15:58 -08:00
|
|
|
|
|
|
|
# run_as PROGRAM_NAME COMMAND [ARG...]
|
|
|
|
#
|
|
|
|
# Runs a command with argv[0] set to PROGRAM_NAME, if possible, in a
|
|
|
|
# subshell. Most utilities print argc[0] as part of their messages,
|
|
|
|
# so this makes it easier to figure out which particular utility
|
|
|
|
# prints a message if a bunch of identical processes are running.
|
|
|
|
#
|
|
|
|
# Not all shells support "exec -a NAME", so test for it.
|
2019-01-25 16:21:22 +03:00
|
|
|
if (exec -a myname true 2>/dev/null); then
|
2017-12-31 21:15:58 -08:00
|
|
|
run_as () {
|
2018-05-25 17:11:07 -07:00
|
|
|
(exec -a "$@")
|
2017-12-31 21:15:58 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
run_as () {
|
|
|
|
shift
|
2018-05-25 17:11:07 -07:00
|
|
|
(exec "$@")
|
2017-12-31 21:15:58 -08:00
|
|
|
}
|
|
|
|
fi
|
2015-01-13 14:57:14 -08:00
|
|
|
]
|
|
|
|
m4_divert_pop([PREPARE_TESTS])
|
|
|
|
|
2018-09-04 13:59:06 -07:00
|
|
|
OVS_START_SHELL_HELPERS
|
2018-11-14 21:55:55 -08:00
|
|
|
ovs_cleanup() {
|
2024-01-10 11:22:23 +01:00
|
|
|
if test "$(echo sanitizers.*)" != 'sanitizers.*'; then
|
|
|
|
echo "Undefined Behavior Sanitizer or Address Sanitizer reported errors in:" sanitizers.*
|
|
|
|
cat sanitizers.*
|
2022-04-11 13:39:16 +02:00
|
|
|
AT_FAIL_IF([:])
|
|
|
|
fi
|
2018-11-14 21:55:55 -08:00
|
|
|
}
|
|
|
|
|
2018-09-04 13:59:06 -07:00
|
|
|
ovs_wait () {
|
|
|
|
echo "$1: waiting $2..." >&AS_MESSAGE_LOG_FD
|
|
|
|
|
|
|
|
# First try the condition without waiting.
|
|
|
|
if ovs_wait_cond; then echo "$1: wait succeeded immediately" >&AS_MESSAGE_LOG_FD; return 0; fi
|
|
|
|
|
|
|
|
# Try a quick sleep, so that the test completes very quickly
|
|
|
|
# in the normal case. POSIX doesn't require fractional times to
|
|
|
|
# work, so this might not work.
|
|
|
|
sleep 0.1
|
|
|
|
if ovs_wait_cond; then echo "$1: wait succeeded quickly" >&AS_MESSAGE_LOG_FD; return 0; fi
|
|
|
|
|
2019-11-06 17:29:58 +01:00
|
|
|
# Then wait up to OVS_CTL_TIMEOUT seconds.
|
2018-09-04 13:59:06 -07:00
|
|
|
local d
|
2019-11-06 17:29:58 +01:00
|
|
|
for d in `seq 1 "$OVS_CTL_TIMEOUT"`; do
|
2018-09-04 13:59:06 -07:00
|
|
|
sleep 1
|
|
|
|
if ovs_wait_cond; then echo "$1: wait succeeded after $d seconds" >&AS_MESSAGE_LOG_FD; return 0; fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "$1: wait failed after $d seconds" >&AS_MESSAGE_LOG_FD
|
|
|
|
ovs_wait_failed
|
|
|
|
AT_FAIL_IF([:])
|
|
|
|
}
|
|
|
|
OVS_END_SHELL_HELPERS
|
2015-07-05 10:19:30 -07:00
|
|
|
m4_define([OVS_WAIT], [dnl
|
|
|
|
ovs_wait_cond () {
|
|
|
|
$1
|
2015-01-13 14:57:14 -08:00
|
|
|
}
|
2018-09-04 13:59:06 -07:00
|
|
|
ovs_wait_failed () {
|
|
|
|
:
|
2015-07-05 10:19:30 -07:00
|
|
|
$2
|
2018-09-04 13:59:06 -07:00
|
|
|
}
|
|
|
|
ovs_wait "AS_ESCAPE([$3])" "AS_ESCAPE([$4])"
|
2015-07-05 10:19:30 -07:00
|
|
|
])
|
2015-11-03 15:29:32 -08:00
|
|
|
|
2019-12-04 15:06:09 -08:00
|
|
|
dnl OVS_WAIT_UNTIL(COMMAND, [IF-FAILED])
|
2015-11-03 15:29:32 -08:00
|
|
|
dnl
|
2019-12-04 15:06:09 -08:00
|
|
|
dnl Executes shell COMMAND in a loop until it returns zero. If COMMAND does
|
|
|
|
dnl not return zero within a reasonable time limit, executes the commands
|
|
|
|
dnl in IF-FAILED (if provided) and fails the test.
|
2018-02-01 10:08:05 -08:00
|
|
|
m4_define([OVS_WAIT_UNTIL],
|
2022-03-22 14:35:56 +01:00
|
|
|
[AT_FAIL_IF([test "$#" -ge 3])
|
|
|
|
dnl The second argument should not be a number (confused with AT_CHECK ?).
|
|
|
|
AT_FAIL_IF([test "$#" -eq 2 && test "$2" -eq "$2" 2>/dev/null])
|
|
|
|
OVS_WAIT([$1], [$2], [AT_LINE], [until $1])])
|
|
|
|
|
|
|
|
dnl OVS_WAIT_UNTIL_EQUAL(COMMAND, OUTPUT)
|
|
|
|
dnl
|
|
|
|
dnl Executes shell COMMAND in a loop until it returns zero and the output
|
|
|
|
dnl equals OUTPUT. If COMMAND does not return zero or a desired output within
|
|
|
|
dnl a reasonable time limit, fails the test.
|
|
|
|
m4_define([OVS_WAIT_UNTIL_EQUAL],
|
|
|
|
[AT_FAIL_IF([test "$#" -ge 3])
|
|
|
|
echo "$2" > wait_until_expected
|
|
|
|
OVS_WAIT_UNTIL([$1 | diff -u wait_until_expected - ])])
|
2015-11-03 15:29:32 -08:00
|
|
|
|
2019-12-04 15:06:09 -08:00
|
|
|
dnl OVS_WAIT_WHILE(COMMAND, [IF-FAILED])
|
2015-11-03 15:29:32 -08:00
|
|
|
dnl
|
2019-12-04 15:06:09 -08:00
|
|
|
dnl Executes shell COMMAND in a loop until it returns nonzero. If COMMAND does
|
|
|
|
dnl not return nonzero within a reasonable time limit, executes the commands
|
|
|
|
dnl in IF-FAILED (if provided) and fails the test.
|
2015-01-13 14:57:14 -08:00
|
|
|
m4_define([OVS_WAIT_WHILE],
|
2022-03-22 14:35:56 +01:00
|
|
|
[AT_FAIL_IF([test "$#" -ge 3])
|
|
|
|
dnl The second argument should not be a number (confused with AT_CHECK ?).
|
|
|
|
AT_FAIL_IF([test "$#" -eq 2 && test "$2" -eq "$2" 2>/dev/null])
|
|
|
|
OVS_WAIT([if $1; then return 1; else return 0; fi], [$2],
|
2018-02-01 10:08:05 -08:00
|
|
|
[AT_LINE], [while $1])])
|
2015-01-13 14:57:14 -08:00
|
|
|
|
|
|
|
dnl OVS_APP_EXIT_AND_WAIT(DAEMON)
|
|
|
|
dnl
|
2016-06-10 12:17:57 -04:00
|
|
|
dnl Ask the daemon named DAEMON to exit, via ovs-appctl, and then wait for it
|
2015-01-13 14:57:14 -08:00
|
|
|
dnl to exit.
|
|
|
|
m4_define([OVS_APP_EXIT_AND_WAIT],
|
2016-06-10 12:17:57 -04:00
|
|
|
[AT_CHECK([test -e $OVS_RUNDIR/$1.pid])
|
|
|
|
TMPPID=$(cat $OVS_RUNDIR/$1.pid)
|
2017-06-07 17:58:10 -03:00
|
|
|
AT_CHECK(m4_if([$1],[ovs-vswitchd],
|
2019-10-10 16:23:57 +02:00
|
|
|
[ovs-appctl -t $1 exit --cleanup],
|
|
|
|
[ovs-appctl -t $1 exit]))
|
2016-03-02 16:40:45 -05:00
|
|
|
OVS_WAIT_WHILE([kill -0 $TMPPID 2>/dev/null])])
|
2015-01-13 14:57:14 -08:00
|
|
|
|
2016-06-10 12:17:57 -04:00
|
|
|
dnl OVS_APP_EXIT_AND_WAIT_BY_TARGET(TARGET, PIDFILE)
|
2016-03-21 15:40:01 -05:00
|
|
|
dnl
|
2016-06-10 12:17:57 -04:00
|
|
|
dnl Ask the daemon identified by TARGET to exit, via ovs-appctl (using the target
|
|
|
|
dnl argument), and then wait for it to exit.
|
2016-03-21 15:40:01 -05:00
|
|
|
m4_define([OVS_APP_EXIT_AND_WAIT_BY_TARGET],
|
2016-06-10 12:17:57 -04:00
|
|
|
[AT_CHECK([test -e $2])
|
|
|
|
TMPPID=$(cat $2)
|
2019-10-10 16:23:57 +02:00
|
|
|
AT_CHECK([ovs-appctl --target=$1 exit])
|
2016-03-21 15:40:01 -05:00
|
|
|
OVS_WAIT_WHILE([kill -0 $TMPPID 2>/dev/null])])
|
|
|
|
|
2022-09-01 18:02:04 +02:00
|
|
|
dnl OVS_DAEMONIZE([command], [pidfile])
|
|
|
|
dnl
|
|
|
|
dnl Run 'command' as a background process and record its pid to 'pidfile' to
|
|
|
|
dnl allow cleanup on exit.
|
|
|
|
m4_define([OVS_DAEMONIZE],
|
|
|
|
[$1 & echo $! > $2
|
|
|
|
on_exit "kill `cat $2`"
|
|
|
|
])
|
|
|
|
|
2015-09-09 10:26:11 -07:00
|
|
|
dnl on_exit "COMMAND"
|
2015-01-13 14:57:14 -08:00
|
|
|
dnl
|
2015-09-09 10:26:11 -07:00
|
|
|
dnl Add the shell COMMAND to a collection executed when the current test
|
2015-01-13 14:57:14 -08:00
|
|
|
dnl completes, as a cleanup action. (The most common use is to kill a
|
|
|
|
dnl daemon started by the test. This is important to prevent tests that
|
|
|
|
dnl start daemons from hanging at exit.)
|
2015-04-07 17:17:39 -07:00
|
|
|
dnl
|
2015-09-09 10:26:11 -07:00
|
|
|
dnl Cleanup commands are executed in the reverse order of calls to this
|
|
|
|
dnl function.
|
|
|
|
m4_divert_text([PREPARE_TESTS], [dnl
|
|
|
|
on_exit () {
|
|
|
|
(echo "$1"; cat cleanup) > cleanup.tmp
|
|
|
|
mv cleanup.tmp cleanup
|
|
|
|
}
|
|
|
|
])
|
2016-02-26 12:46:48 -08:00
|
|
|
|
|
|
|
dnl Autoconf 2.63 compatibility verison of macro introduced in Autoconf 2.64:
|
|
|
|
m4_ifndef([AS_VAR_APPEND],
|
|
|
|
[m4_divert_text([PREPARE_TESTS],
|
|
|
|
[as_var_append () {
|
|
|
|
eval $1=\$$1\$2
|
|
|
|
}
|
|
|
|
])
|
|
|
|
m4_define([AS_VAR_APPEND], [as_var_append $1 $2])])
|
2016-02-22 09:57:50 -08:00
|
|
|
|
|
|
|
dnl Autoconf 2.63 compatibility verison of macro introduced in Autoconf 2.64:
|
|
|
|
m4_ifndef([AT_CHECK_UNQUOTED],
|
|
|
|
[m4_define([AT_CHECK_UNQUOTED],
|
|
|
|
[_AT_CHECK([$1], [$2], AS_ESCAPE(m4_dquote(m4_expand([$3])), [""]),
|
|
|
|
AS_ESCAPE(m4_dquote(m4_expand([$4])),[""]), [$5], [$6])])])
|
|
|
|
|
|
|
|
dnl Autoconf 2.63 compatibility verison of macro introduced in Autoconf 2.64:
|
|
|
|
m4_ifndef([AT_SKIP_IF],
|
|
|
|
[m4_define([AT_SKIP_IF],
|
|
|
|
[AT_CHECK([($1) \
|
|
|
|
&& exit 77 || exit 0], [0], [ignore], [ignore])])])
|
|
|
|
|
|
|
|
dnl Autoconf 2.63 compatibility verison of macro introduced in Autoconf 2.64:
|
|
|
|
m4_ifndef([AT_FAIL_IF],
|
|
|
|
[m4_define([AT_FAIL_IF],
|
|
|
|
[AT_CHECK([($1) \
|
|
|
|
&& exit 99 || exit 0], [0], [ignore], [ignore])])])
|
2020-07-23 09:32:06 -07:00
|
|
|
|
tests: Add support for running system tests under retis.
Retis is very useful for debugging our system tests or debugging
kernel issues through our system tests. This change adds a convenient
way to run any kernel system test with the retis capture on the
background. E.g.:
make check-kernel OVS_TEST_WITH_RETIS=yes TESTSUITEFLAGS='167 -d'
Retis 1.5 is required, since we're using ifdump profile, and it also
will mount debugfs for us in case of running in a different namespace.
It should be available in $PATH.
In addition to just capturing the retis.data, we're also running the
capture with --print to print all the events as they appear, and
producing the sorted output in the end. This makes it easier to work
across systems with different versions of retis and saves time for
running the sort manually. The raw data is still available for
advanced processing, if needed.
Not specifying any particular collector, capturing everything that's
enabled by default. OVS tracking is turned on by default.
Since OVS tracking is used, it's required to start retis after the
kernel datapath is created, otherwise it will fail to obtain the map
of upcall PIDs. That's why we need to start it after the bridge is
created.
Only adding support for kernel-related test suites for now. For
userspace test suites it may also be useful at some point, but
currently that requires running without --ovs-track and isn't too
important.
Startup of the retis capture adds significant amount of time to each
test, so not running it by default.
Link: https://github.com/retis-org/retis
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2025-06-30 19:09:57 +02:00
|
|
|
dnl Start retis to track all the traffic passing through OVS.
|
|
|
|
m4_define([RETIS_CHECK_AND_RUN],
|
|
|
|
[if test "$OVS_TEST_WITH_RETIS" = yes && retis --version > /dev/null; then
|
|
|
|
on_exit 'retis sort --utc retis.data > retis.sorted'
|
|
|
|
OVS_DAEMONIZE([retis -p ifdump collect --utc --allow-system-changes \
|
|
|
|
--ovs-track --out --print 2>retis.err 1>retis.log],
|
|
|
|
[retis.pid])
|
|
|
|
OVS_WAIT_UNTIL([grep -q 'loaded' retis.err])
|
|
|
|
fi])
|
|
|
|
|
2020-07-23 09:32:06 -07:00
|
|
|
dnl Add a rule to always accept the traffic.
|
2024-11-15 17:28:54 +00:00
|
|
|
dnl The first argument to this macro should be the command to run:
|
|
|
|
dnl iptables or ip6tables
|
|
|
|
dnl The second argument to this macro should be the interface name (netdev)
|
2020-07-23 09:32:06 -07:00
|
|
|
m4_define([IPTABLES_ACCEPT],
|
2024-11-15 17:28:54 +00:00
|
|
|
[AT_CHECK([$1 -I INPUT 1 -i $2 -j ACCEPT])
|
|
|
|
on_exit '$1 -D INPUT 1'])
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
|
|
|
|
dnl Certain Linux distributions, like CentOS, have default iptable rules
|
|
|
|
dnl to reject input traffic from bridges such as br-underlay.
|
2024-11-15 17:28:54 +00:00
|
|
|
dnl This implies the existence of a ip filter INPUT chain for IPv4 or an
|
|
|
|
dnl ip6 filter INPUT chain for IPv6. If that chain exists then add a rule
|
|
|
|
dnl to it to always accept all traffic.
|
|
|
|
dnl The first argument to this macro should be the filter chain: ip or ipv6
|
|
|
|
dnl The second argument to this macro should be the interface name (netdev)
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
m4_define([NFT_ACCEPT],
|
2024-11-15 17:28:54 +00:00
|
|
|
[if nft list chain $1 filter INPUT > /dev/null 2>1; then
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
AT_CHECK([nft -ae \
|
2024-11-15 17:28:54 +00:00
|
|
|
"insert rule $1 filter INPUT iifname \"$2\" counter accept"],
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
[0], [stdout-nolog])
|
|
|
|
dnl Extract handle, which is used to delete the rule
|
|
|
|
AT_CHECK([sed -n 's/.*handle //; T; p' < stdout], [0], [stdout])
|
2024-11-15 17:28:54 +00:00
|
|
|
on_exit "nft \"delete rule $1 filter INPUT handle $(cat stdout)\""
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
fi])
|
|
|
|
|
|
|
|
dnl Certain Linux distributions, like CentOS, have default iptable rules
|
|
|
|
dnl to reject input traffic from bridges such as br-underlay.
|
|
|
|
dnl Add a rule to always accept the traffic.
|
2024-11-15 17:28:54 +00:00
|
|
|
dnl IPv4 variant of this macro.
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
m4_define([XT_ACCEPT],
|
|
|
|
[if test $HAVE_NFT = yes; then
|
2024-11-15 17:28:54 +00:00
|
|
|
NFT_ACCEPT([ip], [$1])
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
else
|
2024-11-15 17:28:54 +00:00
|
|
|
IPTABLES_ACCEPT([iptables], [$1])
|
|
|
|
fi])
|
|
|
|
|
|
|
|
dnl Certain Linux distributions, like CentOS, have default iptable rules
|
|
|
|
dnl to reject input traffic from bridges such as br-underlay.
|
|
|
|
dnl Add a rule to always accept the traffic.
|
|
|
|
dnl IPv6 variant of this macro.
|
|
|
|
m4_define([XT6_ACCEPT],
|
|
|
|
[if test $HAVE_NFT = yes; then
|
|
|
|
NFT_ACCEPT([ip6], [$1])
|
|
|
|
else
|
|
|
|
IPTABLES_ACCEPT([ip6tables], [$1])
|
tests: Add nft accept support.
Certain Linux distributions, like CentOS, have default iptable rules
to reject input traffic from bridges such as br-underlay.
To address this, IPTABLES_ACCEPT adds an iptables rule to always accept
the traffic.
As part of an effort to use nft in place of iptables in the testsuite,
implement NFT_ACCEPT, an nft version of IPTABLES_ACCEPT. As the
condition where IPTABLES_ACCEPT implies the existence of an INPUT chain,
only instantiate an nft rule in that chain if it already exists.
Also provide a wrapper, XT_ACCEPT, which will call NFT_ACCEPT if
nft is available, and IPTABLES_ACCEPT otherwise
And provide OVS_CHECK_XT, which can be used to check if the
prerequisites for running XT_ACCEPT are present, and skips the current
test otherwise.
Update the one test where IPTABLES_ACCEPT is used so that it
now uses XT_ACCEPT and OVS_CHECK_XT.
Signed-off-by: Simon Horman <horms@ovn.org>
Signed-off-by: Aaron Conole <aconole@redhat.com>
2024-11-05 08:27:29 +00:00
|
|
|
fi])
|