r21134 - in /branches/upstream/libsys-syslog-perl/current: Changes MANIFEST META.yml Makefile.PL README Syslog.pm Syslog.xs t/00-load.t t/data-validation.t t/distchk.t t/pod.t t/podcover.t t/podspell.t t/portfs.t t/syslog.t

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sat Jun 14 21:45:43 UTC 2008


Author: gregoa
Date: Sat Jun 14 21:45:43 2008
New Revision: 21134

URL: http://svn.debian.org/wsvn/?sc=1&rev=21134
Log:
[svn-upgrade] Integrating new upstream version, libsys-syslog-perl (0.25)

Added:
    branches/upstream/libsys-syslog-perl/current/t/data-validation.t
Modified:
    branches/upstream/libsys-syslog-perl/current/Changes
    branches/upstream/libsys-syslog-perl/current/MANIFEST
    branches/upstream/libsys-syslog-perl/current/META.yml
    branches/upstream/libsys-syslog-perl/current/Makefile.PL
    branches/upstream/libsys-syslog-perl/current/README
    branches/upstream/libsys-syslog-perl/current/Syslog.pm
    branches/upstream/libsys-syslog-perl/current/Syslog.xs
    branches/upstream/libsys-syslog-perl/current/t/00-load.t
    branches/upstream/libsys-syslog-perl/current/t/distchk.t
    branches/upstream/libsys-syslog-perl/current/t/pod.t
    branches/upstream/libsys-syslog-perl/current/t/podcover.t
    branches/upstream/libsys-syslog-perl/current/t/podspell.t
    branches/upstream/libsys-syslog-perl/current/t/portfs.t
    branches/upstream/libsys-syslog-perl/current/t/syslog.t

Modified: branches/upstream/libsys-syslog-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/Changes?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/Changes (original)
+++ branches/upstream/libsys-syslog-perl/current/Changes Sat Jun 14 21:45:43 2008
@@ -1,4 +1,18 @@
 Revision history for Sys-Syslog
+
+0.25 -- 2008.05.17 -- Sebastien Aperghis-Tramoni (SAPER)
+        [BUGFIX] CPAN-RT#34691: Fixed an incorrect call to sysopen() which
+        prevented Sys::Syslog from working on some Solaris systems. 
+        Thanks to Paul Townsend. 
+        [BUGFIX] CPAN-RT#34753: Fixed a slowness introduced in v0.19 (which 
+        was to work around OSX syslog own slowness). Thanks to Alex Efros.
+        [BUGFIX] CPAN-RT#35952: Fixed a bug with the "nofatal" option.
+        [BUGFIX] Fixed build on Win32, thanks to Adam Kennedy.
+        [FEATURE] setlogsock() now interprets the second argument as the 
+        hostname for network mechanisms.
+        [DIST] Add AUTHOR to WriteMakefile() in order to fix the META.yml
+        generated by ExtUtils::MakeMaker.
+        [TESTS] Improved t/pod.t with Pod::Checker.
 
 0.24 -- 2007.12.31 -- Sebastien Aperghis-Tramoni (SAPER)
         [BUGFIX] CPANT-RT#32001: Skip the setlogsock('stream') tests when 
@@ -44,6 +58,8 @@
         via syslog().
         [BUGFIX] Rewrote the constants generation code in order to provide 
         fallback value for non-standard macros.
+        [BUGFIX] Mark Blackman and Edmund von der Burg identified and fixed the
+        random failures appearing on OSX, caused by a UDP timeout.
         [FEATURE] Added Win32 event log support thanks to Yves Orton.
         [FEATURE] Added new macros from modern BSD and IRIX.
         [FEATURE] Each non-standard macro now fall backs to a standard macro.

Modified: branches/upstream/libsys-syslog-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/MANIFEST?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/MANIFEST (original)
+++ branches/upstream/libsys-syslog-perl/current/MANIFEST Sat Jun 14 21:45:43 2008
@@ -13,6 +13,7 @@
 eg/syslog.pl
 t/00-load.t
 t/constants.t
+t/data-validation.t
 t/distchk.t
 t/syslog.t
 t/pod.t

