Mixed testing issues.

This commit is contained in:
Mats Erik Andersson
2012-11-14 13:24:12 +01:00
parent cd22e53cf7
commit 3299ba83d9
13 changed files with 158 additions and 33 deletions

View File

@@ -1,3 +1,36 @@
2012-11-14 Mats Erik Andersson <gnu@gisladisker.se>
* libinetutils/daemon.c (waitdaemon) [_SC_OPEN_MAX]:
Remove HAVE_SYSCONF from preprocessor conditional.
* src/syslogd.c (main): Install `die' for SIGINT, SIGQUIT,
and SIGUSR1 based on NoDetach. Initially set `dpg_output = 1'
only in debug mode. Print a notice also in non-detached mode.
(cfline): Move assignment to `f->f_file' outside of
if-statement.
(dbg_printf): Test `!(NoDetach && dbg_output)' for output.
* tests/waitdaemon.c: New source file.
* tests/Makefile.am (check_PROGRAMS): Add waitdaemon.
(TESTS): Likewise.
* tests/.gitignore: Likewise.
* tests/syslogd.sh: Add a sleep period after `kill -HUP'.
(OBSCURE): New environment variable. Conduct configuration
test for non-existent log host only if OBSCURE is set.
* tests/utmp.sh: Use who(1), if possible, to improve
reliability of test, checking known users only.
* configure.ac <*-freebsd9* || *-freebsd10*>:
Do not disable syslogd and talkd, as the updated test script
`utmp.sh' will catch the failure as long as it remains.
* src/Makefile.am (AM_CPPFLAGS): Add $(PATHDEF_TTY_PFX).
* talkd/Makefile.am (AM_CPPFLAGS): Likewise.
* telnetd/Makefile.am (AM_CPPFLAGS): Likewise.
* whois/Makefile.am: Set `LANG=C' when invoking perl.
2012-11-10 Mats Erik Andersson <gnu@gisladisker.se>
Consistent use of device prefix.

View File

@@ -966,8 +966,6 @@ case "$host" in
# readutmp module from GNUlib.
enable_ftpd=no ftpd_BUILD=''
enable_rlogind=no rlogind_BUILD=''
enable_syslogd=no syslogd_BUILD=''
enable_talkd=no talkd_BUILD=''
enable_telnetd=no telnetd_BUILD=''
enable_uucpd=no uucpd_BUILD=''
;;

View File

@@ -174,7 +174,7 @@ waitdaemon (int nochdir, int noclose, int maxwait)
int i;
long fdlimit = -1;
#if defined HAVE_SYSCONF && defined _SC_OPEN_MAX
#if defined _SC_OPEN_MAX
fdlimit = sysconf (_SC_OPEN_MAX);
#elif defined (HAVE_GETDTABLESIZE)
fdlimit = getdtablesize ();

View File

@@ -102,7 +102,7 @@ EXTRA_PROGRAMS += uucpd
INCLUDES = $(iu_INCLUDES) $(INCAUTH) -I$(top_srcdir)/libicmp $(INCIDN)
AM_CPPFLAGS = $(PATHDEF_BSHELL) $(PATHDEF_CONSOLE) $(PATHDEF_CP) $(PATHDEF_DEFPATH) $(PATHDEF_DEV) $(PATHDEF_INETDCONF) $(PATHDEF_INETDDIR) $(PATHDEF_INETDPID) $(PATHDEF_KLOG) $(PATHDEF_LOG) $(PATHDEF_LOGCONF) $(PATHDEF_LOGIN) $(PATHDEF_LOGPID) $(PATHDEF_NOLOGIN) $(PATHDEF_RLOGIN) $(PATHDEF_RSH) $(PATHDEF_TTY) $(PATHDEF_UTMP) $(PATHDEF_UTMPX) $(PATHDEF_UUCICO)
AM_CPPFLAGS = $(PATHDEF_BSHELL) $(PATHDEF_CONSOLE) $(PATHDEF_CP) $(PATHDEF_DEFPATH) $(PATHDEF_DEV) $(PATHDEF_INETDCONF) $(PATHDEF_INETDDIR) $(PATHDEF_INETDPID) $(PATHDEF_KLOG) $(PATHDEF_LOG) $(PATHDEF_LOGCONF) $(PATHDEF_LOGIN) $(PATHDEF_LOGPID) $(PATHDEF_NOLOGIN) $(PATHDEF_RLOGIN) $(PATHDEF_RSH) $(PATHDEF_TTY) $(PATHDEF_TTY_PFX) $(PATHDEF_UTMP) $(PATHDEF_UTMPX) $(PATHDEF_UUCICO)
SUIDMODE = -o root -m 4775

View File

@@ -506,7 +506,8 @@ main (int argc, char *argv[])
}
else
{
dbg_output = 1;
if (Debug)
dbg_output = 1;
setvbuf (stdout, 0, _IOLBF, 0);
}
@@ -554,10 +555,10 @@ main (int argc, char *argv[])
consfile.f_un.f_fname = strdup (ctty);
signal (SIGTERM, die);
signal (SIGINT, Debug ? die : SIG_IGN);
signal (SIGQUIT, Debug ? die : SIG_IGN);
signal (SIGINT, NoDetach ? die : SIG_IGN);
signal (SIGQUIT, NoDetach ? die : SIG_IGN);
signal (SIGALRM, domark);
signal (SIGUSR1, Debug ? dbg_toggle : SIG_IGN);
signal (SIGUSR1, NoDetach ? dbg_toggle : SIG_IGN);
alarm (TIMERINTVL);
/* We add 3 = 1(klog) + 2(inet,inet6), even if they may stay unused. */
@@ -640,8 +641,9 @@ main (int argc, char *argv[])
signal (SIGHUP, trigger_restart);
if (Debug)
if (NoDetach)
{
dbg_output = 1;
dbg_printf ("Debugging disabled, send SIGUSR1 to turn on debugging.\n");
dbg_output = 0;
}
@@ -2134,7 +2136,8 @@ cfline (const char *line, struct filed *f)
case '|':
f->f_un.f_fname = strdup (p);
if ((f->f_file = open (++p, O_RDWR | O_NONBLOCK)) < 0)
f->f_file = open (++p, O_RDWR | O_NONBLOCK);
if (f->f_file < 0)
{
f->f_type = F_UNUSED;
logerror (p);
@@ -2152,7 +2155,8 @@ cfline (const char *line, struct filed *f)
case '/':
f->f_un.f_fname = strdup (p);
if ((f->f_file = open (p, O_WRONLY | O_APPEND | O_CREAT, 0644)) < 0)
f->f_file = open (p, O_WRONLY | O_APPEND | O_CREAT, 0644);
if (f->f_file < 0)
{
f->f_type = F_UNUSED;
logerror (p);
@@ -2231,7 +2235,7 @@ dbg_printf (const char *fmt, ...)
{
va_list ap;
if (!(Debug && dbg_output))
if (!(NoDetach && dbg_output))
return;
va_start (ap, fmt);

View File

@@ -35,6 +35,6 @@ talkd_SOURCES = \
@PATHDEFS_MAKE@
AM_CPPFLAGS = $(PATHDEF_DEV) $(PATHDEF_UTMP) $(PATHDEF_UTMPX)
AM_CPPFLAGS = $(PATHDEF_DEV) $(PATHDEF_TTY_PFX) $(PATHDEF_UTMP) $(PATHDEF_UTMPX)
INCLUDES = $(iu_INCLUDES)
LDADD = $(iu_LIBRARIES)

View File

@@ -29,7 +29,7 @@ noinst_HEADERS = telnetd.h
@PATHDEFS_MAKE@
AM_CPPFLAGS = $(PATHDEF_DEV) $(PATHDEF_TTY) $(PATHDEF_LOGIN)
AM_CPPFLAGS = $(PATHDEF_DEV) $(PATHDEF_TTY) $(PATHDEF_TTY_PFX) $(PATHDEF_LOGIN)
INCLUDES = $(iu_INCLUDES) -I$(top_srcdir) $(INCAUTH) $(NCURSES_INCLUDE)
LDADD = $(iu_LIBRARIES) $(top_builddir)/libtelnet/libtelnet.a $(LIBTERMCAP) $(LIBUTIL) $(LIBCRYPT) $(LIBAUTH)

3
tests/.gitignore vendored
View File

@@ -1,4 +1,5 @@
addrpeek
localhost
readutmp
addrpeek
tools.sh
waitdaemon

View File

@@ -21,7 +21,7 @@ AM_CPPFLAGS = $(iu_INCLUDES)
LDADD = $(iu_LIBRARIES)
check_PROGRAMS = localhost readutmp
check_PROGRAMS = localhost readutmp waitdaemon
if ENABLE_inetd
check_PROGRAMS += addrpeek
endif
@@ -68,7 +68,7 @@ if ENABLE_dnsdomainname
dist_check_SCRIPTS += dnsdomainname.sh
endif
TESTS = localhost $(dist_check_SCRIPTS)
TESTS = localhost waitdaemon $(dist_check_SCRIPTS)
TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT)

View File

@@ -43,6 +43,9 @@ IU_TESTDIR If set, use this as testing dir. Unless
NOCLEAN is also set, any created \$IU_TESTDIR
will be erased after the test. A non-existing
directory must be named as a template for mktemp(1).
OBSCURE If set, make additional tests that are prone to
false negatives in some setups lacking full
connectivity.
REMOTE_LOGHOST Add this host as a receiving loghost.
TARGET Receiving IPv4 address.
TARGET6 Receiving IPv6 address.
@@ -307,8 +310,6 @@ fi
#
cat > "$CONF" <<-EOT
*.* $OUT
# Test incorrect forwarding.
*.* @not.in.existence
# Recover from missing action field and short selector.
12345
*.*
@@ -318,6 +319,18 @@ EOT
# Add a user recipient in verbose mode.
$silence false || echo "*.* $USER" >> "$CONF"
# Testing a remote log host known not to exist,
# will introduce sizable timeout. We avoid it
# unless told to include this test, based on
# OBSCURE in our environment.
if [ -n "$OBSCURE" ]; then
# Append an invalid recipient.
cat >> "$CONF" <<-EOT
# Test incorrect forwarding.
*.* @not.in.existence
EOT
fi
# Set REMOTE_LOGHOST to activate forwarding
#
if [ -n "$REMOTE_LOGHOST" ]; then
@@ -435,6 +448,7 @@ TAG2="syslogd-reload-test"
# Load the new configuration
kill -HUP `cat "$PID"`
sleep 1
if $do_unix_socket; then
# Two messages, but absence is also awarded credit.

View File

@@ -34,25 +34,35 @@ if test -n "$VERBOSE"; then
set -x
fi
# Execute READUTMP once without argument, and once with
# ourself as argument. Both should succeed, but if either
# fails report only a skipped test, giving some complimentary
# explanations.
errno=0
$READUTMP || errno=77
if who >/dev/null 2>&1; then
# Check that readutmp agrees with who(1),
# limiting ourselves to at most three users.
for nn in `who | sed 's/ .*//; 3q;'`; do
$READUTMP $nn || errno=1
done
else
# Execute READUTMP once without argument, and once with
# ourself as argument. Both should succeed, but are reported
# as skipped test in case of failure. They are known to be
# produce false positives in some circumstances.
$READUTMP || errno=77
$READUTMP `func_id_user` || errno=77
fi
$READUTMP `func_id_user` || errno=77
if test $errno -ne 0; then
if test $errno -eq 77; then
cat >&2 <<-EOT
NOTICE: read_utmp() from Gnulib just failed. This can be
due to running this test in sudo mode, or using a role.
Should this script fail while running it as a logged in
user, then read_utmp() is indeed broken on this system.
Then the present syslog and talkd are not fully functional.
You are then welcome to report this failure.
Then the present executables syslogd and talkd are not
fully functional.
EOT
elif test $errno -eq 1; then
cat >&2 <<-EOT
User messaging is broken in syslogd and talkd.
EOT
fi

65
tests/waitdaemon.c Normal file
View File

@@ -0,0 +1,65 @@
/* waitdaemon -- Verify that waitdaemon() is functional.
Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
This file is part of GNU Inetutils.
GNU Inetutils is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
GNU Inetutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see `http://www.gnu.org/licenses/'. */
/* Verify that waitdaemon() in libinetutils.a is functional.
This is needed by syslogd.
*/
#include <config.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include <signal.h>
#include <errno.h>
#include <error.h>
#include <progname.h>
#include <libinetutils.h>
#include <unused-parameter.h>
extern int waitdaemon (int nochdir, int noclose, int maxwait);
void
doexit (int signo _GL_UNUSED_PARAMETER)
{
_exit (EXIT_SUCCESS);
}
int
main (int argc _GL_UNUSED_PARAMETER, char *argv[])
{
pid_t ppid;
set_program_name (argv[0]);
signal (SIGTERM, doexit); /* Parent exits nicely at SIGTERM. */
ppid = waitdaemon (0, 0, 5); /* Five seconds of delay. */
/* Child should return here before parent. */
if (ppid > 0)
kill (ppid, SIGTERM); /* Bless the parent process. */
/* Only grand child reaches this statement. */
return EXIT_FAILURE;
}

View File

@@ -34,10 +34,10 @@ INCLUDES = $(iu_INCLUDES)
LDADD = $(iu_LIBRARIES)
as_del.h: $(srcdir)/as_del_list $(srcdir)/make_as_del.pl
perl $(srcdir)/make_as_del.pl < $(srcdir)/as_del_list > as_del.h
LANG=C perl $(srcdir)/make_as_del.pl < $(srcdir)/as_del_list > as_del.h
ip_del.h: $(srcdir)/ip_del_list $(srcdir)/make_ip_del.pl
perl $(srcdir)/make_ip_del.pl < $(srcdir)/ip_del_list > ip_del.h
LANG=C perl $(srcdir)/make_ip_del.pl < $(srcdir)/ip_del_list > ip_del.h
tld_serv.h: $(srcdir)/tld_serv_list $(srcdir)/make_tld_serv.pl
perl $(srcdir)/make_tld_serv.pl < $(srcdir)/tld_serv_list > tld_serv.h
LANG=C perl $(srcdir)/make_tld_serv.pl < $(srcdir)/tld_serv_list > tld_serv.h