2002-10-01 20:10:54 +02:00
|
|
|
#
|
|
|
|
# Copyright 2002 Patrik Stridvall
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-10-01 20:10:54 +02:00
|
|
|
#
|
|
|
|
|
|
|
|
package tests;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
|
|
|
require Exporter;
|
|
|
|
|
|
|
|
@ISA = qw(Exporter);
|
|
|
|
@EXPORT = qw();
|
|
|
|
@EXPORT_OK = qw($tests);
|
|
|
|
|
|
|
|
use vars qw($tests);
|
|
|
|
|
|
|
|
use config qw($current_dir $wine_dir $winapi_dir);
|
|
|
|
use options qw($options);
|
|
|
|
use output qw($output);
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub import(@) {
|
2002-10-01 20:10:54 +02:00
|
|
|
$Exporter::ExportLevel++;
|
2004-10-26 02:12:21 +02:00
|
|
|
Exporter::import(@_);
|
2002-10-01 20:10:54 +02:00
|
|
|
$Exporter::ExportLevel--;
|
|
|
|
|
|
|
|
$tests = 'tests'->new;
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub parse_tests_file($);
|
|
|
|
|
|
|
|
sub new($) {
|
2002-10-01 20:10:54 +02:00
|
|
|
my $proto = shift;
|
|
|
|
my $class = ref($proto) || $proto;
|
|
|
|
my $self = {};
|
|
|
|
bless ($self, $class);
|
|
|
|
|
|
|
|
$self->parse_tests_file();
|
|
|
|
|
|
|
|
return $self;
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub parse_tests_file($) {
|
2002-10-01 20:10:54 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $file = "tests.dat";
|
|
|
|
|
|
|
|
my $tests = \%{$self->{TESTS}};
|
|
|
|
|
|
|
|
$output->lazy_progress($file);
|
|
|
|
|
|
|
|
my $test_dir;
|
|
|
|
my $test;
|
|
|
|
my $section;
|
|
|
|
|
|
|
|
open(IN, "< $winapi_dir/$file") || die "$winapi_dir/$file: $!\n";
|
|
|
|
while(<IN>) {
|
|
|
|
s/^\s*?(.*?)\s*$/$1/; # remove whitespace at beginning and end of line
|
|
|
|
s/^(.*?)\s*#.*$/$1/; # remove comments
|
|
|
|
/^$/ && next; # skip empty lines
|
|
|
|
|
|
|
|
if (/^%%%\s*(\S+)$/) {
|
|
|
|
$test_dir = $1;
|
|
|
|
} elsif (/^%%\s*(\w+)$/) {
|
|
|
|
$test = $1;
|
|
|
|
} elsif (/^%\s*(\w+)$/) {
|
|
|
|
$section = $1;
|
|
|
|
} elsif (!/^%/) {
|
|
|
|
if (!exists($$tests{$test_dir}{$test}{$section})) {
|
|
|
|
$$tests{$test_dir}{$test}{$section} = [];
|
|
|
|
}
|
|
|
|
push @{$$tests{$test_dir}{$test}{$section}}, $_;
|
|
|
|
} else {
|
|
|
|
$output->write("$file:$.: parse error: '$_'\n");
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(IN);
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub get_tests($$) {
|
2002-10-01 20:10:54 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $tests = \%{$self->{TESTS}};
|
|
|
|
|
|
|
|
my $test_dir = shift;
|
|
|
|
|
|
|
|
my %tests = ();
|
|
|
|
if (defined($test_dir)) {
|
|
|
|
foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
|
|
|
|
$tests{$test}++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach my $test_dir (sort(keys(%$tests))) {
|
|
|
|
foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
|
|
|
|
$tests{$test}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sort(keys(%tests));
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub get_test_dirs($$) {
|
2002-10-01 20:10:54 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $tests = \%{$self->{TESTS}};
|
|
|
|
|
|
|
|
my $test = shift;
|
|
|
|
|
|
|
|
my %test_dirs = ();
|
|
|
|
if (defined($test)) {
|
|
|
|
foreach my $test_dir (sort(keys(%$tests))) {
|
|
|
|
if (exists($$tests{$test_dir}{$test})) {
|
|
|
|
$test_dirs{$test_dir}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach my $test_dir (sort(keys(%$tests))) {
|
|
|
|
$test_dirs{$test_dir}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sort(keys(%test_dirs));
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub get_sections($$$) {
|
2002-11-04 23:40:13 +01:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $tests = \%{$self->{TESTS}};
|
|
|
|
|
|
|
|
my $test_dir = shift;
|
|
|
|
my $test = shift;
|
|
|
|
|
|
|
|
my %sections = ();
|
|
|
|
if (defined($test_dir)) {
|
|
|
|
if (defined($test)) {
|
|
|
|
foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
|
|
|
|
$sections{$section}++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
|
|
|
|
foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
|
|
|
|
$sections{$section}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} elsif (defined($test)) {
|
|
|
|
foreach my $test_dir (sort(keys(%$tests))) {
|
|
|
|
foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
|
|
|
|
$sections{$section}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach my $test_dir (sort(keys(%$tests))) {
|
|
|
|
foreach my $test (sort(keys(%{$$tests{$test_dir}}))) {
|
|
|
|
foreach my $section (sort(keys(%{$$tests{$test_dir}{$test}}))) {
|
|
|
|
$sections{$section}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return sort(keys(%sections));
|
|
|
|
}
|
|
|
|
|
2004-10-26 02:12:21 +02:00
|
|
|
sub get_section($$$$) {
|
2002-10-01 20:10:54 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my $tests = \%{$self->{TESTS}};
|
|
|
|
|
|
|
|
my $test_dir = shift;
|
|
|
|
my $test = shift;
|
|
|
|
my $section = shift;
|
|
|
|
|
2002-11-04 23:40:13 +01:00
|
|
|
my $array = $$tests{$test_dir}{$test}{$section};
|
|
|
|
if (defined($array)) {
|
|
|
|
return @$array;
|
|
|
|
} else {
|
|
|
|
return ();
|
|
|
|
}
|
2002-10-01 20:10:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|