Catchup merge
authorMattD <mattd@symbian.org>
Tue, 26 Jan 2010 15:39:24 +0000
changeset 855 9d6a5309852c
parent 854 c0e6dd77e67f (current diff)
parent 841 2958b22b1b70 (diff)
child 856 0e553fdaa218
Catchup merge
--- a/.hgtags	Mon Jan 25 15:15:37 2010 +0000
+++ b/.hgtags	Tue Jan 26 15:39:24 2010 +0000
@@ -9,3 +9,4 @@
 e13acd883fbe11620a838de22ed6421e8b8ada56 PDK_2.0.1
 b9c988316957ef97c64cc53a9731f8754966755e PDK_3.0.d
 2a9e6403efaf2ab5e2e5e689b762f3617eeeee4f PDK_2.0.2
+a1ebf7f8e66f1b8fc44ccf78ad8a90faf2d6969a PDK_3.0.e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/test/pckg_status/database/example/package_test_status.xml	Tue Jan 26 15:39:24 2010 +0000
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE package SYSTEM "package_test_status.dtd">
+<!-- This is the xml file used for the package tests status -->
+
+<!-- is the next line necessary??????? -->
+<!-- 
+<project name="PACKAGES_STATUS" xmlns:hlm="http://www.nokia.com/helium">
+-->
+
+<package>
+ <pckgname> kernelhwsrv </pckgname>
+ <pckg_id> 1 </pckg_id>
+ <domain type="OS_Base_Services"/>
+ <owner>
+  <surname> Imhofe </surname>
+  <firstname> John  </firstname>
+  <company> Nokia </company>
+  <city> London </city>
+  <country> UK </country>
+  <email> john.imhofe@nokia.com </email>
+ </owner>
+ <location>
+  <license type="oss" />
+  <branch type="MCL" />
+  <repository> http://developer.symbian.org/oss/MCL/sf/os/kernelhwsrv </repository>
+ </location>
+ <testable>
+  <suite>
+   <test_level type="package" />
+   <test_type type="tef" />
+   <suite_type type="smoke_test" />
+   <suite_type type="sanity_test" />
+  </suite>
+  <builditem>
+   <build_type type="test_build"/>
+   <bldinf_location> sf\os\kernelhwsrv\eka\generic.inf </bldinf_location>
+   <pckg_def_xml_loc> sf\os\kernelhwsrv\package_definition.xml </pckg_def_xml_loc>
+   <pckg_test_def_xml_loc> sf\os\kernelhwsrv\package_definition_test.xml </pckg_test_def_xml_loc>
+  </builditem>
+  <mapping>
+   <src> ? </src>
+   <dest> ? </dest>
+  </mapping>
+  <run>
+   <cmd> ? </cmd>
+   <param> ? </param>
+  </run>
+  </testable> 
+</package>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/test/pckg_status/database/package_test_status.dtd	Tue Jan 26 15:39:24 2010 +0000
@@ -0,0 +1,47 @@
+<!-- This is the template used to fill the package test status for a package -->
+
+<!-- Root for package -->
+<!ELEMENT package (domain,owner,location,testable*)>
+<!ATTLIST package
+ pckgname CDATA #REQUIRED
+ pckg_id CDATA #REQUIRED>
+<!ELEMENT domain (#PCDATA)>
+ <!ATTLIST domain type (Base_OS_Serivices|Data_Communications|Device_Connectivity|Device_Management|Location|Multimedia|Multimedia_Apss|Personal_Comms|Productivity|Runtimes_and_Web|Security|Tools|User_Interface|undefined) "undefined">
+<!-- owner is child of package -->
+<!ELEMENT owner (surname,firstname,company,city,country,email)>
+<!ELEMENT surname (#PCDATA)>
+<!ELEMENT firstname (#PCDATA)>
+<!ELEMENT company (#PCDATA)>
+<!ELEMENT city (#PCDATA)>
+<!ELEMENT country (#PCDATA)>
+<!ELEMENT email (#PCDATA)>
+<!-- location  is child of package-->
+<!ELEMENT location (license,branch,repository)>
+<!ATTLIST license type (oss|sfl|rnd|undefined) "undefined">
+ <!ATTLIST branch type (MCL|RCL_1|FCL|undefined) "undefined">
+<!ELEMENT repository (#PCDATA)>
+<!-- testable is child of package -->
+<!ELEMENT testable (suite,builditem*,mapping,run)>
+<!-- suite is a child of testable -->
+<!ELEMENT suite (test_level*,test_type,suite_type*)>
+<!-- test_level: Platform (aka system test) or Package -->
+<!ATTLIST test_level type (platform|package) "package">
+<!-- test_type: stif, tef or rtest (maybe MTF???) -->
+<!ATTLIST test_type type (stif|tef|rtest|undefined) "undefined">
+<!-- suite_type: Only one at the time smoketest or sanity, both of them are part of the regression and we can have one or both ticked for a test suite -->
+<!ATTLIST suite_type type (smoketest|sanitytest|regressiontest) "regressiontest">
+<!-- builditem is a child of testable -->
+<!ELEMENT builditem (build_type,bldinf_location,pckg_def_xml_loc,pckg_test_def_xml_loc)>
+<!-- build_type: production or test -->
+<!ATTLIST build_type type (production_build|test_build|undefined) "undefined">
+<!ELEMENT bldinf_location (#PCDATA)>
+<!ELEMENT pckg_def_xml_loc (#PCDATA)>
+<!ELEMENT pckg_test_def_xml_loc (#PCDATA)>
+<!-- mapping is a child of testable src for where the file come from and dest where the file will be in ROM -->
+<!ELEMENT mapping (src,dest)>
+<!ELEMENT src (#PCDATA)>
+<!ELEMENT dest (#PCDATA)>
+<!-- run is a child of testable -->
+<!ELEMENT run (cmd,param+)>
+<!ELEMENT cmd (#PCDATA)>
+<!ELEMENT param (#PCDATA)>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/test/pckg_status/scripts/check_all_pckg_test_status.pl	Tue Jan 26 15:39:24 2010 +0000
@@ -0,0 +1,445 @@
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+#
+# Script name: check_all_pckg_test_status.pl
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+#
+# Contributors:
+# Arnaud Lenoir <arnaudl@symbian.org>
+#
+# Created 30/11/2009
+#
+# Description:
+# Task 286 - Package test status prep - Compile a global view for all packages that we want to analyse
+#
+# Parameters passed:
+#	Param1: Path to the file containing the directories to check for test status
+#	Param2: Path to the directory containing the source code to analyse (generate a file)
+#	Param3: Path to the directory where DB will be published
+
+# Modules necessary to run this script
+use Getopt::Long;
+use strict;
+use Text::CSV;
+
+# Parameters passed to this script
+my $help;
+my $source_path_to_analyse;
+my $dirs_file_path_to_analyse;
+my $source_csv_path_to_analyse;
+my $publication_directory_path;
+my $pattern_file_path;
+
+# Variables
+my @tab_package_extraction;
+my @tab_package_extraction_S2;
+my @tab_package_extraction_S3;
+
+my $system_cmd;
+
+# Constantes declaration
+my $default_publication_directory_path = "\.\\results";
+my $default_pattern_file_path = ".\\pckg_test_status_patterns.csv";
+my $pckg_dir_paths_file_name = "pckg_test_status_paths.txt";
+my $pckg_dir_paths_file_name_S2 = "pckg_test_status_paths_S2.txt";
+my $pckg_dir_paths_file_name_S3 = "pckg_test_status_paths_S3.txt";
+my $all_pckgs_from_source_csv= "all_pckgs_from_source_csv.txt";
+my $pckg_definition_pattern = "package_definition*.xml";
+my $pckg_definition_pattern_S2 = "package_definition.xml";
+my $pckg_definition_pattern_S3 = "package_definition_*.xml";
+my $pckg_definition_extraction_pattern = "(^[\\w\\W]+)\\package_definition";
+my $csv_status_file_name = "packages_tests_supported_status.csv";
+
+my $nb_arg_passed = scalar(@ARGV);
+if(!$nb_arg_passed)
+{
+	print "No arguments/parameters passed then print help!\n";
+	helpme();
+}
+
+my %optmap = (  'source_path_to_analyse' => \$source_path_to_analyse,
+			    'dirs_file_path_to_analyse' => \$dirs_file_path_to_analyse,
+			    'publication_directory_path' => \$publication_directory_path,
+				'source_csv_path_to_analyse' => \$source_csv_path_to_analyse,
+			    'pattern_file_path' => \$pattern_file_path,
+                'help' => \$help);
+
+GetOptions(\%optmap,
+		  'source_path_to_analyse=s',
+		  'dirs_file_path_to_analyse=s',
+		  'publication_directory_path=s',
+		  'source_csv_path_to_analyse=s',
+		  'pattern_file_path=s',
+          'help');
+
+print "The value for help is: <$help>\n";
+print "source_path_to_analyse: <$source_path_to_analyse>\n";
+print "dirs_file_path_to_analyse: <$dirs_file_path_to_analyse>\n";
+print "publication_directory_path: <$publication_directory_path>\n";
+print "source_csv_path_to_analyse: <$source_csv_path_to_analyse>\n";
+print "pattern_file_path: <$pattern_file_path>\n";
+
+if ($help)
+{
+	print "We want to print the help\n";
+	helpme();
+}
+else
+{
+	print "\nIt's from here that the real work starts!\n";
+}
+
+# Check if we need default values for some of the parameters
+# Publication directory
+if (!defined($publication_directory_path))
+{
+	print "No publication_directory_path passed as argument, therefore use default path\n";
+	$publication_directory_path = $default_publication_directory_path;
+	print "publication_directory_path = <$publication_directory_path>\n";
+}
+# Check if we have a directory use for publishing. If not create it
+print "Check if $publication_directory_path exist or not!\n";
+if (!(-d $publication_directory_path))
+{
+	print "The directory $publication_directory_path, doesn't exist, therefore we create it\n";
+	$system_cmd = "mkdir $publication_directory_path";	
+	print "Exec: $system_cmd\n";
+	system($system_cmd);
+}
+
+# We are going to packages type of tests supported in a csv file and before to do that we are going to make sure that if a file exist, then we rename it.
+# File will be renamed before .csv with date & time in the format:
+# year-month-day@hour-minute
+# Eg: packages_tests_supported_status-2009-12-11@10-57.csv
+
+my $csv_status_file_path = "$publication_directory_path\\$csv_status_file_name";
+print "The full path for the csv packages tests status file is: $csv_status_file_path\n";
+
+if(-f $csv_status_file_path)
+{
+	print "the file exists, we need to rename it to allow a new file to be created with new data\n";
+	my $date;
+	my $time;
+	
+	open (GETTIME,"time /t |");
+	$time = <GETTIME>;
+	chomp($time);
+	
+	open (GETDATE,"date /t |");
+	$date = <GETDATE>;
+	chomp($date);
+	
+	print "date is <$date>\n";
+	print "time is <$time>\n";
+	
+	$time =~ s/:/-/g;
+	
+	$date =~ m~([0-9]+)\/([0-9]+)\/([0-9]+)~;
+	print "$3-$2-$1\n";
+	$date = "$3-$2-$1";
+	
+	print "date is <$date>\n";
+	print "time is <$time>\n";
+
+	my $csv_status_file_path_renamed = $csv_status_file_name;
+	print "Current file name: $csv_status_file_path_renamed\n";	
+	$csv_status_file_path_renamed =~ s/\.csv/\-$date\@$time.csv/;
+	print "Renamed file name: $csv_status_file_path_renamed\n";
+
+	# Rename file to be saved and to use new one to work with.
+	$system_cmd = "rename $csv_status_file_path $csv_status_file_path_renamed";	
+	print "Exec: $system_cmd\n";
+	system($system_cmd);
+}
+else
+{
+	print "The file doesn't exist, we are starting from scratch! Nothing else to do!\n";
+}
+
+# Define Pacakge list & path by searching for "package_definition*.xml" file.
+# The directory having that file is considerated as the short package name.
+# Store list in a file? DB? or table?
+
+if (defined($source_csv_path_to_analyse))
+{
+	print "We have been given the path to a source.csv file to extract all the packages to be used\n";
+	if(!(-f $source_csv_path_to_analyse))
+	{
+		print "The file $source_csv_path_to_analyse doesn't exist! Please provide a new path!";
+		exit(0);
+	}
+	open (CSVFILE, "$source_csv_path_to_analyse");
+	
+	my @local_tab = <CSVFILE>;
+	
+	# Need to discard the first line of the file
+	print "local_tab[0]=<$local_tab[0]>\n";
+	$local_tab[0] = undef;
+	print "local_tab[0]=<$local_tab[0]> has been removed as garbage for us\n";
+	
+	my $nb_packgs_in_csv = 0;
+
+	# Extract package names
+	foreach my $line (@local_tab)
+	{
+		#Typical line: <E:\hgcache\mercurial_master_prod/sfl/MCL/sf/app/contentcontrol/,/sf/app/contentcontrol,changeset,8cb47bc684d4,layers.sysdef.xml>
+		#print "Line from file is: $line\n";
+		#if($line =~ m;,(/sf/[\w\/_]+),;) # Use for the second column of the csv file
+		if($line =~ m;([\w\W]+)\/,\/sf;) # Use for the first column of the csv file
+		{
+			#print "We have detected $1\n";
+			my $transform = $1;
+			$transform =~ s/\//\\/ig;
+			#print "transformed to: $transform\n";
+			$tab_package_extraction[$nb_packgs_in_csv++] = $transform;
+		}
+	}
+	print "# of packages is: <$nb_packgs_in_csv>\n";
+	
+	close (CSVFILE);
+	
+	# Save data in a file to be reused later on.
+	my $file2use = "$publication_directory_path\\$all_pckgs_from_source_csv";
+	print "File to open=$file2use\n";
+	
+	open(SAVINGDATAFILE,">$file2use");
+	foreach my $val2save (@tab_package_extraction)
+	{
+		print SAVINGDATAFILE "$val2save\n";
+	}
+	close(SAVINGDATAFILE);
+}
+elsif (defined($dirs_file_path_to_analyse))
+{
+	print "Use the file <$dirs_file_path_to_analyse> that contains the directories to scan\n";
+	
+	open(FILEWITHPCKGPATHS,"$dirs_file_path_to_analyse");
+	my $count_line = 0;
+	
+	while(<FILEWITHPCKGPATHS>)
+	{
+		#print "$_";
+		$tab_package_extraction[$count_line] = $_;
+		#print "tab_package_extraction[$count_line]=$tab_package_extraction[$count_line]\n";
+		$count_line++;
+	}
+	my $total_pckg_found = scalar(@tab_package_extraction);
+	print "nb of packages found in $dirs_file_path_to_analyse is: <$total_pckg_found>\n";
+	close(FILEWITHPCKGPATHS);
+}
+elsif (defined($source_path_to_analyse))
+{
+	print "Use the directory \\sf that contains the code to scan\n";
+	generate_file_with_path_2_pckgs($source_path_to_analyse);
+}
+else
+{
+	print "No parameters <source_path_to_analyse> or <dirs_file_path_to_analyse> or <source_csv_path_to_analyse> passed, therefore can't work\n";
+	helpme();
+}
+
+# Patterns file used
+if (!defined($pattern_file_path))
+{
+	print "No specific patterns file has been passed as parameters, therefore we use default patterns file\n";
+	$pattern_file_path = $default_pattern_file_path;
+	print "pattern_file_path = <$pattern_file_path>\n";
+}
+# End check if default values are necessary
+
+print "\n\n";
+
+# Call script to extract test data from each packge.
+# foreach package in the list, call check_pckg_test_status.pl script with right parameters
+# check_pckg_test_status.pl will automatically fill the DB with the right info	
+
+# May need to remove trailing \n using chomp($path2passed);
+foreach my $path2passed (@tab_package_extraction)
+{
+	#print "Remove trailing \\n for each line\n";
+	chomp($path2passed);
+	#print "The path we pass is: <$path2passed>\n";
+	
+	$system_cmd = "check_pckg_test_status.pl --package_path=$path2passed --pattern_file_path=$pattern_file_path --publication_directory_path=$publication_directory_path";	
+	print "Exec: $system_cmd\n";
+	system($system_cmd);
+}
+
+# Create / update the global DB files.
+# Can be adding all the smaller files generated to a bigger unigue file
+# Use XSLT using all the xml files generated?
+
+# End of the script
+exit(0);
+
+
+# Functions section
+
+# If no parameters entered or help selected, display help
+sub helpme
+{
+	print "\nfct: helpme\n";
+	print "check_all_pckg_test_status.pl\n";
+	print "Usage:\n";
+	print "check_all_pckg_test_status.pl --help\n";
+	print "check_all_pckg_test_status.pl --dirs_file_path_to_analyse=I:\\Task-286\\Scripts\\pckg_test_status_paths.txt --publication_directory_path=.\\result\n";
+	print "check_all_pckg_test_status.pl --source_path_to_analyse=I:\\sf --publication_directory_path=.\\result --pattern_file_path=I:\\Task-286\\Scripts\\pckg_test_status_patterns.csv\n";
+	print "check_all_pckg_test_status.pl --source_csv_path_to_analyse=I:\\sf --publication_directory_path=.\\result --pattern_file_path=I:\\Task-286\\Scripts\\pckg_test_status_patterns.csv\n";
+	print "Options:\n";
+	print "--help:\t\t\t\t display this help and exit\n";
+	print "--dirs_file_path_to_analyse:\t path to a file that contains the path to the directories containing package_definition.xml\n";
+	print "--source_path_to_analyse:\t path of the root of the source code \\sf\n";
+	print "--publication_directory_path:\t is the path to the directory where the results will be published (optional)\n";
+	print "--source_csv_path_to_analyse:\t is path to sources.csv file in case packages haven't got a package_definition.xml (optional)\n";
+	print "\t\t\t\t default value is $default_publication_directory_path\n";
+	print "--pattern_file_path:\t is the path to file that contain the patterns to be search for (optional)\n";
+	print "\t\t\t\t default value is $default_pattern_file_path\n";
+
+	exit(0);
+}
+# End section related to help
+
+
+# This function is called with the path to the directory \\sf and then we scan for all the directories / packages that contains package_definition*.xml
+# Result should be a file with something like this: "I:\sf\os\kernelhwsrv"
+# Parameter passed is the path to the directory \\sf
+sub generate_file_with_path_2_pckgs
+{
+	my ($path_2_dir_sf_2_analyse) = @_;
+	my @tab_package_definition_list;
+	
+	print "The path to the \\sf directory we want to analyse is: <$path_2_dir_sf_2_analyse>\n";
+	
+	print "The pattern used to find out the root directory for a pacakge is: <$pckg_definition_pattern>\n";
+	
+	# Ananlyse directories for package_definition*.xml
+	# Find a way to parse all the directories and get results as fast as possible
+	# something like <dir I:\sf\package_definition*.xml /s/b>
+
+	print "\n";
+	
+	open(FINDPCKDEFPATHS,"dir $path_2_dir_sf_2_analyse\\$pckg_definition_pattern /s/b |");
+	my $local_ctr = 0;
+	
+	while(<FINDPCKDEFPATHS>)
+	{
+		print "$_";
+		$tab_package_definition_list[$local_ctr] = $_;
+		#print "tab_package_definition_list[$local_ctr]=$tab_package_definition_list[$local_ctr]\n";
+		$local_ctr++;
+	}
+	my $total_pckg_def_files_found = scalar(@tab_package_definition_list);
+	print "nb of $pckg_definition_pattern found in $path_2_dir_sf_2_analyse are: <$total_pckg_def_files_found>\n";
+	
+	close(FINDPCKDEFPATHS);
+	
+	print "\n";
+	
+	my $local_ctr1=0;
+	my $local_ctr2=0;
+	my $local_ctr3=0;
+		
+	# What to extract
+	#I:\sf\adaptation\qemu\package_definition.xml
+	#I:\sf\adaptation\qemu\package_definition_2.0.1.xml
+	# Anything before the last \\, whcih should not be included!
+	foreach my $val (@tab_package_definition_list)
+	{		
+		if ($val =~ m#(^[\w\W]+)\\package_definition#i)
+		#if ($val =~ m,$pckg_definition_extraction_pattern,i)
+		{
+			#print "Value to analyse is: $val\n";
+			#print "Managed to extract: $1\n";
+			$tab_package_extraction[$local_ctr1] = $1;
+			#print "tab_package_extraction[$local_ctr1]=$tab_package_extraction[$local_ctr1]\n";
+			$local_ctr1++;
+		}
+		
+		#print "\n";
+		
+		# Create tables for S^2 & S^3 package_definition.xml file
+		# Store them in a table and save it in 2 different files
+
+		#S^2
+		if ($val =~ m#(^[\w\W]+)\\package_definition.xml#i)
+		{
+			#print "Value to analyse is: $val\n";
+			#print "Managed to extract: $1\n";
+			$tab_package_extraction_S2[$local_ctr2] = $1;
+			#print "tab_package_extraction_S2[$local_ctr2]=$tab_package_extraction_S2[$local_ctr2]\n";
+			$local_ctr2++;
+		}
+
+		#S^3
+		if ($val =~ m#(^[\w\W]+)\\package_definition_#i)
+		{
+			#print "Value to analyse is: $val\n";
+			#print "Managed to extract: $1\n";
+			$tab_package_extraction_S3[$local_ctr3] = $1;
+			#print "tab_package_extraction_S3[$local_ctr3]=$tab_package_extraction_S3[$local_ctr3]\n";
+			$local_ctr3++;
+		}
+	}
+
+	# Eliminate duplicates packages paths!
+	my %seen;
+	for ( my $i = 0; $i <= $#tab_package_extraction ; )
+	{
+    splice @tab_package_extraction, --$i, 1
+        if $seen{$tab_package_extraction[$i++]}++;
+	}
+	#print "Sorted out table:\n @tab_package_extraction\n";
+
+	# Save data in a file that will be reused later on
+	# Create a new file everytime. Save old one if exist with date and time?
+	print "Path to the file where data will be saved is called: <$publication_directory_path>\n";
+	print "File name where data will be saved is called: <$pckg_dir_paths_file_name>\n";
+	
+	my $data_2_save_file_path = "$publication_directory_path\\$pckg_dir_paths_file_name";
+	my $path2save;
+	
+	print "The path to the file to write to is: <$data_2_save_file_path>\n";
+	
+	# Save generic table in a file
+	# Open the file
+	open(FILE2SAVEDATA, ">$data_2_save_file_path");
+	
+	foreach $path2save (@tab_package_extraction)
+	{
+		print FILE2SAVEDATA "$path2save\n";
+	}
+	
+	# Close the file
+	close(FILE2SAVEDATA);
+
+	# Save generic table for S^2 in a file
+	$data_2_save_file_path = "$publication_directory_path\\$pckg_dir_paths_file_name_S2";
+	print "The path to the file to write to is: <$data_2_save_file_path>\n";
+	# Open the file
+	open(FILE2SAVEDATA, ">$data_2_save_file_path");
+	
+	foreach $path2save (@tab_package_extraction_S2)
+	{
+		print FILE2SAVEDATA "$path2save\n";
+	}
+
+	# Save generic table for S^3 in a file
+	$data_2_save_file_path = "$publication_directory_path\\$pckg_dir_paths_file_name_S3";
+	print "The path to the file to write to is: <$data_2_save_file_path>\n";
+	# Open the file
+	open(FILE2SAVEDATA, ">$data_2_save_file_path");
+	
+	foreach $path2save (@tab_package_extraction_S3)
+	{
+		print FILE2SAVEDATA "$path2save\n";
+	}
+	
+	# Close the file
+	close(FILE2SAVEDATA);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/test/pckg_status/scripts/check_pckg_test_status.pl	Tue Jan 26 15:39:24 2010 +0000
@@ -0,0 +1,1087 @@
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Script name: check_pckg_test_status.pl
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+#
+# Contributors:
+# Arnaud Lenoir <arnaudl@symbian.org>
+#
+# Created 27/11/2009
+#
+# Description:
+# Task 286 - Package test status prep
+#
+# This script must be used at package level only!!!!
+# For a general search to several packages, PDK, etc then use check_all_pckg_test_status.pl script
+#
+# Parameters passed:
+#	Param1: Path to the root directory for the package (where the package_definition.xml is present)
+#	Param2: Path to the file containing the different patterns to have a look for
+#	Param3: Path to the directory where DB will be published
+
+# Modules necessary to run this script
+use Getopt::Long;
+use strict;
+use Text::CSV;
+use Switch;
+use Data::Dumper;
+
+
+# Variables for parameters
+my $help;
+my $package_path;
+my $pattern_file_path;
+my $publication_directory_path;
+
+# variables
+my $system_cmd;		# Used to execute DOS commands
+my $pckg_name="";	# Contains the name of the package
+my @key_dirs_tab;	# Used to trace the patterns/keys for directories search
+my %dirs_hashes;	# Contains the list of directories found hash_array=fct(directory_name(key),directory_path(values that are tables)
+my @key_files_tab;	# Used to trace the patterns/keys for files search
+my %files_hashes;	# Contains the list of files found hash_array=fct(file_name(key),file_path(values that are tables)
+my @key_pattern_in_file_tab;	# Used to trace the patterns/keys for pattern in file search
+my %pattern_in_file_hashes;		# Contains the list of files that contains the pattern found hash_array=fct(file_name(key),file_path(values that are tables)
+my @key_file_in_dir_tab;	# Used to trace the patterns/keys for file in directory search
+my %file_in_dir_hashes;		# Contains the list of files that are in a specific directory hash_array=fct(file_name(key),file_path(values that are tables)
+my @directory;		# Used to extract data from the csv file that contains the different patterns to look for
+my @file;			# Used to extract data from the csv file that contains the different patterns to look for
+my @pattern;		# Used to extract data from the csv file that contains the different patterns to look for
+my @test_type;		# Used to extract data from the csv file that contains the different patterns to look for
+my %existing_tests;	# Hash array that record the tests that are supported / exist for the package.
+my %patterns_anywhere_hashes;	# Hash array that record the list of file / directory that contain a specific pattern using pattern as key which point to a table with the data gathered.
+my %patterns_anywhere_in_dir_hashes;	# Hash array that record the list of files that contain a specific pattern in a directory.
+my %patterns_in_dir_in_file_hashes;	# Hash array that record the list of files that contain a specific pattern in a directory and in a file that is included in tha directory (or sub-directory).
+
+# Constantes declaration
+my $default_publication_directory_path = "\.\\results";
+my $default_pattern_file_path = ".\\pckg_test_status_patterns.csv";
+my $output_file_base_name = "package_test_status_";
+my $output_file_extension = ".xml";
+my $csv_status_file_name = "packages_tests_supported_status.csv";
+# Used for search algorithm
+# Directory		File	Pattern		Value	Action
+#	0			 0			1		  1		Look for pattern anywhere in a file, directory/file name
+#	0			 1			0		  2		Look for a file
+#	0			 1			1		  3		Look for a pattern in a file
+#	1			 0			0		  4		Look for a directory
+#	1			 0			1		  5		Look for a pattern in the directory anywhere in a directory/file name
+#	1			 1			0		  6		Look for a file in a directory
+#	1			 1			1		  7		Look for a pattern in a specific file in a specific directory
+my $search_algo_4_pattern_anywhere = 1;
+my $search_algo_4_file = 2;
+my $search_algo_4_pattern_in_file = 3;
+my $search_algo_4_directory = 4;
+my $search_algo_4_pattern_anywhere_in_directory = 5;
+my $search_algo_4_file_in_directory = 6;
+my $search_algo_4_pattern_in_specific_file_directory = 7;
+
+
+my $nb_arg_passed = scalar(@ARGV);
+if(!$nb_arg_passed)
+{
+	print "No arguments/parameters passed then print help!\n";
+	helpme();
+}
+
+my %optmap = (  'package_path' => \$package_path,
+			    'pattern_file_path' => \$pattern_file_path,
+				'publication_directory_path' => \$publication_directory_path,
+                'help' => \$help);
+
+GetOptions(\%optmap,
+		  'package_path=s',
+		  'pattern_file_path=s',
+		  'publication_directory_path=s',
+          'help');
+
+print "The value for help is: <$help>\n";
+print "package_path: <$package_path>\n";
+print "pattern_file_path: <$pattern_file_path>\n";
+print "publication_directory_path: <$publication_directory_path>\n";
+
+# Check if we need default values for some of the parameters
+# Publication directory
+if (!defined($publication_directory_path))
+{
+	print "No publication_directory_path passed as argument, therefore use default path\n";
+	$publication_directory_path = $default_publication_directory_path;
+	print "publication_directory_path = <$publication_directory_path>\n";
+}
+# Check if we have a directory use for publishing. If not create it
+#print "Check if $publication_directory_path exist or not!\n";
+if (!(-d $publication_directory_path))
+{
+	print "The directory $publication_directory_path, doesn't exist, therefore we create it\n";
+	$system_cmd = "mkdir $publication_directory_path";	
+	print "Exec: $system_cmd\n";
+	system($system_cmd);
+}
+# Patterns file used
+if (!defined($pattern_file_path))
+{
+	print "No specific patterns file has been passed as parameters, therefore we use default patterns file\n";
+	$pattern_file_path = $default_pattern_file_path;
+	print "pattern_file_path = <$pattern_file_path>\n";
+}
+
+if ($help)
+{
+	print "We want to print the help\n";
+	helpme();
+}
+else
+{
+	print "\nIt's from here that the real work starts!\n";
+}
+
+
+# Define if the path given as a package_definition*.xml file.
+# If yes, the directroy correspond to the package name.
+# If no, then there is a problem, and therefore we should stop.
+# 1. Check that the path contains the package_definition*.xml.
+# 2. Extract package name from path given. 
+
+print "Package name to extract from: $package_path\n";
+if($package_path =~ m;\\([\w]+)$;)
+{
+	$pckg_name = $1;
+	print "########################################################################\n";
+	print "\t\tThe Package name is: <$pckg_name>\n";
+	print "########################################################################\n";
+}
+
+# Load file with patterns
+# If file doesn't exist, then exit
+# Then
+# Extract patterns from file
+# Store in tables/hash array???
+# Count number of lines in the file - header!
+# Check for column name and stick it in the appropriate table
+
+print "Open the patterns file .csv and extract data from it.\n";
+
+open(PATTERNSFILE, "$pattern_file_path") or die "Can't open file $pattern_file_path. The error is <$!>\n";
+
+#my $csv = Text::CSV->new({blank_is_undef => 1});
+#my $csv = Text::CSV->new({empty_is_undef => 1});
+my $csv = Text::CSV->new();
+
+my $header=0;
+my $count_nb_total_lines=0;
+my @columns;
+
+while (<PATTERNSFILE>) {
+	if ($csv->parse($_)) 
+	{
+		@columns = $csv->fields();
+		
+		if(!$header)
+		{
+			#print "This is the first line of the csv file\n";
+			$header=1;
+			foreach (@columns) 
+			{
+				#print $_."\n";
+			}			
+		}
+		else
+		{
+			#print "line #$count_nb_total_lines of the csv file\n";
+			
+			foreach (@columns) 
+			{
+				#print "<$_>\n";
+			}
+			push(@directory, $columns[0]);
+			push(@file, $columns[1]);
+			push(@pattern, $columns[2]);
+			push(@test_type, $columns[3]);
+			$count_nb_total_lines++;
+		}
+	} 
+	else 
+	{
+		my $err = $csv->error_input;
+		print "Failed to parse line: $err";
+	}
+}
+print "The number of lines counted in the CSV file is: $count_nb_total_lines\n";
+print "\n";
+
+# Used to display the tables that extracted from the CSV file to check if data are correct
+#for (my $i=0;$i<$count_nb_total_lines;$i++)
+#{
+#	print "$i:\t$directory[$i]\t\t$file[$i]\t\t$pattern[$i]\t\t\t$test_type[$i]\n";
+#}
+
+close(PATTERNSFILE);
+
+# Establish the list of type file we have in the package
+# 1. Create the table that contains the list of all the type of tests listed in the CSV file
+# 1.a Create a hash array with table "test_type"
+# 1.b Keep only one entry of each
+# 2. Make sure that we fill it as we go along
+
+#display_array("Type of test",@test_type);
+foreach (@test_type)
+{
+	#print "The test type is: $_\n";
+	$existing_tests{$_} = "";
+}
+#print "List of type of tests we are looking for\n";
+#print Dumper(\%existing_tests);
+
+# Look for patterns and fill tables
+# foreach lines 
+# 7 different outputs depending on the line contain
+# directory, file and pattern (see Excel spreadsheet called "patterns_search_rules.xlsx")
+
+my $select_search_type;
+	
+my $count =0;
+while($count<$count_nb_total_lines)
+{
+	#print "count=$count\n";
+	$select_search_type = 0;
+	if($directory[$count] ne "")
+	{
+		$select_search_type += 4;
+		#print "A directory value exist => select_search_type= <$select_search_type>\n";
+	}
+	if($file[$count] ne "")
+	{
+		$select_search_type += 2;
+		#print "A file value exist => select_search_type= <$select_search_type>\n";
+	}
+	if($pattern[$count] ne "")
+	{
+		$select_search_type += 1;
+		#print "A pattern value exist => select_search_type= <$select_search_type>\n";
+	}
+	#print "select_search_type= <$select_search_type>\n";
+
+	switch($select_search_type)
+	{
+		case ($search_algo_4_pattern_anywhere)
+		{
+			print "Value is $search_algo_4_pattern_anywhere, meaning call fct_search_algo_4_pattern_anywhere\n";
+			my @pattern_anywhere_returned_table = fct_search_algo_4_pattern_anywhere($pattern[$count]);
+			
+			push (@{ $patterns_anywhere_hashes {$pattern[$count]} }, @pattern_anywhere_returned_table);
+			
+			my $calcul_tab_size = scalar(@pattern_anywhere_returned_table);
+			
+			if($calcul_tab_size)
+			{
+				print "There is data for this search: <$calcul_tab_size>\n";
+				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
+			}
+		}
+		case ($search_algo_4_file)
+		{
+			print "Value is $search_algo_4_file, meaning call fct_search_algo_4_file\n";
+			my @files_returned_table = fct_search_algo_4_file($file[$count]);
+			
+			# Display table in a nice way
+			#display_array("files ".$file[$count],@files_returned_table);
+			
+			# Check if the key exists or not. If it doesn't exist then add it to the list
+			@key_files_tab = add_key_for_dynamic_hash_array($file[$count], @key_files_tab);
+			
+			# Save table containing files list returned by fct in the hash array to key file pattern
+			# hash array: files_hashes
+			# contains a key called file_pattern1 ($file[$count]) which contains the table @files_returned_table that lists the files found having for name file_pattern1
+			# contains a key called file_pattern2 ($file[$count]) which contains the table @filess_returned_table that lists the files found having for name file_pattern2
+			# Contain as many key as we are looking for files
+			push (@{ $files_hashes{$file[$count]} }, @files_returned_table);
+			
+			my $calcul_tab_size = scalar(@files_returned_table);
+			if($calcul_tab_size)
+			{
+				print "There is data for this search: <$calcul_tab_size>\n";
+				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
+			}
+		}
+		case ($search_algo_4_pattern_in_file)
+		{
+			print "Value is $search_algo_4_pattern_in_file, meaning call fct_search_algo_4_pattern_in_file\n";
+			# Hash array filling level 1 deepnees
+			my @values_found_returned_table;
+			my @pattern_in_file_returned_table = fct_search_algo_4_pattern_in_file($package_path."\\".$file[$count],$pattern[$count],"/s /m");
+			
+			# Display table in a nice way
+			#display_array("files with pattern ".$pattern[$count],@pattern_in_file_returned_table);
+
+			# Check if the key exists or not. If it doesn't exist then add it to the list
+			@key_pattern_in_file_tab = add_key_for_dynamic_hash_array($pattern[$count], @key_pattern_in_file_tab);
+
+			# Used to verify if we have updated the table properly by replacing it with the table passed back
+			#display_array("keys list after",@key_dirs_tab);
+			
+			# Save table containing files list returned by fct in the hash array to key pattern pattern
+			# hash array: pattern_in_file_hashes
+			# contains a key called pattern_pattern1 ($pattern[$count]) which contains the table @dirs_returned_table that lists the directories found having for name directory_pattern1
+			# contains a key called pattern_pattern2 ($pattern[$count]) which contains the table @dirs_returned_table that lists the directories found having for name directory_pattern2
+			# Contain as many key as we are looking for directories
+			foreach (@pattern_in_file_returned_table)
+			{
+				#print "Value: $_\n";
+				$pattern_in_file_hashes{$pattern[$count]}->{$_} = "";
+				#print "Value entered: <$pattern_in_file_hashes{$pattern[$count]}->{$_}>\n";
+			}
+			#print "\nDump contain of hash array:\n";
+			#print Dumper(\%pattern_in_file_hashes);
+			#print "Contain of hash array dumped\n\n";
+			
+			# Hash array filling level 2 deepnees
+			# Take keys (file) taken in the 1st level deepness of the file to do next search
+			foreach my $path2file2look_into (sort keys %{$pattern_in_file_hashes{$pattern[$count]}} )
+			{
+				print "path2file2look_into=<$path2file2look_into>\n";
+				
+				@values_found_returned_table = fct_search_algo_4_pattern_in_file($path2file2look_into,$pattern[$count],"/s");
+				#display_array("lines in <$path2file2look_into>",@values_found_returned_table);
+			
+				# Do we need to remove?????????:
+				#	"I:\sf\os\kernelhwsrv\baseintegtests\baseintegrationtest\testsuites\sd\group\bld.inf:"
+				# Keep only what is after ":" (not included)
+
+				# To remove????? - Beginning
+#				my @pattern_in_file_cleanedup_table;
+#				my $local_string;
+#				$local_string = "\....:([\\w\\W]+)";
+#				print "local_string: $local_string\n";
+#				foreach my $line2transform (@values_found_returned_table)
+#				{
+#					print "line2transform: <$line2transform>\n";
+#					$line2transform =~ /$local_string/;
+#					print "line2transformed: <$line2transform>\n";
+#					push (@pattern_in_file_cleanedup_table,$line2transform);
+#				}
+				# To remove????? - End
+				
+				# Populate data in the hash array{pattern}{file}[(lines]	{key} - [table]
+				$pattern_in_file_hashes{$pattern[$count]}->{$path2file2look_into} = \@values_found_returned_table;
+				# To remove????? - Beginning
+				#$pattern_in_file_hashes{$pattern[$count]}->{$path2file2look_into} = \@pattern_in_file_cleanedup_table;
+				# To remove????? - End
+			}
+			#print "\nDump full contain of hash array:\n";
+			#print Dumper(\%pattern_in_file_hashes);
+			#print "Full contain of hash array dumped\n\n";
+			
+			my $calcul_tab_size = scalar(@values_found_returned_table);
+			if($calcul_tab_size)
+			{
+				print "There is data for this search: <$calcul_tab_size>\n";
+				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
+			}
+		}
+		case ($search_algo_4_directory)
+		{
+			print "Value is $search_algo_4_directory, meaning call fct_search_algo_4_directory\n";
+			my @dirs_returned_table = fct_search_algo_4_directory($directory[$count]);
+			
+			# Display table in a nice way
+			#display_array("directories ".$directory[$count],@dirs_returned_table);
+			
+			# Used to verify if table for the keys is managed properly
+			#display_array("keys list before",@key_dirs_tab);
+
+			# Check if the key exists or not. If it doesn't exist then add it to the list
+			@key_dirs_tab = add_key_for_dynamic_hash_array($directory[$count], @key_dirs_tab);
+
+			# Used to verify if we have updated the table properly by replacing it with the table passed back
+			#display_array("keys list after",@key_dirs_tab);
+			
+			# Save table containing directories list returned by fct in the hash array to key directory pattern
+			# hash array: dirs_hashes
+			# contains a key called directory_pattern1 ($directory[$count]) which contains the table @dirs_returned_table that lists the directories found having for name directory_pattern1
+			# contains a key called directory_pattern2 ($directory[$count]) which contains the table @dirs_returned_table that lists the directories found having for name directory_pattern2
+			# Contain as many key as we are looking for directories
+			push (@{ $dirs_hashes{$directory[$count]} }, @dirs_returned_table);
+			
+			my $calcul_tab_size = scalar(@dirs_returned_table);
+			if($calcul_tab_size)
+			{
+				print "There is data for this search: <$calcul_tab_size>\n";
+				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
+			}
+		}
+
+		case ($search_algo_4_pattern_anywhere_in_directory)
+		{
+			print "Value is $search_algo_4_pattern_anywhere_in_directory, meaning call fct_search_algo_4_pattern_anywhere_in_directory\n";
+			my @patterns_in_dir_returned_table = fct_search_algo_4_pattern_anywhere_in_directory($directory[$count],$pattern[$count]);
+			
+			push (@{ $patterns_anywhere_in_dir_hashes{$pattern[$count]} }, @patterns_in_dir_returned_table);
+			
+			my $calcul_tab_size = scalar(@patterns_in_dir_returned_table);
+			if($calcul_tab_size)
+			{
+				print "There is data for this search: <$calcul_tab_size>\n";
+				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
+			}
+		}
+		case ($search_algo_4_file_in_directory)
+		{
+			print "Value is $search_algo_4_file_in_directory, meaning call fct_search_algo_4_file_in_directory\n";
+			my @file_in_dir_returned_table = fct_search_algo_4_file_in_directory($directory[$count],$file[$count]);
+			#display_array("file <".$file[$count]."> in directory <".$directory[$count].">",@file_in_dir_returned_table);
+			
+			# Check if the key exists or not. If it doesn't exist then add it to the list
+			@key_file_in_dir_tab = add_key_for_dynamic_hash_array($file[$count], @key_file_in_dir_tab);
+			
+			#@key_file_in_dir_tab
+			#%file_in_dir_hashes
+			push (@{ $file_in_dir_hashes{$file[$count]} }, @file_in_dir_returned_table);
+			
+			print "\nDump full contain of hash array:\n";
+			#print Dumper(\%file_in_dir_hashes);
+			print "Full contain of hash array dumped\n\n";
+			
+			my $calcul_tab_size = scalar(@file_in_dir_returned_table);
+			if($calcul_tab_size)
+			{
+				print "There is data for this search: <$calcul_tab_size>\n";
+				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
+			}
+		}
+		case ($search_algo_4_pattern_in_specific_file_directory)
+		{
+			print "Value is $search_algo_4_pattern_in_specific_file_directory, call fct_meaning search_algo_4_pattern_in_specific_file_directory\n";
+			my @patterns_in_dir_in_file_returned_table = fct_search_algo_4_pattern_in_specific_file_and_directory($directory[$count],$file[$count],$pattern[$count]);
+
+			push (@{ $patterns_in_dir_in_file_hashes{$pattern[$count]} }, @patterns_in_dir_in_file_returned_table);
+			
+			my $calcul_tab_size = scalar(@patterns_in_dir_in_file_returned_table);
+			print "calcul_tab_size = <$calcul_tab_size>\n";
+			if($calcul_tab_size)
+			{
+				print "There is data for this search: <$calcul_tab_size>\n";
+				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
+			}
+		}		
+		else
+		{
+			# default for the switch
+			# Added one for the line error as we need to add 1st line of the csv file, which is the header line
+			print "No correct values was passed <$select_search_type>, which is impossible in our system!!! Error on line ". ($count+1). " of file $pattern_file_path\n";
+		}
+	}
+	$count++;
+}
+
+# Output generated in a file which is following special naming convention because used to create the globabl picture
+# pckg_test_atatus[pckgname].xml?
+# Create file if doesn't exist. If exist already, update? delete & create from scratch?
+#
+# 1. Extract package name
+# 2. Create a file called "package_test_status_[package_name].xml
+# 3. Fill xml file using data gathered in this script
+# 4. Close xml file
+
+print "\n";
+
+#
+# Display data
+#
+print "!!!!This section is related to the display of the data gatehered by this script!!!!\n\n";
+
+# To remove????? - Beginning
+#my @display_hash_tab;
+#@display_hash_tab = keys(%dirs_hashes);
+#foreach my $key_val (@display_hash_tab)
+#{
+#	print "Key: <$key_val>:\n";
+#	my @read_table_in_hash_array = @{$dirs_hashes{$key_val}};
+#	foreach my $tab_val (@read_table_in_hash_array)
+#	{
+#		print "\tValue: <$tab_val>\n";
+#	}
+#}
+#print "\n";
+# To remove????? - End
+
+# Display of the search we have done for the directories we need information from
+if(%dirs_hashes)
+{
+	print "Look for directories:\n";
+	#display_hash_array_1_level_deep ("directories", %dirs_hashes);
+	print Dumper({%dirs_hashes});
+	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+}
+
+# Display of the search we have done for the files we need information from
+if(%files_hashes)
+{
+	print "Look for files:\n";
+	#display_hash_array_1_level_deep ("files", %files_hashes);
+	print Dumper({%files_hashes});
+	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+}
+
+# Display of the search we have done for the pattern in files we need information from
+if(%pattern_in_file_hashes)
+{
+	print "Look for pattern in a file:\n";
+	#display_hash_array_2_levels_deep ("1st & 2nd levels of patterns (files & lines) in files", %pattern_in_file_hashes);	
+	
+	print Dumper(\%pattern_in_file_hashes);
+	#print Dumper({%pattern_in_file_hashes});	# same result as above
+	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+}
+
+# Display of the search we have done for the files we need information from
+if(%file_in_dir_hashes)
+{
+	print "Look for files in a specific directory:\n";
+	#display_hash_array_1_level_deep ("specific file in a specific directory", %file_in_dir_hashes);
+	print Dumper({%file_in_dir_hashes});
+	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+}
+
+# Display of the search we have done for the patterns anywhere in directory / file names and in the files themselves.
+if(%patterns_anywhere_hashes)
+{
+	print "Look for a pattern everywhere:\n";
+	print Dumper({%patterns_anywhere_hashes});
+	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+}
+
+# Display of the search we have done for the patterns anywhere in a specific directory.
+if(%patterns_anywhere_in_dir_hashes)
+{
+	print "Look for a pattern everywhere in a directory:\n";
+	print Dumper({%patterns_anywhere_in_dir_hashes});
+	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+}
+
+# Display of the search we have done for the patterns in a specific directory that contain a specific file in that directory/sub-directory.
+if(%patterns_in_dir_in_file_hashes)
+{
+	print "Look for a pattern in a specific file in a specific directory:\n";
+	print Dumper({%patterns_in_dir_in_file_hashes});
+	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+}
+
+print "\n";
+
+print "Indicates the type of tests supported by the package $pckg_name:\n";
+print Dumper(\%existing_tests);	
+
+print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
+
+#
+# Save data in files
+#
+print "!!!!This section is related to the saving of the data in files!!!!\n\n";
+
+print "Save basic data about the type of tests supported by the package in a generic csv file\n";
+
+my $csv_status_file_path = "$publication_directory_path\\$csv_status_file_name";
+print "The full path for the csv packages tests status file is: $csv_status_file_path\n";
+
+if(!(-f $csv_status_file_path))
+{
+	print "The file doesn't exist, we need to create it and fill it with the hearder row\n";
+	open(CSVSTATUSFILE,">$csv_status_file_path");	# Create the file from scratch
+	
+	print CSVSTATUSFILE "Package_Name";
+	
+	foreach my $type_test_key (sort keys %existing_tests)
+	{
+		# Fields separated by comas
+		print "Enter header name: type_test_key is $type_test_key\n";
+		print CSVSTATUSFILE ",$type_test_key";
+	}
+	print CSVSTATUSFILE "\n";	# To make sure we are ready for the next line
+}
+else
+{
+	print "The file exists, we need to populate it with the necessary info\n";
+	open(CSVSTATUSFILE,">>$csv_status_file_path");	# Append the file as it exists already and we are just going to add a new line
+	
+	# Do we need to check if we have the same number of info on the header row (1st row)?????
+}
+
+print CSVSTATUSFILE "$pckg_name";
+foreach my $type_test_key4val (sort keys %existing_tests)
+{
+	# Fields separated by comas
+	print "$pckg_name: The key test type is: <$type_test_key4val> and the value associated with is: <$existing_tests{$type_test_key4val}>\n";
+	print CSVSTATUSFILE ",$existing_tests{$type_test_key4val}";
+}
+print CSVSTATUSFILE "\n";	# To make sure we are ready for the next line
+
+close(CSVSTATUSFILE);
+print "We have now updated the file <$csv_status_file_path> with the data gathered for the package $pckg_name\n\n";
+
+my $output_file_name = $output_file_base_name.$pckg_name.$output_file_extension;
+print "The output file name is: $output_file_name\n";
+my $path4output_file = "$publication_directory_path\\$output_file_name";
+print "The full path for the output file is: $path4output_file\n";
+
+print "\nCreate and fill file <$path4output_file>\n";
+
+# Should we create a function that will be called form the switch/case that will save the info directly in the appropriate xml file and / or csv file?
+open(OUTPUTFILE,">$path4output_file");
+
+print "Fill the xml file with data we have gathered in this script!!!!!\n";
+print OUTPUTFILE "Fill the xml file with data we have!!!!!\n";
+
+close (OUTPUTFILE);
+
+# End of the script
+exit(0);
+# THE END OF THE END AT THE END OF THIS SCRIPT
+
+#
+# Functions section
+#
+
+# If no parameters entered or help selected, display help
+sub helpme
+{	
+	print "\nfct: helpme\n";
+	print "check_pckg_test_status.pl\n";
+	print "Usage:\n";
+	print "check_pckg_test_status.pl --help\n";
+	print "check_pckg_test_status.pl --package_path=I:\\sf\\os\\kernelhwsrv --pattern_file_path=I:\\pckg_test_status_patterns.txt --publication_directory_path=I:\\results\\kernelhwsrv\n";
+	print "Options:\n";
+	print "--help:\t\t\t\t display this help and exit\n";
+	print "--package_path:\t\t\t is the path to the directory containing the package_definition.xml file\n";
+	print "--pattern_file_path:\t\t is the path to the file containing the patterns to be lookeed for\n";
+	print "--publication_directory_path:\t is the path to the directory where the results will be published\n";
+	print "\t\t\t\t default value is $default_publication_directory_path\n";
+	
+	exit(0);
+}
+
+# Search functions
+sub fct_search_algo_4_pattern_anywhere
+{
+	my ($pattern) = @_;
+
+	print "This is the function: fct_search_algo_4_pattern_anywhere\n";
+
+	print "Search for pattern: <$pattern>\n";
+	my @pattern_search_tab;
+	
+	# Firstly have a look for the pattern in the directories and files names
+	print "Search for the pattern in any directory or file names\n";
+	
+	@pattern_search_tab = fct_dos_cmd_dir_search("$package_path\\*$pattern*", "/s /b");
+	
+	#print "Pattern <$pattern> was found in: @pattern_search_tab\n";
+	#print "\n";
+	
+	# Secondly have a look in any files if we can find the pattern.
+	# Should we use: fct_search_algo_4_pattern_in_file()?
+
+	my @local_returned_table = fct_search_algo_4_pattern_in_file($package_path . "\\*",$pattern[$count],"/s /n");
+	# If we just want to display the files and not the contain of the line. As well should elimintate the duplicate for files?
+	#my @local_returned_table = fct_search_algo_4_pattern_in_file($local_package_path,$pattern[$count],"/s /m");
+	push(@pattern_search_tab,@local_returned_table);
+	
+	#print "\n";
+	#print "Pattern <$pattern> was found in: @pattern_search_tab\n";
+	#print "\n";
+	
+	return (@pattern_search_tab);
+}
+sub fct_search_algo_4_file
+{
+	my ($file) = @_;
+
+	print "This is the function: fct_search_algo_4_file\n";
+	print "Search for file: <$file>\n";
+	
+	my @files;
+
+	@files = fct_dos_cmd_dir_search("$package_path\\$file", "/s /b");
+
+	#print "files found are: @files\n";
+	
+	print "\n";
+	return (@files);
+}
+
+# This function was originally setup to have a look for a pattern in a specific files,
+# but we can do a search in a directory by adding \\* at the end of the path, which will be like look in all the files in the directory and sub-directories.
+sub fct_search_algo_4_pattern_in_file
+{
+	my ($file,$pattern,$options) = @_;
+
+	print "This is the function: fct_search_algo_4_pattern_in_file\n";
+
+	#print "Search for file: <$file>\n";
+	#print "Search for pattern: <$pattern>\n";
+	#print "Options: <$options>\n";
+	
+	my @pattern_in_files;
+	
+	# Check findstr /? to find out about the "regular expression"
+	# "." Wildcard: any character
+	# "*" Repeat: zero or more occurances of previous character or class
+		
+	# Check if the pattern contain a dot. If yes replace any "." by "\."
+	if ( $pattern =~ /\./)
+	{
+		$pattern =~ s/\./\\./;
+		#print "Replaced all \. by \\. to the pattern: <$pattern>\n";
+	}
+	else
+	{
+		#print "$pattern doesn't doesn't contain a \.\n";
+	}
+	# Check if the pattern contain a star. If yes replace any "*" by ".*"
+	# For a string to have a look at "string*.txt", the "*" equivalent for findstr is ".*"
+	# For more info, check out here: http://technet.microsoft.com/en-us/library/bb490907.aspx
+	if ( $pattern =~ /\*/)
+	{
+		$pattern =~ s/\*/\.\*/g;
+		#print "Replaced all \* by \.* to the pattern: <$pattern>\n";
+	}
+	else
+	{
+		#print "$pattern doesn't contain a *\n";
+	}
+
+	# If the pattern contains a starting " and and end ", we consider we are looking for a the full string included between "" and therefore we need to use the option /c:"pattern to look for"
+	if ( ($pattern =~ /^"/) && ($pattern =~ /"$/))
+	{
+		# Replace the first <"> by </c:">
+		$pattern =~ s/\"/\/c:\"/;
+		#print "Replaced first <\"> by <\/c:\"> to become: <$pattern>\n";
+	}
+	else
+	{
+		#print "$pattern is not contained between\"\" \n";
+	}
+
+	open(SEARCHPATTERNINFILE,"findstr $options $pattern $file |");
+	
+	while(<SEARCHPATTERNINFILE>)
+	{
+		my $val = $_;
+		
+		#remove the trailing \n
+		chomp($val);
+		
+		#print "value found is <$val>\n";
+		
+		if($val =~ /.hg/)
+		{
+			#print "Discard that line!\n"
+		}
+		else
+		{
+			#print "We need to save the value <$val>\n";
+			# Push value in a table and pass it as a parameter!?
+			push(@pattern_in_files,$val);
+		}
+	}
+	close(SEARCHPATTERNINFILE);
+
+	print "\n";
+	
+	return (@pattern_in_files);
+}
+
+sub fct_search_algo_4_directory
+{
+	#my $dir = $_[0]; # get first argument passed to the function
+	my ($dir) = @_;
+		
+	print "This is the function: fct_search_algo_4_directory\n";
+	print "Search for directory: <$dir>\n";
+	
+	my @dirs;
+	
+	# To remove????? - Beginning
+	#opendir DIR, $package_path or die "can't read $package_path: $!";
+	#@dirs = readdir DIR;
+	#@dirs = dir "$dir", readdir DIR;
+	#closedir DIR;
+	#print "\n";
+	#print @dirs;
+	#print "\n\n";
+	# To remove????? - End
+	
+	@dirs = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
+	
+	# To remove????? - Beginning
+	if(scalar(@dirs))
+	{
+		#print "\n";
+		#print "Here is the list of directories that we have found named <$dir>:\n";
+		foreach (@dirs)
+		{
+			#print "\t$_\n";
+		}
+	}
+	#print "\n";
+	# To remove????? - End
+	
+	return (@dirs);
+}
+
+sub fct_search_algo_4_pattern_anywhere_in_directory
+{
+	my ($dir,$pattern) = @_;
+
+	print "This is the function: fct_search_algo_4_pattern_anywhere_in_directory\n";
+
+	print "Findout if there is one or more directory called: <$dir>\n";
+	my @local_dir_exist_tab;
+	my @table_to_return_with_search;
+	
+	@local_dir_exist_tab = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
+	
+	print "we found <$dir>: \n<\n@local_dir_exist_tab \n>\n";
+	
+	print "Search for pattern: <$pattern> in directory $dir\n";
+	foreach my $dir_to_search (@local_dir_exist_tab)
+	{
+		print "The directory that we examine is: $dir_to_search\n";
+		
+		my @local_pattern_in_directory_returned_table = fct_search_algo_4_pattern_in_file($dir_to_search. "\\*",$pattern,"/s /n");
+		push(@table_to_return_with_search,@local_pattern_in_directory_returned_table);
+		
+		#print "Here are all the values we found for $pattern in $dir_to_search:\n";
+		#print Dumper(@local_pattern_in_directory_returned_table);
+	}
+
+	#print "Here are all the values we found and that will be returned: \n";
+	#print Dumper(@table_to_return_with_search);
+	
+	print "\n";
+	
+	return (@table_to_return_with_search);
+}
+
+sub fct_search_algo_4_file_in_directory
+{
+	my ($dir,$file) = @_;
+
+	print "This is the function: fct_search_algo_4_file_in_directory\n";
+
+	print "Search for directory: <$dir>\n";
+	print "Search for file: <$file>\n";
+
+	print "\n";
+	my @dir_list;
+	my @file_in_dir;
+
+	print "Look for directories <$dir>\n";
+	@dir_list = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
+	
+	#print "we found <$dir>: \n<\n@dir_list \n>\n";
+
+	# Look for files in the directories we have previously found
+	print "Look for the file <$file> in the directory found previously\n";
+	
+	foreach my $dir_to_search (@dir_list)
+	{
+		#print "Look file <$file> in directory <$dir_to_search>\n";
+		
+		@file_in_dir = fct_dos_cmd_dir_search("$dir_to_search\\$file", "/s /b");
+		
+		open(SEARCHFILEDIR,"dir /s /b $dir_to_search\\$file |");
+	}
+	
+	#print "we found <$file> in: \n<\n@file_in_dir \n>\n";
+	
+	return (@file_in_dir);
+}
+
+sub fct_search_algo_4_pattern_in_specific_file_and_directory
+{
+	my ($dir,$file,$pattern) = @_;
+
+	print "This is the function: fct_search_algo_4_pattern_in_specific_file_and_directory\n";
+
+	my @local_dir_exist_tab;
+	my @local_file_exist_in_dir_tab;
+	my @table_to_return_with_search;
+	
+	# Look for directories
+	print "Look for directories <$dir>\n";
+	@local_dir_exist_tab = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
+	
+	#print "we found <$dir>: \n<\n@local_dir_exist_tab \n>\n";
+
+	# Look for files in the directories we have previously found
+	print "Look for the file <$file> in the directory found previously\n";
+	
+	foreach my $dir_to_search (@local_dir_exist_tab)
+	{
+		#print "Look file <$file> in directory <$dir_to_search>\n";
+		
+		@local_file_exist_in_dir_tab = fct_dos_cmd_dir_search("$dir_to_search\\$file", "/s /b");
+		
+		open(SEARCHFILEDIR,"dir /s /b $dir_to_search\\$file |");
+	}
+	
+	#print "we found <$file> in: \n<\n@local_file_exist_in_dir_tab \n>\n";
+	
+	print "Search for pattern: $pattern in directory $dir and file $file\n";
+	foreach my $file_to_search (@local_file_exist_in_dir_tab)
+	{
+		#print "File to examine is: $file_to_search\n";
+		
+		my @local_pattern_in_file_returned_table = fct_search_algo_4_pattern_in_file($file_to_search,$pattern,"/s /n");
+		push(@table_to_return_with_search,@local_pattern_in_file_returned_table);
+		
+		#print "Here are all the values we found for $pattern in $file_to_search:\n";
+		#print Dumper(@local_pattern_in_file_returned_table);
+	}
+
+	#print "Here are all the values we found and that will be returned: \n";
+	#print Dumper(@table_to_return_with_search);
+	
+	print "\n";
+	
+	return (@table_to_return_with_search);
+}
+
+# create a function that will look for a file or directory
+sub fct_dos_cmd_dir_search
+{
+	my ($what_to_look_for,$options) = @_;
+	
+	print "This is the function: fct_dos_cmd_dir_search\n";
+	my @search_result_tab;
+	
+	print "what_to_look_for: <$what_to_look_for>\n";
+	print "options: <$options>\n";
+
+	open(SEARCHUSINGDIRDOSCMD,"dir $options $what_to_look_for |");
+	
+	while(<SEARCHUSINGDIRDOSCMD>)
+	{
+		my $val = $_;
+		
+		#remove the trailing \n
+		chomp($val);
+		
+		#print "value found is <$val>\n";
+		
+		if($val =~ /.hg/)
+		{
+			#print "Discard that line!\n"
+		}
+		else
+		{
+			#print "We need to save the value <$val>\n";
+			# Push value in a table and pass it as a parameter!?
+			push(@search_result_tab,$val);
+		}
+	}
+	close(SEARCHUSINGDIRDOSCMD);
+	
+	return (@search_result_tab);
+}
+
+# Display an array with text indicating what it is
+sub display_array
+{
+	# It is important to pass variable first then table, otherwise if variable comes second, you can't find it using @_. Why?
+	my ($what_is_it,@table2display) = @_;
+
+	#print "what_is_it: <$what_is_it>\n";
+	print "The table containing all the ". $what_is_it ." is:\n";
+	
+	foreach (@table2display)
+	{
+		print "\t".$_."\n";
+	}
+	print "\n";
+}
+
+# Display a 1 level deep hash array in a nice way
+sub display_hash_array_1_level_deep
+{
+	# It is important to pass variable first then table, otherwise if variable comes second, you can't find it using @_. Why?
+	my ($what_is_it,%hash_array2display) = @_;
+	
+	print "The hash array containing all the ". $what_is_it ." is:\n";
+	
+	foreach my $k (keys %hash_array2display)
+	{
+	   print "$k:\n";
+	   foreach (@{$hash_array2display{$k}})
+	   {
+		  print "\t$_\n";
+	   }
+	   print "\n";
+	}
+}
+
+# Display a 2 levels deep hash array in a nice way
+sub display_hash_array_2_levels_deep
+{
+	# It is important to pass variable first then table, otherwise if variable comes second, you can't find it using @_. Why?
+	my ($what_is_it,%hash_array2display) = @_;
+	
+	print "The hash array containing all the ". $what_is_it ." is:\n";
+	
+	foreach my $k1 ( sort keys %hash_array2display )
+	{
+		print "$k1\n";
+
+        foreach my $k2 ( sort keys %{$hash_array2display{ $k1 }} )
+		{
+            print "\t$k2\n";
+
+            foreach my $k3 ( @{$hash_array2display{ $k1 }->{ $k2 }} )
+			{
+				print "\t\t$k3\n";
+            }
+        }
+    }
+}
+
+# Add new key to table if the key is not already present in the table
+sub add_key_for_dynamic_hash_array
+{
+	my ($key2look4,@table2look_into) = @_;
+	
+	#print "Nb of pattern keys in table2look_into is:<".scalar(@table2look_into).">\n";
+	if(!scalar(@table2look_into))
+	{
+		#print "No keys in the table right now. Add <$directory[$count]> as a new key\n";
+		push (@table2look_into,$key2look4);
+	}
+	#print "table2look_into:\n\t@table2look_into\n";
+	
+	my $counter_found_key=0;
+	
+	foreach my $local_var(@table2look_into)
+	{
+		#print "local_var= <$local_var>\n";
+		if($key2look4 eq $local_var)
+		{
+			#print "That key exists already\n";
+			$counter_found_key++;
+		}
+	}
+	#print "counter_found_key=$counter_found_key\n";
+	if(!$counter_found_key)
+	{
+		#print "The key <$directory[$count]> has not be found in the list\n";
+		# Save key in the table to detect if exit or not
+		push (@table2look_into,$key2look4);
+	}
+	return (@table2look_into);
+}
+
+# End section related to help
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/test/pckg_status/scripts/pckg_test_status_patterns.csv	Tue Jan 26 15:39:24 2010 +0000
@@ -0,0 +1,25 @@
+Directory,File,Pattern,Test_type
+,*.inf,.script,TEF/MTF
+,*.pkg,,TEF/MTF
+,*.inf,PRJ_TESTMMPFILES,All
+,*.inf,PRJ_TESTEXPORTS,All
+*test*,,,test_dir
+tsrc,,,tsrc_dir
+*svs*,,,svs_dir
+,*.mmp,.cfg,STIF
+,*.mmp,stif*.lib,STIF
+,*.cfg,[TEST],STIF
+,*.cfg,[ENDTEST],STIF
+,*.mmp,.script,TEF
+,*.mmp,testexecute*.lib,TEF
+,*.script,LOAD_SUITE,TEF
+tsrc,test.xml,,CTC++
+,test.xml,ctcdata.txt,CTC++
+,*.cpp,""".Start(""",RTest
+,*.cpp,""".Next(""",RTest
+,*.cpp,""".End();""",RTest
+,*.cpp,""".close();""",RTest
+,*.h,"""class RTest : public""",RTest
+,*.h,""": public RTest""",RTest
+rtest,,,RTest
+,*.cpp,"""RTest test(""",RTest