~n3npq/lsb/distribution-checker

« back to all changes in this revision

Viewing changes to utils/Tests/Qt3_azov_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
# Qt3-azov Test Module (Qt3_azov_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 Qt3_azov_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
use X11_common;
 
34
#----------------------------------------------------------------------
 
35
 
 
36
my $checkpoints = undef;
 
37
 
 
38
#----------------------------------------------------------------------
 
39
 
 
40
sub check {
 
41
        my ($self) = @_;
 
42
        
 
43
        if ( does_shell_know ("ldconfig") ) {
 
44
                for my $lib ( qw/libqt-mt.so.3/ ) {
 
45
                        my $lib_grep = "\\<".$lib." ";
 
46
                        $lib_grep =~ s/\./\\./g;
 
47
                        cmd("ldconfig -p | grep ".shq($lib_grep)) == 0
 
48
                                or return error $self->{NAME}." test can't be run without library '$lib'.";
 
49
                }
 
50
        }
 
51
        
 
52
        is_ok $self->prepare_options() or return $Error::Last;
 
53
        
 
54
        return 1; # OK
 
55
}
 
56
 
 
57
sub prepare_options {
 
58
        my ($self) = @_;
 
59
        
 
60
        ( defined $self->{OPTIONS} )
 
61
                or return error "Answers are undefined"; # Should not happen
 
62
        
 
63
        my $testsuite_dir = $self->option('TESTSUITE_DIR') || "/opt/lsb/test/qt3-azov";
 
64
        $self->{TESTSUITE_DIR} = $testsuite_dir;
 
65
        $self->{RESULTS_DIR} = $self->option('RESULTS_DIR') || "/opt/lsb/test/qt3-azov/results";
 
66
        
 
67
        my $q = 'X11_FONT_PATH';
 
68
        if ( !defined $self->{OPTIONS}{$q}->{VALUE} ) {
 
69
                my $x11_fonts_dir = X11_common::guess_font_dir();
 
70
                is_ok($x11_fonts_dir) or return error $self->name
 
71
                        ." test requires certain X11 fonts to be installed.", $Error::Last;
 
72
                $self->{OPTIONS}{$q}->{VALUE} = $x11_fonts_dir."/misc";
 
73
        }
 
74
        
 
75
        return 1;
 
76
}
 
77
 
 
78
sub prepare {
 
79
        my ($self) = @_;
 
80
 
 
81
        # Call the parent's prepare function
 
82
        is_ok $self->Test_common::prepare() or return $Error::Last;
 
83
        
 
84
        # Download and install required packages
 
85
        is_ok $self->prepare_test_packages()  # According to the Manifest
 
86
                or return error "Failed to download and install packages for '"
 
87
                                        .$self->name."' test.", $Error::Last;
 
88
        
 
89
        cmd ("killall -q Xvfb"); # Should be done before calling guess_display()
 
90
        sleep 1;
 
91
        
 
92
        is_ok $self->prepare_options() or return $Error::Last;
 
93
        
 
94
        # Remove old results
 
95
        cmd("rm -rf ".shq($self->{RESULTS_DIR})."/*");
 
96
        
 
97
        init_checkpoint_data($self->{VERSION});
 
98
        
 
99
        return 1;
 
100
}
 
101
 
 
102
sub run {
 
103
        my ($self) = @_;
 
104
        
 
105
        my $subshell = $self->Spawn_subshell();
 
106
        is_ok $subshell or return $Error::Last;
 
107
        
 
108
        # Change to the test suite directory
 
109
        $subshell->Settle();
 
110
        $subshell->Send("cd ".shq($self->{TESTSUITE_DIR})."\n");
 
111
        
 
112
        my $test_display = ":9.0";
 
113
        my $x11_fonts_dir = $self->option('X11_FONT_PATH')
 
114
                or return error "X11 font dir is not set";
 
115
        
 
116
        # Start X Virtual Frame Buffer
 
117
        $subshell->Settle();
 
118
        $subshell->Send( "/opt/lsb/bin/Xvfb"
 
119
                        ." -render -screen 0 1024x768x24"
 
120
                        ." ".$test_display
 
121
                        ." -ac +bs -kb -fp"
 
122
                        ." ".shq($x11_fonts_dir)
 
123
                        ." &"."\n" );
 
124
        
 
125
        $subshell->Settle();
 
126
        $subshell->Send("export DISPLAY=$test_display"."\n");
 
127
        
 
128
        $subshell->Settle();
 
129
        $subshell->Send("export G_SLICE=always-malloc"."\n");
 
130
        
 
131
        # Run the test
 
132
        $subshell->Settle();
 
133
        $subshell->Send("./run_tests.sh; exit"."\n");
 
134
        
 
135
        # Just wait for the test finished
 
136
        while ( my $line = $subshell->Read(2) ) {
 
137
                $self->check_progress($line);
 
138
        }
 
139
        
 
140
        # Just confirm that the subshell has finished
 
141
        $subshell->WaitForSubshell();
 
142
        
 
143
        return 1; # Ok
 
144
}
 
145
 
 
146
sub check_progress {
 
147
        my ($self, $line) = @_;
 
148
        
 
149
        defined $line or $line = "";
 
150
        
 
151
        if ( $line =~ /^Executing tests for (.*)[\r\n]/ ) {
 
152
                my $testcase = $1;
 
153
                $self->progress_profiled($checkpoints, $testcase);
 
154
                return;
 
155
        }
 
156
        # else:
 
157
        $self->progress_profiled();
 
158
}
 
159
 
 
160
sub after_run {
 
161
        my ($self) = @_;
 
162
        
 
163
        $self->{JOURNAL_FILE} = $self->name.".journal";
 
164
        $self->{JOURNAL_TYPE} = 'TET';
 
165
        
 
166
        # Find the journal file and copy it to where it should be.
 
167
        is_ok $self->copy_file_globbed( $self->{RESULTS_DIR}."/0*/journal", $self->journal_file )
 
168
                or $self->report_error($Error::Last);
 
169
        
 
170
        return 1;
 
171
}
 
172
 
 
173
sub Cleanup {
 
174
        my ($self) = @_;
 
175
        
 
176
        cmd ("killall -q Xvfb");
 
177
}
 
178
 
 
179
sub init_checkpoint_data {
 
180
        my ($ver) = @_;
 
181
        
 
182
        # qt3-azov v. 4.0.0-1 for LSB 4.0
 
183
        $checkpoints = [
 
184
                [ 0, 'QButtonGroup' ],
 
185
                [ 6, 'QCanvasPixmap' ],
 
186
                [ 12, 'QFilePreview' ],
 
187
                [ 18, 'QFile' ],
 
188
                [ 24, 'QHebrewCodec' ],
 
189
                [ 30, 'QMenuItem' ],
 
190
                [ 39, 'QHttpHeader' ],
 
191
                [ 46, 'QMetaObject' ],
 
192
                [ 52, 'QPixmapCache' ],
 
193
                [ 62, 'QTableSelection' ],
 
194
                [ 69, 'QStyleSheet' ],
 
195
                [ 75, 'QListBoxPixmap' ],
 
196
                [ 81, 'QDataBrowser' ],
 
197
                [ 88, 'QComboBox' ],
 
198
                [ 94, 'QPushButton' ],
 
199
        ];
 
200
}
 
201
 
 
202
1; # return value