source: /cluster/svnroot/bccd-ng/branches/skylar-test_fw/trees/home/bccd/tests/test_defs.pm @ 2730

Last change on this file since 2730 was 2730, checked in by skylar, 10 years ago

don't liberate unless LIVE (#520)

File size: 2.5 KB
Line 
1package tests;
2
3use bccd_test_suite;
4use vars qw/ %tests /;
5use Cwd;
6use POSIX;
7use Carp;
8use Bccd;
9
10my $Bccd = new Bccd();
11
12%tests = (
13    'test' => sub { #Test the test suite
14        (my $testdir, my $testname) = @_;
15        my $storeOutput =
16            bccd_test_suite::generate_storeOutput($testdir,$testname);
17        system("
18                echo \"BCCD\nBCCD\nBCCD\" $storeOutput
19                echo \"ok, it works.\" $storeOutput
20                ")
21    },
22   
23    'fail' => sub { #Guarantee an error report
24        (my $testdir, my $testname) = @_;
25        my $storeOutput =
26            bccd_test_suite::generate_storeOutput($testdir,$testname);
27        system( "seq 1 100 | sort -R $storeOutput");
28    },
29   
30    'system' => sub { #Print system information
31        (my $testdir, my $testname) = @_;
32        chdir("$ENV{HOME}/tests"); # Hack time
33        my $storeOutput =
34            bccd_test_suite::generate_storeOutput($testdir,$testname);
35        my $out = getcwd()."/$testdir/$testname.dat";
36        open(my $OUT, '>>', $out) or
37            croak "Can't open $out for appending: $!\n";
38        my @uname = POSIX::uname();
39        print $OUT "@uname\n";
40        open(my $CPUI, '<', '/proc/cpuinfo') or
41            croak "Can't open /proc/cpuinfo for reading: $!\n";
42        while(my $line = <$CPUI>) {
43            chomp $line;
44            print $OUT "$line\n";
45        }
46        close($CPUI);
47        close($OUT);
48    },
49   
50    'BCCD' => sub { #Test the BCCD's built-in tests
51       
52    },
53   
54    'GalaxSee' => sub { #Test GalaxSee
55        (my $testdir, my $testname) = @_;
56        bccd_test_suite::mpi_test($testdir, $testname);
57    },
58   
59    'Life' => sub { #Test Conway's Game of Life
60        (my $testdir, my $testname) = @_;
61        bccd_test_suite::mpi_test($testdir, $testname);
62    },
63
64    'liberate' => sub { # Liberate to /dev/hda
65        (my $testdir, my $testname) = @_;
66        if($Bccd->get_stage() eq 'LIVE') {
67            chdir("$ENV{HOME}/tests");
68            my $out = getcwd()."/$testdir/$testname.dat";
69            open(my $OUT, '>>', $out) or
70                croak "Can't open $out for appending: $!\n";
71            open(my $LIB, '-|', '/usr/bin/sudo',
72                 '/usr/bin/perl', '/root/liberate.pl',
73                 '--libdev=/dev/hda') or
74                     croak "Can't open /root/liberate.pl: $!\n";
75           
76            while(my $line = <$LIB>) {
77                chomp $line;
78                print $LIB "$line\n";
79            }
80           
81            close($LIB);
82            close($OUT);
83        }
84    },
85    )
86   
Note: See TracBrowser for help on using the repository browser.