From 62dd233fb558c3f651c4b73ba69c30e00f23eb2c Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Mon, 25 Jan 2010 20:33:08 +0000 Subject: initial import --- t/add-syslog.t | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100755 t/add-syslog.t diff --git a/t/add-syslog.t b/t/add-syslog.t new file mode 100755 index 0000000..638040e --- /dev/null +++ b/t/add-syslog.t @@ -0,0 +1,108 @@ +#!/usr/bin/perl +# $Id: gprintify 257533 2009-05-23 12:45:15Z guillomovitch $ + +use strict; +use warnings; +use Test::More; +use Digest::MD5; +use FindBin qw/$Bin/; +use File::Temp; +use lib "$Bin/../lib"; + +my @selector_tests = ( + [ [ qw/local1 debug emerg/ ], 'local1.*' , 'debug -> emerg' ], + [ [ qw/local1 info emerg/ ], 'local1.info' , 'info -> emerg' ], + [ [ qw/local1 debug alert/ ], 'local1.=debug;local1.=info;local1.=notice;local1.=warning;local1.=err;local1.=crit;local1.=alert' , 'debug -> alert' ], + [ [ qw/local1 info alert/ ], 'local1.=info;local1.=notice;local1.=warning;local1.=err;local1.=crit;local1.=alert' , 'info -> alert' ], +); + +plan tests => 5 + scalar @selector_tests; + +# test loading +ok(require("add-syslog"), "loading file OK"); + +# test string function +foreach my $test (@selector_tests) { + is(get_selector(@{$test->[0]}), $test->[1], $test->[2]); +} + +# test service configuration file modification +my $file; +$file = setup(<new(UNLINK => 0); + print $out $content; + close $out; + + return $out->filename(); +} + +sub get_syslog_option { + my ($file) = @_; + + my $options; + open(my $in, '<', $file) or die "can't read $file: $!"; + while (my $line = <$in>) { + chomp $line; + next unless $line =~ /^SYSLOGD_OPTIONS=(.+)/; + $options = $1; + last; + } + close($in); + + return $options; +} + -- cgit v1.2.1