Modified: branches/upstream/libsys-syslog-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/META.yml?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/META.yml (original)
+++ branches/upstream/libsys-syslog-perl/current/META.yml Sat Jun 14 21:45:43 2008
@@ -1,14 +1,28 @@
---- #YAML:1.0
-name:                Sys-Syslog
-version:             0.24
-abstract:            Perl interface to the UNIX syslog(3) calls
-license:             perl
-author:              ~
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    Test::More:                    0
-    XSLoader:                      0
+---
+name: Sys-Syslog
+version: 0.25
+author:
+  - 'Sebastien Aperghis-Tramoni <sebastien at aperghis.net>'
+abstract: Perl interface to the UNIX syslog(3) calls
+license: perl
+resources:
+  license: http://dev.perl.org/licenses/
+requires:
+  Carp: 0
+  Fcntl: 0
+  File::Basename: 0
+  File::Spec: 0
+  POSIX: 0
+  Socket: 0
+  XSLoader: 0
+  perl: 5.005
+build_requires:
+  Test::More: 0
+provides:
+  Sys::Syslog:
+    file: Syslog.pm
+    version: 0.25
+generated_by: Module::Build version 0.2808
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+  url: http://module-build.sourceforge.net/META-spec-v1.2.html
+  version: 1.2

Modified: branches/upstream/libsys-syslog-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/Makefile.PL?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/Makefile.PL (original)
+++ branches/upstream/libsys-syslog-perl/current/Makefile.PL Sat Jun 14 21:45:43 2008
@@ -29,10 +29,13 @@
     print " * Win32::EventLog detected.\n";
     my $name = "PerlLog";
 
-    push @extra_prereqs, "Win32::TieRegistry" => 0, "Win32::EventLog" => 0;
+    push @extra_prereqs, 
+        Win32 => 0,  "Win32::TieRegistry" => 0,  "Win32::EventLog" => 0;
 
     $virtual_path{'win32/Win32.pm'   } = '$(INST_LIBDIR)/Syslog/Win32.pm';
     $virtual_path{'win32/PerlLog.dll'} = '$(INST_ARCHAUTODIR)/PerlLog.dll';
