0
|
1 |
#
|
|
2 |
# Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
########################################## VARIABLES ##########################################
|
|
18 |
|
|
19 |
$appname_and_version = "NokiaTSY Test Tool - installer v1";
|
|
20 |
$date_and_author = "20-Nov-2008 Martti Suvanne";
|
|
21 |
|
|
22 |
#info string
|
|
23 |
$syntax = "\n----------------------------------------------------------------------------\n";
|
|
24 |
$syntax = $syntax. " $appname_and_version $date_and_author\n";
|
|
25 |
$syntax = $syntax. "----------------------------------------------------------------------------\n\n";
|
|
26 |
$syntax = $syntax. "Checks that the environment is ready for testing, and makes the necessary\n";
|
|
27 |
$syntax = $syntax. "changes to NokiaTSY. \n";
|
|
28 |
$syntax = $syntax. "NOTE: you have to have your environment mapped as a virtual drive \n\n\n";
|
|
29 |
$syntax = $syntax. "";
|
|
30 |
$syntax = $syntax. "*************************************************************************";
|
|
31 |
$syntax = $syntax. "*** THIS SCRIPT SHOULD BE RUN IN THE DIRECTORY IN WHICH IT IS LOCATED ***";
|
|
32 |
$syntax = $syntax. "*************************************************************************";
|
|
33 |
$syntax = $syntax. "";
|
|
34 |
$syntax = $syntax. "Usage: install.pl [/parameters] \n\n";
|
|
35 |
$syntax = $syntax. " /? Show this help.\n";
|
|
36 |
$syntax = $syntax. " /N NO to ALL, this installs ONLY the modifications that are\n";
|
|
37 |
$syntax = $syntax. " not overwriting anything. And does NOT compile anything.\n";
|
|
38 |
$syntax = $syntax. " /Y YES to ALL, this installs ALL the modifications and\n";
|
|
39 |
$syntax = $syntax. " compiles everything.\n";
|
|
40 |
$syntax = $syntax. " /cs Activate scripts only.\n";
|
|
41 |
$syntax = $syntax. " /compileonly YES to all COMPILATIONS.\n";
|
|
42 |
$syntax = $syntax. " /modifyonly YES to all COMPILATIONS.\n";
|
|
43 |
$syntax = $syntax. " /version show version and environment information\n\n\n";
|
|
44 |
$syntax = $syntax. "HELP END.\n----------------------------------------------------------------------------\n";
|
|
45 |
|
|
46 |
#GLOBAL VARs
|
|
47 |
$stif_installation = 0; #0-no stiff, 1-stiff exist, but not compiled, 2-stif ok
|
|
48 |
$testtool_installation = 0; #0-no ntsytt, 1-ntsytt exist, but not compiled, 2-ntsytt ok
|
|
49 |
$nokiatsy_installation = 0; #0-no ntsy, 1-ntsy exist, but not compiled, 2-ntsy ok
|
|
50 |
|
|
51 |
$compileall = 0; #ask, yes, no
|
|
52 |
$modifyall = 0; #ask, yes, no
|
|
53 |
|
|
54 |
$mod_flag = "INTERNAL_NTSY_TESTTOOL_MOD";
|
|
55 |
$nokiatsy_path = "";
|
|
56 |
|
|
57 |
########################################## SCRIPT STARTS ##########################################
|
|
58 |
|
|
59 |
$amount = @ARGV;
|
|
60 |
#if($amount==0){die "\nHelp:".$syntax;} #empty
|
|
61 |
|
|
62 |
# Make files modifiable
|
|
63 |
chdir ("cd ../../../../../..");
|
|
64 |
system ("attrib -R /S");
|
|
65 |
|
|
66 |
for($i_args=0;$i_args<$amount;$i_args++)
|
|
67 |
{
|
|
68 |
#HELP
|
|
69 |
if (@ARGV[$i_args] =~ m/^[\/-](\?|h|help)$/i)
|
|
70 |
{
|
|
71 |
die "\nHelp:".$syntax;
|
|
72 |
}
|
|
73 |
#VERSION
|
|
74 |
elsif(@ARGV[$i_args] =~ m/^[\/-](v|version)$/i)
|
|
75 |
{
|
|
76 |
die "\n$appname_and_version - $date_and_author\n\n";
|
|
77 |
}
|
|
78 |
#N
|
|
79 |
elsif(@ARGV[$i_args] =~ m/^[\/-](n|no)$/i)
|
|
80 |
{
|
|
81 |
print "\nNO to all.\n";
|
|
82 |
$compileall =2;
|
|
83 |
$modifyall =2;
|
|
84 |
}
|
|
85 |
#Y
|
|
86 |
elsif(@ARGV[$i_args] =~ m/^[\/-](y|yes)$/i)
|
|
87 |
{
|
|
88 |
print "\nYES to all.\n";
|
|
89 |
$compileall =1;
|
|
90 |
$modifyall =1;
|
|
91 |
}
|
|
92 |
#compileonly
|
|
93 |
elsif(@ARGV[$i_args] =~ m/^[\/-](compileonly)$/i)
|
|
94 |
{
|
|
95 |
print "\nCOMPILE only.\n";
|
|
96 |
$compileall =1;
|
|
97 |
$modifyall =2;
|
|
98 |
}
|
|
99 |
#modifyonly
|
|
100 |
elsif(@ARGV[$i_args] =~ m/^[\/-](modifyonly)$/i)
|
|
101 |
{
|
|
102 |
print "\nMODIFY only.\n";
|
|
103 |
$compileall =2;
|
|
104 |
$modifyall =1;
|
|
105 |
}
|
|
106 |
#modifyonly
|
|
107 |
elsif(@ARGV[$i_args] =~ m/^[\/-](cs|copyscript)$/i)
|
|
108 |
{
|
|
109 |
print "\nSCRIPT COPY only.\n";
|
|
110 |
$compileall =2;
|
|
111 |
$modifyall =2;
|
|
112 |
$testroot = "";
|
|
113 |
$testroot = ( !length($testroot) && (-e "/CASW_Integrated/modemadaptation/adaptationlayer/tsy/nokiatsy_dll/internal/test/nokiatsy_test_tool/group/bld.inf"))? "/casw" : $testroot; #CASW
|
|
114 |
$testroot = ( !length($testroot) && (-e "/nokiatsy_test_tool/core/group/bld.inf"))? "/" : $testroot; #root
|
|
115 |
if(!length($testroot))
|
|
116 |
{
|
|
117 |
die "NO NTSY Test Tool installation found.\n";
|
|
118 |
}
|
|
119 |
goto ACTIVATESCRIPTS;
|
|
120 |
}
|
|
121 |
#BAD INPUT
|
|
122 |
else
|
|
123 |
{
|
|
124 |
die "Invalid parameter($i_args): @ARGV[$i_args].\n";
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
print "\n----------------------------------------------------------------------------\n $appname_and_version $date_and_author\n----------------------------------------------------------------------------\n";
|
|
129 |
|
|
130 |
|
|
131 |
### FIND PATHS ###
|
|
132 |
|
|
133 |
$stifroot = "";
|
|
134 |
$stifroot = ( !length($stifroot) && (-e "/CASW_Integrated/stif/TestEngine/group/bld.inf"))? "/CASW_Integrated" : $stifroot; #CASW
|
|
135 |
$stifroot = ( !length($stifroot) && (-e "/stif/TestEngine/group/bld.inf"))? "/" : $stifroot; #root
|
|
136 |
if( !length($stifroot) )
|
|
137 |
{
|
|
138 |
die "NO STIF installation found.\n";
|
|
139 |
}
|
|
140 |
|
|
141 |
print " - PATH: \"".$stifroot."\"\n";
|
|
142 |
|
|
143 |
$testroot = "";
|
|
144 |
$testroot = ( !length($testroot) && (-e "/CASW_Integrated/modemadaptation/adaptationlayer/tsy/nokiatsy_dll/internal/test/nokiatsy_test_tool/group/bld.inf"))? "/CASW_Integrated/modemadaptation/adaptationlayer/tsy/nokiatsy_dll/internal/test" : $testroot; #CASW
|
|
145 |
$testroot = ( !length($testroot) && (-e "/nokiatsy_test_tool/core/group/bld.inf"))? " " : $testroot; #root
|
|
146 |
if(!length($testroot))
|
|
147 |
{
|
|
148 |
die "NO NTSY Test Tool installation found.\n";
|
|
149 |
}
|
|
150 |
print " - PATH: \"".$testroot."\"\n";
|
|
151 |
|
|
152 |
$nokiatsy_path = "";
|
|
153 |
$nokiatsy_path = ( !length($nokiatsy_path) && (-e "/CASW_Integrated/modemadaptation/adaptationlayer/tsy/group/bld.inf"))? "/CASW_Integrated/modemadaptation/adaptationlayer" : $nokiatsy_path; #CASW
|
|
154 |
#$nokiatsy_path = ( !length($nokiatsy_path) && (-e "/ncp_sw/corecom/modemadaptation/adaptationlayer/tsy/group/bld.inf"))? "/ncp_sw/corecom/modemadaptation/adaptationlayer" : $nokiatsy_path; #3.0 RND
|
|
155 |
#$nokiatsy_path = ( !length($nokiatsy_path) && (-e "/ape_cmt/NokiaTSY/NokiaTSY/group/bld.inf"))? "/ape_cmt/NokiaTSY" : $nokiatsy_path; #2.8 RND
|
|
156 |
#$nokiatsy_path = ( !length($nokiatsy_path) && (-e "/bs_adaptation/casw_adaptation/NokiaTSY/NokiaTSY/group/bld.inf" ))? "/bs_adaptation/casw_adaptation/NokiaTSY" : $nokiatsy_path; #OLD 3.0 RND
|
|
157 |
#$nokiatsy_path = ( !length($nokiatsy_path) && (-e "/baseservices/adaptation/nokiaadaptation/NokiaTSY/NokiaTSY/group/bld.inf"))? "/baseservices/adaptation/nokiaadaptation/NokiaTSY" : $nokiatsy_path; #2.6
|
|
158 |
if(!length($nokiatsy_path))
|
|
159 |
{
|
|
160 |
die "NO NokiaTSY installation found.\n";
|
|
161 |
}
|
|
162 |
print " - PATH: \"".$nokiatsy_path."\"\n";
|
|
163 |
|
|
164 |
|
|
165 |
########################################## MODIFICATIONs START ##########################################
|
|
166 |
#
|
|
167 |
# Do the modifications to different files
|
|
168 |
|
|
169 |
print "\n____________________________________________________________________________\n1. INSTALLING CHANGES.\n";
|
|
170 |
|
|
171 |
if(2!=$modifyall) #NO MODIFY
|
|
172 |
{
|
|
173 |
$mod_amount = &AddMods();
|
|
174 |
#print "MODS: $mod_amount";
|
|
175 |
|
|
176 |
for($i_mods=0;$i_mods<$mod_amount;$i_mods++)
|
|
177 |
{
|
|
178 |
&Modify($mod_file{$i_mods}, $mod_oper{$i_mods}, $mod_srch{$i_mods}, $mod_text{$i_mods},$i_mods, $mod_nodf{$i_mods});
|
|
179 |
}
|
|
180 |
|
|
181 |
}
|
|
182 |
else
|
|
183 |
{
|
|
184 |
print " - MODIFICATIONS SKIPPED";
|
|
185 |
}
|
|
186 |
|
|
187 |
########################################## COMPILING PHASES ##########################################
|
|
188 |
#
|
|
189 |
# it is checked that all the components required are installed properly
|
|
190 |
# also if some components haven't been compiled, user is prompted for compilation
|
|
191 |
#
|
|
192 |
|
|
193 |
#--------------------------------------------------------------------------
|
|
194 |
# NokiaTSY
|
|
195 |
#--------------------------------------------------------------------------
|
|
196 |
print "\n____________________________________________________________________________\n4. NOKIATSY.\n";
|
|
197 |
$nokiatsy_installation |= (-e $nokiatsy_path."/tsy/group/bld.inf")? 1 : 0;
|
|
198 |
$nokiatsy_installation |= (-e "/epoc32/release/winscw/UREL/NOKIATSY.DLL")? 2 : 0;
|
|
199 |
|
|
200 |
|
|
201 |
print " - Clean and export for NokiaTSY (export is needed for Nokia TSY Test Tool)";
|
|
202 |
|
|
203 |
#INSTALLATION DIR seems to exist. Clean and export (export is needed for Nokia TSY Test Tool).
|
|
204 |
if( $nokiatsy_installation&1 )
|
|
205 |
{
|
|
206 |
#COMPILE
|
|
207 |
print " - CLEAN AND EXPORT. \n";
|
|
208 |
|
|
209 |
$cpath= $nokiatsy_path."/tsy/group";
|
|
210 |
&Cleanandcompile($cpath,1);
|
|
211 |
}
|
|
212 |
else
|
|
213 |
{
|
|
214 |
print " - NokiaTSY was not found! You need to extract the NokiaTSY in order to use the tool\n You can for example get a snapshot\n from NokiaTSY's newest release project from Synergy.\n";
|
|
215 |
print " ...ERROR.\n";
|
|
216 |
exit;
|
|
217 |
}
|
|
218 |
print " ...OK.\n";
|
|
219 |
|
|
220 |
|
|
221 |
#--------------------------------------------------------------------------
|
|
222 |
# NTSY Test Tool
|
|
223 |
#--------------------------------------------------------------------------
|
|
224 |
print "\n____________________________________________________________________________\n3. NOKIATSY TEST TOOL.\n";
|
|
225 |
$testtool_installation |= (-e $testroot."/nokiatsy_test_tool/core/group/bld.inf")? 1 : 0;
|
|
226 |
$testtool_installation |= (-e "/epoc32/release/winscw/UREL/NTT_core.dll")? 2 : 0;
|
|
227 |
|
|
228 |
|
|
229 |
#INSTALLATION DIR seems to exist
|
|
230 |
if( $testtool_installation&1 )
|
|
231 |
{
|
|
232 |
$cpath=$testroot."/NokiaTSY_Test_Tool/group";
|
|
233 |
&Compile($cpath);
|
|
234 |
}
|
|
235 |
else #if($stif_installation==0 || $stif_installation==2)
|
|
236 |
{
|
|
237 |
print " - Test Tool was not found! You need to extract the NokiaTSY Test Tool in order to use it\n You can for example get a snapshot\n from NokiaTSY_Test_Tool's newest release project from Synergy.\n";
|
|
238 |
print " ...ERROR.\n";
|
|
239 |
exit;
|
|
240 |
}
|
|
241 |
print " ...OK.\n";
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
#--------------------------------------------------------------------------
|
|
248 |
# NokiaTSY
|
|
249 |
#--------------------------------------------------------------------------
|
|
250 |
print "\n____________________________________________________________________________\n4. NOKIATSY.\n";
|
|
251 |
$nokiatsy_installation |= (-e $nokiatsy_path."/tsy/group/bld.inf")? 1 : 0;
|
|
252 |
$nokiatsy_installation |= (-e "/epoc32/release/winscw/UREL/NOKIATSY.DLL")? 2 : 0;
|
|
253 |
|
|
254 |
|
|
255 |
#INSTALLATION DIR seems to exist
|
|
256 |
if( $nokiatsy_installation&1 )
|
|
257 |
{
|
|
258 |
#COMPILE
|
|
259 |
$cpath= $nokiatsy_path."/tsy/group";
|
|
260 |
&Compile($cpath,1);
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
print " - NokiaTSY was not found! You need to extract the NokiaTSY in order to use the tool\n You can for example get a snapshot\n from NokiaTSY's newest release project from Synergy.\n";
|
|
265 |
print " ...ERROR.\n";
|
|
266 |
exit;
|
|
267 |
}
|
|
268 |
print " ...OK.\n";
|
|
269 |
|
|
270 |
|
|
271 |
########################################## ACTIVATE ALL SCRIPTS ##########################################
|
|
272 |
ACTIVATESCRIPTS:
|
|
273 |
print "\n____________________________________________________________________________\n6. COPY SCRIPTs.\n";
|
|
274 |
if(1!=$compileall)
|
|
275 |
{
|
|
276 |
#ACTIVATE
|
|
277 |
@filesfrom;
|
|
278 |
use File::Find;
|
|
279 |
find(\&SearchScripts, $testroot.'/NokiaTSY_Test_Tool'); #Fills the $filesfrom
|
|
280 |
@filesto2 = ('/epoc32/winscw/c/TestFramework/TestFramework.ini');
|
|
281 |
print "\n - ACTIVATE SCRIPTS:\n (NOTE: If you activate ALL the scripts, it may slow down starting test)\n";
|
|
282 |
$fop = &ActivateScripts( \@filesfrom, \@filesto2 ); #passing references
|
|
283 |
if( $fop != 1)
|
|
284 |
{
|
|
285 |
print " - error is script activation: $fop\n";
|
|
286 |
}
|
|
287 |
else
|
|
288 |
{
|
|
289 |
print " - activating ok.\n";
|
|
290 |
}
|
|
291 |
}
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
########################################## ENDING ##########################################
|
|
296 |
|
|
297 |
#ENDING
|
|
298 |
print "\n____________________________________________________________________________\n\n";
|
|
299 |
print " - Installer ended, to start the NokiaTSY Test Tool:\n Start emulator and give a command in prompt: consoleui\n and browse test cases using arrow keys.\n\n";
|
|
300 |
exit;
|
|
301 |
|
|
302 |
########################################## MAIN END ##########################################
|
|
303 |
#----------------------------------------- MAIN END -----------------------------------------#
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
########################################## SUBROUTINES ##########################################
|
|
316 |
|
|
317 |
######### Compile and clean
|
|
318 |
sub Compile
|
|
319 |
{
|
|
320 |
local($comppath) = $_[0]; #Compilation path
|
|
321 |
local($notreally) = $_[1]; #No cleaning wanted
|
|
322 |
|
|
323 |
chdir $comppath;
|
|
324 |
print " - PREPARE BUILD FILES. \n";
|
|
325 |
system("bldmake bldfiles") == 0 or exit;
|
|
326 |
|
|
327 |
if(!$notreally)
|
|
328 |
{
|
|
329 |
print " - CLEAN OLD. \n";
|
|
330 |
system("abld reallyclean winscw") == 0 or exit;
|
|
331 |
}
|
|
332 |
print " - BUILD WINSCW. \n";
|
|
333 |
system("abld build winscw") == 0 or exit;
|
|
334 |
}
|
|
335 |
|
|
336 |
######### Compile and clean
|
|
337 |
sub Cleanandcompile
|
|
338 |
{
|
|
339 |
local($comppath) = $_[0]; #Compilation path
|
|
340 |
|
|
341 |
chdir $comppath;
|
|
342 |
print " - PREPARE BUILD FILES. \n";
|
|
343 |
system("bldmake bldfiles") == 0 or exit;
|
|
344 |
|
|
345 |
print " - CLEAN OLD. \n";
|
|
346 |
system("abld reallyclean winscw nokiatsy_dll") == 0 or exit;
|
|
347 |
|
|
348 |
print " - BUILD WINSCW. \n";
|
|
349 |
system("abld build winscw nokiatsy_dll") == 0 or exit;
|
|
350 |
|
|
351 |
}
|
|
352 |
|
|
353 |
######### Search
|
|
354 |
sub SearchScripts
|
|
355 |
{
|
|
356 |
local($filetype) = 'cfg';
|
|
357 |
if($_ =~ m/\.$filetype$/i)
|
|
358 |
{
|
|
359 |
print " ".$File::Find::name."\n";
|
|
360 |
push(@filesfrom,$File::Find::name)
|
|
361 |
}
|
|
362 |
}
|
|
363 |
|
|
364 |
######### Modify files
|
|
365 |
sub Modify
|
|
366 |
{
|
|
367 |
local($filepath) = $_[0];
|
|
368 |
local($operation) = $_[1];
|
|
369 |
local($search) = $_[2];
|
|
370 |
local($replace) = $_[3];
|
|
371 |
local($id) = $_[4];
|
|
372 |
local($nodef) = $_[5];
|
|
373 |
|
|
374 |
local($mod_def_start) ="";
|
|
375 |
local($mod_def_else) ="";
|
|
376 |
local($mod_def_end) ="";
|
|
377 |
local($data) = "";
|
|
378 |
local($permission) = 1;
|
|
379 |
|
|
380 |
#make paths to correct format
|
|
381 |
$filepath =~ s/\\/\//g;
|
|
382 |
|
|
383 |
my($directory, $filename) = $filepath =~ m/(.*\/)(.*)$/;
|
|
384 |
local($linecomment) = ($filename =~ /\.ini$/i )?"#":"//";
|
|
385 |
|
|
386 |
#flagging
|
|
387 |
local($ifdefs) = ($filename =~ /\.(cpp|h|mmp)$/i )?1:0;
|
|
388 |
local($mod_def_name) = ($filename =~ /\.mmp$/i )?$mod_flag."_MMP":$mod_flag;
|
|
389 |
#print "def: $mod_def_name\n";
|
|
390 |
|
|
391 |
local($changenote) = "\n\n".$linecomment."NOKIATSY TEST TOOL (ID:".$id.")";
|
|
392 |
|
|
393 |
#OPEN FILE
|
|
394 |
print "\n - modifying file: $filename\n -- reading..\n";
|
|
395 |
if(!open( RESOURCE, "< $filepath" ))
|
|
396 |
{
|
|
397 |
print " -- NOT FOUND! skipped\n";
|
|
398 |
return;
|
|
399 |
}
|
|
400 |
|
|
401 |
#read file
|
|
402 |
while ( <RESOURCE> )
|
|
403 |
{
|
|
404 |
$data .= $_;
|
|
405 |
}
|
|
406 |
close( RESOURCE );
|
|
407 |
|
|
408 |
#check if already modified
|
|
409 |
$cn=$changenote;
|
|
410 |
$cn =~ s/\s+/\\s\*/g;
|
|
411 |
$cn =~ s/([().+?\/])/\\$1/g;
|
|
412 |
if($data =~ /$cn/ )
|
|
413 |
{
|
|
414 |
print " -- File has been modified already, proceed anyway? [y/n] ";
|
|
415 |
|
|
416 |
$modcomp= &ReadKey();
|
|
417 |
|
|
418 |
if($modcomp =~ m/^[^y]/i)
|
|
419 |
{
|
|
420 |
$permission = 0;
|
|
421 |
}
|
|
422 |
}
|
|
423 |
|
|
424 |
if($permission!=0)
|
|
425 |
{
|
|
426 |
print " -- applying modification\n";
|
|
427 |
|
|
428 |
if($ifdefs!=0 && $nodef!=1)
|
|
429 |
{
|
|
430 |
$mod_def_start = ($filename =~ /\.(mmp)$/i )?"\n#if defined $mod_def_name\n":"#ifdef $mod_def_name\n";
|
|
431 |
$mod_def_else = "\n#else //$mod_def_name\n";
|
|
432 |
$mod_def_end = "\n#endif //$mod_def_name\n";
|
|
433 |
}
|
|
434 |
|
|
435 |
#PREPARE SEARCH
|
|
436 |
$search =~ s/\s+/\\s\*/g;
|
|
437 |
$search =~ s/([().+?\/])/\\$1/g;
|
|
438 |
$search =~ s/_ANY_/\)\(\(\.\|\\s\)\*\?\)\(/g;
|
|
439 |
$mod_text=~ s/\s+/\\s\*/g;
|
|
440 |
$mod_text=~ s/([().+?\/])/\\$1/g;
|
|
441 |
|
|
442 |
#AFTER ANY
|
|
443 |
if("afterany" eq $operation)
|
|
444 |
{
|
|
445 |
$changenote .= "(added following)\n";
|
|
446 |
if($data =~ /($search)/ )
|
|
447 |
{
|
|
448 |
$mod = ($ifdefs!=0 && $nodef!=1)?"$mod_def_start$replace$mod_def_end":"$replace";
|
|
449 |
$data =~ s/($search)/$1$2$changenote$mod\n$4/g;
|
|
450 |
}
|
|
451 |
else
|
|
452 |
{
|
|
453 |
print " -- not found:\n $search";
|
|
454 |
}
|
|
455 |
}
|
|
456 |
#REPLACE
|
|
457 |
elsif("replace" eq $operation)
|
|
458 |
{
|
|
459 |
$changenote .= "(replacement)\n";
|
|
460 |
if($data =~ /($search)/ )
|
|
461 |
{
|
|
462 |
$mod = ($ifdefs!=0 && $nodef!=1)?"$mod_def_start$replace$mod_def_else$1$mod_def_end":"$replace";
|
|
463 |
$data =~ s/($search)/$changenote$mod\n/g;
|
|
464 |
}
|
|
465 |
else
|
|
466 |
{
|
|
467 |
print " -- not found ($operation):\n $search";
|
|
468 |
}
|
|
469 |
}
|
|
470 |
|
|
471 |
#COMMENT
|
|
472 |
elsif("comment" eq $operation)
|
|
473 |
{
|
|
474 |
$changenote .= "(commented following)\n";
|
|
475 |
if($data =~ /($search)/ )
|
|
476 |
{
|
|
477 |
$commented = $1;
|
|
478 |
$comm = $commented;
|
|
479 |
$commented =~ s/\n/\n$linecomment/g;
|
|
480 |
$mod = ($ifdefs!=0 && $nodef!=1)?"$mod_def_start$linecomment$commented$mod_def_else$comm$mod_def_end":"$linecomment$commented";
|
|
481 |
$data =~ s/($search)/$changenote$mod/g;
|
|
482 |
}
|
|
483 |
else
|
|
484 |
{
|
|
485 |
print " -- not found:\n \"$search\"\n";
|
|
486 |
}
|
|
487 |
}
|
|
488 |
#UNCOMMENT
|
|
489 |
elsif("uncomment" eq $operation)
|
|
490 |
{
|
|
491 |
$changenote .= "(uncommented following)\n";
|
|
492 |
if($data =~ /([\s#\/]*$search)/ )
|
|
493 |
{
|
|
494 |
$uncommented = $1;
|
|
495 |
$uncommented =~ s/(^\s*$linecomment|(\n)\s*$linecomment)/$2/g;
|
|
496 |
$mod = ($ifdefs!=0 && $nodef!=1)?"$mod_def_start$uncommented$mod_def_else$1$mod_def_end":"$uncommented";
|
|
497 |
$data =~ s/([\s#\/]*$search)/$changenote$mod/g;
|
|
498 |
}
|
|
499 |
else
|
|
500 |
{
|
|
501 |
print " -- not found:\n \"$search\"\n";
|
|
502 |
}
|
|
503 |
}
|
|
504 |
|
|
505 |
#ADD BELOW (add below search)
|
|
506 |
elsif("addbelow" eq $operation)
|
|
507 |
{
|
|
508 |
$changenote .= "(added)\n";
|
|
509 |
if($data =~ /($search)/ )
|
|
510 |
{
|
|
511 |
$mod = ($ifdefs!=0 && $nodef!=1)?"$mod_def_start$replace$mod_def_end":"$replace";
|
|
512 |
$data =~ s/($search)/$1$changenote$mod\n/g;
|
|
513 |
}
|
|
514 |
else
|
|
515 |
{
|
|
516 |
print " -- not found:\n \"$search\"\n";
|
|
517 |
}
|
|
518 |
}
|
|
519 |
#ADD TO TOP
|
|
520 |
elsif("addtop" eq $operation)
|
|
521 |
{
|
|
522 |
$changenote .= "(added)\n";
|
|
523 |
$mod = ($ifdefs!=0 && $nodef!=1)?"$mod_def_start$replace$mod_def_end":"$replace";
|
|
524 |
$data = "$changenote$mod\n$data";
|
|
525 |
}
|
|
526 |
|
|
527 |
#UNKNOWN
|
|
528 |
else
|
|
529 |
{
|
|
530 |
print " -- unknown modification request: \"$operation\"\n";
|
|
531 |
}
|
|
532 |
|
|
533 |
$mod="";
|
|
534 |
open( OUTFILE, "> $filepath" ) || die " - BREAK: Cannot open output file, is it marked READ ONLY?.\n$!\n";
|
|
535 |
print OUTFILE $data;
|
|
536 |
close( OUTFILE );
|
|
537 |
}
|
|
538 |
else
|
|
539 |
{
|
|
540 |
print " -- modification skipped\n";
|
|
541 |
}
|
|
542 |
print " -- modification end\n";
|
|
543 |
}
|
|
544 |
|
|
545 |
######### COPY FROM -> TO
|
|
546 |
sub CopyFiles
|
|
547 |
{
|
|
548 |
my($ref_from, $ref_to) = @_; # Two
|
|
549 |
local(@from) = @{$ref_from};
|
|
550 |
local(@to) = @{$ref_to};
|
|
551 |
local($size_from) = scalar(@from);
|
|
552 |
local($size_to) = scalar(@to);
|
|
553 |
|
|
554 |
if($size_from==0 || $size_to==0)
|
|
555 |
{
|
|
556 |
return (" - no files to copy.\n");
|
|
557 |
}
|
|
558 |
|
|
559 |
local($i_from);
|
|
560 |
for( $i_from=0; $i_from<$size_from; $i_from++ )
|
|
561 |
{
|
|
562 |
local($i_to);
|
|
563 |
for( $i_to=0; $i_to<$size_to; $i_to++ )
|
|
564 |
{
|
|
565 |
#$fromall = join('+', @from);
|
|
566 |
|
|
567 |
#make paths to correct format
|
|
568 |
@from[$i_from] =~ s/\//\\/g;
|
|
569 |
@to[$i_to] =~ s/\//\\/g;
|
|
570 |
$command = "copy ".@from[$i_from]." ".@to[$i_to]." /-Y\n";
|
|
571 |
|
|
572 |
#print $command;
|
|
573 |
system($command) == 0 or return ("Copy Error.");
|
|
574 |
}
|
|
575 |
}
|
|
576 |
print " - COPY FINISHED\n";
|
|
577 |
return 1;
|
|
578 |
}
|
|
579 |
|
|
580 |
|
|
581 |
######### ACTIVATE SCRIPTS
|
|
582 |
sub ActivateScripts
|
|
583 |
{
|
|
584 |
my($ref_name, $ref_location) = @_; # Two
|
|
585 |
local(@name) = @{$ref_name};
|
|
586 |
local(@location) = @{$ref_location};
|
|
587 |
local($size_name) = scalar(@name);
|
|
588 |
local($size_location) = scalar(@location);
|
|
589 |
|
|
590 |
if($size_name==0 || $size_location==0)
|
|
591 |
{
|
|
592 |
return (" - no scripts to activate.\n");
|
|
593 |
}
|
|
594 |
|
|
595 |
#COMMENT DEMO MODULE
|
|
596 |
# -----------------------------------------------------------------------
|
|
597 |
$scr_id = 100;
|
|
598 |
$scr_file{$scr_id} = @location[0]; #'/epoc32/winscw/c/TestFramework/TestFramework.ini';
|
|
599 |
$scr_oper{$scr_id} = 'comment';
|
|
600 |
$scr_srch{$scr_id} =
|
|
601 |
'\[New_Module\]
|
|
602 |
ModuleName= demomodule
|
|
603 |
\[End_Module\]';
|
|
604 |
$scr_text{$scr_id} = '';
|
|
605 |
$scr_nodf{$scr_id} = 1; #NOKIATSY defs are not active
|
|
606 |
$scr_id++;
|
|
607 |
|
|
608 |
#COMMENT ADAPTATION TEST ENV
|
|
609 |
# -----------------------------------------------------------------------
|
|
610 |
$scr_file{$scr_id} = @location[0]; #'/epoc32/winscw/c/TestFramework/TestFramework.ini';
|
|
611 |
$scr_oper{$scr_id} = 'comment';
|
|
612 |
$scr_srch{$scr_id} =
|
|
613 |
'\[New_Module\]
|
|
614 |
ModuleName= adaptationtestenvstifadapter
|
|
615 |
\[End_Module\]';
|
|
616 |
$scr_text{$scr_id} = '';
|
|
617 |
$scr_nodf{$scr_id} = 1; #NOKIATSY defs are not active
|
|
618 |
$scr_id++;
|
|
619 |
|
|
620 |
local($i_name);
|
|
621 |
local($old_name) = "";
|
|
622 |
local($activated) = "";
|
|
623 |
|
|
624 |
for( $i_name=0; $i_name<$size_name; $i_name++ )
|
|
625 |
{
|
|
626 |
my($scr_dir, $scr_filename) = @name[$i_name] =~ m/(.*\/)(.*)$/;
|
|
627 |
|
|
628 |
if(!(@name[$i_name] eq $old_name))
|
|
629 |
{
|
|
630 |
print " - Do you want to add '".$scr_filename."' to the TestFramework.ini? [y/n] ";
|
|
631 |
$key = &ReadKey();
|
|
632 |
}
|
|
633 |
if('y' eq $key)
|
|
634 |
{
|
|
635 |
$activated .= 'TestCaseFile= c:\\TestFramework\\'.$scr_filename."\n";
|
|
636 |
}
|
|
637 |
else
|
|
638 |
{
|
|
639 |
$activated .= '#TestCaseFile= c:\\TestFramework\\'.$scr_filename."\n";
|
|
640 |
}
|
|
641 |
$old_name = @from[$i_name];
|
|
642 |
}
|
|
643 |
|
|
644 |
if(length($activated))
|
|
645 |
{
|
|
646 |
#ADD NEW MODULEs
|
|
647 |
# -----------------------------------------------------------------------
|
|
648 |
$scr_file{$scr_id} = @location[0]; #'/epoc32/winscw/c/TestFramework/TestFramework.ini';
|
|
649 |
$scr_oper{$scr_id} = 'addbelow';
|
|
650 |
$scr_srch{$scr_id} =
|
|
651 |
'# name of the test module when adding new test module';
|
|
652 |
$scr_text{$scr_id} =
|
|
653 |
'[New_Module]
|
|
654 |
ModuleName= testscripter
|
|
655 |
'.$activated.'[End_Module]';
|
|
656 |
$scr_nodf{$scr_id} = 1; #NOKIATSY defs are not active
|
|
657 |
$scr_id++;
|
|
658 |
}
|
|
659 |
|
|
660 |
$mod_amount = $scr_id;
|
|
661 |
|
|
662 |
#modify
|
|
663 |
for($i_mods=100;$i_mods<$mod_amount;$i_mods++)
|
|
664 |
{
|
|
665 |
&Modify($scr_file{$i_mods}, $scr_oper{$i_mods}, $scr_srch{$i_mods}, $scr_text{$i_mods},$i_mods, $scr_nodf{$i_mods});
|
|
666 |
}
|
|
667 |
print " - ACTIVATING FINISHED\n";
|
|
668 |
return 1;
|
|
669 |
}
|
|
670 |
|
|
671 |
|
|
672 |
######### Read a Key.
|
|
673 |
sub ReadKey
|
|
674 |
{
|
|
675 |
#READKEY
|
|
676 |
$readkey=lc( getc(STDIN) );
|
|
677 |
while($readkey =~ /([^a-z0-9])/ )
|
|
678 |
{
|
|
679 |
$readkey=lc( getc(STDIN) );
|
|
680 |
}
|
|
681 |
return substr( $readkey, 0, 1);
|
|
682 |
}
|
|
683 |
|
|
684 |
|
|
685 |
######### CREATING A MODIFICATION LIST
|
|
686 |
#
|
|
687 |
# each MOD shoud have at least three of the following:
|
|
688 |
#
|
|
689 |
# 1. $mod_file{$mod_id}
|
|
690 |
# - path to the file to be modified
|
|
691 |
#
|
|
692 |
# 2. $mod_oper{$mod_id}
|
|
693 |
# - modification operation, currently supported:
|
|
694 |
# "addbelow" - adds text($mod_text) to $mod_file right after the $mod_srch -text
|
|
695 |
# "replace" - replaces instances of $mod_srch by $mod_text
|
|
696 |
# "comment" - puts a c-style comment to every line in $mod_srch
|
|
697 |
# "afterany" - adds text($mod_text) to $mod_file according to a keyword "_ANY_" in $mod_srch
|
|
698 |
# "addtop" - adds to top of the $mod_file
|
|
699 |
#
|
|
700 |
# 3. $mod_srch{$mod_id}
|
|
701 |
# - search string(can be multiple lines)
|
|
702 |
#
|
|
703 |
# 4. $mod_text{$mod_id}
|
|
704 |
# - text replacement or addition, depending on operation.
|
|
705 |
#
|
|
706 |
# 5. $mod_nodf{$mod_id}
|
|
707 |
# - if the modification should _NOT_ be flagged. Use this only for special cases!
|
|
708 |
#
|
|
709 |
#
|
|
710 |
sub AddMods
|
|
711 |
{
|
|
712 |
$mod_id = 0;
|
|
713 |
|
|
714 |
|
|
715 |
# -----------------------------------------------------------------------
|
|
716 |
$mod_file{$mod_id} = $nokiatsy_path.'/tsy/nokiatsy_dll/group/nokiatsy_dll.mmp';
|
|
717 |
$mod_oper{$mod_id} = 'replace';
|
|
718 |
$mod_srch{$mod_id} = 'LIBRARY commontsy.lib // for using Common Tsy';
|
|
719 |
$mod_text{$mod_id} = 'LIBRARY NTT_core.lib // for TEST tool';
|
|
720 |
$mod_id++;
|
|
721 |
|
|
722 |
# -----------------------------------------------------------------------
|
|
723 |
$mod_file{$mod_id} = $nokiatsy_path.'/tsy/nokiatsy_dll/group/nokiatsy_dll.mmp';
|
|
724 |
$mod_oper{$mod_id} = 'addbelow';
|
|
725 |
$mod_srch{$mod_id} = 'UID 0x1000008D 0x1000A84A';
|
|
726 |
$mod_text{$mod_id} =
|
|
727 |
' #define '.$mod_flag.'_MMP
|
|
728 |
#if defined('.$mod_flag.'_MMP)
|
|
729 |
MACRO '.$mod_flag.'
|
|
730 |
#endif //'.$mod_flag.'_MMP
|
|
731 |
';
|
|
732 |
$mod_nodf{$mod_id} = 1;
|
|
733 |
$mod_id++;
|
|
734 |
|
|
735 |
|
|
736 |
#EPOC.INI (for running emulator in textshell)
|
|
737 |
# -----------------------------------------------------------------------
|
|
738 |
$mod_file{$mod_id} = '/epoc32/data/epoc.ini';
|
|
739 |
$mod_oper{$mod_id} = 'addtop';
|
|
740 |
$mod_srch{$mod_id} = '';
|
|
741 |
$mod_text{$mod_id} = 'textshell';
|
|
742 |
$mod_id++;
|
|
743 |
|
|
744 |
# -----------------------------------------------------------------------
|
|
745 |
$mod_file{$mod_id} = '/epoc32/data/epoc.ini';
|
|
746 |
$mod_oper{$mod_id} = 'replace';
|
|
747 |
$mod_srch{$mod_id} = 'configuration epoc_480x640.ini';
|
|
748 |
$mod_text{$mod_id} = '// configuration epoc_480x640.ini';
|
|
749 |
$mod_id++;
|
|
750 |
|
|
751 |
# -----------------------------------------------------------------------
|
|
752 |
$mod_file{$mod_id} = '/epoc32/data/epoc.ini';
|
|
753 |
$mod_oper{$mod_id} = 'replace';
|
|
754 |
$mod_srch{$mod_id} = 'configuration epoc_640x480.ini';
|
|
755 |
$mod_text{$mod_id} = '// configuration epoc_640x480.ini';
|
|
756 |
$mod_id++;
|
|
757 |
|
|
758 |
|
|
759 |
#STIF SPEEDUP
|
|
760 |
# -----------------------------------------------------------------------
|
|
761 |
$mod_file{$mod_id} = $stifroot.'/stif/ConsoleUI/src/ConsoleUI.cpp';
|
|
762 |
$mod_oper{$mod_id} = 'comment';
|
|
763 |
$mod_srch{$mod_id} =
|
|
764 |
' RDebug::Print(_L("We have to wait until emulator is up & running"));
|
|
765 |
User::After(40000000);';
|
|
766 |
$mod_text{$mod_id} = '';
|
|
767 |
$mod_nodf{$mod_id} = 1; #NOKIATSY defs are not active in STIF
|
|
768 |
$mod_id++;
|
|
769 |
|
|
770 |
|
|
771 |
#TEST FRAMEWORK INI (create your own additions)
|
|
772 |
# -----------------------------------------------------------------------
|
|
773 |
#$mod_file = '/stif/Group/TestFrameWork.INI';
|
|
774 |
#$mod_file = '/epoc32/data/Z/System/Data/TestFrameWork.INI';
|
|
775 |
#$mod_file = '/epoc32/winscw/c/TestFramework/TestFrameWork.INI';
|
|
776 |
#$mod_file = '/epoc32/wins/c/TestFramework/TestFrameWork.INI';
|
|
777 |
#$mod_id++;
|
|
778 |
|
|
779 |
##################### ADD NEW MODIFICATIONS HERE ######################
|
|
780 |
|
|
781 |
|
|
782 |
# NEW MOD TASK TEMPLATE
|
|
783 |
#$mod_file{$mod_id} = '/filepath';
|
|
784 |
#$mod_oper{$mod_id} = 'command'; #POSSIBLE KEYWORDS: ('afterany'|'replace'|'comment'|'addbelow')
|
|
785 |
#$mod_srch{$mod_id} = 'searched text (multiline is ok)';
|
|
786 |
#$mod_text{$mod_id} = 'text to be added (when relevant, otherwise leave empty)';
|
|
787 |
#$mod_id++;
|
|
788 |
|
|
789 |
##################### END MODIFICATIONS HERE ######################
|
|
790 |
return ($mod_id);
|
|
791 |
}
|
|
792 |
|
|
793 |
|
|
794 |
|
|
795 |
########### END SUBROUTINES ###########
|
|
796 |
|
|
797 |
################### SCRIPT ENDS ################### |