"Fossies" - the Fresh Open Source Software Archive

Member "Parse-Syslog-1.10/t/dst.t" (30 Sep 2007, 1539 Bytes) of package /linux/privat/old/Parse-Syslog-1.10.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use lib 'lib';
    2 use Parse::Syslog;
    3 use Test;
    4 use POSIX;
    5 use Time::Local;
    6 
    7 BEGIN {
    8 	# only test if IO::Scalar is available
    9 	eval 'require IO::Scalar;' or do {
   10 		plan tests => 0;
   11 		warn "IO::Scalar not available: test skipped.\n";
   12 		exit;
   13 	};
   14 	if($Time::Local::VERSION lt '1.07_94') {
   15 		warn "Time::Local too old for DST-switch code to work (is: $Time::Local::VERSION, must be: 1.07_94)";
   16 		plan test => 0;
   17 		exit;
   18 	}
   19 
   20 	plan tests => 20
   21 };
   22 
   23 $ENV{TZ} = 'CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00';
   24 POSIX::tzset();
   25 
   26 my $data = <<END;
   27 Oct 30 01:40:00 ivr3 bla: bla
   28 Oct 30 02:00:00 ivr3 bla: bla
   29 Oct 30 02:20:00 ivr3 bla: bla
   30 Oct 30 02:40:00 ivr3 bla: bla
   31 Oct 30 02:59:58 ivr3 bla: bla
   32 Oct 30 02:00:00 ivr3 bla: bla
   33 Oct 30 02:20:00 ivr3 bla: bla
   34 Oct 30 02:40:00 ivr3 bla: bla
   35 Oct 30 03:00:00 ivr3 bla: bla
   36 Oct 30 03:20:00 ivr3 bla: bla
   37 END
   38 
   39 my $file = IO::Scalar->new(\$data);
   40 
   41 my $parser = Parse::Syslog->new($file, year=>2005);
   42 
   43 my $result = <<END;
   44 Sun Oct 30 01:40:00 2005
   45 Sun Oct 30 02:00:00 2005
   46 Sun Oct 30 02:20:00 2005
   47 Sun Oct 30 02:40:00 2005
   48 Sun Oct 30 02:59:58 2005
   49 Sun Oct 30 02:00:00 2005
   50 Sun Oct 30 02:20:00 2005
   51 Sun Oct 30 02:40:00 2005
   52 Sun Oct 30 03:00:00 2005
   53 Sun Oct 30 03:20:00 2005
   54 END
   55 my @result = split(/\n/, $result);
   56 
   57 my $last_t=0;
   58 while(my $sl = $parser->next) {
   59 	# check that we get the correct localtime where a timewarp is noticeable
   60 	# but always an increasing timestamp
   61 	my $lt = localtime($sl->{timestamp});
   62 	ok($lt, shift @result);
   63 	ok($sl->{timestamp} > $last_t);
   64 	$last_t = $sl->{timestamp};
   65 }
   66 
   67 # vim: ft=perl