136e2c
From 5157b540532338184b3867bc0370a8a27cef56f9 Mon Sep 17 00:00:00 2001
136e2c
From: Eric Garver <eric@garver.life>
136e2c
Date: Thu, 31 Oct 2019 12:57:23 -0400
136e2c
Subject: [PATCH 120/122] fix: tests: convert ip6tables checks to runtime
136e2c
136e2c
(cherry picked from commit 49d4021e6ebf74e82142ca4fa6e6715a80d9b547)
136e2c
(cherry picked from commit 7328e687353fbba92e303a97cf5f2c25884e6dae)
136e2c
---
136e2c
 src/tests/firewall-cmd.at           |  2 +-
136e2c
 src/tests/functions.at              | 14 ++++++++------
136e2c
 src/tests/regression/rhbz1594657.at |  2 +-
136e2c
 3 files changed, 10 insertions(+), 8 deletions(-)
136e2c
136e2c
diff --git a/src/tests/firewall-cmd.at b/src/tests/firewall-cmd.at
136e2c
index 2977cd6b5332..e9d5b6d1abc0 100644
136e2c
--- a/src/tests/firewall-cmd.at
136e2c
+++ b/src/tests/firewall-cmd.at
136e2c
@@ -831,7 +831,7 @@ FWD_START_TEST([direct passthrough])
136e2c
     FWD_CHECK([--direct --remove-passthrough ipv4 --table filter --append INPUT --in-interface dummy0 --protocol tcp --destination-port 67 --jump ACCEPT], 0, ignore)
136e2c
     FWD_CHECK([--direct --query-passthrough ipv4 --table filter --append INPUT --in-interface dummy0 --protocol tcp --destination-port 67 --jump ACCEPT], 1, ignore, ignore)
136e2c
 
136e2c
-    m4_if(yes, HOST_SUPPORTS_IP6TABLES, [dnl
136e2c
+    IF_HOST_SUPPORTS_IP6TABLES([
136e2c
     FWD_CHECK([--direct --add-passthrough ipv6 --table filter --append FORWARD --destination fd00:dead:beef:ff0::/64 --in-interface dummy0 --out-interface dummy0 --jump ACCEPT], 0, ignore)
136e2c
     FWD_CHECK([--direct --get-passthroughs ipv6 | grep "fd00:dead:beef:ff0::/64"], 0, ignore)
136e2c
     FWD_CHECK([--direct --get-all-passthroughs | grep "fd00:dead:beef:ff0::/64"], 0, ignore)
136e2c
diff --git a/src/tests/functions.at b/src/tests/functions.at
136e2c
index 97506cc1396f..97df8914444a 100644
136e2c
--- a/src/tests/functions.at
136e2c
+++ b/src/tests/functions.at
136e2c
@@ -256,7 +256,7 @@ m4_define([IPTABLES_LIST_RULES], [
136e2c
 
136e2c
 m4_define([IP6TABLES_LIST_RULES_ALWAYS], [
136e2c
     m4_ifdef([TESTING_FIREWALL_OFFLINE_CMD], [], [
136e2c
-    m4_if(yes, HOST_SUPPORTS_IP6TABLES, [
136e2c
+	IF_HOST_SUPPORTS_IP6TABLES([
136e2c
         NS_CHECK([$IP6TABLES -w -n -t $1 -L $2 | TRIM_WHITESPACE | tail -n +3], [$3], [m4_strip([$4])], [m4_strip([$5])], [$6], [$7])
136e2c
     ])
136e2c
     ])
136e2c
@@ -422,13 +422,15 @@ m4_define([IF_HOST_SUPPORTS_NFT_FIB], [
136e2c
     fi
136e2c
 ])
136e2c
 
136e2c
-m4_define([HOST_SUPPORTS_IP6TABLES], m4_esyscmd(
136e2c
+m4_define([IF_HOST_SUPPORTS_IP6TABLES], [
136e2c
     if $IP6TABLES -L >/dev/null 2>&1; then
136e2c
-        echo -n "yes"
136e2c
+        :
136e2c
+        $1
136e2c
     else
136e2c
-        echo -n "no"
136e2c
+        :
136e2c
+        $2
136e2c
     fi
136e2c
-))
136e2c
+])
136e2c
 
136e2c
 m4_define([HOST_SUPPORTS_IPV6], m4_esyscmd(
136e2c
     if sysctl -a |grep -F "net.ipv6" >/dev/null 2>&1; then
136e2c
@@ -441,6 +443,6 @@ m4_define([HOST_SUPPORTS_IPV6], m4_esyscmd(
136e2c
 m4_define([IF_IPV6_SUPPORTED], [
136e2c
     m4_ifdef([TESTING_FIREWALL_OFFLINE_CMD], [$1], [
136e2c
     m4_if(nftables, FIREWALL_BACKEND, [$1], [
136e2c
-    m4_if(yes, HOST_SUPPORTS_IP6TABLES, [$1], [$2])
136e2c
+    IF_HOST_SUPPORTS_IP6TABLES([$1], [$2])
136e2c
     ])])
136e2c
 ])
136e2c
diff --git a/src/tests/regression/rhbz1594657.at b/src/tests/regression/rhbz1594657.at
136e2c
index 33b7bafe6b08..93cc2c2ef5b8 100644
136e2c
--- a/src/tests/regression/rhbz1594657.at
136e2c
+++ b/src/tests/regression/rhbz1594657.at
136e2c
@@ -6,7 +6,7 @@ FWD_CHECK([--direct --passthrough ipv4 -t filter -C dummy_chain -j ACCEPT], 13,
136e2c
 FWD_CHECK([--direct --passthrough ipv4 -t filter -L dummy_chain], 13, [ignore], [ignore])
136e2c
 FWD_CHECK([--direct --passthrough ipv4 -t filter -L INPUT], 0, [ignore])
136e2c
 
136e2c
-m4_if(yes, HOST_SUPPORTS_IP6TABLES, [dnl
136e2c
+IF_HOST_SUPPORTS_IP6TABLES([
136e2c
 FWD_CHECK([--direct --passthrough ipv6 -t filter -C dummy_chain -j ACCEPT], 13, [ignore], [ignore])
136e2c
 FWD_CHECK([--direct --passthrough ipv6 -t filter -L dummy_chain], 13, [ignore], [ignore])
136e2c
 FWD_CHECK([--direct --passthrough ipv6 -t filter -L INPUT], 0, [ignore])
136e2c
-- 
136e2c
2.23.0
136e2c