bb602c
From 8d2f8e36353fc23c198d06fd7bbcb2835d973d41 Mon Sep 17 00:00:00 2001
bb602c
From: Eric Garver <eric@garver.life>
bb602c
Date: Tue, 8 Oct 2019 16:50:28 -0400
bb602c
Subject: [PATCH 117/122] fix: build: distribute testsuite
bb602c
bb602c
Make some build changes that allow distributing the testsuite. User will
bb602c
still need to run ./configure to generate atconfig and atlocal, but they
bb602c
won't need autoconf installed anymore.
bb602c
bb602c
(cherry picked from commit 374f9411106b80b4d333053936b1582eeb4fab96)
bb602c
(cherry picked from commit 077eadda76bc6d9e4b433027ab2371ca781e69ab)
bb602c
---
bb602c
 .gitignore             |  1 +
bb602c
 configure.ac           |  1 +
bb602c
 src/tests/Makefile.am  | 17 ++++++-----------
bb602c
 src/tests/atlocal.in   |  6 ++++++
bb602c
 src/tests/functions.at |  6 +++---
bb602c
 5 files changed, 17 insertions(+), 14 deletions(-)
bb602c
 create mode 100644 src/tests/atlocal.in
bb602c
bb602c
diff --git a/.gitignore b/.gitignore
bb602c
index a0f455d7bf28..11e257f5f0b0 100644
bb602c
--- a/.gitignore
bb602c
+++ b/.gitignore
bb602c
@@ -39,6 +39,7 @@
bb602c
 /src/firewall-offline-cmd
bb602c
 /src/firewalld
bb602c
 /src/tests/atconfig
bb602c
+/src/tests/atlocal
bb602c
 /src/tests/package.m4
bb602c
 /src/tests/testsuite*
bb602c
 Makefile
bb602c
diff --git a/configure.ac b/configure.ac
bb602c
index 1f8f8dff07ae..ea5d1d72009e 100644
bb602c
--- a/configure.ac
bb602c
+++ b/configure.ac
bb602c
@@ -170,6 +170,7 @@ AC_CONFIG_FILES([Makefile
bb602c
 		 src/firewall/config/__init__.py
bb602c
 		 src/Makefile
bb602c
 		 src/tests/Makefile
bb602c
+		 src/tests/atlocal
bb602c
 		 src/icons/Makefile])
bb602c
 
