"Fossies" - the Fresh Open Source Software Archive

Member "Parse-Syslog-1.10/t/filetail.t" (30 Sep 2007, 952 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 Test;
    2 use lib "lib";
    3 BEGIN {
    4 	# only test if File::Tail is installed
    5 	eval 'require File::Tail;' or do {
    6 		plan tests => 0;
    7 		exit;
    8 	};
    9 	plan tests => 2;
   10 };
   11 
   12 use File::Tail;
   13 use Parse::Syslog;
   14 ok(1); # If we made it this far, we're ok.
   15 
   16 my $ft = File::Tail->new(name=>'t/linux-syslog', tail=>-1);
   17 my $parser = Parse::Syslog->new($ft, year=>2001);
   18 
   19 open(PARSED, "<t/linux-parsed") or die "can't open t/linux-parsed: $!\n";
   20 
   21 # read only one syslog line
   22 $sl = $parser->next;
   23 my $is = '';
   24 $is .= "time    : ".(localtime($sl->{timestamp}))."\n";
   25 $is .= "host    : $sl->{host}\n";
   26 $is .= "program : $sl->{program}\n";
   27 $is .= "pid     : ".(defined $sl->{pid} ? $sl->{pid} : 'undef')."\n";
   28 $is .= "text    : $sl->{text}\n";
   29 $is .= "\n";
   30 print "$is";
   31 
   32 my $shouldbe = '';
   33 $shouldbe .= <PARSED>;
   34 $shouldbe .= <PARSED>;
   35 $shouldbe .= <PARSED>;
   36 $shouldbe .= <PARSED>;
   37 $shouldbe .= <PARSED>;
   38 $shouldbe .= <PARSED>;
   39 
   40 ok($is, $shouldbe);
   41 
   42 # vim: set filetype=perl: