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
14 # - - - - - - - - - - - - - - - - - - - - - - - - - -
20 $verbose = $ENV{'debug'} if $ENV{'debug'};
22 my $result = GetOptions
(
23 "verbose=i" => \
$verbose,
29 pod2usage
(1) if $help;
30 pod2usage
(-exitstatus
=> 0, -verbose
=> 2) if $man;
32 open(LOGFILE
,">> $ENV{LOGDIR}/test.log") || die "Can't open test.log. $!";
33 print LOGFILE
"------------ Test $0 starting ------------\n";
38 # write test result and set next test
42 print STDERR
"\n===> $0 FAILED with $errors errors\n";
43 print LOGFILE
"\n===> $0 FAILED with $errors errors\n";
45 print STDERR
"\n===> $0 PASSED successfully\n";
46 print LOGFILE
"\n===> $0 PASSED successfully\n";
47 print LOGFILE
"NEXTTEST=$nexttest\n" if $nexttest;
56 my $dev = qx#mount|grep $mount|cut -d' ' -f1#;
63 my ($device, $expected) = @_;
64 my ($value) = qx#grep -i "^$device\\b" /proc/mdstat# =~ m/$device\s*:\s*(.*)/i;
66 if ($value eq $expected) {
67 print LOGFILE
"Check raid $device success\n";
70 print LOGFILE
"Check raid $device FAILED.\n Expect <$expected>\n Found <$value>\n";
76 sub checkE2fsAttribute
{
78 my ($device, $attribute, $expected) = @_;
80 # since attribute is a space separated list of attributes, IMO we must loop over
81 # the list. Ask Sebastian again
82 my ($value) = qx#tune2fs -l $device |grep -i "$attribute"# =~ m/$attribute:\s+(.*)/i;
84 if ($value eq $expected) {
85 print LOGFILE
"Check $attribute for $device success\n";
88 print LOGFILE
"Check $attribute for $device FAILED.\n Expect <$expected>\n Found <$value>\n";