[Fai-commit] r5475 - in trunk: debian examples/simple examples/simple/tests

Thomas Lange lange at alioth.debian.org
Wed Jul 22 14:23:32 UTC 2009


Author: lange
Date: 2009-07-22 14:23:31 +0000 (Wed, 22 Jul 2009)
New Revision: 5475

Added:
   trunk/examples/simple/tests/
   trunk/examples/simple/tests/Faitest.pm
Modified:
   trunk/debian/changelog
Log:
tests/Faitest.pm: new file including subroutines for tests. Thanks to
Sebastian Hetze for the initial version.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2009-07-21 18:45:34 UTC (rev 5474)
+++ trunk/debian/changelog	2009-07-22 14:23:31 UTC (rev 5475)
@@ -1,4 +1,4 @@
-fai (3.2.23~beta2) unstable; urgency=low
+fai (3.2.23~beta4) unstable; urgency=low
 
   [ Thomas Lange ]
   * subroutines-linux: fix log message
@@ -39,6 +39,8 @@
   * package_config/FAIBASE: remove rsh-client, discover
   * fai-chboot: ignore ~ and .bak entries
   * faimond-gui: add task tests
+  * tests/Faitest.pm: new file including subroutines for tests. Thanks to
+    Sebastian Hetze for the initial version.
   
   [ Michael Tautschnig ]
   * setup-storage/Parser.pm: Set the boot flag on partition mounted at /, if
@@ -73,7 +75,7 @@
     debugging this).  (closes: #532321)
   * Bumped setup-storage version number to 1.1.
   
- -- Thomas Lange <lange at debian.org>  Sun, 19 Jul 2009 23:07:51 +0200
+ -- Thomas Lange <lange at debian.org>  Wed, 22 Jul 2009 16:21:35 +0200
 
 fai (3.2.20) unstable; urgency=low
 

Added: trunk/examples/simple/tests/Faitest.pm
===================================================================
--- trunk/examples/simple/tests/Faitest.pm	                        (rev 0)
+++ trunk/examples/simple/tests/Faitest.pm	2009-07-22 14:23:31 UTC (rev 5475)
@@ -0,0 +1,95 @@
+#! /usr/bin/perl
+
+# Subroutines for automatic tests
+#
+# Copyright (C) 2009 Thomas Lange, lange at informatik.uni-koeln.de
+# Based on the first version by Sebastian Hetze, 08/2008
+
+package FAITEST;
+
+$errors = 0;
+
+use Getopt::Long;
+use Pod::Usage;
+#  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
+sub setup_test {
+
+  my $verbose = 0;
+  my $help = 0;
+  my $man  = 0;
+  $verbose = $ENV{'debug'} if $ENV{'debug'};
+
+  my $result = GetOptions (
+	"verbose=i" => \$verbose,
+	"help" => \$help,
+	"man" => \$man,
+
+	);
+
+  pod2usage(1) if $help;
+  pod2usage(-exitstatus => 0, -verbose => 2) if $man;
+
+  open(LOGFILE,">> $ENV{LOGDIR}/test.log") || die "Can't open test.log. $!";
+  print LOGFILE "------------   Test $0 starting  ------------\n";
+}
+
+sub printresult {
+
+  # write test result and set next test
+  my ($nexttest) = @_;
+
+  if ($errors > 0) {
+    print STDERR  "\n===>  $0 FAILED with $errors errors\n";
+    print LOGFILE "\n===>  $0 FAILED with $errors errors\n";
+  } else {
+    print STDERR  "\n===>  $0 PASSED successfully\n";
+    print LOGFILE "\n===>  $0 PASSED successfully\n";
+    print LOGFILE "NEXTTEST=$nexttest\n" if $nexttest;
+  }
+  close (LOGFILE);
+  return $errors;
+}
+
+sub getDevByMount {
+
+  my $mount = shift;
+  my $dev = qx#mount|grep $mount|cut -d' ' -f1#;
+  chomp $dev;
+  return $dev
+}
+
+sub checkMdStat {
+
+  my ($device, $expected) = @_;
+  my ($value) = qx#grep -i "^$device\\b" /proc/mdstat# =~ m/$device\s*:\s*(.*)/i;
+
+  if ($value eq $expected) {
+    print LOGFILE "Check raid $device success\n";
+    return 0;
+  } else {
+    print LOGFILE "Check raid $device FAILED.\n   Expect <$expected>\n   Found <$value>\n";
+    $errors++;
+    return 1;
+  }
+}
+
+sub checkE2fsAttribute {
+
+  my ($device, $attribute, $expected) = @_;
+
+  # since attribute is a space separated list of attributes, IMO we must loop over
+  # the list. Ask Sebastian again
+  my ($value) = qx#tune2fs -l $device |grep -i "$attribute"# =~ m/$attribute:\s+(.*)/i;
+
+  if ($value eq $expected) {
+    print LOGFILE "Check $attribute for $device success\n";
+    return 0;
+  } else {
+    print LOGFILE "Check $attribute for $device FAILED.\n   Expect <$expected>\n   Found  <$value>\n";
+
+    $errors++;
+    return 1;
+  }
+}
+
+1;




More information about the Fai-commit mailing list