+
+    push @extra_params, CCFLAGS => "-Ifallback";
 
     # recreate the DLL from its uuencoded form if it's not here
     if (! -f File::Spec->catfile("win32", "$name.dll")) {
@@ -76,19 +79,31 @@
 WriteMakefile(
     NAME            => 'Sys::Syslog',
     LICENSE         => 'perl',
+    AUTHOR          => 'Sebastien Aperghis-Tramoni <sebastien at aperghis.net>',
     VERSION_FROM    => 'Syslog.pm', 
     ABSTRACT_FROM   => 'Syslog.pm', 
     INSTALLDIRS     => 'perl',
     XSPROTOARG      => '-noprototypes',
     PM              => \%virtual_path, 
     PREREQ_PM       => {
-        'Test::More' => 0,
-        'XSLoader'   => 0,
+        # run prereqs
+        'Carp'              => 0,
+        'Fcntl'             => 0,
+        'File::Basename'    => 0,
+        'File::Spec'        => 0,
+        'POSIX'             => 0,
+        'Socket'            => 0,
+        'XSLoader'          => 0,
         @extra_prereqs,
+
+        # build/test prereqs
+        'Test::More'        => 0,
     },
     dist            => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
     clean           => { FILES => 'Sys-Syslog-*' }, 
-    realclean       => { FILES => 'lib const-c.inc const-xs.inc macros.all PerlLog.h *.bak *.bin *.rc' },
+    realclean       => { FILES => 'lib const-c.inc const-xs.inc macros.all '
+        .'PerlLog.h typemap *.bak *.bin *.rc win32/PerlLog_dll' },
+    NO_META         => 1,
     @extra_params
 );
 

Modified: branches/upstream/libsys-syslog-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/README?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/README (original)
+++ branches/upstream/libsys-syslog-perl/current/README Sat Jun 14 21:45:43 2008
@@ -63,5 +63,7 @@
 
 COPYRIGHT AND LICENCE
 
+    Copyright (C) 1990-2008 by Larry Wall and others.
+
     This program is free software; you can redistribute it and/or modify it
     under the same terms as Perl itself.

Modified: branches/upstream/libsys-syslog-perl/current/Syslog.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/Syslog.pm?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/Syslog.pm (original)
+++ branches/upstream/libsys-syslog-perl/current/Syslog.pm Sat Jun 14 21:45:43 2008
@@ -1,16 +1,17 @@
 package Sys::Syslog;
 use strict;
+use warnings;
 use warnings::register;
 use Carp;
+use Exporter ();
 use Fcntl qw(O_WRONLY);
 use File::Basename;
 use POSIX qw(strftime setlocale LC_TIME);
 use Socket ':all';
 require 5.005;
-require Exporter;
 
 {   no strict 'vars';
-    $VERSION = '0.24';
+    $VERSION = '0.25';
     @ISA = qw(Exporter);
 
     %EXPORT_TAGS = (
@@ -76,6 +77,11 @@
 # 
 use vars qw($host);             # host to send syslog messages to (see notes at end)
 
+#
+# Prototypes
+#
+sub silent_eval (&);
+
 # 
 # Global variables
 # 
@@ -85,6 +91,7 @@
 my $syslog_path = undef;        # syslog path for "stream" and "unix" mechanisms
 my $syslog_xobj = undef;        # if defined, holds the external object used to send messages
 my $transmit_ok = 0;            # flag to indicate if the last message was transmited
+my $sock_timeout  = 0;          # socket timeout, see below
 my $current_proto = undef;      # current mechanism used to transmit messages
 my $ident = '';                 # identifiant prepended to each message
 $facility = '';                 # current facility
@@ -105,15 +112,12 @@
     @connectMethods = grep { $_ ne 'udp' } @connectMethods;
 }
 
+# And on Win32 systems, we try to use the native mechanism for this 
+# platform, the events logger, available through Win32::EventLog.
 EVENTLOG: {
-    # use EventLog on Win32
     my $is_Win32 = $^O =~ /Win32/i;
 
-    # some applications are trying to be too smart
-    # yes I'm speaking of YOU, SpamAssassin, grr..
-    local($SIG{__DIE__}, $SIG{__WARN__}, $@);
-
-    if (eval "use Sys::Syslog::Win32; 1") {
+    if (can_load("Sys::Syslog::Win32")) {
         unshift @connectMethods, 'eventlog';
     }
     elsif ($is_Win32) {
@@ -123,6 +127,18 @@
 
 my @defaultMethods = @connectMethods;
 my @fallbackMethods = ();
+
+# The timeout in connection_ok() was pushed up to 0.25 sec in 
+# Sys::Syslog v0.19 in order to address a heisenbug on MacOSX:
+# http://london.pm.org/pipermail/london.pm/Week-of-Mon-20061211/005961.html
+# 
+# However, this also had the effect of slowing this test for 
+# all other operating systems, which apparently impacted some 
+# users (cf. CPAN-RT #34753). So, in order to make everybody 
+# happy, the timeout is now zero by default on all systems 
+# except on OSX where it is set to 250 msec, and can be set 
+# with the infamous setlogsock() function.
+$sock_timeout = 0.25 if $^O =~ /darwin/;
 
 # coderef for a nicer handling of errors
 my $err_sub = $options{nofatal} ? \&warnings::warnif : \&croak;
@@ -155,7 +171,7 @@
         $options{$opt} = 1 if exists $options{$opt}
     }
 
-    $err_sub = $options{nofatal} ? \&warnings::warnif : \&croak;
+    $err_sub = delete $options{nofatal} ? \&warnings::warnif : \&croak;
     return 1 unless $options{ndelay};
     connect_log();
 } 
@@ -172,8 +188,11 @@
 }
  
 sub setlogsock {
-    my $setsock = shift;
-    $syslog_path = shift;
+    my ($setsock, $setpath, $settime) = @_;
+
+    $syslog_path  = $setpath if defined $setpath;
+    $sock_timeout = $settime if defined $settime;
+
     disconnect_log() if $connected;
     $transmit_ok = 0;
     @fallbackMethods = ();
@@ -237,7 +256,7 @@
         @connectMethods = qw(native);
 
     } elsif (lc $setsock eq 'eventlog') {
-        if (eval "use Win32::EventLog; 1") {
+        if (can_load("Win32::EventLog")) {
             @connectMethods = qw(eventlog);
         } else {
             warnings::warnif "eventlog passed to setlogsock, but no Win32 API available";
@@ -248,6 +267,7 @@
     } elsif (lc $setsock eq 'tcp') {
 	if (getservbyname('syslog', 'tcp') || getservbyname('syslogng', 'tcp')) {
             @connectMethods = qw(tcp);
+            $host = $syslog_path;
 	} else {
             warnings::warnif "tcp passed to setlogsock, but tcp service unavailable";
 	    return undef;
@@ -256,6 +276,7 @@
     } elsif (lc $setsock eq 'udp') {
 	if (getservbyname('syslog', 'udp')) {
             @connectMethods = qw(udp);
+            $host = $syslog_path;
 	} else {
             warnings::warnif "udp passed to setlogsock, but udp service unavailable";
 	    return undef;
@@ -293,25 +314,29 @@
     croak "syslog: expecting argument \$priority" unless defined $priority;
     croak "syslog: expecting argument \$format"   unless defined $mask;
 
+    croak "syslog: invalid level/facility: $priority" if $priority =~ /^-\d+$/;
     @words = split(/\W+/, $priority, 2);    # Allow "level" or "level|facility".
     undef $numpri;
     undef $numfac;
 
-    foreach (@words) {
-	$num = xlate($_);		    # Translate word to number.
-	if ($num < 0) {
-	    croak "syslog: invalid level/facility: $_"
-	}
-	elsif ($num <= &LOG_PRIMASK) {
-	    croak "syslog: too many levels given: $_" if defined $numpri;
-	    $numpri = $num;
-	    return 0 unless LOG_MASK($numpri) & $maskpri;
-	}
-	else {
-	    croak "syslog: too many facilities given: $_" if defined $numfac;
-	    $facility = $_;
-	    $numfac = $num;
-	}
+    for my $word (@words) {
+        next if length $word == 0;
+
+        $num = xlate($word);        # Translate word to number.
+
+        if ($num < 0) {
+            croak "syslog: invalid level/facility: $word"
+        }
+        elsif ($num <= &LOG_PRIMASK) {
+            croak "syslog: too many levels given: $word" if defined $numpri;
+            $numpri = $num;
+            return 0 unless LOG_MASK($numpri) & $maskpri;
+        }
+        else {
+            croak "syslog: too many facilities given: $word" if defined $numfac;
+            $facility = $word;
+            $numfac = $num;
+        }
     }
 
     croak "syslog: level must be given" unless defined $numpri;
@@ -464,14 +489,14 @@
 # private function to translate names to numeric values
 # 
 sub xlate {
-    my($name) = @_;
+    my ($name) = @_;
+
     return $name+0 if $name =~ /^\s*\d+\s*$/;
     $name = uc $name;
     $name = "LOG_$name" unless $name =~ /^LOG_/;
-    $name = "Sys::Syslog::$name";
-    # Can't have just eval { &$name } || -1 because some LOG_XXX may be zero.
-    my $value = eval { no strict 'refs'; &$name };
-    $@ = "";
+    my $value = constant($name);
+    $value = -1 if $value =~ /not a valid/;
+
     return defined $value ? $value : -1;
 }
 
@@ -546,11 +571,10 @@
     }
 
     setsockopt(SYSLOG, SOL_SOCKET, SO_KEEPALIVE, 1);
-    if (eval { IPPROTO_TCP() }) {
+    if (silent_eval { IPPROTO_TCP() }) {
         # These constants don't exist in 5.005. They were added in 1999
         setsockopt(SYSLOG, IPPROTO_TCP(), TCP_NODELAY(), 1);
     }
-    $@ = "";
     if (!connect(SYSLOG, $addr)) {
 	push @$errs, "tcp connect: $!";
 	return 0;
@@ -619,7 +643,7 @@
 	push @$errs, "stream $syslog_path is not writable";
 	return 0;
     }
-    if (!sysopen(SYSLOG, $syslog_path, 0400, O_WRONLY)) {
+    if (!sysopen(SYSLOG, $syslog_path, O_WRONLY, 0400)) {
 	push @$errs, "stream can't open $syslog_path: $!";
 	return 0;
     }
@@ -697,12 +721,7 @@
         $logopt += xlate($opt) if $options{$opt}
     }
 
-    eval { openlog_xs($ident, $logopt, xlate($facility)) };
-    if ($@) {
-        push @$errs, $@;
-        return 0;
-    }
-
+    openlog_xs($ident, $logopt, xlate($facility));
     $syslog_send = \&_syslog_send_native;
 
     return 1;
@@ -741,7 +760,7 @@
 
     my $rin = '';
     vec($rin, fileno(SYSLOG), 1) = 1;
-    my $ret = select $rin, undef, $rin, 0.25;
+    my $ret = select $rin, undef, $rin, $sock_timeout;
     return ($ret ? 0 : 1);
 }
 
@@ -761,7 +780,26 @@
     return close SYSLOG;
 }
 
-1;
+
+#
+# Wrappers around eval() that makes sure that nobody, and I say NOBODY, 
+# ever knows that I wanted to test if something was here or not. 
+# It is needed because some applications are trying to be too smart,
+# do it wrong, and it ends up in EPIC FAIL. 
+# Yes I'm speaking of YOU, SpamAssassin.
+#
+sub silent_eval (&) {
+    local($SIG{__DIE__}, $SIG{__WARN__}, $@);
+    return eval $_[0]
+}
+
+sub can_load {
+    local($SIG{__DIE__}, $SIG{__WARN__}, $@);
+    return eval "use $_[0]; 1"
+}
+
+
+"Eighth Rule: read the documentation."
 
 __END__
 
@@ -771,7 +809,7 @@
 
 =head1 VERSION
 
-Version 0.24
+Version 0.25
 
 =head1 SYNOPSIS
 
@@ -965,6 +1003,8 @@
 
 =item B<setlogsock($sock_type, $stream_location)> (added in Perl 5.004_02)
 
+=item B<setlogsock($sock_type, $stream_location, $sock_timeout)> (added in 0.25)
+
 Sets the socket type to be used for the next call to
 C<openlog()> or C<syslog()> and returns true on success,
 C<undef> on failure. The available mechanisms are: 
@@ -984,15 +1024,18 @@
 =item *
 
 C<"tcp"> - connect to a TCP socket, on the C<syslog/tcp> or C<syslogng/tcp> 
-service. 
+service. If defined, the second parameter is used as a hostname to connect to.
 
 =item *
 
 C<"udp"> - connect to a UDP socket, on the C<syslog/udp> service.
-
-=item *
-
-C<"inet"> - connect to an INET socket, either TCP or UDP, tried in that order. 
+If defined, the second parameter is used as a hostname to connect to, 
+and the third parameter as the timeout used to check for UDP response. 
+
+=item *
+
+C<"inet"> - connect to an INET socket, either TCP or UDP, tried in that 
+order.  If defined, the second parameter is used as a hostname to connect to.
 
 =item *
 
@@ -1026,7 +1069,8 @@
 When this calling method is used, the array should contain a list of
 mechanisms which are attempted in order.
 
-The default is to try C<native>, C<tcp>, C<udp>, C<unix>, C<stream>, C<console>.
+The default is to try C<native>, C<tcp>, C<udp>, C<unix>, C<pipe>, C<stream>, 
+C<console>.
 Under systems with the Win32 API, C<eventlog> will be added as the first 
 mechanism to try if C<Win32::EventLog> is available.
 
@@ -1113,8 +1157,7 @@
 
 Log to UDP port on C<$remotehost> instead of logging locally:
 
-    setlogsock('udp');
-    $Sys::Syslog::host = $remotehost;
+    setlogsock("udp", $remotehost);
     openlog($program, 'ndelay', 'user');
     syslog('info', 'something happened over here');
 
@@ -1342,16 +1385,19 @@
 L<http://www.gnu.org/software/libc/manual/html_node/Syslog.html>
 
 Solaris 10 documentation on syslog, 
-L<http://docs.sun.com/app/docs/doc/816-5168/6mbb3hruo?a=view>
-
-IRIX 6.4 documentation on syslog,
-L<http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0640&db=man&fname=3c+syslog>
+L<http://docs.sun.com/app/docs/doc/816-5168/syslog-3c?a=view>
+
+Mac OS X documentation on syslog,
+L<http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/syslog.3.html>
+
+IRIX 6.5 documentation on syslog,
+L<http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=3c+syslog>
 
 AIX 5L 5.3 documentation on syslog, 
 L<http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf2/syslog.htm>
 
 HP-UX 11i documentation on syslog, 
-L<http://docs.hp.com/en/B9106-90010/syslog.3C.html>
+L<http://docs.hp.com/en/B2355-60130/syslog.3C.html>
 
 Tru64 5.1 documentation on syslog, 
 L<http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51_HTML/MAN/MAN3/0193____.HTM>
@@ -1455,7 +1501,7 @@
 
 =head1 COPYRIGHT
 
-Copyright (C) 1990-2007 by Larry Wall and others.
+Copyright (C) 1990-2008 by Larry Wall and others.
 
 
 =head1 LICENSE
@@ -1518,6 +1564,9 @@
 
 Links
 -----
+Linux Fast-STREAMS
+- L<http://www.openss7.org/streams.html>
+
 II12021: SYSLOGD HOWTO TCPIPINFO (z/OS, OS/390, MVS)
 - L<http://www-1.ibm.com/support/docview.wss?uid=isg1II12021>
 

Modified: branches/upstream/libsys-syslog-perl/current/Syslog.xs
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/Syslog.xs?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/Syslog.xs (original)
+++ branches/upstream/libsys-syslog-perl/current/Syslog.xs Sat Jun 14 21:45:43 2008
@@ -9,13 +9,13 @@
 #define HAVE_SYSLOG 1
 #endif
 
-#if defined(I_SYSLOG) || PATCHLEVEL < 6
-#include <syslog.h>
-#endif
-
 #if defined(_WIN32) && !defined(__CYGWIN__)
-#undef HAVE_SYSLOG
-#include "fallback/syslog.h"
+#  undef HAVE_SYSLOG
+#  include "fallback/syslog.h"
+#else
+#  if defined(I_SYSLOG) || PATCHLEVEL < 6
+#    include <syslog.h>
+#  endif
 #endif
 
 static SV *ident_svptr;
@@ -126,7 +126,9 @@
     INPUT:
         int mask
     CODE:
-        setlogmask(mask);
+        RETVAL = setlogmask(mask);
+    OUTPUT:
+        RETVAL
 
 void
 closelog_xs()

Modified: branches/upstream/libsys-syslog-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/00-load.t?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/00-load.t (original)
+++ branches/upstream/libsys-syslog-perl/current/t/00-load.t Sat Jun 14 21:45:43 2008
@@ -2,9 +2,7 @@
 use strict;
 use Test::More tests => 1;
 
-BEGIN {
-    use_ok( 'Sys::Syslog' );
-}
+use_ok( 'Sys::Syslog' );
 
 diag( "Testing Sys::Syslog $Sys::Syslog::VERSION, Perl $], $^X" )
     unless $ENV{PERL_CORE};

Added: branches/upstream/libsys-syslog-perl/current/t/data-validation.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/data-validation.t?rev=21134&op=file
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/data-validation.t (added)
+++ branches/upstream/libsys-syslog-perl/current/t/data-validation.t Sat Jun 14 21:45:43 2008
@@ -1,0 +1,114 @@
+#!perl -w
+# --------------------------------------------------------------------
+# The aim of this test is to start a syslog server (TCP or UDP) using 
+# the one available in POE, make Sys::Syslog connect to it by manually 
+# select the corresponding mechanism, send some messages and, inside 
+# the POE syslog server, check that these message are correctly crafted. 
+# --------------------------------------------------------------------
+use strict;
+
+my $port;
+BEGIN {
+    # override getservbyname()
+    *CORE::GLOBAL::getservbyname = sub ($$) {
+        my @v = CORE::getservbyname($_[0], $_[1]);
+
+        if (@v) {
+            $v[2] = $port;
+        } else {
+            @v = ($_[0], "", $port, $_[1]);
+        }
+
+        return wantarray ? @v : $port
+    }
+}
+
+use File::Spec;
+use Test::More;
+use Socket;
+use Sys::Syslog qw(:standard :extended :macros);
+
+
+# check than POE is available
+plan skip_all => "POE is not available" unless eval "use POE; 1";
+
+# check than POE::Component::Server::Syslog is available
+plan skip_all => "POE::Component::Server::Syslog is not available"
+    unless eval "use POE::Component::Server::Syslog; 1";
+
+plan tests => 1;
+
+   $port    = 5140;
+my $proto   = "tcp";
+
+my $ident   = "pocosyslog";
+my $text    = "Close the world, txEn eht nepO.";
+
+
+$SIG{ALRM} = sub {
+    ok( 0, "test took too much time to execute" );
+    exit
+};
+alarm 30;
+
+my $pid = fork();
+
+if ($pid) {
+    # parent: setup a syslog server
+    POE::Component::Server::Syslog->spawn(
+        Alias       => 'syslog',
+        Type        => $proto, 
+        BindAddress => '127.0.0.1',
+        BindPort    => $port,
+        InputState  => \&client_input,
+        ErrorState  => \&client_error,
+    );
+
+    $SIG{CHLD} = sub { wait() };
+
+    POE::Kernel->run;
+}
+else {
+    # child: send a message to the syslog server setup in the parent
+    sleep 2;
+    openlog($ident, "ndelay,pid", "local0");
+    setlogsock($proto);
+    syslog(info => $text);
+    closelog();
+    exit
+}
+
+sub client_input {
+    my $message = $_[&ARG0];
+    delete $message->{'time'};  # too hazardous to test
+    my $nl = $^O =~ /darwin/ ? "" : "\n";
+
+    is_deeply(
+        $message,
+        {
+            host     => scalar gethostbyaddr(inet_aton('127.0.0.1'), AF_INET),
+            pri      => &LOG_LOCAL0 + &LOG_INFO,
+            facility => &LOG_LOCAL0 >> 3,
+            severity => &LOG_INFO,
+            msg      => "$ident\[$pid]: $text$nl\0",
+        },
+        "checking syslog message"
+    );
+
+    POE::Kernel->post(syslog => "shutdown");
+    POE::Kernel->stop;
+}
+
+sub client_error {
+    my $message = $_[&ARG0];
+
+    require Data::Dumper;
+    $Data::Dumper::Indent   = 0;    $Data::Dumper::Indent   = 0;
+    $Data::Dumper::Sortkeys = 1;    $Data::Dumper::Sortkeys = 1;
+    fail "checking syslog message";
+    diag "[client_error] message = ", Data::Dumper::Dumper($message);
+
+    POE::Kernel->post(syslog => "shutdown");
+    POE::Kernel->stop;
+}
+

Modified: branches/upstream/libsys-syslog-perl/current/t/distchk.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/distchk.t?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/distchk.t (original)
+++ branches/upstream/libsys-syslog-perl/current/t/distchk.t Sat Jun 14 21:45:43 2008
@@ -1,5 +1,6 @@
 #!perl -w
 use strict;
 use Test::More;
-eval "use Test::Distribution not => [qw(versions podcover use)]";
-plan skip_all => "Test::Distribution required for checking distribution" if $@;
+
+plan skip_all => "Test::Distribution required for checking distribution"
+    unless eval "use Test::Distribution not => [qw(versions podcover use)]; 1";

Modified: branches/upstream/libsys-syslog-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/pod.t?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/pod.t (original)
+++ branches/upstream/libsys-syslog-perl/current/t/pod.t Sat Jun 14 21:45:43 2008
@@ -1,6 +1,12 @@
 #!perl -wT
 use strict;
 use Test::More;
-eval "use Test::Pod 1.14";
-plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+use Pod::Checker;
+
+plan skip_all => "Test::Pod 1.14 required for testing POD"
+    unless eval "use Test::Pod 1.14; 1";
+
 all_pod_files_ok();
+
+my $checker = Pod::Checker->new(-warnings => 1);
+$checker->parse_from_file($_, \*STDERR) for all_pod_files();

Modified: branches/upstream/libsys-syslog-perl/current/t/podcover.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/podcover.t?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/podcover.t (original)
+++ branches/upstream/libsys-syslog-perl/current/t/podcover.t Sat Jun 14 21:45:43 2008
@@ -1,6 +1,10 @@
 #!perl -wT
 use strict;
 use Test::More;
-eval "use Test::Pod::Coverage 1.06";
-plan skip_all => "Test::Pod::Coverage 1.06 required for testing POD coverage" if $@;
-all_pod_coverage_ok({also_private => [qw(^constant$ ^connect ^disconnect ^xlate$ ^LOG_ _xs$)]});
+
+plan skip_all => "Test::Pod::Coverage 1.06 required for testing POD coverage"
+    unless eval "use Test::Pod::Coverage 1.06; 1";
+
+all_pod_coverage_ok({
+    also_private => [qw(^constant$ ^connect ^disconnect ^xlate$ ^LOG_ can_load silent_eval _xs$)]
+});

Modified: branches/upstream/libsys-syslog-perl/current/t/podspell.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/podspell.t?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/podspell.t (original)
+++ branches/upstream/libsys-syslog-perl/current/t/podspell.t Sat Jun 14 21:45:43 2008
@@ -1,9 +1,11 @@
 #!perl -w
 use strict;
 use Test::More;
+
 plan skip_all => "Pod spelling: for developer interest only :)" unless -d 'releases';
-eval "use Test::Spelling";
-plan skip_all => "Test::Spelling required for testing POD spell" if $@;
+plan skip_all => "Test::Spelling required for testing POD spell"
+    unless eval "use Test::Spelling; 1";
+
 set_spell_cmd('aspell -l --lang=en');
 add_stopwords(<DATA>);
 all_pod_files_spelling_ok();

Modified: branches/upstream/libsys-syslog-perl/current/t/portfs.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/portfs.t?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/portfs.t (original)
+++ branches/upstream/libsys-syslog-perl/current/t/portfs.t Sat Jun 14 21:45:43 2008
@@ -1,8 +1,9 @@
 #!perl -wT
 use strict;
 use Test::More;
-eval "use Test::Portability::Files";
-plan skip_all => "Test::Portability::Files required for testing filenames portability" if $@;
+
+plan skip_all => "Test::Portability::Files required for testing filenames portability"
+    unless eval "use Test::Portability::Files; 1";
 
 # run the selected tests
 run_tests();

Modified: branches/upstream/libsys-syslog-perl/current/t/syslog.t
URL: http://svn.debian.org/wsvn/branches/upstream/libsys-syslog-perl/current/t/syslog.t?rev=21134&op=diff
==============================================================================
--- branches/upstream/libsys-syslog-perl/current/t/syslog.t (original)
+++ branches/upstream/libsys-syslog-perl/current/t/syslog.t Sat Jun 14 21:45:43 2008
@@ -115,41 +115,46 @@
 }
 
 
-BEGIN { $tests += 20 * 8 }
+BEGIN { $tests += 22 * 8 }
 # try to open a syslog using all the available connection methods
 my @passed = ();
 for my $sock_type (qw(native eventlog unix pipe stream inet tcp udp)) {
     SKIP: {
-        skip "the 'stream' mechanism because a previous mechanism with similar interface succeeded", 20 
+        skip "the 'stream' mechanism because a previous mechanism with similar interface succeeded", 22 
             if $sock_type eq 'stream' and grep {/pipe|unix/} @passed;
 
         # setlogsock() called with an arrayref
         $r = eval { setlogsock([$sock_type]) } || 0;
-        skip "can't use '$sock_type' socket", 20 unless $r;
+        skip "can't use '$sock_type' socket", 22 unless $r;
         is( $@, '', "[$sock_type] setlogsock() called with ['$sock_type']" );
         ok( $r, "[$sock_type] setlogsock() should return true: '$r'" );
 
         # setlogsock() called with a single argument
         $r = eval { setlogsock($sock_type) } || 0;
-        skip "can't use '$sock_type' socket", 18 unless $r;
+        skip "can't use '$sock_type' socket", 20 unless $r;
         is( $@, '', "[$sock_type] setlogsock() called with '$sock_type'" );
         ok( $r, "[$sock_type] setlogsock() should return true: '$r'" );
 
         # openlog() without option NDELAY
         $r = eval { openlog('perl', '', 'local0') } || 0;
-        skip "can't connect to syslog", 16 if $@ =~ /^no connection to syslog available/;
+        skip "can't connect to syslog", 18 if $@ =~ /^no connection to syslog available/;
         is( $@, '', "[$sock_type] openlog() called with facility 'local0' and without option 'ndelay'" );
         ok( $r, "[$sock_type] openlog() should return true: '$r'" );
 
         # openlog() with the option NDELAY
         $r = eval { openlog('perl', 'ndelay', 'local0') } || 0;
-        skip "can't connect to syslog", 14 if $@ =~ /^no connection to syslog available/;
+        skip "can't connect to syslog", 16 if $@ =~ /^no connection to syslog available/;
         is( $@, '', "[$sock_type] openlog() called with facility 'local0' with option 'ndelay'" );
         ok( $r, "[$sock_type] openlog() should return true: '$r'" );
 
         # syslog() with negative level, should fail
         $r = eval { syslog(-1, "$test_string by connecting to a $sock_type socket") } || 0;
         like( $@, '/^syslog: invalid level\/facility: /', "[$sock_type] syslog() called with level -1" );
+        ok( !$r, "[$sock_type] syslog() should return false: '$r'" );
+
+        # syslog() with invalid level, should fail
+        $r = eval { syslog("plonk", "$test_string by connecting to a $sock_type socket") } || 0;
+        like( $@, '/^syslog: invalid level\/facility: /', "[$sock_type] syslog() called with level plonk" );
         ok( !$r, "[$sock_type] syslog() should return false: '$r'" );
 
         # syslog() with levels "info" and "notice" (as a strings), should fail




More information about the Pkg-perl-cvs-commits mailing list