~n3npq/lsb/distribution-checker

« back to all changes in this revision

Viewing changes to utils/Tests/Olver_test.pm

  • Committer: biga
  • Date: 2009-04-24 14:16:44 UTC
  • Revision ID: biga@spidey.linux-foundation.org-20090424141644-7evzd6mjocix7e68
init

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# LSB Test Execution Framework
 
2
# Olver Test Module (Olver_test.pm)
 
3
#
 
4
# Copyright (C) 2007-2009 The Linux Foundation. All rights reserved.
 
5
#
 
6
# This program has been developed by ISP RAS for LF.
 
7
# The ptyshell tool is originally written by Jiri Dluhos <jdluhos@suse.cz>
 
8
# Copyright (C) 2005-2007 SuSE Linux Products GmbH
 
9
#
 
10
# This program is free software; you can redistribute it and/or
 
11
# modify it under the terms of the GNU General Public License
 
12
# version 2 as published by the Free Software Foundation.
 
13
#
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
#
 
19
# You should have received a copy of the GNU General Public License
 
20
# along with this program; if not, write to the Free Software
 
21
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
22
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
23
 
 
24
package Olver_test;
 
25
use strict;
 
26
 
 
27
use Misc;
 
28
use Subshell;
 
29
 
 
30
use Test_common;
 
31
our @ISA = qw(Test_common); # Inherit Test_common
 
32
#----------------------------------------------------------------------
 
33
 
 
34
my $checkpoints = undef;
 
35
 
 
36
#----------------------------------------------------------------------
 
37
 
 
38
sub prepare {
 
39
        my ($self) = @_;
 
40
 
 
41
        # Call the parent's prepare function
 
42
        is_ok $self->Test_common::prepare() or return $Error::Last;
 
43
        
 
44
        # Download and install required packages
 
45
        is_ok $self->prepare_test_packages()  # According to the Manifest
 
46
                or return error "Failed to download and install packages for '"
 
47
                                        .$self->name."' test.", $Error::Last;
 
48
        
 
49
        my $testsuite_dir = $self->option('TESTSUITE_DIR') || "/opt/lsb/test/olver-core";
 
50
        $self->{TESTSUITE_DIR} = $testsuite_dir;
 
51
        $self->{RESULTS_DIR} = $self->option('RESULTS_DIR') || "/var/opt/lsb/test/olver-core";
 
52
        
 
53
        # Remove old results
 
54
        cmd("rm -rf ".shq($self->{RESULTS_DIR})."/*");
 
55
        
 
56
        init_checkpoint_data($self->{VERSION});
 
57
        
 
58
        return 1;
 
59
}
 
60
 
 
61
sub run {
 
62
        my ($self) = @_;
 
63
        
 
64
        my $subshell = $self->Spawn_subshell();
 
65
        is_ok $subshell or return $Error::Last;
 
66
        
 
67
        # Change to the test suite directory
 
68
        $subshell->Settle();
 
69
        $subshell->Send( "cd ".shq($self->{TESTSUITE_DIR})."\n" );
 
70
        
 
71
        # Run the test
 
72
        $subshell->Settle();
 
73
        $subshell->Send("./bin/olver_run_tests; exit\n");
 
74
        
 
75
        # Just wait for the test finished
 
76
        while ( my $line = $subshell->Read(2) ) {
 
77
                $self->check_progress($line);
 
78
        }
 
79
        
 
80
        # Just confirm that the subshell has finished
 
81
        $subshell->WaitForSubshell();
 
82
        
 
83
        return 1; # Ok
 
84
}
 
85
 
 
86
sub check_progress {
 
87
        my ($self, $line) = @_;
 
88
        
 
89
        defined $line or $line = "";
 
90
        
 
91
        if ( $line =~ /^Running scenario (\S+).*[\r\n]/ ) {
 
92
                my $testcase = $1;
 
93
                $self->progress_profiled($checkpoints, $testcase);
 
94
                return;
 
95
        }
 
96
        # else:
 
97
        $self->progress_profiled();
 
98
}
 
99
 
 
100
sub after_run {
 
101
        my ($self) = @_;
 
102
        
 
103
        # Journal
 
104
        $self->{JOURNAL_FILE} = $self->name.".journal";
 
105
        $self->{JOURNAL_TYPE} = 'TET';
 
106
        
 
107
        # Find the journal file and copy it to where it should be.
 
108
        is_ok $self->copy_file_globbed( $self->{RESULTS_DIR}."/*/tet/tetreport.log", $self->journal_file )
 
109
                or $self->report_error($Error::Last);
 
110
        
 
111
        is_ok $self->copy_file_globbed( "/var/opt/lsb/test/olver-core/*", $globals->{"test_result_dir"}."/olver_full" )
 
112
                or $self->report_error($Error::Last);
 
113
        
 
114
        return 1;
 
115
}
 
116
 
 
117
sub init_checkpoint_data {
 
118
        my ($ver) = @_;
 
119
        
 
120
        # olver v. 4.0.0-5 for LSB 4.0
 
121
        $checkpoints = [
 
122
                [ 0, 'dir_scenario' ],
 
123
                [ 10, 'fstream_action_scenario' ],
 
124
                [ 16, 'line_scenario' ],
 
125
                [ 22, 'window_attr_scenario' ],
 
126
                [ 29, 'execle_scenario' ],
 
127
                [ 40, 'ualarm_scenario' ],
 
128
                [ 47, 'vswscanf_scenario' ],
 
129
                [ 54, 'scanf_scenario' ],
 
130
                [ 62, 'vsprintf_scenario' ],
 
131
                [ 68, 'vsscanf_scenario' ],
 
132
                [ 75, 'getopt_scenario' ],
 
133
        ];
 
134
}
 
135
 
 
136
1; # return value