@@ -167,6 +167,28 @@ if [ "$RUN_CHECK_DEPS" = "true" ]; then
167167 " ${BASE_ROOT_DIR} /contrib/devtools/check-deps.sh" " ${BASE_BUILD_DIR} "
168168fi
169169
170+ function get_interfaces()
171+ {
172+ set -o pipefail
173+ ifconfig | awk -F ' :| ' ' /^[^[:space:]]/ { if (!match($1, /^lo/)) { print $1 } }'
174+ set +o pipefail
175+ }
176+
177+ # ip_addr_on_interface (add|del) ip_address interface_name
178+ function ip_addr_on_interface()
179+ {
180+ op=$1
181+ ip_addr=$2
182+ interface=$3
183+ if which ip > /dev/null 2>&1 ; then
184+ if [ " $op " = " add" ] ; then
185+ ip addr add " $ip_addr " dev " $interface "
186+ else
187+ ip addr del " $ip_addr " dev " $interface "
188+ fi
189+ fi
190+ }
191+
170192if [ " $RUN_UNIT_TESTS " = " true" ]; then
171193 DIR_UNIT_TEST_DATA=" ${DIR_UNIT_TEST_DATA} " \
172194 LD_LIBRARY_PATH=" ${DEPENDS_DIR} /${HOST} /lib" \
@@ -178,6 +200,11 @@ if [ "$RUN_UNIT_TESTS" = "true" ]; then
178200fi
179201
180202if [ " $RUN_FUNCTIONAL_TESTS " = " true" ]; then
203+ non_loopback_interface=$( get_interfaces | head -1)
204+ if [ -n " $non_loopback_interface " ] ; then
205+ ip_addr_on_interface " add" " 1.1.1.1/32" " $non_loopback_interface "
206+ ip_addr_on_interface " add" " 2.2.2.2/32" " $non_loopback_interface "
207+ fi
181208 # parses TEST_RUNNER_EXTRA as an array which allows for multiple arguments such as TEST_RUNNER_EXTRA='--exclude "rpc_bind.py --ipv6"'
182209 eval " TEST_RUNNER_EXTRA=($TEST_RUNNER_EXTRA )"
183210 LD_LIBRARY_PATH=" ${DEPENDS_DIR} /${HOST} /lib" \
@@ -190,6 +217,10 @@ if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
190217 " ${TEST_RUNNER_EXTRA[@]} " \
191218 --quiet \
192219 --failfast
220+ if [ -n " $non_loopback_interface " ] ; then
221+ ip_addr_on_interface " del" " 1.1.1.1/32" " $non_loopback_interface "
222+ ip_addr_on_interface " del" " 2.2.2.2/32" " $non_loopback_interface "
223+ fi
193224fi
194225
195226if [ " ${RUN_TIDY} " = " true" ]; then
0 commit comments