check_swap.t 690 B

12345678910111213141516171819202122232425
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # Swap Space Tests via check_swap
  4. #
  5. # $Id$
  6. #
  7. use strict;
  8. use Test;
  9. use NPTest;
  10. use vars qw($tests);
  11. BEGIN {$tests = 6; plan tests => $tests}
  12. my $t;
  13. my $successOutput = '/^SWAP OK - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
  14. my $failureOutput = '/^SWAP CRITICAL - [0-9]+\% free \([0-9]+ MB out of [0-9]+ MB\)/';
  15. $t += checkCmd( "./check_swap -w 1048576 -c 1048576", 0, $successOutput ); # 1MB free
  16. $t += checkCmd( "./check_swap -w 1\% -c 1\%", 0, $successOutput ); # 1% free
  17. $t += checkCmd( "./check_swap -w 100\% -c 100\%", 2, $failureOutput ); # 100% free (always fails)
  18. exit(0) if defined($Test::Harness::VERSION);
  19. exit($tests - $t);