bb602c
 m4_foreach([FILE], [[src/firewall-applet],
bb602c
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
bb602c
index 9a0352bcab05..cfb80aa0c8c0 100644
bb602c
--- a/src/tests/Makefile.am
bb602c
+++ b/src/tests/Makefile.am
bb602c
@@ -8,7 +8,8 @@ EXTRA_DIST = \
bb602c
 	$(TESTSUITE) \
bb602c
 	$(TESTSUITE_FILES) \
bb602c
 	$(wildcard $(srcdir)/python/*.py) \
bb602c
-	$(srcdir)/package.m4
bb602c
+	$(srcdir)/package.m4 \
bb602c
+	atlocal.in
bb602c
 
bb602c
 DISTCLEANFILES = atconfig
bb602c
 
bb602c
@@ -18,23 +19,17 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac $(top_srcdir)/firewalld.spec $(
bb602c
 	echo 'm4_define([AT_PACKAGE_VERSION],[$(PACKAGE_VERSION)])' && \
bb602c
 	echo 'm4_define([AT_PACKAGE_STRING],[$(PACKAGE_STRING)])' && \
bb602c
 	echo 'm4_define([AT_PACKAGE_URL],[http://firewalld.org/])' && \
bb602c
-	echo 'm4_define([AT_PACKAGE_BUGREPORT],[https://github.com/firewalld/firewalld])' && \
bb602c
-	echo 'm4_define([IPTABLES],[$(IPTABLES)])' && \
bb602c
-	echo 'm4_define([IPTABLES_RESTORE],[$(IPTABLES_RESTORE)])' && \
bb602c
-	echo 'm4_define([IP6TABLES],[$(IP6TABLES)])' && \
bb602c
-	echo 'm4_define([IP6TABLES_RESTORE],[$(IP6TABLES_RESTORE)])' ; \
bb602c
+	echo 'm4_define([AT_PACKAGE_BUGREPORT],[https://github.com/firewalld/firewalld])' ; \
bb602c
 	} > "$@"
bb602c
 
bb602c
-check-local: atconfig $(TESTSUITE)
bb602c
+check-local: atconfig atlocal $(TESTSUITE)
bb602c
 	$(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) \
bb602c
 		AUTOTEST_PATH="src" \
bb602c
-		PYTHON="$(PYTHON)" \
bb602c
 		PYTHONPATH="${abs_top_srcdir}/src:${PYTHONPATH}" \
bb602c
 		FIREWALLD_DEFAULT_CONFIG="${abs_top_srcdir}/config"
bb602c
 
bb602c
-installcheck-local: atconfig $(TESTSUITE)
bb602c
-	$(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS) \
bb602c
-		PYTHON="$(PYTHON)"
bb602c
+installcheck-local: atconfig atlocal $(TESTSUITE)
bb602c
+	$(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
bb602c
 
bb602c
 clean-local:
bb602c
 	test ! -f '$(TESTSUITE)' || $(SHELL) '$(TESTSUITE)' --clean
bb602c
diff --git a/src/tests/atlocal.in b/src/tests/atlocal.in
bb602c
new file mode 100644
bb602c
index 000000000000..474685515437
bb602c
--- /dev/null
bb602c
+++ b/src/tests/atlocal.in
bb602c
@@ -0,0 +1,6 @@
bb602c
+export PYTHON=@PYTHON@
bb602c
+
bb602c
+export IPTABLES=@IPTABLES@
bb602c
+export IPTABLES_RESTORE=@IPTABLES_RESTORE@
bb602c
+export IP6TABLES=@IP6TABLES@
bb602c
+export IP6TABLES_RESTORE=@IP6TABLES_RESTORE@
bb602c
diff --git a/src/tests/functions.at b/src/tests/functions.at
bb602c
index 17ca6c9fc052..debabba8b8eb 100644
bb602c
--- a/src/tests/functions.at
bb602c
+++ b/src/tests/functions.at
bb602c
@@ -244,7 +244,7 @@ m4_define([EBTABLES_LIST_RULES], [
bb602c
 
bb602c
 m4_define([IPTABLES_LIST_RULES_ALWAYS], [
bb602c
     m4_ifdef([TESTING_FIREWALL_OFFLINE_CMD], [], [
bb602c
-        NS_CHECK([IPTABLES -w -n -t $1 -L $2 | TRIM_WHITESPACE | tail -n +3], [$3], [m4_strip([$4])], [m4_strip([$5])], [$6], [$7])
bb602c
+        NS_CHECK([$IPTABLES -w -n -t $1 -L $2 | TRIM_WHITESPACE | tail -n +3], [$3], [m4_strip([$4])], [m4_strip([$5])], [$6], [$7])
bb602c
     ])
bb602c
 ])
bb602c
 
bb602c
@@ -257,7 +257,7 @@ m4_define([IPTABLES_LIST_RULES], [
bb602c
 m4_define([IP6TABLES_LIST_RULES_ALWAYS], [
bb602c
     m4_ifdef([TESTING_FIREWALL_OFFLINE_CMD], [], [
bb602c
     m4_if(yes, HOST_SUPPORTS_IP6TABLES, [
bb602c
-        NS_CHECK([IP6TABLES -w -n -t $1 -L $2 | TRIM_WHITESPACE | tail -n +3], [$3], [m4_strip([$4])], [m4_strip([$5])], [$6], [$7])
bb602c
+        NS_CHECK([$IP6TABLES -w -n -t $1 -L $2 | TRIM_WHITESPACE | tail -n +3], [$3], [m4_strip([$4])], [m4_strip([$5])], [$6], [$7])
bb602c
     ])
bb602c
     ])
bb602c
 ])
bb602c
@@ -425,7 +425,7 @@ m4_define([CHECK_MODULE_PROTO_GRE], [
bb602c
 m4_define([NFT_NUMERIC_ARGS], m4_esyscmd([nft -h |grep "numeric-protocol" >/dev/null && echo -n "" || { echo -n "-" && echo -n "nn"; } ]))
bb602c
 
bb602c
 m4_define([HOST_SUPPORTS_IP6TABLES], m4_esyscmd(
bb602c
-    if IP6TABLES -L >/dev/null 2>&1; then
bb602c
+    if $IP6TABLES -L >/dev/null 2>&1; then
bb602c
         echo -n "yes"
bb602c
     else
bb602c
         echo -n "no"
bb602c
-- 
bb602c
2.23.0
bb602c