[PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location

Subsystems: the rest

STALE3729d

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location

From: Tarmigan Casebolt <hidden>
Date: 2016-06-15 22:47:44

On my machine with CentOS, httpd is located at /usr/sbin/httpd, and
the modules are located at /usr/lib64/httpd/modules.  To enable easy
testing of httpd, we would like those locations to be detected
automatically.

uname might not be the best way to determine the default location for
httpd since different Linux distributions apparently put httpd in
different places, so we test a couple different locations for httpd,
and use the first one that we come across.  We do the same for the
modules directory.

Signed-off-by: Tarmigan Casebolt <redacted>
---

Would any machines have httpd or the modules/ directory in several of
these locations?

Also I don't really know shell scripting, so while this Works For Me,
it may be completely wrong.

 t/lib-httpd.sh |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 6765b08..6b86353 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -12,16 +12,23 @@ fi
 
 HTTPD_PARA=""
 
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+do
+	test -x "$DEFAULT_HTTPD_PATH" && break
+done
+
+for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
+                                 '/usr/lib/apache2/modules' \
+                                 '/usr/lib64/httpd/modules' \
+                                 '/usr/lib/httpd/modules'
+do
+	test -d "$DEFAULT_HTTPD_MODULE_PATH" && break
+done
+
 case $(uname) in
 	Darwin)
-		DEFAULT_HTTPD_PATH='/usr/sbin/httpd'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/libexec/apache2'
 		HTTPD_PARA="$HTTPD_PARA -DDarwin"
 	;;
-	*)
-		DEFAULT_HTTPD_PATH='/usr/sbin/apache2'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
-	;;
 esac
 
 LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"}
-- 
1.6.5.52.g35487

[PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.

From: Tarmigan Casebolt <hidden>
Date: 2016-06-15 22:47:44

With smart http, git over http is likely to become much more common.
To increase testing of smart http, enable the http tests by default.

If we cannot detect httpd, we still skip these tests, so it should not
cause problems on platforms where we cannot run the tests.

Signed-off-by: Tarmigan Casebolt <redacted>
---
 t/lib-httpd.sh |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 6b86353..db537b4 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -3,11 +3,12 @@
 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
 #
 
-if test -z "$GIT_TEST_HTTPD"
+if test -n "$NO_GIT_TEST_HTTPD"
 then
-	say "skipping test, network testing disabled by default"
-	say "(define GIT_TEST_HTTPD to enable)"
+	say "Skipping http tests because NO_GIT_TEST_HTTPD is defined"
 	test_done
+else
+	say "Define NO_GIT_TEST_HTTPD to disable http testing"
 fi
 
 HTTPD_PARA=""
-- 
1.6.5.52.g35487

Re: [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location

From: Jay Soffian <hidden>
Date: 2016-06-15 22:47:44

On Thu, Nov 19, 2009 at 8:22 PM, Tarmigan Casebolt
[off-list ref] wrote:
uname might not be the best way to determine the default location for
httpd since different Linux distributions apparently put httpd in
different places, so we test a couple different locations for httpd,
and use the first one that we come across.  We do the same for the
modules directory.
Perhaps testing the distribution and looking in the known location for
that distribution then? That said, going through a list of well known
locations should work too.
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+do
+       test -x "$DEFAULT_HTTPD_PATH" && break
+done
Unfortunately this leaves DEFAULT_HTTPD_PATH as the last item in the
list even if the test does not pass. You can add an empty item to the
end of the list if you want to do this way.
+for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
+                                 '/usr/lib/apache2/modules' \
+                                 '/usr/lib64/httpd/modules' \
+                                 '/usr/lib/httpd/modules'
+do
+       test -d "$DEFAULT_HTTPD_MODULE_PATH" && break
+done
Ditto.

j.

Re: [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location

From: Tarmigan <hidden>
Date: 2016-06-15 22:47:44

On Thu, Nov 19, 2009 at 7:14 PM, Jay Soffian [off-list ref] wrote:
On Thu, Nov 19, 2009 at 8:22 PM, Tarmigan Casebolt
[off-list ref] wrote:
quoted
uname might not be the best way to determine the default location for
httpd since different Linux distributions apparently put httpd in
different places, so we test a couple different locations for httpd,
and use the first one that we come across.  We do the same for the
modules directory.
Perhaps testing the distribution and looking in the known location for
that distribution then? That said, going through a list of well known
locations should work too.
Is there a nice way to test the distribution?  Seems to me like doing
that might be more complicated and also more fragile.
quoted
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+do
+       test -x "$DEFAULT_HTTPD_PATH" && break
+done
Unfortunately this leaves DEFAULT_HTTPD_PATH as the last item in the
list even if the test does not pass. You can add an empty item to the
end of the list if you want to do this way.
Yes.  I think this is how it was before though too, and it is caught
later in the script with the LIB_HTTPD_PATH setting and testing.
quoted
+for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
+                                 '/usr/lib/apache2/modules' \
+                                 '/usr/lib64/httpd/modules' \
+                                 '/usr/lib/httpd/modules'
+do
+       test -d "$DEFAULT_HTTPD_MODULE_PATH" && break
+done
Ditto.
Yes.  Again, this is still more thorough than before, but in this case
the script does not check later.  Perhaps the script should test this
value and test_done if it's not a directory?

Thanks,
Tarmigan

[PATCH v2] t/lib-http.sh: Restructure finding of default httpd location

From: Tarmigan Casebolt <hidden>
Date: 2016-06-15 22:47:57

On CentOS 5, httpd is located at /usr/sbin/httpd, and the modules are
located at /usr/lib64/httpd/modules.  To enable easy testing of httpd,
we would like those locations to be detected automatically.

uname might not be the best way to determine the default location for
httpd since different Linux distributions apparently put httpd in
different places, so we test a couple different locations for httpd,
and use the first one that we come across.  We do the same for the
modules directory.

cc: Jay Soffian <redacted>
Signed-off-by: Tarmigan Casebolt <redacted>
---
Jay was concerned about the final fallthrough cases for testing these
lists.  I have added a test for the modules directory and the existing
tests later in the script already test that the apache executable
exists.  If either cannot be found, we do test_done.

Would any machines have httpd or the modules/ directory in several of
these locations?
---
 t/lib-httpd.sh |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 6765b08..27b466b 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -12,16 +12,29 @@ fi
 
 HTTPD_PARA=""
 
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+do
+	if test -x "$DEFAULT_HTTPD_PATH"
+	then
+	        break
+	fi
+done
+
+for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
+                                 '/usr/lib/apache2/modules' \
+                                 '/usr/lib64/httpd/modules' \
+                                 '/usr/lib/httpd/modules'
+do
+        if test -d "$DEFAULT_HTTPD_MODULE_PATH"
+	then
+	        break
+	fi
+done
+
 case $(uname) in
 	Darwin)
-		DEFAULT_HTTPD_PATH='/usr/sbin/httpd'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/libexec/apache2'
 		HTTPD_PARA="$HTTPD_PARA -DDarwin"
 	;;
-	*)
-		DEFAULT_HTTPD_PATH='/usr/sbin/apache2'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
-	;;
 esac
 
 LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"}
@@ -49,6 +62,11 @@ then
 			say "skipping test, at least Apache version 2 is required"
 			test_done
 		fi
+		if ! test -d "$DEFAULT_HTTPD_MODULE_PATH"
+		then
+			say "Apache module directory not found.  Skipping tests."
+			test_done
+		fi
 
 		LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH"
 	fi
-- 
1.6.6.236.gc56f3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help