messagingfw/msgtest/targetautomation/Script/autoprep.pl
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 # Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     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".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 #
       
    15 
       
    16 #!perl
       
    17 # -----------------------------------------------------------------
       
    18 
       
    19 sub load_default_bat {
       
    20 	unless (open DEFAULT_BAT, $default_bat_file) {
       
    21 		die "ERROR: Cannot open default batch file: $!";
       
    22 	}
       
    23 	@default_bat = <DEFAULT_BAT>;
       
    24 	close DEFAULT_BAT;
       
    25 }
       
    26 
       
    27 # -----------------------------------------------------------------
       
    28 
       
    29 sub create_default_cleanup {
       
    30 	if (@default_clean == 0) {
       
    31 		unless (open DEFAULT_CLEAN, "DEFAULTCLEAN.TXT") {
       
    32 			die "ERROR: Cannot open default cleanup batch file: $!";
       
    33 		}
       
    34 		@default_clean = <DEFAULT_CLEAN>;
       
    35 		close DEFAULT_CLEAN;
       
    36 	}
       
    37 	$file_name = "\\epoc32\\data\\z\\system\\msgtest\\$_[0]\\T_$_[1]_CLEANUP_FROM_TEST.BAT";
       
    38 	unless (open NEW_CLEAN, ">$file_name") {
       
    39 		die "ERROR: Could not create cleanup batch file: $!";
       
    40 	}
       
    41 	print NEW_CLEAN @default_clean;
       
    42 	close NEW_CLEAN;
       
    43 }
       
    44 
       
    45 # -----------------------------------------------------------------
       
    46 
       
    47 sub auto_create_bat {
       
    48 	# check for existance of bat file, if not present, create
       
    49 	$file_name = "\\epoc32\\data\\z\\system\\msgtest\\$_[0]\\$_[1].BAT";
       
    50 	unless (open NEW_BAT, $file_name) {
       
    51 		unless (open NEW_BAT, ">$file_name") {
       
    52 			die "ERROR: Could not create batch file: $!";
       
    53 		}
       
    54 		@auto_bat = @default_bat;
       
    55 		foreach (@auto_bat) {
       
    56 			s/\@HARNESSNAME@/$_[1]/;
       
    57 		}
       
    58 		print NEW_BAT @auto_bat;
       
    59 		print "$file_name created.\n";
       
    60 	}
       
    61 	close NEW_BAT;
       
    62 }
       
    63 
       
    64 # -----------------------------------------------------------------
       
    65 
       
    66 sub add_to_ibybat {
       
    67 	$file_name = "T_$_[0]_$_[1]_TEST.BAT";
       
    68 	print HARNESSIBY "data=\\epoc32\\data\\z\\system\\msgtest\\BUILD_DIR\\$file_name System\\MsgTest\\$file_name\n";
       
    69 	print AUTOEXECUDEB "$file_name\n";
       
    70 	print AUTOEXECUDEB $change_dir;
       
    71 	print AUTOEXECUREL "$file_name\n";
       
    72 	print AUTOEXECUDEB $change_dir;
       
    73 }
       
    74 
       
    75 # -----------------------------------------------------------------
       
    76 
       
    77 die "ERROR: Bad arguments\n\n" if (@ARGV!=2);
       
    78 
       
    79 $default_bat_file = $ARGV[1];
       
    80 pop @ARGV;
       
    81 
       
    82 &load_default_bat();
       
    83 
       
    84 unless (open HARNESSIBY, ">\\epoc32\\rom\\include\\MsgTestHarnesses.iby") {
       
    85 	die "ERROR: Cannot create MSGTESTHARNESSES.IBY file: $!";
       
    86 }
       
    87 print HARNESSIBY "REM\nREM Copyright © 2002 Symbian Ltd. All rights reserved.\nREM\n\n";
       
    88 print HARNESSIBY "data=\\epoc32\\data\\z\\system\\msgtest\\BUILD_DIR\\AUTOEXEC.BAT AUTOEXEC.BAT\n\n";
       
    89 
       
    90 
       
    91 $change_dir = "z:\ncd \\system\\msgtest\n";
       
    92 unless (open AUTOEXECUDEB, ">\\epoc32\\data\\z\\system\\msgtest\\udeb\\AUTOEXEC.BAT") {
       
    93 	die "ERROR: Cannot create file: $!";
       
    94 }
       
    95 print AUTOEXECUDEB $change_dir;
       
    96 
       
    97 unless (open AUTOEXECUREL, ">\\epoc32\\data\\z\\system\\msgtest\\urel\\AUTOEXEC.BAT") {
       
    98 	die "ERROR: Cannot create file: $!";
       
    99 }
       
   100 print AUTOEXECUREL $change_dir;
       
   101 
       
   102 while (<>) {
       
   103 	chomp;
       
   104 	# remove comments
       
   105 	@fields = split /#/, $_;
       
   106 	$_ = $fields[0];
       
   107 	next if ("");
       
   108 
       
   109 	# check for a COMPONENT line
       
   110 	if (/COMPONENT/i) {
       
   111 		# add cleanup stage for previous component AUTOEXEC file(s)...
       
   112 		&add_to_ibybat($component,"CLEANUP_FROM") if ($start_located);
       
   113 
       
   114 		# expect line of this form: COMPONENT <COMPONENT_NAME>
       
   115 		@fields = split;
       
   116 		$component = $fields[1];
       
   117 		print HARNESSIBY "\nREM $component\n\n#include <T_$component.IBY>\n";
       
   118 		print "COMPONENT: $component.\n";
       
   119 
       
   120 		&create_default_cleanup("UREL", $component);
       
   121 		&create_default_cleanup("UDEB", $component);
       
   122 
       
   123 		# add preparation stage to AUTOEXEC file(s).
       
   124 		&add_to_ibybat($component,"PREPARE_FOR");		
       
   125 		$start_located = 1;
       
   126 		next;
       
   127 	}
       
   128 
       
   129 	# check for a test harness line
       
   130 	if ((/UREL|UDEB/i) && defined($start_located)) {
       
   131 		@fields = split;
       
   132 		$test_harness = $fields[0];
       
   133 		$test_harness_iby = $test_harness . ".IBY";
       
   134 		$test_harness_bat = $test_harness . ".BAT";
       
   135 
       
   136 		# add to iby
       
   137 		print HARNESSIBY "data=\\epoc32\\data\\z\\system\\msgtest\\BUILD_DIR\\$test_harness_bat System\\MsgTest\\$test_harness_bat\n";
       
   138 
       
   139 		&auto_create_bat("urel",$test_harness);
       
   140 		&auto_create_bat("udeb",$test_harness);
       
   141 
       
   142 		if (/UREL/si) {
       
   143 			print AUTOEXECUREL "$test_harness_bat\n";
       
   144 			print AUTOEXECUREL $change_dir;
       
   145 			print AUTOEXECUREL "T_SERIALLOG c:\\MsgLogs\\$test_harness.THUMB.REL.LOG\n";
       
   146 		}
       
   147 
       
   148 		if (/UDEB/si) {
       
   149 			print AUTOEXECUDEB "$test_harness_bat\n";
       
   150 			print AUTOEXECUDEB $change_dir;
       
   151 ####			print AUTOEXECUDEB "T_SERIALLOG d:\\MsgLogs\\$test_harness.THUMB.DEB.LOG\n";
       
   152 		}
       
   153 #		print $_ . "\n";
       
   154 	}
       
   155 
       
   156 }
       
   157 
       
   158 if (defined($component)) {
       
   159 	&add_to_ibybat($component,"CLEANUP_FROM");
       
   160 }
       
   161 
       
   162 close HARNESSIBY;
       
   163 
       
   164 print AUTOEXECUREL $change_dir;
       
   165 print AUTOEXECUREL "T_SERIALLOG TERMINATE\n";
       
   166 print AUTOEXECUREL "T_SERIALLOG TERMINATE\n";
       
   167 close AUTOEXECUREL;
       
   168 
       
   169 print AUTOEXECUDEB $change_dir;
       
   170 ####print AUTOEXECUDEB "T_SERIALLOG TERMINATE\n";
       
   171 ####print AUTOEXECUDEB "T_SERIALLOG TERMINATE\n";
       
   172 close AUTOEXECUDEB;
       
   173 
       
   174 print "Automatic preparation completed.\n";