From 226d3f5deb80ff1f0d4decae2642f5dd71ce0405 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 19 Nov 2010 15:35:48 +0100 Subject: Add various tests for --filter --- t/50-icli.t | 41 ++++++++++++++++++++++++++++++++++++++++- t/out/filter_.A.o | 7 +++++++ t/out/filter_.o | 7 +++++++ t/out/filter_.o.A.D | 3 +++ t/out/filter_A | 0 t/out/filter_D | 17 +++++++++++++++++ t/out/filter_S | 7 +++++++ t/out/filter_c | 3 +++ t/out/filter_u | 3 +++ t/out/filter_w | 3 +++ t/out/h_filter_.o | 2 ++ t/out/h_filter_S | 2 ++ t/out/h_filter_S.x.A | 1 + t/out/h_filter_d | 1 + t/out/h_filter_x | 1 + 15 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 t/out/filter_.A.o create mode 100644 t/out/filter_.o create mode 100644 t/out/filter_.o.A.D create mode 100644 t/out/filter_A create mode 100644 t/out/filter_D create mode 100644 t/out/filter_S create mode 100644 t/out/filter_c create mode 100644 t/out/filter_u create mode 100644 t/out/filter_w create mode 100644 t/out/h_filter_.o create mode 100644 t/out/h_filter_S create mode 100644 t/out/h_filter_S.x.A create mode 100644 t/out/h_filter_d create mode 100644 t/out/h_filter_x (limited to 't') diff --git a/t/50-icli.t b/t/50-icli.t index 7bf7d9b..6b3129a 100644 --- a/t/50-icli.t +++ b/t/50-icli.t @@ -3,7 +3,7 @@ use strict; use warnings; use 5.010; -use Test::Command tests => (22*3); +use Test::Command tests => (36*3); my $icli = 'bin/icli -f t/in/status.dat -c t/in/objects.cache'; @@ -11,6 +11,19 @@ my $EMPTY = q{}; my $cmd = Test::Command->new(cmd => $icli); +sub run_filter_test { + my ($prefix, $run, $filter) = @_; + + my $file = $filter; + $file =~ tr/,//d; + $file =~ tr/!/./; + + $cmd = Test::Command->new(cmd => "$icli $run -z $filter"); + $cmd->exit_is_num(0); + $cmd->stdout_is_file("t/out/${prefix}_${file}"); + $cmd->stderr_is_eq($EMPTY); +} + $cmd->exit_is_num(0); $cmd->stdout_is_file('t/out/standard'); $cmd->stderr_is_eq($EMPTY); @@ -106,6 +119,32 @@ $cmd->exit_isnt_num(0); $cmd->stdout_is_eq($EMPTY); $cmd->stderr_is_eq("See perldoc -F bin/icli\n"); +for my $filter (qw( + A + !A,!o + c + D + !o + !o,!A,!D + S + u + w + )) +{ + run_filter_test('filter', q{}, $filter); +} + +for my $filter (qw( + d + !o + S + S,!x,!A + x + )) +{ + run_filter_test('h_filter', '-lh', $filter); +} + $icli = "bin/icli -f t/in/status.dat.weird.1 -c t/in/objects.cache"; diff --git a/t/out/filter_.A.o b/t/out/filter_.A.o new file mode 100644 index 0000000..f6396c5 --- /dev/null +++ b/t/out/filter_.A.o @@ -0,0 +1,7 @@ + +aneurysm + Load CRITICAL OK - load average: 0.17, 0.13, 0.09 + Processes  UNKNOWN PROCS OK: 118 processes + +steel.derf0.net + Users  WARNING USERS OK - 0 users currently logged in diff --git a/t/out/filter_.o b/t/out/filter_.o new file mode 100644 index 0000000..f6396c5 --- /dev/null +++ b/t/out/filter_.o @@ -0,0 +1,7 @@ + +aneurysm + Load CRITICAL OK - load average: 0.17, 0.13, 0.09 + Processes  UNKNOWN PROCS OK: 118 processes + +steel.derf0.net + Users  WARNING USERS OK - 0 users currently logged in diff --git a/t/out/filter_.o.A.D b/t/out/filter_.o.A.D new file mode 100644 index 0000000..abd6201 --- /dev/null +++ b/t/out/filter_.o.A.D @@ -0,0 +1,3 @@ + +steel.derf0.net + Users  WARNING USERS OK - 0 users currently logged in diff --git a/t/out/filter_A b/t/out/filter_A new file mode 100644 index 0000000..e69de29 diff --git a/t/out/filter_D b/t/out/filter_D new file mode 100644 index 0000000..105ebbe --- /dev/null +++ b/t/out/filter_D @@ -0,0 +1,17 @@ + +alpha + HTTP  OK  HTTP OK: HTTP/1.0 200 OK - 2333 bytes in 0.019 second response time + +aneurysm + Disk: /  OK  DISK OK - free space: / 4846 MB (75% inode=90%): + Disk: /boot  OK  DISK OK - free space: /boot 119 MB (53% inode=99%): + Disk: /data  OK  DISK OK - free space: /data 60091 MB (48% inode=99%): + Disk: /home  OK  DISK OK - free space: /home 58378 MB (59% inode=98%): + HTTP  OK  HTTP OK: HTTP/1.1 200 OK - 7467 bytes in 0.001 second response time + HTTPS  OK  HTTP OK: HTTP/1.1 200 OK - 7467 bytes in 0.018 second response time + Load CRITICAL OK - load average: 0.17, 0.13, 0.09 + Processes  UNKNOWN PROCS OK: 118 processes + SMTP  OK  SMTP OK - 0.038 sec. response time + SSH  OK  SSH OK - OpenSSH_5.5p1 Debian-4 (protocol 2.0) + SSH password login d  OK  Password login disabled (server accepts publickey) + System Backup PENDING /dev/mapper/misc-backup 109G 40G 69G 37% /backup diff --git a/t/out/filter_S b/t/out/filter_S new file mode 100644 index 0000000..f6396c5 --- /dev/null +++ b/t/out/filter_S @@ -0,0 +1,7 @@ + +aneurysm + Load CRITICAL OK - load average: 0.17, 0.13, 0.09 + Processes  UNKNOWN PROCS OK: 118 processes + +steel.derf0.net + Users  WARNING USERS OK - 0 users currently logged in diff --git a/t/out/filter_c b/t/out/filter_c new file mode 100644 index 0000000..acc5847 --- /dev/null +++ b/t/out/filter_c @@ -0,0 +1,3 @@ + +aneurysm + Load CRITICAL OK - load average: 0.17, 0.13, 0.09 diff --git a/t/out/filter_u b/t/out/filter_u new file mode 100644 index 0000000..ba2b691 --- /dev/null +++ b/t/out/filter_u @@ -0,0 +1,3 @@ + +aneurysm + Processes  UNKNOWN PROCS OK: 118 processes diff --git a/t/out/filter_w b/t/out/filter_w new file mode 100644 index 0000000..abd6201 --- /dev/null +++ b/t/out/filter_w @@ -0,0 +1,3 @@ + +steel.derf0.net + Users  WARNING USERS OK - 0 users currently logged in diff --git a/t/out/h_filter_.o b/t/out/h_filter_.o new file mode 100644 index 0000000..7c08a69 --- /dev/null +++ b/t/out/h_filter_.o @@ -0,0 +1,2 @@ +alpha  DOWN  PING OK - Packet loss = 0%, RTA = 0.73 ms +aneurysm UNREACHABLE PING OK - Packet loss = 0%, RTA = 0.10 ms diff --git a/t/out/h_filter_S b/t/out/h_filter_S new file mode 100644 index 0000000..7c08a69 --- /dev/null +++ b/t/out/h_filter_S @@ -0,0 +1,2 @@ +alpha  DOWN  PING OK - Packet loss = 0%, RTA = 0.73 ms +aneurysm UNREACHABLE PING OK - Packet loss = 0%, RTA = 0.10 ms diff --git a/t/out/h_filter_S.x.A b/t/out/h_filter_S.x.A new file mode 100644 index 0000000..8ecadc0 --- /dev/null +++ b/t/out/h_filter_S.x.A @@ -0,0 +1 @@ +alpha  DOWN  PING OK - Packet loss = 0%, RTA = 0.73 ms diff --git a/t/out/h_filter_d b/t/out/h_filter_d new file mode 100644 index 0000000..8ecadc0 --- /dev/null +++ b/t/out/h_filter_d @@ -0,0 +1 @@ +alpha  DOWN  PING OK - Packet loss = 0%, RTA = 0.73 ms diff --git a/t/out/h_filter_x b/t/out/h_filter_x new file mode 100644 index 0000000..df4ab1a --- /dev/null +++ b/t/out/h_filter_x @@ -0,0 +1 @@ +aneurysm UNREACHABLE PING OK - Packet loss = 0%, RTA = 0.10 ms -- cgit v1.2.3