Blob Blame History Raw
From c17c51550281fa8f9db246b06197149d2714b82e Mon Sep 17 00:00:00 2001
From: Eric Garver <eric@garver.life>
Date: Thu, 31 Oct 2019 13:00:28 -0400
Subject: [PATCH 121/122] fix: tests: convert host ipv6 checks to runtime

(cherry picked from commit dfbd62fe435ff621eec3b3e9c7bb5de0d5ae64ec)
(cherry picked from commit a3bb1c5d4db860c82b65d4ac446cbe6d7fc5d9bf)
---
 src/tests/functions.at        | 10 ++++++----
 src/tests/regression/gh335.at | 14 +++++++-------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/tests/functions.at b/src/tests/functions.at
index 97df8914444a..a84a22c3da4b 100644
--- a/src/tests/functions.at
+++ b/src/tests/functions.at
@@ -432,13 +432,15 @@ m4_define([IF_HOST_SUPPORTS_IP6TABLES], [
     fi
 ])
 
-m4_define([HOST_SUPPORTS_IPV6], m4_esyscmd(
+m4_define([IF_HOST_SUPPORTS_IPV6], [
     if sysctl -a |grep -F "net.ipv6" >/dev/null 2>&1; then
-        echo -n "yes"
+        :
+        $1
     else
-        echo -n "no"
+        :
+        $2
     fi
-))
+])
 
 m4_define([IF_IPV6_SUPPORTED], [
     m4_ifdef([TESTING_FIREWALL_OFFLINE_CMD], [$1], [
diff --git a/src/tests/regression/gh335.at b/src/tests/regression/gh335.at
index cf307ef35365..d3c2b225a2df 100644
--- a/src/tests/regression/gh335.at
+++ b/src/tests/regression/gh335.at
@@ -1,7 +1,7 @@
 FWD_START_TEST([forward-port toaddr enables IP forwarding])
 
 NS_CHECK([sysctl -w net.ipv4.conf.all.forwarding=0], 0, [ignore], [ignore])
-m4_if(yes, HOST_SUPPORTS_IPV6, [
+IF_HOST_SUPPORTS_IPV6([
 NS_CHECK([sysctl -w net.ipv6.conf.all.forwarding=0], 0, [ignore], [ignore])
 ])
 FWD_CHECK([-q --add-forward-port=port=12345:proto=tcp:toaddr=10.10.10.10])
@@ -11,19 +11,19 @@ FWD_RELOAD
 
 IF_IPV6_SUPPORTED([
 NS_CHECK([sysctl -w net.ipv4.conf.all.forwarding=0], 0, [ignore], [ignore])
-m4_if(yes, HOST_SUPPORTS_IPV6, [
+IF_HOST_SUPPORTS_IPV6([
 NS_CHECK([sysctl -w net.ipv6.conf.all.forwarding=0], 0, [ignore], [ignore])
 ])
 FWD_CHECK([-q --add-forward-port=port=12345:proto=tcp:toport=54321:toaddr="1234:5678::4321"])
 NS_CHECK([[sysctl -a |grep "net.ipv4.conf.all.forwarding[ ]*=[ ]*1"]], 1, [ignore], [ignore])
-m4_if(yes, HOST_SUPPORTS_IPV6, [
+IF_HOST_SUPPORTS_IPV6([
 NS_CHECK([[sysctl -a |grep "net.ipv6.conf.all.forwarding[ ]*=[ ]*1"]], 0, [ignore], [ignore])
 ])
 FWD_RELOAD
 ])
 
 NS_CHECK([sysctl -w net.ipv4.conf.all.forwarding=0], 0, [ignore], [ignore])
-m4_if(yes, HOST_SUPPORTS_IPV6, [
+IF_HOST_SUPPORTS_IPV6([
 NS_CHECK([sysctl -w net.ipv6.conf.all.forwarding=0], 0, [ignore], [ignore])
 ])
 FWD_CHECK([-q --add-rich-rule='rule family=ipv4 forward-port port="12345" protocol="tcp" to-port="54321" to-addr="10.10.10.10"'])
@@ -33,12 +33,12 @@ FWD_RELOAD
 
 IF_IPV6_SUPPORTED([
 NS_CHECK([sysctl -w net.ipv4.conf.all.forwarding=0], 0, [ignore], [ignore])
-m4_if(yes, HOST_SUPPORTS_IPV6, [
+IF_HOST_SUPPORTS_IPV6([
 NS_CHECK([sysctl -w net.ipv6.conf.all.forwarding=0], 0, [ignore], [ignore])
 ])
 FWD_CHECK([-q --add-rich-rule='rule family=ipv6 forward-port port="12345" protocol="tcp" to-port="54321" to-addr="1234:5678::4321"'])
 NS_CHECK([[sysctl -a |grep "net.ipv4.conf.all.forwarding[ ]*=[ ]*1"]], 1, [ignore], [ignore])
-m4_if(yes, HOST_SUPPORTS_IPV6, [
+IF_HOST_SUPPORTS_IPV6([
 NS_CHECK([[sysctl -a |grep "net.ipv6.conf.all.forwarding[ ]*=[ ]*1"]], 0, [ignore], [ignore])
 ])
 FWD_RELOAD
@@ -46,7 +46,7 @@ FWD_RELOAD
 
 dnl following tests should _not_ enable IP forwarding
 NS_CHECK([sysctl -w net.ipv4.conf.all.forwarding=0], 0, [ignore], [ignore])
-m4_if(yes, HOST_SUPPORTS_IPV6, [
+IF_HOST_SUPPORTS_IPV6([
 NS_CHECK([sysctl -w net.ipv6.conf.all.forwarding=0], 0, [ignore], [ignore])
 ])
 
-- 
2.23.0