3 # Subroutines for automatic tests
5 # Copyright (C) 2009 Thomas Lange, lange@informatik.uni-koeln.de
6 # Based on the first version by Sebastian Hetze, 08/2008
15 # - - - - - - - - - - - - - - - - - - - - - - - - - -
21 $verbose = $ENV{'debug'} if $ENV{'debug'};
23 my $result = GetOptions
(
24 "verbose=i" => \
$verbose,
30 pod2usage
(1) if $help;
31 pod2usage
(-exitstatus
=> 0, -verbose
=> 2) if $man;
33 open(LOGFILE
,">> $ENV{LOGDIR}/test.log") || die "Can't open test.log. $!";
34 print LOGFILE
"------------ Test $0 starting ------------\n";
39 # write test result and set next test
43 print STDERR
"\n===> $0 FAILED with $errors errors\n";
44 print LOGFILE
"\n===> $0 FAILED with $errors errors\n";
46 print STDERR
"\n===> $0 PASSED successfully\n";
47 print LOGFILE
"\n===> $0 PASSED successfully\n";
48 print LOGFILE
"NEXTTEST=$nexttest\n" if $nexttest;
57 my $dev = qx#mount|grep $mount|cut -d' ' -f1#;
64 my ($device, $expected) = @_;
65 my ($value) = qx#grep -i "^$device\\b" /proc/mdstat# =~ m/$device\s*:\s*(.*)/i;
67 if ($value eq $expected) {
68 print LOGFILE
"Check raid $device success\n";
71 print LOGFILE
"Check raid $device FAILED.\n Expect <$expected>\n Found <$value>\n";
77 sub checkE2fsAttribute
{
79 my ($device, $attribute, $expected) = @_;
81 # since attribute is a space separated list of attributes, IMO we must loop over
82 # the list. Ask Sebastian again
83 my ($value) = qx#tune2fs -l $device |grep -i "$attribute"# =~ m/$attribute:\s+(.*)/i;
85 if ($value eq $expected) {
86 print LOGFILE
"Check $attribute for $device success\n";
89 print LOGFILE
"Check $attribute for $device FAILED.\n Expect <$expected>\n Found <$value>\n";