sl@0
|
1 |
# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
# All rights reserved.
|
sl@0
|
3 |
# This component and the accompanying materials are made available
|
sl@0
|
4 |
# under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
# which accompanies this distribution, and is available
|
sl@0
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
#
|
sl@0
|
8 |
# Initial Contributors:
|
sl@0
|
9 |
# Nokia Corporation - initial contribution.
|
sl@0
|
10 |
#
|
sl@0
|
11 |
# Contributors:
|
sl@0
|
12 |
#
|
sl@0
|
13 |
# Description:
|
sl@0
|
14 |
#
|
sl@0
|
15 |
|
sl@0
|
16 |
#!/usr/bin/perl
|
sl@0
|
17 |
|
sl@0
|
18 |
################################################################################
|
sl@0
|
19 |
######### This file is meant to be used only once to create an initial
|
sl@0
|
20 |
######### test list and the belonging batch and command files.
|
sl@0
|
21 |
################################################################################
|
sl@0
|
22 |
|
sl@0
|
23 |
######### The input is the old mmbuild batch files under TestTools\Scripts
|
sl@0
|
24 |
################################################################################
|
sl@0
|
25 |
use strict;
|
sl@0
|
26 |
|
sl@0
|
27 |
# open file which contains all batch files that contains copy and delete commands.
|
sl@0
|
28 |
open FILES, "test_data.txt" or die "couldn't open file: $!";
|
sl@0
|
29 |
|
sl@0
|
30 |
my $input_file;
|
sl@0
|
31 |
my $output_copy_file;
|
sl@0
|
32 |
my $output_del_file;
|
sl@0
|
33 |
|
sl@0
|
34 |
while (<FILES>)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
chomp;
|
sl@0
|
37 |
|
sl@0
|
38 |
$output_copy_file = $_;
|
sl@0
|
39 |
$input_file = $output_copy_file;
|
sl@0
|
40 |
$output_copy_file =~ s/.bat//g;
|
sl@0
|
41 |
$output_copy_file =~ s/\.\.\/run//g;
|
sl@0
|
42 |
$output_copy_file .= "_copy_data.txt";
|
sl@0
|
43 |
|
sl@0
|
44 |
open OUT, ">$output_copy_file" or die "couldn't open $output_copy_file: $!";
|
sl@0
|
45 |
|
sl@0
|
46 |
open IN, "$input_file" or die "couldn't open $input_file: $!";
|
sl@0
|
47 |
|
sl@0
|
48 |
# write all copy commands to OUT file.
|
sl@0
|
49 |
while (<IN>)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
chomp;
|
sl@0
|
52 |
my $line = $_;
|
sl@0
|
53 |
if ($line =~ /^md/i || $line =~ /^copy/i)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
print OUT $line . "\n";
|
sl@0
|
56 |
}
|
sl@0
|
57 |
}
|
sl@0
|
58 |
close OUT;
|
sl@0
|
59 |
close IN;
|
sl@0
|
60 |
|
sl@0
|
61 |
# create the DABS pretest command file. Can only be one row.
|
sl@0
|
62 |
#commented out for the moment as a DABS hack exists.
|
sl@0
|
63 |
#my $output_cmd_file = $output_copy_file;
|
sl@0
|
64 |
#$output_cmd_file =~ s/bat$/txt/;
|
sl@0
|
65 |
#open DABS_cmd_file, ">$output_cmd_file" or die "couldn't open $output_cmd_file: $!";
|
sl@0
|
66 |
|
sl@0
|
67 |
#print DABS_cmd_file "call e:\\$output_copy_file\n";
|
sl@0
|
68 |
|
sl@0
|
69 |
#close DABS_cmd_file;
|
sl@0
|
70 |
|
sl@0
|
71 |
$output_del_file = $output_copy_file;
|
sl@0
|
72 |
$output_del_file =~ s/copy/del/g;
|
sl@0
|
73 |
|
sl@0
|
74 |
open OUT, ">$output_del_file" or die "couldn't open $output_del_file: $!";
|
sl@0
|
75 |
|
sl@0
|
76 |
open IN, "$input_file" or die "couldn't open $input_file: $!";
|
sl@0
|
77 |
|
sl@0
|
78 |
# write all del commands to OUT file
|
sl@0
|
79 |
while (<IN>)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
chomp;
|
sl@0
|
82 |
my $line = $_;
|
sl@0
|
83 |
if ($line =~ /^del.*c:/i)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
print OUT $line . "\n";
|
sl@0
|
86 |
}
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
close OUT;
|
sl@0
|
90 |
close IN;
|
sl@0
|
91 |
|
sl@0
|
92 |
# create the DABS posttest command file. Can only be one row.
|
sl@0
|
93 |
#commented out for the moment as a DABS hack exists.
|
sl@0
|
94 |
#$output_cmd_file = $output_del_file;
|
sl@0
|
95 |
#$output_cmd_file =~ s/bat$/txt/;
|
sl@0
|
96 |
#open DABS_cmd_file, ">$output_cmd_file" or die "couldn't open $output_cmd_file: $!";
|
sl@0
|
97 |
|
sl@0
|
98 |
#print DABS_cmd_file "call e:\\$output_del_file\n";
|
sl@0
|
99 |
|
sl@0
|
100 |
#close DABS_cmd_file;
|
sl@0
|
101 |
|
sl@0
|
102 |
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
close FILES;
|
sl@0
|
106 |
|
sl@0
|
107 |
open DABS_TESTS, "new_tests_92.txt" or die "couldn't open file: $!";
|
sl@0
|
108 |
|
sl@0
|
109 |
open FILES, "test_data.txt" or die "couldn't open file: $!";
|
sl@0
|
110 |
|
sl@0
|
111 |
open OUT_SCRIPT, ">real_tests_92.txt" or die "couldn't open file: $!";
|
sl@0
|
112 |
|
sl@0
|
113 |
my @test_rows;
|
sl@0
|
114 |
|
sl@0
|
115 |
# find where in the test list the pretest and posttest commands should be,
|
sl@0
|
116 |
# and insert them in the list.
|
sl@0
|
117 |
# This while loop actually creates load of duplicates of tests that don't
|
sl@0
|
118 |
# need a pre or post test command.
|
sl@0
|
119 |
# Those duplicates are removed futher down.
|
sl@0
|
120 |
while (<DABS_TESTS>)
|
sl@0
|
121 |
{
|
sl@0
|
122 |
my ( $program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand );
|
sl@0
|
123 |
|
sl@0
|
124 |
chomp;
|
sl@0
|
125 |
|
sl@0
|
126 |
($program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand) = split(/,/);
|
sl@0
|
127 |
|
sl@0
|
128 |
# Strip any trailing spaces
|
sl@0
|
129 |
$program =~ s!\ $!! if( defined($program));
|
sl@0
|
130 |
$log =~ s!\ $!! if( defined($log));
|
sl@0
|
131 |
$commdb =~ s!\ $!! if( defined($commdb));
|
sl@0
|
132 |
$script =~ s!\ $!! if( defined($script));
|
sl@0
|
133 |
$timeout =~ s!\ $!! if( defined($timeout));
|
sl@0
|
134 |
$release =~ s!\ $!! if( defined($release));
|
sl@0
|
135 |
$preCommand =~ s!\ $!! if( defined($preCommand));
|
sl@0
|
136 |
$postCommand =~ s!\ $!! if( defined($postCommand));
|
sl@0
|
137 |
|
sl@0
|
138 |
# Strip any leading spaces
|
sl@0
|
139 |
$program =~ s!^\ !! if( defined($program));
|
sl@0
|
140 |
$log =~ s!^\ !! if( defined($log));
|
sl@0
|
141 |
$commdb =~ s!^\ !! if( defined($commdb));
|
sl@0
|
142 |
$script =~ s!^\ !! if( defined($script));
|
sl@0
|
143 |
$timeout =~ s!^\ !! if( defined($timeout));
|
sl@0
|
144 |
$release =~ s!^\ !! if( defined($release));
|
sl@0
|
145 |
$preCommand =~ s!^\ !! if( defined($preCommand));
|
sl@0
|
146 |
$postCommand =~ s!^\ !! if( defined($postCommand));
|
sl@0
|
147 |
|
sl@0
|
148 |
# Set defaults for undefined values
|
sl@0
|
149 |
$program = "" unless ($program);
|
sl@0
|
150 |
$log = "" unless ($log);
|
sl@0
|
151 |
$commdb = "" unless ($commdb);
|
sl@0
|
152 |
$script = "" unless ($script);
|
sl@0
|
153 |
$timeout = $::TestTimeout unless ($timeout);
|
sl@0
|
154 |
$preCommand = "" unless ($preCommand);
|
sl@0
|
155 |
$postCommand = "" unless ($postCommand);
|
sl@0
|
156 |
|
sl@0
|
157 |
my $found_script = 0;
|
sl@0
|
158 |
open FILES, "test_data.txt" or die "couldn't open file: $!";
|
sl@0
|
159 |
|
sl@0
|
160 |
while (<FILES>)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
chomp;
|
sl@0
|
163 |
my $input_file = $_;
|
sl@0
|
164 |
|
sl@0
|
165 |
open IN, "$input_file" or die "couldn't open $input_file: $!";
|
sl@0
|
166 |
|
sl@0
|
167 |
while (<IN>)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
chomp;
|
sl@0
|
170 |
my $line = $_;
|
sl@0
|
171 |
if ($line =~ /$script/i)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
$preCommand = $input_file;
|
sl@0
|
174 |
$preCommand =~ s/.bat//g;
|
sl@0
|
175 |
$preCommand =~ s/\.\.\/run//g;
|
sl@0
|
176 |
$preCommand .= "_copy_data.txt";
|
sl@0
|
177 |
$postCommand = $preCommand;
|
sl@0
|
178 |
$postCommand =~ s/copy/del/g;
|
sl@0
|
179 |
|
sl@0
|
180 |
push @test_rows, "$program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand\n";
|
sl@0
|
181 |
$found_script = 1;
|
sl@0
|
182 |
}
|
sl@0
|
183 |
}
|
sl@0
|
184 |
close IN;
|
sl@0
|
185 |
}
|
sl@0
|
186 |
close FILES;
|
sl@0
|
187 |
|
sl@0
|
188 |
if (!$found_script)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
push @test_rows, "$program, $log, $commdb, $script, $timeout, $release, ,\n";
|
sl@0
|
191 |
}
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
|
sl@0
|
195 |
# Some perl magic to remove duplicate lines.
|
sl@0
|
196 |
# Input: @list
|
sl@0
|
197 |
# Output: @uniqed
|
sl@0
|
198 |
my %u = ();
|
sl@0
|
199 |
|
sl@0
|
200 |
my @uniqed = grep {defined} map {
|
sl@0
|
201 |
if (exists $u{$_}) { undef; } else { $u{$_} = undef; $_; }
|
sl@0
|
202 |
} @test_rows;
|
sl@0
|
203 |
|
sl@0
|
204 |
undef %u;
|
sl@0
|
205 |
|
sl@0
|
206 |
my $row;
|
sl@0
|
207 |
|
sl@0
|
208 |
# The tests have been uniqed, so write them out to the new test list.
|
sl@0
|
209 |
foreach $row (@uniqed)
|
sl@0
|
210 |
{
|
sl@0
|
211 |
print OUT_SCRIPT "$row";
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
close OUT_SCRIPT;
|
sl@0
|
215 |
|
sl@0
|
216 |
open DABS_TESTS, "real_tests_92.txt" or die "couldn't open file: $!";
|
sl@0
|
217 |
|
sl@0
|
218 |
# Fix the del files so they remove the log file of the test script.
|
sl@0
|
219 |
while (<DABS_TESTS>)
|
sl@0
|
220 |
{
|
sl@0
|
221 |
my ( $program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand );
|
sl@0
|
222 |
|
sl@0
|
223 |
chomp;
|
sl@0
|
224 |
|
sl@0
|
225 |
($program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand) = split(/,/);
|
sl@0
|
226 |
|
sl@0
|
227 |
next if ($postCommand eq "");
|
sl@0
|
228 |
|
sl@0
|
229 |
# Strip any trailing spaces
|
sl@0
|
230 |
$log =~ s!\ $!! if( defined($log));
|
sl@0
|
231 |
$postCommand =~ s!\ $!! if( defined($postCommand));
|
sl@0
|
232 |
|
sl@0
|
233 |
# Strip any leading spaces
|
sl@0
|
234 |
$log =~ s!^\ !! if( defined($log));
|
sl@0
|
235 |
$postCommand =~ s!^\ !! if( defined($postCommand));
|
sl@0
|
236 |
|
sl@0
|
237 |
# $postCommand =~ s/\.txt/\.bat/i;
|
sl@0
|
238 |
|
sl@0
|
239 |
open DEL, ">>$postCommand" || die "couldn't open $postCommand for append: $!";
|
sl@0
|
240 |
print DEL "del c:\\$log\n";
|
sl@0
|
241 |
close DEL;
|
sl@0
|
242 |
}
|