mirror of
https://github.com/curl/curl.git
synced 2025-09-16 00:52:42 +03:00
tests/http: improved httpd detection
- better error messages when not found/complete - handling of `--without-test-httpd` Reported-by: kwind on github Fixes #10879 Closes #10883
This commit is contained in:
parent
164dab7864
commit
e0c3424fb1
26
configure.ac
26
configure.ac
|
@ -323,10 +323,11 @@ AC_SUBST(CADDY)
|
||||||
|
|
||||||
dnl we'd like a httpd+apachectl as test server
|
dnl we'd like a httpd+apachectl as test server
|
||||||
dnl
|
dnl
|
||||||
|
HTTPD_ENABLED="maybe"
|
||||||
AC_ARG_WITH(test-httpd, [AS_HELP_STRING([--with-test-httpd=PATH],
|
AC_ARG_WITH(test-httpd, [AS_HELP_STRING([--with-test-httpd=PATH],
|
||||||
[where to find httpd/apache2 for testing])],
|
[where to find httpd/apache2 for testing])],
|
||||||
[request_httpd=$withval], [request_httpd=check])
|
[request_httpd=$withval], [request_httpd=check])
|
||||||
if test x"$request_httpd" = "xcheck"; then
|
if test x"$request_httpd" = "xcheck" -o x"$request_httpd" = "xyes"; then
|
||||||
if test -x "/usr/sbin/apache2" -a -x "/usr/sbin/apache2ctl"; then
|
if test -x "/usr/sbin/apache2" -a -x "/usr/sbin/apache2ctl"; then
|
||||||
# common location on distros (debian/ubuntu)
|
# common location on distros (debian/ubuntu)
|
||||||
HTTPD="/usr/sbin/apache2"
|
HTTPD="/usr/sbin/apache2"
|
||||||
|
@ -334,6 +335,7 @@ if test x"$request_httpd" = "xcheck"; then
|
||||||
AC_PATH_PROG([APXS], [apxs])
|
AC_PATH_PROG([APXS], [apxs])
|
||||||
if test "x$APXS" != "x"; then
|
if test "x$APXS" != "x"; then
|
||||||
AC_MSG_NOTICE([apache2-dev not installed, httpd tests disabled])
|
AC_MSG_NOTICE([apache2-dev not installed, httpd tests disabled])
|
||||||
|
HTTPD_ENABLED="no"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
AC_PATH_PROG([HTTPD], [httpd])
|
AC_PATH_PROG([HTTPD], [httpd])
|
||||||
|
@ -343,26 +345,36 @@ if test x"$request_httpd" = "xcheck"; then
|
||||||
AC_PATH_PROG([APACHECTL], [apachectl])
|
AC_PATH_PROG([APACHECTL], [apachectl])
|
||||||
AC_PATH_PROG([APXS], [apxs])
|
AC_PATH_PROG([APXS], [apxs])
|
||||||
if test "x$HTTPD" = "x" -o "x$APACHECTL" = "x"; then
|
if test "x$HTTPD" = "x" -o "x$APACHECTL" = "x"; then
|
||||||
AC_MSG_NOTICE([httpd/apache2 not in PATH, httpd tests disabled])
|
AC_MSG_NOTICE([httpd/apache2 not in PATH, http tests disabled])
|
||||||
|
HTTPD_ENABLED="no"
|
||||||
fi
|
fi
|
||||||
if test "x$APXS" = "x"; then
|
if test "x$APXS" = "x"; then
|
||||||
AC_MSG_NOTICE([apxs not in PATH, httpd tests disabled])
|
AC_MSG_NOTICE([apxs not in PATH, http tests disabled])
|
||||||
|
HTTPD_ENABLED="no"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
elif test x"$request_httpd" != "xno"; then
|
||||||
HTTPD="${request_httpd}/bin/httpd"
|
HTTPD="${request_httpd}/bin/httpd"
|
||||||
APACHECTL="${request_httpd}/bin/apachectl"
|
APACHECTL="${request_httpd}/bin/apachectl"
|
||||||
APXS="${request_httpd}/bin/apxs"
|
APXS="${request_httpd}/bin/apxs"
|
||||||
if test ! -x "${HTTPD}"; then
|
if test ! -x "${HTTPD}"; then
|
||||||
AC_MSG_NOTICE([httpd not found as ${HTTPD}, httpd tests disabled])
|
AC_MSG_NOTICE([httpd not found as ${HTTPD}, http tests disabled])
|
||||||
|
HTTPD_ENABLED="no"
|
||||||
elif test ! -x "${APACHECTL}"; then
|
elif test ! -x "${APACHECTL}"; then
|
||||||
AC_MSG_NOTICE([apachectl not found as ${APACHECTL}, httpd tests disabled])
|
AC_MSG_NOTICE([apachectl not found as ${APACHECTL}, http tests disabled])
|
||||||
|
HTTPD_ENABLED="no"
|
||||||
elif test ! -x "${APXS}"; then
|
elif test ! -x "${APXS}"; then
|
||||||
AC_MSG_NOTICE([apxs not found as ${APXS}, httpd tests disabled])
|
AC_MSG_NOTICE([apxs not found as ${APXS}, http tests disabled])
|
||||||
|
HTTPD_ENABLED="no"
|
||||||
else
|
else
|
||||||
AC_MSG_NOTICE([using HTTPD=$HTTPD for tests])
|
AC_MSG_NOTICE([using HTTPD=$HTTPD for tests])
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if test x"$HTTPD_ENABLED" = "xno"; then
|
||||||
|
HTTPD=""
|
||||||
|
APACHECTL=""
|
||||||
|
APXS=""
|
||||||
|
fi
|
||||||
AC_SUBST(HTTPD)
|
AC_SUBST(HTTPD)
|
||||||
AC_SUBST(APACHECTL)
|
AC_SUBST(APACHECTL)
|
||||||
AC_SUBST(APXS)
|
AC_SUBST(APXS)
|
||||||
|
|
|
@ -57,9 +57,11 @@ def log_global_env_facts(record_testsuite_property, env):
|
||||||
@pytest.fixture(scope='package')
|
@pytest.fixture(scope='package')
|
||||||
def httpd(env) -> Httpd:
|
def httpd(env) -> Httpd:
|
||||||
httpd = Httpd(env=env)
|
httpd = Httpd(env=env)
|
||||||
assert httpd.exists(), f'httpd not found: {env.httpd}'
|
if not httpd.exists():
|
||||||
|
pytest.skip(f'httpd not found: {env.httpd}')
|
||||||
httpd.clear_logs()
|
httpd.clear_logs()
|
||||||
assert httpd.start()
|
if not httpd.start():
|
||||||
|
pytest.fail(f'failed to start httpd: {env.httpd}')
|
||||||
yield httpd
|
yield httpd
|
||||||
httpd.stop()
|
httpd.stop()
|
||||||
|
|
||||||
|
|
|
@ -166,11 +166,15 @@ class EnvConfig:
|
||||||
@property
|
@property
|
||||||
def httpd_version(self):
|
def httpd_version(self):
|
||||||
if self._httpd_version is None and self.apxs is not None:
|
if self._httpd_version is None and self.apxs is not None:
|
||||||
p = subprocess.run(args=[self.apxs, '-q', 'HTTPD_VERSION'],
|
try:
|
||||||
capture_output=True, text=True)
|
p = subprocess.run(args=[self.apxs, '-q', 'HTTPD_VERSION'],
|
||||||
if p.returncode != 0:
|
capture_output=True, text=True)
|
||||||
raise Exception(f'{self.apxs} failed to query HTTPD_VERSION: {p}')
|
if p.returncode != 0:
|
||||||
self._httpd_version = p.stdout.strip()
|
log.error(f'{self.apxs} failed to query HTTPD_VERSION: {p}')
|
||||||
|
else:
|
||||||
|
self._httpd_version = p.stdout.strip()
|
||||||
|
except Exception as e:
|
||||||
|
log.error(f'{self.apxs} failed to run: {e}')
|
||||||
return self._httpd_version
|
return self._httpd_version
|
||||||
|
|
||||||
def _versiontuple(self, v):
|
def _versiontuple(self, v):
|
||||||
|
@ -178,6 +182,8 @@ class EnvConfig:
|
||||||
return tuple(map(int, v.split('.')))
|
return tuple(map(int, v.split('.')))
|
||||||
|
|
||||||
def httpd_is_at_least(self, minv):
|
def httpd_is_at_least(self, minv):
|
||||||
|
if self.httpd_version is None:
|
||||||
|
return False
|
||||||
hv = self._versiontuple(self.httpd_version)
|
hv = self._versiontuple(self.httpd_version)
|
||||||
return hv >= self._versiontuple(minv)
|
return hv >= self._versiontuple(minv)
|
||||||
|
|
||||||
|
@ -188,12 +194,14 @@ class EnvConfig:
|
||||||
os.path.isfile(self.apxs)
|
os.path.isfile(self.apxs)
|
||||||
|
|
||||||
def get_incomplete_reason(self) -> Optional[str]:
|
def get_incomplete_reason(self) -> Optional[str]:
|
||||||
|
if self.httpd is None or len(self.httpd.strip()) == 0:
|
||||||
|
return f'httpd not configured, see `--with-test-httpd=<path>`'
|
||||||
if not os.path.isfile(self.httpd):
|
if not os.path.isfile(self.httpd):
|
||||||
return f'httpd ({self.httpd}) not found'
|
return f'httpd ({self.httpd}) not found'
|
||||||
if not os.path.isfile(self.apachectl):
|
if not os.path.isfile(self.apachectl):
|
||||||
return f'apachectl ({self.apachectl}) not found'
|
return f'apachectl ({self.apachectl}) not found'
|
||||||
if self.apxs is None:
|
if self.apxs is None:
|
||||||
return f"apxs (provided by apache2-dev) not found"
|
return f"command apxs not found (commonly provided in apache2-dev)"
|
||||||
if not os.path.isfile(self.apxs):
|
if not os.path.isfile(self.apxs):
|
||||||
return f"apxs ({self.apxs}) not found"
|
return f"apxs ({self.apxs}) not found"
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user