tsrc/scripts/EunitRunner.pl
changeset 0 f0cf47e981f9
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     1 #
       
     2 # Copyright (c) 2009 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 "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 #!perl
       
    17 #line 5
       
    18 
       
    19 #--------------------------------------------------------------------------------------------------
       
    20 # This Script will be used to run EUnit testcases
       
    21 # Example Usage in Nightly build script
       
    22 # 	my $currentdir = cwd;
       
    23 #		chdir "$ProjLocation\\mmsharing\\internal\\group";
       
    24 #		system ("EunitRunner.pl -command=eu  -all -dest=$Plog -summary=$Plog\\scanlog.html 2>&1 >> $Plog\\EUnit.log");
       
    25 #		system ("EunitRunner.pl -command=ctc -all -dest=$Plog -summary=$Plog\\scanlog.html  2>&1 >> $Plog\\CTC.log");
       
    26 #		chdir $currentdir;
       
    27 # Version : 1.0
       
    28 #--------------------------------------------------------------------------------------------------
       
    29 
       
    30 #	Perl packages used.
       
    31 use File::Find;			# File operations
       
    32 use XML::Simple;		# XML parsing
       
    33 use File::Spec::Win32;  # File operartions
       
    34 use Getopt::Long;		# parameter handling
       
    35 use Cwd;						# Directory operations
       
    36 
       
    37 # Parameters related to Epoc.
       
    38 my($build_destination_dir)= "\\Epoc32\\release\\winscw\\udeb\\";
       
    39 my($build_tools_dir)= "\\Epoc32\\tools\\";
       
    40 
       
    41 # Parameters related to Digia Eunit.
       
    42 my($eunit_xml_file_name)= "EUnit_Log.xml";
       
    43 my($eunit_xml_file)= "\\Epoc32\\winscw\\C\\shared\\EUnit\\Logs\\".$eunit_xml_file_name;
       
    44 my($eunitParams) = "/l xml /e S60AppEnv /w 40 /p All /t 50";
       
    45 my($eunitParams2) = " /d alloc";
       
    46 my($eunitApp) = "/epoc32/release/winscw/udeb/EUnitExeRunner.exe";
       
    47 my($eunit_destination_dir)= "\\Epoc32\\release\\winscw\\udeb\\z\\sys\\bin\\";
       
    48 my($unittest_result_file)="eunit_result.html";
       
    49 
       
    50 # Parameters related to Codetest(ctc).
       
    51 $coverageSymbols = "MON.sym";
       
    52 $ctcCommandPart1 = "ctc-abld-winscw -i d -n";
       
    53 $ctcCommandPart2 = "-- test build winscw udeb"; 
       
    54 $ctcIgnoredPart1 = " -C \"EXCLUDE+*/internal/*.cpp";
       
    55 $ctcIgnoredPart2 = "\"";
       
    56 $coverageProfile = "profile.txt";
       
    57 my($ctc_result_file)="./\CTCHTML/\indexF.html";
       
    58 
       
    59 # Parameters related to filenames.
       
    60 #my($overal_summary_file)="Overall_Summary.html";
       
    61 my($overal_summary_file)="scanlog.html";
       
    62 
       
    63 # Hack : This will be used if dll names are not retrived from build environment.
       
    64 my(@default_subsystems)=("UT_AVAILABILITY",
       
    65                          "UT_AOPLUGIN",
       
    66                          "UT_SIPCRPLUGIN",
       
    67                          "UT_MUSAIWPROVIDER",
       
    68                          "UT_MUSWPADAPTER",
       
    69                          "UT_MUSMANAGERCLIENT",
       
    70                          "UT_MUSMANAGERSERVER",
       
    71                          "UT_MUSENGINE" );
       
    72 my(@default_dll_filenames)=("UT_AVAILABILITY.DLL",
       
    73 												    "UT_AOPLUGIN.DLL",
       
    74 												    "UT_SIPCRPLUGIN.DLL",
       
    75 												    "UT_MUSAIWPROVIDER.DLL",
       
    76 												    "UT_MUSWPADAPTER.DLL",
       
    77 												    "UT_MUSMANAGERCLIENT.DLL",
       
    78 												    "UT_MUSMANAGERSERVER.DLL",
       
    79 												    "UT_MUSENGINE.DLL" );
       
    80 												    
       
    81 
       
    82 my @uncompiled_sub_systems;# Holds list of uncompiled subsystems . Will be printed in report later.
       
    83 my($currentdir)= cwd; # Current working directory.
       
    84 my($results_destinationdir)=cwd;	# Results will be stored here.
       
    85 my($results_destinationdir_log)=cwd; # Log prints will be stored here.
       
    86 my ($unittest_log_file) = "EUnit.log"; # Eunit build process logs will be in this file.
       
    87 
       
    88 # Parameters related to result prints
       
    89 my($eunit_passpercent,
       
    90 	 $eunit_failpercent,
       
    91 	 $eunit_total_pass_count,
       
    92 	 $eunit_total_fail_count,
       
    93 	 $eunit_total_count,
       
    94 	 $eunit_total_pass_percent);
       
    95 my(@eunit_testsuite_name,
       
    96 	 @eunit_testsuite_total_testcase,
       
    97 	 @eunit_testsuite_pass_count);
       
    98 
       
    99 # Parameters related to globally used variables.
       
   100 my (@subsystems, 						# List of user selected sub systems
       
   101 		@sourcefiles,						# List of user selected source files
       
   102 		@exclude_sourcefiles,		# List of test source files.
       
   103 		@makefiles,							# List of make files
       
   104 		@dll_filenames);				# List of dll file names
       
   105 		
       
   106 my ($param_help,		 			  # To view help
       
   107 		$param_command,		 		  # Command to Run
       
   108 		$param_dest,						# Copy results to
       
   109 		$param_all,							# Build all
       
   110 		$param_noclean,					# Do not run abld clean
       
   111 		$param_nobuild,					# Do not run abld build
       
   112 		$param_nostub,					# Do not build stub		
       
   113 		$param_exe,			        # Specify exe file to be run instead Eunirexerunner.exe
       
   114 		$param_overall_summay,  # Overall Summary
       
   115 		$param_version);				# Version		
       
   116 my @gloabl_errors;
       
   117 		
       
   118 # Parameters for user choice.		
       
   119 my($choice,
       
   120 	 $user_selection,
       
   121 	 $count);
       
   122 
       
   123 #--------------------------------------------------------------------------------------------------
       
   124 #																				Main
       
   125 #--------------------------------------------------------------------------------------------------
       
   126 
       
   127 #**************************************************************************************************
       
   128 # Read commandline options.
       
   129 #**************************************************************************************************
       
   130 my $result = GetOptions('help'			=> \$param_help,						# Display help info
       
   131 												'command=s'    => \$param_command,			# Command to run
       
   132 												'dest=s' 		=> \$param_dest,					  # Destination directory
       
   133 												'all'				=> \$param_all,       			# Run all												
       
   134  												'noclean'  	=> \$param_noclean,    			# Dont run reallyclean
       
   135 												'nobuild'		=> \$param_nobuild, 		    # Dont run symbian build commands
       
   136 												'nostub'		=> \$param_nostub, 				  # Dont build stupbs												
       
   137 												'exe=s'     => \$param_exe,			        # Launch the exe specified.if nothing then epoc will be used
       
   138 												'summary=s' => \$param_overall_summay,	# Launch the exe specified.if nothing then epoc will be used
       
   139 												'version'   => \$param_version);				# Version Information
       
   140 
       
   141 #Test
       
   142 #my $mapped_drive = "\\\\Vagrp006\\groups5\\SP_IDO\\IPASDo_MSDo";
       
   143 #$results_destinationdir = "$mapped_drive\\Builds\\multimediasharing\\3.2\\NightlyBuilds\\2008-wk8\\18-Monday\\Log\\EUnitAndCTC";
       
   144 #exit 1;
       
   145 
       
   146 #**************************************************************************************************
       
   147 # Step 1 : Pre Cleanup.
       
   148 #**************************************************************************************************
       
   149 	run_system_command("del "."$eunit_destination_dir"."*.dll");  	
       
   150 	run_system_command("del "."$eunit_xml_file");  	
       
   151 
       
   152 #**************************************************************************************************
       
   153 # Step 2 : Check pre-conditions.
       
   154 #**************************************************************************************************
       
   155 	if (! -e $build_destination_dir."EUnitExeRunner.exe") 
       
   156 		{	
       
   157   	print "*** EUnit is not installed for this SDK ***\n"; 
       
   158   	exit 1;  
       
   159   	}
       
   160 
       
   161 #************************************************************************************************** 
       
   162 # Step 2 : Check command line parameters and configure if not present to default.
       
   163 #**************************************************************************************************
       
   164 	if(defined $param_overall_summay)
       
   165 		{
       
   166 		$overal_summary_file = 	$param_overall_summay ;
       
   167 		}
       
   168 	if ($param_command eq ('ctc'|'CTC'|'Ctc') )
       
   169 		{
       
   170 		$choice=1;
       
   171 		}
       
   172 	elsif ($param_command eq ('eu'|'EU'))
       
   173 		{
       
   174 		$choice=2;
       
   175 		}
       
   176 	else
       
   177 		{
       
   178 		usage();
       
   179 		}
       
   180 	$param_exe=$eunitApp if(!defined $param_exe);
       
   181 	if(defined $param_dest)
       
   182 		{
       
   183 		$results_destinationdir=$param_dest ;		
       
   184 		}
       
   185 	else
       
   186 		{
       
   187 		print "\n Note: No results destination directory specified. Results will be copied to $currentdir/\Eunit\n";	
       
   188 		}	
       
   189 	$results_destinationdir=~s/\//\\/g;
       
   190 	$results_destinationdir_log = "$results_destinationdir";# This is were logs are stored in nightly build env.
       
   191 	run_system_command("mkdir $results_destinationdir\\EUnitAndCTC") if (! -e "$results_destinationdir\\EUnitAndCTC");
       
   192 	$results_destinationdir="$results_destinationdir\\EUnitAndCTC";
       
   193 	$param_noclean=1 if(defined $param_nobuild);
       
   194 	$ENV{'CTC_DATA_PATH'}= "";	
       
   195 	run_system_command("bldmake bldfiles") if (!defined $param_nobuild);
       
   196 
       
   197 #************************************************************************************************** 
       
   198 # Step 3 : Display subsystems to user. So he can make a choice for which one to compile
       
   199 #          if command line parameter -all specified then it will not be shown.
       
   200 #************************************************************************************************** 
       
   201 	display_sybsystems(); 
       
   202 	if(defined $param_all)
       
   203 		{
       
   204 		print "\nOptions -all specified.Building all components \n ";
       
   205 		$user_selection=0;
       
   206 		}
       
   207 	else 
       
   208 		{	
       
   209 		print "\t Options selected : ";
       
   210 		$user_selection = <STDIN>;
       
   211 		chomp ($user_selection);
       
   212 		exit 0 if $user_selection =~ /^[Qq]/;
       
   213 		}
       
   214 
       
   215 #************************************************************************************************** 	
       
   216 # Step 4 : Build	subsystems.
       
   217 #************************************************************************************************** 
       
   218 	if(!$param_nostub)
       
   219 		{	
       
   220 		print "\n *** Building unittest stubs  ***\n ";
       
   221 		run_system_command("abld reallyclean winscw udeb");
       
   222 		run_system_command("abld build winscw udeb");
       
   223 		print "\n *** End of building stubs ***\n ";	
       
   224 	}
       
   225 	if (!defined $param_nobuild)
       
   226 		{
       
   227 		print "\n *** Building test components ***\n";
       
   228 		if($choice==1)
       
   229 			{			
       
   230 			$ENV{'CTC_DATA_PATH'}= $currentdir;	
       
   231 			build_user_selected("$ctcCommandPart1  $coverageSymbols $ctcIgnoredPart1 $ctcIgnoredPart2 $ctcCommandPart2");		
       
   232 			}
       
   233   	elsif($choice==2)
       
   234   		{
       
   235 			build_user_selected("abld test build winscw udeb");
       
   236 			}
       
   237 		print "\n *** End of Building test components ***\n ";
       
   238 		}	
       
   239 	
       
   240 #************************************************************************************************** 		
       
   241 # Step 5 : Run EunitRunner.exe .
       
   242 #************************************************************************************************** 	
       
   243 	print "\n *** Running EUnit with selected subsystems ***\n";	
       
   244 	chomp(@dll_filenames);
       
   245 	if( scalar @dll_filenames eq 0 )
       
   246 		{
       
   247 		print "Can not find dll names automatically.Using default configured values\n";
       
   248 		@dll_filenames = @default_dll_filenames;
       
   249 		}
       
   250 	copy_dlls(); # copy dlls to eunit directory
       
   251 	if($choice==1)
       
   252 		{  
       
   253 		run_system_command("$param_exe "."$eunitParams");# Run without alloc failure  		   
       
   254 		#run_system_command("$param_exe "."$eunitParams"."$eunitParams2");# Run with alloc failure   		   
       
   255 		}
       
   256 	elsif ($choice==2)
       
   257 		{		
       
   258 		run_system_command("$param_exe "."$eunitParams");  		   
       
   259 		}
       
   260 
       
   261 #************************************************************************************************** 		 
       
   262 # Step 6 : Print Results.
       
   263 #************************************************************************************************** 		
       
   264 	print "\n *** Printing Reports ***\n";	
       
   265 	if($choice==1)
       
   266 		{	
       
   267 		run_system_command("ctcpost $coverageSymbols $coverageDat -p $coverageProfile -T 70");		
       
   268 		run_system_command("ctc2html -i $coverageProfile -t 70 -nsb");	
       
   269 		run_system_command("xcopy  /R/F/Y/I CTCHTML $results_destinationdir\\CTCHTML");	
       
   270 		print_overall_summary_ctc();		
       
   271 		}
       
   272 	elsif($choice==2)
       
   273 		{	
       
   274 		print_overall_summary_error();# Mainly needed for nightly build env and for eunit.		
       
   275 		print_eunit_html_report();			
       
   276 		print_overall_summary_eunit();		
       
   277 		run_system_command("copy $eunit_xml_file $results_destinationdir\\$eunit_xml_file_name");		
       
   278 		run_system_command("copy $unittest_result_file $results_destinationdir\\$unittest_result_file");		
       
   279 		}
       
   280 #This reports other script errors which might have harmed the flow of execution.
       
   281 print_overall_summary_script_error();
       
   282 
       
   283 #************************************************************************************************** 		 
       
   284 # Step 7 : Post Cleanup.
       
   285 #************************************************************************************************** 		 
       
   286 	$ENV{'CTC_DATA_PATH'}= "";	
       
   287 	run_system_command("del "."$eunit_destination_dir"."*.dll");  	
       
   288 	run_system_command("del "."$eunit_xml_file");  	
       
   289 	print "\n *** DONE ***\n";
       
   290 
       
   291 #---------------------------------------Main Ends--------------------------------------------------
       
   292 
       
   293 #--------------------------------------------------------------------------------------------------
       
   294 # This sub routine displays all the subsystems to the user.
       
   295 #--------------------------------------------------------------------------------------------------
       
   296 sub display_sybsystems 
       
   297 	{  
       
   298   get_subsystems();
       
   299   if(scalar @subsystems==0)
       
   300   	{
       
   301   	print "Can't find subsystem name automatically.Using default configured values\n" ;
       
   302   	@subsystems = @default_subsystems;  	
       
   303   	}  
       
   304   print "\n\tPlease choose an option listed below \n";   
       
   305   print "\n\tenter +/- to build backward or forward \n";   
       
   306   print "\t\t0.To build all \n";    	
       
   307   $count=1;
       
   308   foreach(@subsystems)
       
   309   	{   	
       
   310    	print "\t\t".$count++. "." .$_."\n";   	
       
   311    	}
       
   312   print "\t\tq.Exit \n";   
       
   313   }
       
   314 
       
   315 #--------------------------------------------------------------------------------------------------
       
   316 # Runs abld commands for the user selected choice.
       
   317 #--------------------------------------------------------------------------------------------------
       
   318 sub build_user_selected 
       
   319 	{	 	
       
   320  	if($user_selection==0)
       
   321  		{  
       
   322   	for($count=0;$count<@subsystems;$count++)
       
   323   		{
       
   324   		run_system_command("abld test reallyclean winscw udeb @subsystems[$count]");
       
   325   		run_system_command("@_[0] @subsystems[$count]");  		 
       
   326   		get_dll_names(@makefiles[$count]);  				  				  				 				  				
       
   327   		}  	
       
   328   	}  	  		  		 
       
   329 	elsif($user_selection=~/\+/)
       
   330 		{ 				 			
       
   331   	for($count=substr($user_selection,0,1)-1;$count<@subsystems;$count++)
       
   332   		{
       
   333   		run_system_command("abld test reallyclean winscw udeb @subsystems[$count]");
       
   334   		run_system_command("@_[0] @subsystems[$count]"); 		 
       
   335   		get_dll_names(@makefiles[$count]);  				  				  				 				  				
       
   336   		}
       
   337   	}
       
   338   elsif($user_selection=~/\-/)
       
   339   	{  		  
       
   340   	 for($count=0;$count<substr($user_selection,0,1);$count++)
       
   341   	 	{  				
       
   342   		run_system_command("abld test reallyclean winscw udeb @subsystems[$count]");
       
   343   		run_system_command("@_[0] @subsystems[$count]");  		  				
       
   344   		get_dll_names(@makefiles[$count]);  				  				  				
       
   345   		}
       
   346   	}  	 
       
   347    else
       
   348    	{
       
   349     $count=0;    		
       
   350   	while($count<length $user_selection)
       
   351   		{
       
   352   	  my $str = substr ($user_selection,$count,1); 
       
   353   		run_system_command("abld test reallyclean winscw udeb @subsystems[$str-1]");
       
   354   		run_system_command("@_[0] @subsystems[$str-1]");  		
       
   355   		get_dll_names(@makefiles[$str-1]);  				  				  				  				
       
   356   		$count++;  		  				
       
   357   		}
       
   358   	}  	  		  		  	
       
   359 	}
       
   360 	
       
   361 #--------------------------------------------------------------------------------------------------
       
   362 # Displays critical error which is used for debugging purpose.
       
   363 #--------------------------------------------------------------------------------------------------
       
   364 sub display_critical_error
       
   365 	{  
       
   366   print "\n ->ERROR OCCURED : "."$?"."\n"  if(!@_[0]);  
       
   367   print "\n ->ERROR OCCURED : ".@_[0]."\n" if(@_[0]);  	
       
   368   #exit 1;
       
   369   }
       
   370   
       
   371 #--------------------------------------------------------------------------------------------------
       
   372 # Calls system command and displays error in case.
       
   373 #--------------------------------------------------------------------------------------------------
       
   374 sub run_system_command
       
   375 	{  
       
   376 	print " \n -> Command : " .@_[0] ."\n";
       
   377 	system(@_[0]);	
       
   378 	push @gloabl_errors,"Error Occured for Command : @_[0] Error : $?" if($?!=0);
       
   379 	display_critical_error() if($?!=0);  
       
   380 	return $?;
       
   381 	}
       
   382 	
       
   383 #--------------------------------------------------------------------------------------------------
       
   384 # Prints Usage.
       
   385 #--------------------------------------------------------------------------------------------------
       
   386 sub usage	
       
   387 	{
       
   388 print<<ENDOFUSAGE;
       
   389  Usage :
       
   390       eunitrunner -command=ct|eu|mm -dest=resultdir	
       
   391         -ctc -> To run CTC.
       
   392         -eu -> To run EunitTestcases.
       
   393         -mm -> To run Manual Mode.Useful if you want to find the coverage inside your code.
       
   394         -resultdir->In where results will be copied.	
       
   395 		    		
       
   396      Also you can specify some optional flags to change the behaviour of the script.
       
   397        -all -> To run all subsystems.
       
   398        -sourcefiles -> To Select Source files for instrumentation
       
   399        -noclean -> Don't run reallyclean
       
   400        -nobuild -> Dont run symbian build commands
       
   401        -nostub	 -> Dont build stubs
       
   402        -nosdkinst-> Dont instrument sdk
       
   403 		
       
   404      Some miscellaneous Commands
       
   405        -version -> Version Information.
       
   406        -help -> Usage information.
       
   407 	
       
   408   Examples :
       
   409        eunitrunner -command=ctc
       
   410        eunitrunner -command=eu C:/temp/results
       
   411        eunitrunner -command=eu C:/temp/results -all
       
   412        eunitrunner -command=ctc C:/temp/results\ -sourcefiles -nobuild -noclean -nostub
       
   413        
       
   414   Note:This script should be run from where bld.inf file available
       
   415   Note:Also you must specify TEMP environmental variable.(By default this exists in All windows system)
       
   416 ENDOFUSAGE
       
   417 	exit 0;
       
   418 	}
       
   419 	
       
   420 #--------------------------------------------------------------------------------------------------
       
   421 # Runs abld to make makefile and parse makefile to get subsystems.
       
   422 #--------------------------------------------------------------------------------------------------
       
   423 sub	get_subsystems()
       
   424 	{	
       
   425 	#Testing prupose to check how abld test makefile command runs.
       
   426 	run_system_command("abld test makefile winscw -w");
       
   427 	
       
   428 	open WHATCMD, "abld test makefile winscw -w |";
       
   429 	my @temparray;
       
   430 	while(<WHATCMD>)
       
   431 		{
       
   432 		chomp;
       
   433 		my $makeFile = $_;			
       
   434 		if( $makeFile =~ /winscw$/i )
       
   435 			{
       
   436 			@temparray=split(/\.WINSCW/,$makeFile);			
       
   437 			@temparray=split(/\\/,@temparray[0]);			
       
   438 			push @subsystems,pop(@temparray);					
       
   439 			push @makefiles,$makeFile;
       
   440 			}
       
   441 		}
       
   442 	print "\n Makefiles = @makefiles\n";
       
   443 	print "\n Subsystems = @subsystems\n";
       
   444 	close WHATCMD;	
       
   445 	}
       
   446 	
       
   447 #--------------------------------------------------------------------------------------------------
       
   448 # Parses makefile to get source files. Useful if you want to run coverage for particular source file.
       
   449 #--------------------------------------------------------------------------------------------------
       
   450 sub get_source_files($)
       
   451 	{
       
   452 	open MAKE, @_[0] or die "Cant open $!";	
       
   453 	my @temparray;
       
   454 	while (<MAKE>)
       
   455 		{
       
   456 		my($line)=$_;						
       
   457 		if($line=~/(EPOCBLDUREL).*.\.o.*.:.*.\.cpp/)
       
   458 			{
       
   459 			if($line!~/INTERNAL|internal/)
       
   460 				{		
       
   461 				@temparray=split(/:/,$line);
       
   462 				@temparray=split(/\\/,@temparray[1]);					
       
   463 				push @sourcefiles,pop @temparray;						
       
   464 				}
       
   465 			}			
       
   466 		}
       
   467 	close MAKE;	
       
   468 	}
       
   469 	
       
   470 #--------------------------------------------------------------------------------------------------
       
   471 # Parses makefile to get dll names.
       
   472 #--------------------------------------------------------------------------------------------------
       
   473  sub get_dll_names($)
       
   474  	{ 	
       
   475 	open MAKE, @_[0] or die "Cant open $_ $!";		
       
   476 	my @temparray;
       
   477 	my $dll_name;
       
   478 	while (<MAKE>)
       
   479 		{
       
   480 		my($line)=$_;									
       
   481 		chomp($line);
       
   482 		if($line=~/Target.*.\.dll/)
       
   483 			{				
       
   484 			@temparray=split(/\s+/,$line);				
       
   485 			$dll_name=pop @temparray;								
       
   486 			chomp($dll_name);										
       
   487 			push @dll_filenames,$dll_name;
       
   488 			last;
       
   489 			} 
       
   490 		}
       
   491 	close MAKE;	
       
   492 	}
       
   493 	
       
   494 #--------------------------------------------------------------------------------------------------
       
   495 # Parses eunit result xml file and prints it as html file.
       
   496 #--------------------------------------------------------------------------------------------------
       
   497 sub print_eunit_html_report	
       
   498 	{
       
   499 	my $simple = XML::Simple->new();	
       
   500 	my $struct = eval {$simple->XMLin($eunit_xml_file, forcearray => 1,keyattr => [])};	
       
   501 	push @gloabl_errors,"Invalid XML document Error : $@" if($@);			
       
   502 	open(HTML_FILE, ">$unittest_result_file") ||(push @gloabl_errors,"Can not open $unittest_result_file for Eunit" and return);		
       
   503 	print HTML_FILE "<TABLE BORDER CELLSPACING=\"2\" CELLPADDING=\"2\" WIDTH=\"80%\">\n";		
       
   504 	print HTML_FILE "<CAPTION><H3><P ALIGN=Left>Overall Result:          Passed</H3></CAPTION>\n";										
       
   505 	print HTML_FILE "<tr>\n";	
       
   506 	print HTML_FILE "<th BGCOLOR=\"#CCCCCC\">Total TestCases</th>\n";
       
   507 	print HTML_FILE "<th BGCOLOR=\"#00FF00\">Total Passed</th>\n";
       
   508 	print HTML_FILE "<th BGCOLOR=\"#FF0000\">Total Failed</th>\n";
       
   509 	print HTML_FILE "</tr>\n";	
       
   510 	print HTML_FILE "<tr>\n";							
       
   511 	print HTML_FILE "<td><P ALIGN=Center>      </td>\n";
       
   512 	print HTML_FILE "<td><P ALIGN=Center>      </td>\n";
       
   513 	print HTML_FILE "<td><P ALIGN=Center>      </td>\n";
       
   514 	print HTML_FILE "</tr>\n";	
       
   515 	print HTML_FILE "</table>\n";
       
   516 	print HTML_FILE "                                                     <BR>";
       
   517 	
       
   518 	foreach my $dll(@{$struct->{dll}})
       
   519 		{
       
   520 	  my $dll_pass_count = 0;
       
   521 		foreach my $mtestsuite(@{$dll->{testsuite}})
       
   522 			{									
       
   523 			foreach my $testsuite(@{$mtestsuite->{testsuite}})
       
   524 				{				
       
   525 				my($testcount)=1;						
       
   526 				print HTML_FILE "<TABLE BORDER CELLSPACING=\"2\" CELLPADDING=\"2\" WIDTH=\"80%\">\n";
       
   527 				print HTML_FILE "<CAPTION><H3><P ALIGN=Left>$testsuite->{name}</H3></CAPTION>\n";						
       
   528 				print HTML_FILE "<tr>\n";	
       
   529 				print HTML_FILE "<th>No</th>\n";
       
   530 				print HTML_FILE "<th>Name</th>\n";
       
   531 				print HTML_FILE "<th>Class</th>\n";
       
   532 				print HTML_FILE "<th>Method</th>\n";
       
   533 				print HTML_FILE "<th>Type</th>\n";
       
   534 				print HTML_FILE "<th>Result</th>\n";
       
   535 				print HTML_FILE "</tr>\n";					
       
   536 				foreach my $testcase(@{$testsuite->{testcase}})
       
   537 					{											
       
   538 					print HTML_FILE "<tr>\n";							
       
   539 					print HTML_FILE "<td BGCOLOR=\"#CCCCCC\"><P ALIGN=Left>$testcount</td>\n";
       
   540 					print HTML_FILE "<td BGCOLOR=\"#CCCCCC\"><P ALIGN=Left>$testcase->{name}</td>\n";
       
   541 					print HTML_FILE "<td BGCOLOR=\"#CCCCCC\"><P ALIGN=left>$testcase->{class}</td>\n";
       
   542 					print HTML_FILE "<td BGCOLOR=\"#CCCCCC\"><P ALIGN=Left>$testcase->{method}</td>\n";
       
   543 					print HTML_FILE "<td BGCOLOR=\"#CCCCCC\"><P ALIGN=Left>$testcase->{type}</td>\n";
       
   544 					if($testcase->{result}->[0]->{status} eq "OK")
       
   545 						{
       
   546 						print HTML_FILE "<TD BGCOLOR=\"#00FF00\"><P ALIGN=Left>PASS</TD>\n";		
       
   547 						$eunit_total_pass_count++;										
       
   548 						$dll_pass_count++ ;
       
   549 						}
       
   550 					else
       
   551 						{
       
   552 						print HTML_FILE "<TD BGCOLOR=\"#FF0000\"><P ALIGN=Left>FAIL</TD>\n";
       
   553 						$eunit_total_fail_count++;						
       
   554 						}
       
   555 					print HTML_FILE "</tr>\n";
       
   556 					$testcount++;						
       
   557 					}
       
   558 				print HTML_FILE "</table>\n";
       
   559 				print HTML_FILE "<BR>\n";				
       
   560 				}			
       
   561 			push @eunit_testsuite_name,$mtestsuite->{name};			
       
   562 			push @eunit_testsuite_total_testcase,$mtestsuite->{size};
       
   563 			push @eunit_testsuite_pass_count,$dll_pass_count;
       
   564 			}		
       
   565 		}	
       
   566 	print HTML_FILE "</body><br></html>";	
       
   567 	$eunit_total_count=$eunit_total_fail_count+$eunit_total_pass_count;
       
   568 	seek HTML_FILE,301,0;
       
   569 	print HTML_FILE "$eunit_total_count";
       
   570 	seek HTML_FILE,334,0;
       
   571 	print HTML_FILE "$eunit_total_pass_count";
       
   572 	seek HTML_FILE,367,0;
       
   573 	print HTML_FILE "$eunit_total_fail_count";
       
   574 	if($eunit_total_pass_count>0 && $eunit_total_count>0)
       
   575 		{
       
   576 		$eunit_total_pass_percent=sprintf "%.2f", (($eunit_total_pass_count/$eunit_total_count)*100);	
       
   577 		}
       
   578 	else
       
   579 		{
       
   580 		$eunit_total_pass_percent=sprintf "%.2f","0.00";	
       
   581 		}
       
   582 	seek HTML_FILE,103,0;
       
   583 	print HTML_FILE "$eunit_total_pass_percent%";		
       
   584 	close (HTML_FILE);                   
       
   585 	}
       
   586  
       
   587  #--------------------------------------------------------------------------------------------------
       
   588  # Prints overall summary in file specified in command line argument.
       
   589  #--------------------------------------------------------------------------------------------------
       
   590  sub print_overall_summary_eunit 
       
   591  	{
       
   592 	open OVER_ALL_SUMMARY, ">>$overal_summary_file" or (push @gloabl_errors,"Can not open $overal_summary_file for Eunit" and return); 			
       
   593 	print OVER_ALL_SUMMARY "<h1>Eunit Summary</h1>\n ";		
       
   594 	print OVER_ALL_SUMMARY "<table cellspacing=\"0\"> \n ";
       
   595 	print OVER_ALL_SUMMARY "<tr><td class=\"black\"><strong>PassRate&nbsp;%</strong>&nbsp;</td> \n ";
       
   596 	print OVER_ALL_SUMMARY "<td class=\"black\"><strong>-</strong></td><td class=\"black\">&nbsp;<strong>Pass/&nbsp;all</strong>&nbsp;</td> \n ";
       
   597 	print OVER_ALL_SUMMARY "<td width=\"115\">&nbsp;</td><td class=\"black\"><strong>Subsystem</strong></td></tr> \n ";
       
   598 	print OVER_ALL_SUMMARY "<tr><td colspan=\"5\"><hr width=\"100%\"></td></tr> \n ";
       
   599 	my($count)= 0;
       
   600 	foreach $_(@eunit_testsuite_name)
       
   601 		{
       
   602 		my $dll_pass_percent = 0;
       
   603 		my $dll_fail_percent = 0;
       
   604 		my $dll_name = @eunit_testsuite_name[$count];
       
   605 		my $dll_total = @eunit_testsuite_total_testcase[$count];
       
   606 		my $dll_pass = @eunit_testsuite_pass_count[$count];
       
   607 		if($dll_total>0 && $dll_pass>0)
       
   608 			{
       
   609 			$dll_pass_percent=sprintf "%.2f", (($dll_pass/$dll_total)*100);	
       
   610 			}
       
   611 		else
       
   612 			{
       
   613 			$dll_pass_percent=sprintf "%.2f","0.00 \n ";	
       
   614 			}		
       
   615 		$dll_fail_percent = 100 - $dll_pass_percent;
       
   616 		print OVER_ALL_SUMMARY "<tr> \n ";
       
   617 		print OVER_ALL_SUMMARY "<td align=\"right\" class=\"blue\">$dll_pass_percent&nbsp;%&nbsp;</td><td align=\"right\" class=\"blue\">&nbsp;</td> \n ";
       
   618 		print OVER_ALL_SUMMARY "<td align=\"right\" class=\"blue\">&nbsp;$dll_pass/$dll_total&nbsp;</td> \n ";
       
   619 		print OVER_ALL_SUMMARY "<td width=\"115\"><img border=\"1\" src=\"blue.gif\" width=\"$dll_pass_percent\" height=\"5\" alt=\"\"><img border=\"1\" src=\"red.gif\" width=\"$dll_fail_percent\" height=\"5\" alt=\"\"></td> \n ";
       
   620 		print OVER_ALL_SUMMARY "<td><a class=\"blue\">$dll_name</a></td> \n ";
       
   621 		print OVER_ALL_SUMMARY "</tr> \n ";
       
   622 		$count ++;
       
   623 		}	
       
   624 	print OVER_ALL_SUMMARY "<tr><td colspan=\"5\"><hr width=\"100%\"></td></tr> \n ";
       
   625 	print OVER_ALL_SUMMARY "<tr><td align=\"right\" class=\"black\"><strong>$eunit_total_pass_percent&nbsp;%</strong>&nbsp;</td> \n ";
       
   626 	print OVER_ALL_SUMMARY "<td align=\"right\" class=\"black\"><strong>&nbsp;</strong></td> \n ";
       
   627 	print OVER_ALL_SUMMARY "<td align=\"right\" class=\"black\"><strong>&nbsp;$eunit_total_pass_count/$eunit_total_count</strong>&nbsp;</td> \n ";
       
   628 	my $total_eunit_fail_percent = 100 - $eunit_total_pass_percent;
       
   629 	print OVER_ALL_SUMMARY "<td width=\"115\"><img border=\"1\" src=\"blue.gif\" width=\"$eunit_total_pass_percent\" height=\"5\" alt=\"\"><img border=\"1\" src=\"red.gif\" width=\"$total_eunit_fail_percent\" height=\"5\" alt=\"\"></td> \n ";
       
   630 	print OVER_ALL_SUMMARY "<td class=\"black\"><strong>OVERALL</strong></td></tr> \n ";
       
   631 	print OVER_ALL_SUMMARY "</table><br> \n ";	
       
   632 	print OVER_ALL_SUMMARY "<a href=\"$results_destinationdir\\$unittest_result_file\">View compleate results : $results_destinationdir\\$unittest_result_file</a> \n ";	
       
   633 	close OVER_ALL_SUMMARY;
       
   634   }
       
   635 
       
   636 #--------------------------------------------------------------------------------------------------
       
   637 #Prints overall summary of CTC in file specified in command line argument.
       
   638 #--------------------------------------------------------------------------------------------------
       
   639 sub print_overall_summary_ctc
       
   640  	{
       
   641  	
       
   642 	open OVER_ALL_SUMMARY, ">>$overal_summary_file" or (push @gloabl_errors,"Can not open $overal_summary_file for CTC \n " and return );
       
   643   open CTC_RESULT,"$ctc_result_file";
       
   644  	@lines = <CTC_RESULT>;
       
   645  	print OVER_ALL_SUMMARY "<h1>CTC Summary</h1>\n ";	 	
       
   646  	print OVER_ALL_SUMMARY "<table cellspacing=\"0\"> \n";
       
   647   print OVER_ALL_SUMMARY "<tr><td class=\"black\"><strong>TER&nbsp;%</strong>&nbsp;</td>\n";
       
   648   print OVER_ALL_SUMMARY "<td class=\"black\"><strong>-</strong></td><td class=\"black\">&nbsp;<strong>covered/&nbsp;all</strong>&nbsp;</td>\n";
       
   649 	print OVER_ALL_SUMMARY "<td width=\"115\">&nbsp;</td><td class=\"black\"><strong>Directory</strong></td></tr>\n";	
       
   650  	foreach $_(@lines) 
       
   651  		{
       
   652  		if ($_=~/hr width=/)
       
   653  			{
       
   654  			print OVER_ALL_SUMMARY $_;
       
   655  			} 		
       
   656  		if ($_=~/img border=/)
       
   657  			{ 		 				
       
   658  			print OVER_ALL_SUMMARY $_;
       
   659  			}
       
   660  		}  
       
   661  	print OVER_ALL_SUMMARY "</table><br>\n";
       
   662  	print OVER_ALL_SUMMARY "<a href=\"$results_destinationdir\\CTCHTML\\index.html\">View compleate results : $results_destinationdir\\CTCHTML\\index.html</a> \n ";	
       
   663  	close CTC_RESULT;
       
   664  	close OVER_ALL_SUMMARY;
       
   665 }
       
   666 
       
   667 #--------------------------------------------------------------------------------------------------
       
   668 #Check uncompiled subsystems by checking the dll names.
       
   669 #--------------------------------------------------------------------------------------------------
       
   670 sub copy_dlls
       
   671  	{ 	
       
   672  	my $error = 0;
       
   673  foreach my $dll(@dll_filenames) 
       
   674  		{
       
   675  		$error = run_system_command("copy ".$build_destination_dir.$dll." ".$eunit_destination_dir.$dll);  
       
   676  		push @uncompiled_sub_systems,$dll if($error!=0)
       
   677  	  } 			
       
   678 	}
       
   679 
       
   680 #--------------------------------------------------------------------------------------------------
       
   681 # Prints overall error summary if any compilation errors happen.
       
   682 #--------------------------------------------------------------------------------------------------
       
   683  sub print_overall_summary_error 
       
   684  	{ 	
       
   685  	open OVER_ALL_SUMMARY, ">>$overal_summary_file" or (push @gloabl_errors,"Can not open $overal_summary_file for Eunit" and return) ;
       
   686  	if (scalar @uncompiled_sub_systems != 0)
       
   687  		{		
       
   688 		print OVER_ALL_SUMMARY "<h1>Compilation Errors</h1>\n ";		
       
   689 		my $count = 1;
       
   690 		print OVER_ALL_SUMMARY "<h3>Following dll's were not found. Possibly because of build errors! \n</h3>";
       
   691 		foreach $_(@uncompiled_sub_systems)
       
   692 			{		
       
   693 			print OVER_ALL_SUMMARY "<FONT COLOR=\"#FF0000\"><h4>$count. $_</h4></FONT>\n";
       
   694 			$count++;		
       
   695 			}	
       
   696 		print OVER_ALL_SUMMARY "<a href=\"$results_destinationdir_log\\$unittest_log_file\">View Error details : $results_destinationdir_log\\$unittest_log_file</a> \n ";	
       
   697 	 }	
       
   698 	close OVER_ALL_SUMMARY;
       
   699   }
       
   700   
       
   701  #--------------------------------------------------------------------------------------------------
       
   702 # Prints overall error summary if any compilation errors happen.
       
   703 #--------------------------------------------------------------------------------------------------
       
   704  sub print_overall_summary_script_error 
       
   705  	{ 	
       
   706  	open OVER_ALL_SUMMARY, ">>$overal_summary_file" or return ;
       
   707  	if(scalar @gloabl_errors)
       
   708 		{			
       
   709 		print OVER_ALL_SUMMARY "<h1>Execution Errors</h1>\n ";	
       
   710 		my $count = 1;
       
   711 		foreach $_(@gloabl_errors)
       
   712 			{
       
   713 			print OVER_ALL_SUMMARY "<h3>$count.$_</h3>\n";
       
   714 			$count++;		
       
   715 			}
       
   716 		print OVER_ALL_SUMMARY "<a href=\"$results_destinationdir_log\\$unittest_log_file\">View Error details : $results_destinationdir_log\\$unittest_log_file</a> \n ";	
       
   717 		}
       
   718 	close OVER_ALL_SUMMARY;
       
   719   }
       
   720   
       
   721 # End of file.