Update contrib.
1 # Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
3 # This component and the accompanying materials are made available
4 # under the terms of "Eclipse Public License v1.0"
5 # which accompanies this distribution, and is available
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 # Initial Contributors:
9 # Nokia Corporation - initial contribution.
18 ################################################################################
19 ######### This file is meant to be used only once to create an initial
20 ######### test list and the belonging batch and command files.
21 ################################################################################
23 ######### The input is the old mmbuild batch files under TestTools\Scripts
24 ################################################################################
27 # open file which contains all batch files that contains copy and delete commands.
28 open FILES, "test_data.txt" or die "couldn't open file: $!";
38 $output_copy_file = $_;
39 $input_file = $output_copy_file;
40 $output_copy_file =~ s/.bat//g;
41 $output_copy_file =~ s/\.\.\/run//g;
42 $output_copy_file .= "_copy_data.txt";
44 open OUT, ">$output_copy_file" or die "couldn't open $output_copy_file: $!";
46 open IN, "$input_file" or die "couldn't open $input_file: $!";
48 # write all copy commands to OUT file.
53 if ($line =~ /^md/i || $line =~ /^copy/i)
55 print OUT $line . "\n";
61 # create the DABS pretest command file. Can only be one row.
62 #commented out for the moment as a DABS hack exists.
63 #my $output_cmd_file = $output_copy_file;
64 #$output_cmd_file =~ s/bat$/txt/;
65 #open DABS_cmd_file, ">$output_cmd_file" or die "couldn't open $output_cmd_file: $!";
67 #print DABS_cmd_file "call e:\\$output_copy_file\n";
71 $output_del_file = $output_copy_file;
72 $output_del_file =~ s/copy/del/g;
74 open OUT, ">$output_del_file" or die "couldn't open $output_del_file: $!";
76 open IN, "$input_file" or die "couldn't open $input_file: $!";
78 # write all del commands to OUT file
83 if ($line =~ /^del.*c:/i)
85 print OUT $line . "\n";
92 # create the DABS posttest command file. Can only be one row.
93 #commented out for the moment as a DABS hack exists.
94 #$output_cmd_file = $output_del_file;
95 #$output_cmd_file =~ s/bat$/txt/;
96 #open DABS_cmd_file, ">$output_cmd_file" or die "couldn't open $output_cmd_file: $!";
98 #print DABS_cmd_file "call e:\\$output_del_file\n";
100 #close DABS_cmd_file;
107 open DABS_TESTS, "new_tests_92.txt" or die "couldn't open file: $!";
109 open FILES, "test_data.txt" or die "couldn't open file: $!";
111 open OUT_SCRIPT, ">real_tests_92.txt" or die "couldn't open file: $!";
115 # find where in the test list the pretest and posttest commands should be,
116 # and insert them in the list.
117 # This while loop actually creates load of duplicates of tests that don't
118 # need a pre or post test command.
119 # Those duplicates are removed futher down.
122 my ( $program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand );
126 ($program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand) = split(/,/);
128 # Strip any trailing spaces
129 $program =~ s!\ $!! if( defined($program));
130 $log =~ s!\ $!! if( defined($log));
131 $commdb =~ s!\ $!! if( defined($commdb));
132 $script =~ s!\ $!! if( defined($script));
133 $timeout =~ s!\ $!! if( defined($timeout));
134 $release =~ s!\ $!! if( defined($release));
135 $preCommand =~ s!\ $!! if( defined($preCommand));
136 $postCommand =~ s!\ $!! if( defined($postCommand));
138 # Strip any leading spaces
139 $program =~ s!^\ !! if( defined($program));
140 $log =~ s!^\ !! if( defined($log));
141 $commdb =~ s!^\ !! if( defined($commdb));
142 $script =~ s!^\ !! if( defined($script));
143 $timeout =~ s!^\ !! if( defined($timeout));
144 $release =~ s!^\ !! if( defined($release));
145 $preCommand =~ s!^\ !! if( defined($preCommand));
146 $postCommand =~ s!^\ !! if( defined($postCommand));
148 # Set defaults for undefined values
149 $program = "" unless ($program);
150 $log = "" unless ($log);
151 $commdb = "" unless ($commdb);
152 $script = "" unless ($script);
153 $timeout = $::TestTimeout unless ($timeout);
154 $preCommand = "" unless ($preCommand);
155 $postCommand = "" unless ($postCommand);
157 my $found_script = 0;
158 open FILES, "test_data.txt" or die "couldn't open file: $!";
165 open IN, "$input_file" or die "couldn't open $input_file: $!";
171 if ($line =~ /$script/i)
173 $preCommand = $input_file;
174 $preCommand =~ s/.bat//g;
175 $preCommand =~ s/\.\.\/run//g;
176 $preCommand .= "_copy_data.txt";
177 $postCommand = $preCommand;
178 $postCommand =~ s/copy/del/g;
180 push @test_rows, "$program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand\n";
190 push @test_rows, "$program, $log, $commdb, $script, $timeout, $release, ,\n";
195 # Some perl magic to remove duplicate lines.
200 my @uniqed = grep {defined} map {
201 if (exists $u{$_}) { undef; } else { $u{$_} = undef; $_; }
208 # The tests have been uniqed, so write them out to the new test list.
209 foreach $row (@uniqed)
211 print OUT_SCRIPT "$row";
216 open DABS_TESTS, "real_tests_92.txt" or die "couldn't open file: $!";
218 # Fix the del files so they remove the log file of the test script.
221 my ( $program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand );
225 ($program, $log, $commdb, $script, $timeout, $release, $preCommand, $postCommand) = split(/,/);
227 next if ($postCommand eq "");
229 # Strip any trailing spaces
230 $log =~ s!\ $!! if( defined($log));
231 $postCommand =~ s!\ $!! if( defined($postCommand));
233 # Strip any leading spaces
234 $log =~ s!^\ !! if( defined($log));
235 $postCommand =~ s!^\ !! if( defined($postCommand));
237 # $postCommand =~ s/\.txt/\.bat/i;
239 open DEL, ">>$postCommand" || die "couldn't open $postCommand for append: $!";
240 print DEL "del c:\\$log\n";