common/tools/test/pckg_status/scripts/check_pckg_test_status.pl
changeset 840 3b9cc38657db
equal deleted inserted replaced
839:57b0cd458573 840:3b9cc38657db
       
     1 # Copyright (c) 2009 Symbian Foundation Ltd
       
     2 # This component and the accompanying materials are made available
       
     3 # under the terms of the License "Eclipse Public License v1.0"
       
     4 # which accompanies this distribution, and is available
       
     5 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     6 #
       
     7 # Script name: check_pckg_test_status.pl
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Symbian Foundation Ltd - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 # Arnaud Lenoir <arnaudl@symbian.org>
       
    14 #
       
    15 # Created 27/11/2009
       
    16 #
       
    17 # Description:
       
    18 # Task 286 - Package test status prep
       
    19 #
       
    20 # This script must be used at package level only!!!!
       
    21 # For a general search to several packages, PDK, etc then use check_all_pckg_test_status.pl script
       
    22 #
       
    23 # Parameters passed:
       
    24 #	Param1: Path to the root directory for the package (where the package_definition.xml is present)
       
    25 #	Param2: Path to the file containing the different patterns to have a look for
       
    26 #	Param3: Path to the directory where DB will be published
       
    27 
       
    28 # Modules necessary to run this script
       
    29 use Getopt::Long;
       
    30 use strict;
       
    31 use Text::CSV;
       
    32 use Switch;
       
    33 use Data::Dumper;
       
    34 
       
    35 
       
    36 # Variables for parameters
       
    37 my $help;
       
    38 my $package_path;
       
    39 my $pattern_file_path;
       
    40 my $publication_directory_path;
       
    41 
       
    42 # variables
       
    43 my $system_cmd;		# Used to execute DOS commands
       
    44 my $pckg_name="";	# Contains the name of the package
       
    45 my @key_dirs_tab;	# Used to trace the patterns/keys for directories search
       
    46 my %dirs_hashes;	# Contains the list of directories found hash_array=fct(directory_name(key),directory_path(values that are tables)
       
    47 my @key_files_tab;	# Used to trace the patterns/keys for files search
       
    48 my %files_hashes;	# Contains the list of files found hash_array=fct(file_name(key),file_path(values that are tables)
       
    49 my @key_pattern_in_file_tab;	# Used to trace the patterns/keys for pattern in file search
       
    50 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)
       
    51 my @key_file_in_dir_tab;	# Used to trace the patterns/keys for file in directory search
       
    52 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)
       
    53 my @directory;		# Used to extract data from the csv file that contains the different patterns to look for
       
    54 my @file;			# Used to extract data from the csv file that contains the different patterns to look for
       
    55 my @pattern;		# Used to extract data from the csv file that contains the different patterns to look for
       
    56 my @test_type;		# Used to extract data from the csv file that contains the different patterns to look for
       
    57 my %existing_tests;	# Hash array that record the tests that are supported / exist for the package.
       
    58 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.
       
    59 my %patterns_anywhere_in_dir_hashes;	# Hash array that record the list of files that contain a specific pattern in a directory.
       
    60 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).
       
    61 
       
    62 # Constantes declaration
       
    63 my $default_publication_directory_path = "\.\\results";
       
    64 my $default_pattern_file_path = ".\\pckg_test_status_patterns.csv";
       
    65 my $output_file_base_name = "package_test_status_";
       
    66 my $output_file_extension = ".xml";
       
    67 my $csv_status_file_name = "packages_tests_supported_status.csv";
       
    68 # Used for search algorithm
       
    69 # Directory		File	Pattern		Value	Action
       
    70 #	0			 0			1		  1		Look for pattern anywhere in a file, directory/file name
       
    71 #	0			 1			0		  2		Look for a file
       
    72 #	0			 1			1		  3		Look for a pattern in a file
       
    73 #	1			 0			0		  4		Look for a directory
       
    74 #	1			 0			1		  5		Look for a pattern in the directory anywhere in a directory/file name
       
    75 #	1			 1			0		  6		Look for a file in a directory
       
    76 #	1			 1			1		  7		Look for a pattern in a specific file in a specific directory
       
    77 my $search_algo_4_pattern_anywhere = 1;
       
    78 my $search_algo_4_file = 2;
       
    79 my $search_algo_4_pattern_in_file = 3;
       
    80 my $search_algo_4_directory = 4;
       
    81 my $search_algo_4_pattern_anywhere_in_directory = 5;
       
    82 my $search_algo_4_file_in_directory = 6;
       
    83 my $search_algo_4_pattern_in_specific_file_directory = 7;
       
    84 
       
    85 
       
    86 my $nb_arg_passed = scalar(@ARGV);
       
    87 if(!$nb_arg_passed)
       
    88 {
       
    89 	print "No arguments/parameters passed then print help!\n";
       
    90 	helpme();
       
    91 }
       
    92 
       
    93 my %optmap = (  'package_path' => \$package_path,
       
    94 			    'pattern_file_path' => \$pattern_file_path,
       
    95 				'publication_directory_path' => \$publication_directory_path,
       
    96                 'help' => \$help);
       
    97 
       
    98 GetOptions(\%optmap,
       
    99 		  'package_path=s',
       
   100 		  'pattern_file_path=s',
       
   101 		  'publication_directory_path=s',
       
   102           'help');
       
   103 
       
   104 print "The value for help is: <$help>\n";
       
   105 print "package_path: <$package_path>\n";
       
   106 print "pattern_file_path: <$pattern_file_path>\n";
       
   107 print "publication_directory_path: <$publication_directory_path>\n";
       
   108 
       
   109 # Check if we need default values for some of the parameters
       
   110 # Publication directory
       
   111 if (!defined($publication_directory_path))
       
   112 {
       
   113 	print "No publication_directory_path passed as argument, therefore use default path\n";
       
   114 	$publication_directory_path = $default_publication_directory_path;
       
   115 	print "publication_directory_path = <$publication_directory_path>\n";
       
   116 }
       
   117 # Check if we have a directory use for publishing. If not create it
       
   118 #print "Check if $publication_directory_path exist or not!\n";
       
   119 if (!(-d $publication_directory_path))
       
   120 {
       
   121 	print "The directory $publication_directory_path, doesn't exist, therefore we create it\n";
       
   122 	$system_cmd = "mkdir $publication_directory_path";	
       
   123 	print "Exec: $system_cmd\n";
       
   124 	system($system_cmd);
       
   125 }
       
   126 # Patterns file used
       
   127 if (!defined($pattern_file_path))
       
   128 {
       
   129 	print "No specific patterns file has been passed as parameters, therefore we use default patterns file\n";
       
   130 	$pattern_file_path = $default_pattern_file_path;
       
   131 	print "pattern_file_path = <$pattern_file_path>\n";
       
   132 }
       
   133 
       
   134 if ($help)
       
   135 {
       
   136 	print "We want to print the help\n";
       
   137 	helpme();
       
   138 }
       
   139 else
       
   140 {
       
   141 	print "\nIt's from here that the real work starts!\n";
       
   142 }
       
   143 
       
   144 
       
   145 # Define if the path given as a package_definition*.xml file.
       
   146 # If yes, the directroy correspond to the package name.
       
   147 # If no, then there is a problem, and therefore we should stop.
       
   148 # 1. Check that the path contains the package_definition*.xml.
       
   149 # 2. Extract package name from path given. 
       
   150 
       
   151 print "Package name to extract from: $package_path\n";
       
   152 if($package_path =~ m;\\([\w]+)$;)
       
   153 {
       
   154 	$pckg_name = $1;
       
   155 	print "########################################################################\n";
       
   156 	print "\t\tThe Package name is: <$pckg_name>\n";
       
   157 	print "########################################################################\n";
       
   158 }
       
   159 
       
   160 # Load file with patterns
       
   161 # If file doesn't exist, then exit
       
   162 # Then
       
   163 # Extract patterns from file
       
   164 # Store in tables/hash array???
       
   165 # Count number of lines in the file - header!
       
   166 # Check for column name and stick it in the appropriate table
       
   167 
       
   168 print "Open the patterns file .csv and extract data from it.\n";
       
   169 
       
   170 open(PATTERNSFILE, "$pattern_file_path") or die "Can't open file $pattern_file_path. The error is <$!>\n";
       
   171 
       
   172 #my $csv = Text::CSV->new({blank_is_undef => 1});
       
   173 #my $csv = Text::CSV->new({empty_is_undef => 1});
       
   174 my $csv = Text::CSV->new();
       
   175 
       
   176 my $header=0;
       
   177 my $count_nb_total_lines=0;
       
   178 my @columns;
       
   179 
       
   180 while (<PATTERNSFILE>) {
       
   181 	if ($csv->parse($_)) 
       
   182 	{
       
   183 		@columns = $csv->fields();
       
   184 		
       
   185 		if(!$header)
       
   186 		{
       
   187 			#print "This is the first line of the csv file\n";
       
   188 			$header=1;
       
   189 			foreach (@columns) 
       
   190 			{
       
   191 				#print $_."\n";
       
   192 			}			
       
   193 		}
       
   194 		else
       
   195 		{
       
   196 			#print "line #$count_nb_total_lines of the csv file\n";
       
   197 			
       
   198 			foreach (@columns) 
       
   199 			{
       
   200 				#print "<$_>\n";
       
   201 			}
       
   202 			push(@directory, $columns[0]);
       
   203 			push(@file, $columns[1]);
       
   204 			push(@pattern, $columns[2]);
       
   205 			push(@test_type, $columns[3]);
       
   206 			$count_nb_total_lines++;
       
   207 		}
       
   208 	} 
       
   209 	else 
       
   210 	{
       
   211 		my $err = $csv->error_input;
       
   212 		print "Failed to parse line: $err";
       
   213 	}
       
   214 }
       
   215 print "The number of lines counted in the CSV file is: $count_nb_total_lines\n";
       
   216 print "\n";
       
   217 
       
   218 # Used to display the tables that extracted from the CSV file to check if data are correct
       
   219 #for (my $i=0;$i<$count_nb_total_lines;$i++)
       
   220 #{
       
   221 #	print "$i:\t$directory[$i]\t\t$file[$i]\t\t$pattern[$i]\t\t\t$test_type[$i]\n";
       
   222 #}
       
   223 
       
   224 close(PATTERNSFILE);
       
   225 
       
   226 # Establish the list of type file we have in the package
       
   227 # 1. Create the table that contains the list of all the type of tests listed in the CSV file
       
   228 # 1.a Create a hash array with table "test_type"
       
   229 # 1.b Keep only one entry of each
       
   230 # 2. Make sure that we fill it as we go along
       
   231 
       
   232 #display_array("Type of test",@test_type);
       
   233 foreach (@test_type)
       
   234 {
       
   235 	#print "The test type is: $_\n";
       
   236 	$existing_tests{$_} = "";
       
   237 }
       
   238 #print "List of type of tests we are looking for\n";
       
   239 #print Dumper(\%existing_tests);
       
   240 
       
   241 # Look for patterns and fill tables
       
   242 # foreach lines 
       
   243 # 7 different outputs depending on the line contain
       
   244 # directory, file and pattern (see Excel spreadsheet called "patterns_search_rules.xlsx")
       
   245 
       
   246 my $select_search_type;
       
   247 	
       
   248 my $count =0;
       
   249 while($count<$count_nb_total_lines)
       
   250 {
       
   251 	#print "count=$count\n";
       
   252 	$select_search_type = 0;
       
   253 	if($directory[$count] ne "")
       
   254 	{
       
   255 		$select_search_type += 4;
       
   256 		#print "A directory value exist => select_search_type= <$select_search_type>\n";
       
   257 	}
       
   258 	if($file[$count] ne "")
       
   259 	{
       
   260 		$select_search_type += 2;
       
   261 		#print "A file value exist => select_search_type= <$select_search_type>\n";
       
   262 	}
       
   263 	if($pattern[$count] ne "")
       
   264 	{
       
   265 		$select_search_type += 1;
       
   266 		#print "A pattern value exist => select_search_type= <$select_search_type>\n";
       
   267 	}
       
   268 	#print "select_search_type= <$select_search_type>\n";
       
   269 
       
   270 	switch($select_search_type)
       
   271 	{
       
   272 		case ($search_algo_4_pattern_anywhere)
       
   273 		{
       
   274 			print "Value is $search_algo_4_pattern_anywhere, meaning call fct_search_algo_4_pattern_anywhere\n";
       
   275 			my @pattern_anywhere_returned_table = fct_search_algo_4_pattern_anywhere($pattern[$count]);
       
   276 			
       
   277 			push (@{ $patterns_anywhere_hashes {$pattern[$count]} }, @pattern_anywhere_returned_table);
       
   278 			
       
   279 			my $calcul_tab_size = scalar(@pattern_anywhere_returned_table);
       
   280 			
       
   281 			if($calcul_tab_size)
       
   282 			{
       
   283 				print "There is data for this search: <$calcul_tab_size>\n";
       
   284 				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
       
   285 			}
       
   286 		}
       
   287 		case ($search_algo_4_file)
       
   288 		{
       
   289 			print "Value is $search_algo_4_file, meaning call fct_search_algo_4_file\n";
       
   290 			my @files_returned_table = fct_search_algo_4_file($file[$count]);
       
   291 			
       
   292 			# Display table in a nice way
       
   293 			#display_array("files ".$file[$count],@files_returned_table);
       
   294 			
       
   295 			# Check if the key exists or not. If it doesn't exist then add it to the list
       
   296 			@key_files_tab = add_key_for_dynamic_hash_array($file[$count], @key_files_tab);
       
   297 			
       
   298 			# Save table containing files list returned by fct in the hash array to key file pattern
       
   299 			# hash array: files_hashes
       
   300 			# 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
       
   301 			# 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
       
   302 			# Contain as many key as we are looking for files
       
   303 			push (@{ $files_hashes{$file[$count]} }, @files_returned_table);
       
   304 			
       
   305 			my $calcul_tab_size = scalar(@files_returned_table);
       
   306 			if($calcul_tab_size)
       
   307 			{
       
   308 				print "There is data for this search: <$calcul_tab_size>\n";
       
   309 				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
       
   310 			}
       
   311 		}
       
   312 		case ($search_algo_4_pattern_in_file)
       
   313 		{
       
   314 			print "Value is $search_algo_4_pattern_in_file, meaning call fct_search_algo_4_pattern_in_file\n";
       
   315 			# Hash array filling level 1 deepnees
       
   316 			my @values_found_returned_table;
       
   317 			my @pattern_in_file_returned_table = fct_search_algo_4_pattern_in_file($package_path."\\".$file[$count],$pattern[$count],"/s /m");
       
   318 			
       
   319 			# Display table in a nice way
       
   320 			#display_array("files with pattern ".$pattern[$count],@pattern_in_file_returned_table);
       
   321 
       
   322 			# Check if the key exists or not. If it doesn't exist then add it to the list
       
   323 			@key_pattern_in_file_tab = add_key_for_dynamic_hash_array($pattern[$count], @key_pattern_in_file_tab);
       
   324 
       
   325 			# Used to verify if we have updated the table properly by replacing it with the table passed back
       
   326 			#display_array("keys list after",@key_dirs_tab);
       
   327 			
       
   328 			# Save table containing files list returned by fct in the hash array to key pattern pattern
       
   329 			# hash array: pattern_in_file_hashes
       
   330 			# 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
       
   331 			# 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
       
   332 			# Contain as many key as we are looking for directories
       
   333 			foreach (@pattern_in_file_returned_table)
       
   334 			{
       
   335 				#print "Value: $_\n";
       
   336 				$pattern_in_file_hashes{$pattern[$count]}->{$_} = "";
       
   337 				#print "Value entered: <$pattern_in_file_hashes{$pattern[$count]}->{$_}>\n";
       
   338 			}
       
   339 			#print "\nDump contain of hash array:\n";
       
   340 			#print Dumper(\%pattern_in_file_hashes);
       
   341 			#print "Contain of hash array dumped\n\n";
       
   342 			
       
   343 			# Hash array filling level 2 deepnees
       
   344 			# Take keys (file) taken in the 1st level deepness of the file to do next search
       
   345 			foreach my $path2file2look_into (sort keys %{$pattern_in_file_hashes{$pattern[$count]}} )
       
   346 			{
       
   347 				print "path2file2look_into=<$path2file2look_into>\n";
       
   348 				
       
   349 				@values_found_returned_table = fct_search_algo_4_pattern_in_file($path2file2look_into,$pattern[$count],"/s");
       
   350 				#display_array("lines in <$path2file2look_into>",@values_found_returned_table);
       
   351 			
       
   352 				# Do we need to remove?????????:
       
   353 				#	"I:\sf\os\kernelhwsrv\baseintegtests\baseintegrationtest\testsuites\sd\group\bld.inf:"
       
   354 				# Keep only what is after ":" (not included)
       
   355 
       
   356 				# To remove????? - Beginning
       
   357 #				my @pattern_in_file_cleanedup_table;
       
   358 #				my $local_string;
       
   359 #				$local_string = "\....:([\\w\\W]+)";
       
   360 #				print "local_string: $local_string\n";
       
   361 #				foreach my $line2transform (@values_found_returned_table)
       
   362 #				{
       
   363 #					print "line2transform: <$line2transform>\n";
       
   364 #					$line2transform =~ /$local_string/;
       
   365 #					print "line2transformed: <$line2transform>\n";
       
   366 #					push (@pattern_in_file_cleanedup_table,$line2transform);
       
   367 #				}
       
   368 				# To remove????? - End
       
   369 				
       
   370 				# Populate data in the hash array{pattern}{file}[(lines]	{key} - [table]
       
   371 				$pattern_in_file_hashes{$pattern[$count]}->{$path2file2look_into} = \@values_found_returned_table;
       
   372 				# To remove????? - Beginning
       
   373 				#$pattern_in_file_hashes{$pattern[$count]}->{$path2file2look_into} = \@pattern_in_file_cleanedup_table;
       
   374 				# To remove????? - End
       
   375 			}
       
   376 			#print "\nDump full contain of hash array:\n";
       
   377 			#print Dumper(\%pattern_in_file_hashes);
       
   378 			#print "Full contain of hash array dumped\n\n";
       
   379 			
       
   380 			my $calcul_tab_size = scalar(@values_found_returned_table);
       
   381 			if($calcul_tab_size)
       
   382 			{
       
   383 				print "There is data for this search: <$calcul_tab_size>\n";
       
   384 				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
       
   385 			}
       
   386 		}
       
   387 		case ($search_algo_4_directory)
       
   388 		{
       
   389 			print "Value is $search_algo_4_directory, meaning call fct_search_algo_4_directory\n";
       
   390 			my @dirs_returned_table = fct_search_algo_4_directory($directory[$count]);
       
   391 			
       
   392 			# Display table in a nice way
       
   393 			#display_array("directories ".$directory[$count],@dirs_returned_table);
       
   394 			
       
   395 			# Used to verify if table for the keys is managed properly
       
   396 			#display_array("keys list before",@key_dirs_tab);
       
   397 
       
   398 			# Check if the key exists or not. If it doesn't exist then add it to the list
       
   399 			@key_dirs_tab = add_key_for_dynamic_hash_array($directory[$count], @key_dirs_tab);
       
   400 
       
   401 			# Used to verify if we have updated the table properly by replacing it with the table passed back
       
   402 			#display_array("keys list after",@key_dirs_tab);
       
   403 			
       
   404 			# Save table containing directories list returned by fct in the hash array to key directory pattern
       
   405 			# hash array: dirs_hashes
       
   406 			# 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
       
   407 			# 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
       
   408 			# Contain as many key as we are looking for directories
       
   409 			push (@{ $dirs_hashes{$directory[$count]} }, @dirs_returned_table);
       
   410 			
       
   411 			my $calcul_tab_size = scalar(@dirs_returned_table);
       
   412 			if($calcul_tab_size)
       
   413 			{
       
   414 				print "There is data for this search: <$calcul_tab_size>\n";
       
   415 				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
       
   416 			}
       
   417 		}
       
   418 
       
   419 		case ($search_algo_4_pattern_anywhere_in_directory)
       
   420 		{
       
   421 			print "Value is $search_algo_4_pattern_anywhere_in_directory, meaning call fct_search_algo_4_pattern_anywhere_in_directory\n";
       
   422 			my @patterns_in_dir_returned_table = fct_search_algo_4_pattern_anywhere_in_directory($directory[$count],$pattern[$count]);
       
   423 			
       
   424 			push (@{ $patterns_anywhere_in_dir_hashes{$pattern[$count]} }, @patterns_in_dir_returned_table);
       
   425 			
       
   426 			my $calcul_tab_size = scalar(@patterns_in_dir_returned_table);
       
   427 			if($calcul_tab_size)
       
   428 			{
       
   429 				print "There is data for this search: <$calcul_tab_size>\n";
       
   430 				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
       
   431 			}
       
   432 		}
       
   433 		case ($search_algo_4_file_in_directory)
       
   434 		{
       
   435 			print "Value is $search_algo_4_file_in_directory, meaning call fct_search_algo_4_file_in_directory\n";
       
   436 			my @file_in_dir_returned_table = fct_search_algo_4_file_in_directory($directory[$count],$file[$count]);
       
   437 			#display_array("file <".$file[$count]."> in directory <".$directory[$count].">",@file_in_dir_returned_table);
       
   438 			
       
   439 			# Check if the key exists or not. If it doesn't exist then add it to the list
       
   440 			@key_file_in_dir_tab = add_key_for_dynamic_hash_array($file[$count], @key_file_in_dir_tab);
       
   441 			
       
   442 			#@key_file_in_dir_tab
       
   443 			#%file_in_dir_hashes
       
   444 			push (@{ $file_in_dir_hashes{$file[$count]} }, @file_in_dir_returned_table);
       
   445 			
       
   446 			print "\nDump full contain of hash array:\n";
       
   447 			#print Dumper(\%file_in_dir_hashes);
       
   448 			print "Full contain of hash array dumped\n\n";
       
   449 			
       
   450 			my $calcul_tab_size = scalar(@file_in_dir_returned_table);
       
   451 			if($calcul_tab_size)
       
   452 			{
       
   453 				print "There is data for this search: <$calcul_tab_size>\n";
       
   454 				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
       
   455 			}
       
   456 		}
       
   457 		case ($search_algo_4_pattern_in_specific_file_directory)
       
   458 		{
       
   459 			print "Value is $search_algo_4_pattern_in_specific_file_directory, call fct_meaning search_algo_4_pattern_in_specific_file_directory\n";
       
   460 			my @patterns_in_dir_in_file_returned_table = fct_search_algo_4_pattern_in_specific_file_and_directory($directory[$count],$file[$count],$pattern[$count]);
       
   461 
       
   462 			push (@{ $patterns_in_dir_in_file_hashes{$pattern[$count]} }, @patterns_in_dir_in_file_returned_table);
       
   463 			
       
   464 			my $calcul_tab_size = scalar(@patterns_in_dir_in_file_returned_table);
       
   465 			print "calcul_tab_size = <$calcul_tab_size>\n";
       
   466 			if($calcul_tab_size)
       
   467 			{
       
   468 				print "There is data for this search: <$calcul_tab_size>\n";
       
   469 				$existing_tests{$test_type[$count]}++;	# Add 1 to the count for the type of test supported
       
   470 			}
       
   471 		}		
       
   472 		else
       
   473 		{
       
   474 			# default for the switch
       
   475 			# Added one for the line error as we need to add 1st line of the csv file, which is the header line
       
   476 			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";
       
   477 		}
       
   478 	}
       
   479 	$count++;
       
   480 }
       
   481 
       
   482 # Output generated in a file which is following special naming convention because used to create the globabl picture
       
   483 # pckg_test_atatus[pckgname].xml?
       
   484 # Create file if doesn't exist. If exist already, update? delete & create from scratch?
       
   485 #
       
   486 # 1. Extract package name
       
   487 # 2. Create a file called "package_test_status_[package_name].xml
       
   488 # 3. Fill xml file using data gathered in this script
       
   489 # 4. Close xml file
       
   490 
       
   491 print "\n";
       
   492 
       
   493 #
       
   494 # Display data
       
   495 #
       
   496 print "!!!!This section is related to the display of the data gatehered by this script!!!!\n\n";
       
   497 
       
   498 # To remove????? - Beginning
       
   499 #my @display_hash_tab;
       
   500 #@display_hash_tab = keys(%dirs_hashes);
       
   501 #foreach my $key_val (@display_hash_tab)
       
   502 #{
       
   503 #	print "Key: <$key_val>:\n";
       
   504 #	my @read_table_in_hash_array = @{$dirs_hashes{$key_val}};
       
   505 #	foreach my $tab_val (@read_table_in_hash_array)
       
   506 #	{
       
   507 #		print "\tValue: <$tab_val>\n";
       
   508 #	}
       
   509 #}
       
   510 #print "\n";
       
   511 # To remove????? - End
       
   512 
       
   513 # Display of the search we have done for the directories we need information from
       
   514 if(%dirs_hashes)
       
   515 {
       
   516 	print "Look for directories:\n";
       
   517 	#display_hash_array_1_level_deep ("directories", %dirs_hashes);
       
   518 	print Dumper({%dirs_hashes});
       
   519 	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   520 }
       
   521 
       
   522 # Display of the search we have done for the files we need information from
       
   523 if(%files_hashes)
       
   524 {
       
   525 	print "Look for files:\n";
       
   526 	#display_hash_array_1_level_deep ("files", %files_hashes);
       
   527 	print Dumper({%files_hashes});
       
   528 	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   529 }
       
   530 
       
   531 # Display of the search we have done for the pattern in files we need information from
       
   532 if(%pattern_in_file_hashes)
       
   533 {
       
   534 	print "Look for pattern in a file:\n";
       
   535 	#display_hash_array_2_levels_deep ("1st & 2nd levels of patterns (files & lines) in files", %pattern_in_file_hashes);	
       
   536 	
       
   537 	print Dumper(\%pattern_in_file_hashes);
       
   538 	#print Dumper({%pattern_in_file_hashes});	# same result as above
       
   539 	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   540 }
       
   541 
       
   542 # Display of the search we have done for the files we need information from
       
   543 if(%file_in_dir_hashes)
       
   544 {
       
   545 	print "Look for files in a specific directory:\n";
       
   546 	#display_hash_array_1_level_deep ("specific file in a specific directory", %file_in_dir_hashes);
       
   547 	print Dumper({%file_in_dir_hashes});
       
   548 	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   549 }
       
   550 
       
   551 # Display of the search we have done for the patterns anywhere in directory / file names and in the files themselves.
       
   552 if(%patterns_anywhere_hashes)
       
   553 {
       
   554 	print "Look for a pattern everywhere:\n";
       
   555 	print Dumper({%patterns_anywhere_hashes});
       
   556 	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   557 }
       
   558 
       
   559 # Display of the search we have done for the patterns anywhere in a specific directory.
       
   560 if(%patterns_anywhere_in_dir_hashes)
       
   561 {
       
   562 	print "Look for a pattern everywhere in a directory:\n";
       
   563 	print Dumper({%patterns_anywhere_in_dir_hashes});
       
   564 	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   565 }
       
   566 
       
   567 # Display of the search we have done for the patterns in a specific directory that contain a specific file in that directory/sub-directory.
       
   568 if(%patterns_in_dir_in_file_hashes)
       
   569 {
       
   570 	print "Look for a pattern in a specific file in a specific directory:\n";
       
   571 	print Dumper({%patterns_in_dir_in_file_hashes});
       
   572 	print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   573 }
       
   574 
       
   575 print "\n";
       
   576 
       
   577 print "Indicates the type of tests supported by the package $pckg_name:\n";
       
   578 print Dumper(\%existing_tests);	
       
   579 
       
   580 print "\n\n\t\t.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-\n\n";
       
   581 
       
   582 #
       
   583 # Save data in files
       
   584 #
       
   585 print "!!!!This section is related to the saving of the data in files!!!!\n\n";
       
   586 
       
   587 print "Save basic data about the type of tests supported by the package in a generic csv file\n";
       
   588 
       
   589 my $csv_status_file_path = "$publication_directory_path\\$csv_status_file_name";
       
   590 print "The full path for the csv packages tests status file is: $csv_status_file_path\n";
       
   591 
       
   592 if(!(-f $csv_status_file_path))
       
   593 {
       
   594 	print "The file doesn't exist, we need to create it and fill it with the hearder row\n";
       
   595 	open(CSVSTATUSFILE,">$csv_status_file_path");	# Create the file from scratch
       
   596 	
       
   597 	print CSVSTATUSFILE "Package_Name";
       
   598 	
       
   599 	foreach my $type_test_key (sort keys %existing_tests)
       
   600 	{
       
   601 		# Fields separated by comas
       
   602 		print "Enter header name: type_test_key is $type_test_key\n";
       
   603 		print CSVSTATUSFILE ",$type_test_key";
       
   604 	}
       
   605 	print CSVSTATUSFILE "\n";	# To make sure we are ready for the next line
       
   606 }
       
   607 else
       
   608 {
       
   609 	print "The file exists, we need to populate it with the necessary info\n";
       
   610 	open(CSVSTATUSFILE,">>$csv_status_file_path");	# Append the file as it exists already and we are just going to add a new line
       
   611 	
       
   612 	# Do we need to check if we have the same number of info on the header row (1st row)?????
       
   613 }
       
   614 
       
   615 print CSVSTATUSFILE "$pckg_name";
       
   616 foreach my $type_test_key4val (sort keys %existing_tests)
       
   617 {
       
   618 	# Fields separated by comas
       
   619 	print "$pckg_name: The key test type is: <$type_test_key4val> and the value associated with is: <$existing_tests{$type_test_key4val}>\n";
       
   620 	print CSVSTATUSFILE ",$existing_tests{$type_test_key4val}";
       
   621 }
       
   622 print CSVSTATUSFILE "\n";	# To make sure we are ready for the next line
       
   623 
       
   624 close(CSVSTATUSFILE);
       
   625 print "We have now updated the file <$csv_status_file_path> with the data gathered for the package $pckg_name\n\n";
       
   626 
       
   627 my $output_file_name = $output_file_base_name.$pckg_name.$output_file_extension;
       
   628 print "The output file name is: $output_file_name\n";
       
   629 my $path4output_file = "$publication_directory_path\\$output_file_name";
       
   630 print "The full path for the output file is: $path4output_file\n";
       
   631 
       
   632 print "\nCreate and fill file <$path4output_file>\n";
       
   633 
       
   634 # 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?
       
   635 open(OUTPUTFILE,">$path4output_file");
       
   636 
       
   637 print "Fill the xml file with data we have gathered in this script!!!!!\n";
       
   638 print OUTPUTFILE "Fill the xml file with data we have!!!!!\n";
       
   639 
       
   640 close (OUTPUTFILE);
       
   641 
       
   642 # End of the script
       
   643 exit(0);
       
   644 # THE END OF THE END AT THE END OF THIS SCRIPT
       
   645 
       
   646 #
       
   647 # Functions section
       
   648 #
       
   649 
       
   650 # If no parameters entered or help selected, display help
       
   651 sub helpme
       
   652 {	
       
   653 	print "\nfct: helpme\n";
       
   654 	print "check_pckg_test_status.pl\n";
       
   655 	print "Usage:\n";
       
   656 	print "check_pckg_test_status.pl --help\n";
       
   657 	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";
       
   658 	print "Options:\n";
       
   659 	print "--help:\t\t\t\t display this help and exit\n";
       
   660 	print "--package_path:\t\t\t is the path to the directory containing the package_definition.xml file\n";
       
   661 	print "--pattern_file_path:\t\t is the path to the file containing the patterns to be lookeed for\n";
       
   662 	print "--publication_directory_path:\t is the path to the directory where the results will be published\n";
       
   663 	print "\t\t\t\t default value is $default_publication_directory_path\n";
       
   664 	
       
   665 	exit(0);
       
   666 }
       
   667 
       
   668 # Search functions
       
   669 sub fct_search_algo_4_pattern_anywhere
       
   670 {
       
   671 	my ($pattern) = @_;
       
   672 
       
   673 	print "This is the function: fct_search_algo_4_pattern_anywhere\n";
       
   674 
       
   675 	print "Search for pattern: <$pattern>\n";
       
   676 	my @pattern_search_tab;
       
   677 	
       
   678 	# Firstly have a look for the pattern in the directories and files names
       
   679 	print "Search for the pattern in any directory or file names\n";
       
   680 	
       
   681 	@pattern_search_tab = fct_dos_cmd_dir_search("$package_path\\*$pattern*", "/s /b");
       
   682 	
       
   683 	#print "Pattern <$pattern> was found in: @pattern_search_tab\n";
       
   684 	#print "\n";
       
   685 	
       
   686 	# Secondly have a look in any files if we can find the pattern.
       
   687 	# Should we use: fct_search_algo_4_pattern_in_file()?
       
   688 
       
   689 	my @local_returned_table = fct_search_algo_4_pattern_in_file($package_path . "\\*",$pattern[$count],"/s /n");
       
   690 	# If we just want to display the files and not the contain of the line. As well should elimintate the duplicate for files?
       
   691 	#my @local_returned_table = fct_search_algo_4_pattern_in_file($local_package_path,$pattern[$count],"/s /m");
       
   692 	push(@pattern_search_tab,@local_returned_table);
       
   693 	
       
   694 	#print "\n";
       
   695 	#print "Pattern <$pattern> was found in: @pattern_search_tab\n";
       
   696 	#print "\n";
       
   697 	
       
   698 	return (@pattern_search_tab);
       
   699 }
       
   700 sub fct_search_algo_4_file
       
   701 {
       
   702 	my ($file) = @_;
       
   703 
       
   704 	print "This is the function: fct_search_algo_4_file\n";
       
   705 	print "Search for file: <$file>\n";
       
   706 	
       
   707 	my @files;
       
   708 
       
   709 	@files = fct_dos_cmd_dir_search("$package_path\\$file", "/s /b");
       
   710 
       
   711 	#print "files found are: @files\n";
       
   712 	
       
   713 	print "\n";
       
   714 	return (@files);
       
   715 }
       
   716 
       
   717 # This function was originally setup to have a look for a pattern in a specific files,
       
   718 # 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.
       
   719 sub fct_search_algo_4_pattern_in_file
       
   720 {
       
   721 	my ($file,$pattern,$options) = @_;
       
   722 
       
   723 	print "This is the function: fct_search_algo_4_pattern_in_file\n";
       
   724 
       
   725 	#print "Search for file: <$file>\n";
       
   726 	#print "Search for pattern: <$pattern>\n";
       
   727 	#print "Options: <$options>\n";
       
   728 	
       
   729 	my @pattern_in_files;
       
   730 	
       
   731 	# Check findstr /? to find out about the "regular expression"
       
   732 	# "." Wildcard: any character
       
   733 	# "*" Repeat: zero or more occurances of previous character or class
       
   734 		
       
   735 	# Check if the pattern contain a dot. If yes replace any "." by "\."
       
   736 	if ( $pattern =~ /\./)
       
   737 	{
       
   738 		$pattern =~ s/\./\\./;
       
   739 		#print "Replaced all \. by \\. to the pattern: <$pattern>\n";
       
   740 	}
       
   741 	else
       
   742 	{
       
   743 		#print "$pattern doesn't doesn't contain a \.\n";
       
   744 	}
       
   745 	# Check if the pattern contain a star. If yes replace any "*" by ".*"
       
   746 	# For a string to have a look at "string*.txt", the "*" equivalent for findstr is ".*"
       
   747 	# For more info, check out here: http://technet.microsoft.com/en-us/library/bb490907.aspx
       
   748 	if ( $pattern =~ /\*/)
       
   749 	{
       
   750 		$pattern =~ s/\*/\.\*/g;
       
   751 		#print "Replaced all \* by \.* to the pattern: <$pattern>\n";
       
   752 	}
       
   753 	else
       
   754 	{
       
   755 		#print "$pattern doesn't contain a *\n";
       
   756 	}
       
   757 
       
   758 	# 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"
       
   759 	if ( ($pattern =~ /^"/) && ($pattern =~ /"$/))
       
   760 	{
       
   761 		# Replace the first <"> by </c:">
       
   762 		$pattern =~ s/\"/\/c:\"/;
       
   763 		#print "Replaced first <\"> by <\/c:\"> to become: <$pattern>\n";
       
   764 	}
       
   765 	else
       
   766 	{
       
   767 		#print "$pattern is not contained between\"\" \n";
       
   768 	}
       
   769 
       
   770 	open(SEARCHPATTERNINFILE,"findstr $options $pattern $file |");
       
   771 	
       
   772 	while(<SEARCHPATTERNINFILE>)
       
   773 	{
       
   774 		my $val = $_;
       
   775 		
       
   776 		#remove the trailing \n
       
   777 		chomp($val);
       
   778 		
       
   779 		#print "value found is <$val>\n";
       
   780 		
       
   781 		if($val =~ /.hg/)
       
   782 		{
       
   783 			#print "Discard that line!\n"
       
   784 		}
       
   785 		else
       
   786 		{
       
   787 			#print "We need to save the value <$val>\n";
       
   788 			# Push value in a table and pass it as a parameter!?
       
   789 			push(@pattern_in_files,$val);
       
   790 		}
       
   791 	}
       
   792 	close(SEARCHPATTERNINFILE);
       
   793 
       
   794 	print "\n";
       
   795 	
       
   796 	return (@pattern_in_files);
       
   797 }
       
   798 
       
   799 sub fct_search_algo_4_directory
       
   800 {
       
   801 	#my $dir = $_[0]; # get first argument passed to the function
       
   802 	my ($dir) = @_;
       
   803 		
       
   804 	print "This is the function: fct_search_algo_4_directory\n";
       
   805 	print "Search for directory: <$dir>\n";
       
   806 	
       
   807 	my @dirs;
       
   808 	
       
   809 	# To remove????? - Beginning
       
   810 	#opendir DIR, $package_path or die "can't read $package_path: $!";
       
   811 	#@dirs = readdir DIR;
       
   812 	#@dirs = dir "$dir", readdir DIR;
       
   813 	#closedir DIR;
       
   814 	#print "\n";
       
   815 	#print @dirs;
       
   816 	#print "\n\n";
       
   817 	# To remove????? - End
       
   818 	
       
   819 	@dirs = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
       
   820 	
       
   821 	# To remove????? - Beginning
       
   822 	if(scalar(@dirs))
       
   823 	{
       
   824 		#print "\n";
       
   825 		#print "Here is the list of directories that we have found named <$dir>:\n";
       
   826 		foreach (@dirs)
       
   827 		{
       
   828 			#print "\t$_\n";
       
   829 		}
       
   830 	}
       
   831 	#print "\n";
       
   832 	# To remove????? - End
       
   833 	
       
   834 	return (@dirs);
       
   835 }
       
   836 
       
   837 sub fct_search_algo_4_pattern_anywhere_in_directory
       
   838 {
       
   839 	my ($dir,$pattern) = @_;
       
   840 
       
   841 	print "This is the function: fct_search_algo_4_pattern_anywhere_in_directory\n";
       
   842 
       
   843 	print "Findout if there is one or more directory called: <$dir>\n";
       
   844 	my @local_dir_exist_tab;
       
   845 	my @table_to_return_with_search;
       
   846 	
       
   847 	@local_dir_exist_tab = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
       
   848 	
       
   849 	print "we found <$dir>: \n<\n@local_dir_exist_tab \n>\n";
       
   850 	
       
   851 	print "Search for pattern: <$pattern> in directory $dir\n";
       
   852 	foreach my $dir_to_search (@local_dir_exist_tab)
       
   853 	{
       
   854 		print "The directory that we examine is: $dir_to_search\n";
       
   855 		
       
   856 		my @local_pattern_in_directory_returned_table = fct_search_algo_4_pattern_in_file($dir_to_search. "\\*",$pattern,"/s /n");
       
   857 		push(@table_to_return_with_search,@local_pattern_in_directory_returned_table);
       
   858 		
       
   859 		#print "Here are all the values we found for $pattern in $dir_to_search:\n";
       
   860 		#print Dumper(@local_pattern_in_directory_returned_table);
       
   861 	}
       
   862 
       
   863 	#print "Here are all the values we found and that will be returned: \n";
       
   864 	#print Dumper(@table_to_return_with_search);
       
   865 	
       
   866 	print "\n";
       
   867 	
       
   868 	return (@table_to_return_with_search);
       
   869 }
       
   870 
       
   871 sub fct_search_algo_4_file_in_directory
       
   872 {
       
   873 	my ($dir,$file) = @_;
       
   874 
       
   875 	print "This is the function: fct_search_algo_4_file_in_directory\n";
       
   876 
       
   877 	print "Search for directory: <$dir>\n";
       
   878 	print "Search for file: <$file>\n";
       
   879 
       
   880 	print "\n";
       
   881 	my @dir_list;
       
   882 	my @file_in_dir;
       
   883 
       
   884 	print "Look for directories <$dir>\n";
       
   885 	@dir_list = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
       
   886 	
       
   887 	#print "we found <$dir>: \n<\n@dir_list \n>\n";
       
   888 
       
   889 	# Look for files in the directories we have previously found
       
   890 	print "Look for the file <$file> in the directory found previously\n";
       
   891 	
       
   892 	foreach my $dir_to_search (@dir_list)
       
   893 	{
       
   894 		#print "Look file <$file> in directory <$dir_to_search>\n";
       
   895 		
       
   896 		@file_in_dir = fct_dos_cmd_dir_search("$dir_to_search\\$file", "/s /b");
       
   897 		
       
   898 		open(SEARCHFILEDIR,"dir /s /b $dir_to_search\\$file |");
       
   899 	}
       
   900 	
       
   901 	#print "we found <$file> in: \n<\n@file_in_dir \n>\n";
       
   902 	
       
   903 	return (@file_in_dir);
       
   904 }
       
   905 
       
   906 sub fct_search_algo_4_pattern_in_specific_file_and_directory
       
   907 {
       
   908 	my ($dir,$file,$pattern) = @_;
       
   909 
       
   910 	print "This is the function: fct_search_algo_4_pattern_in_specific_file_and_directory\n";
       
   911 
       
   912 	my @local_dir_exist_tab;
       
   913 	my @local_file_exist_in_dir_tab;
       
   914 	my @table_to_return_with_search;
       
   915 	
       
   916 	# Look for directories
       
   917 	print "Look for directories <$dir>\n";
       
   918 	@local_dir_exist_tab = fct_dos_cmd_dir_search("$package_path\\$dir", "/s /b /a:d");
       
   919 	
       
   920 	#print "we found <$dir>: \n<\n@local_dir_exist_tab \n>\n";
       
   921 
       
   922 	# Look for files in the directories we have previously found
       
   923 	print "Look for the file <$file> in the directory found previously\n";
       
   924 	
       
   925 	foreach my $dir_to_search (@local_dir_exist_tab)
       
   926 	{
       
   927 		#print "Look file <$file> in directory <$dir_to_search>\n";
       
   928 		
       
   929 		@local_file_exist_in_dir_tab = fct_dos_cmd_dir_search("$dir_to_search\\$file", "/s /b");
       
   930 		
       
   931 		open(SEARCHFILEDIR,"dir /s /b $dir_to_search\\$file |");
       
   932 	}
       
   933 	
       
   934 	#print "we found <$file> in: \n<\n@local_file_exist_in_dir_tab \n>\n";
       
   935 	
       
   936 	print "Search for pattern: $pattern in directory $dir and file $file\n";
       
   937 	foreach my $file_to_search (@local_file_exist_in_dir_tab)
       
   938 	{
       
   939 		#print "File to examine is: $file_to_search\n";
       
   940 		
       
   941 		my @local_pattern_in_file_returned_table = fct_search_algo_4_pattern_in_file($file_to_search,$pattern,"/s /n");
       
   942 		push(@table_to_return_with_search,@local_pattern_in_file_returned_table);
       
   943 		
       
   944 		#print "Here are all the values we found for $pattern in $file_to_search:\n";
       
   945 		#print Dumper(@local_pattern_in_file_returned_table);
       
   946 	}
       
   947 
       
   948 	#print "Here are all the values we found and that will be returned: \n";
       
   949 	#print Dumper(@table_to_return_with_search);
       
   950 	
       
   951 	print "\n";
       
   952 	
       
   953 	return (@table_to_return_with_search);
       
   954 }
       
   955 
       
   956 # create a function that will look for a file or directory
       
   957 sub fct_dos_cmd_dir_search
       
   958 {
       
   959 	my ($what_to_look_for,$options) = @_;
       
   960 	
       
   961 	print "This is the function: fct_dos_cmd_dir_search\n";
       
   962 	my @search_result_tab;
       
   963 	
       
   964 	print "what_to_look_for: <$what_to_look_for>\n";
       
   965 	print "options: <$options>\n";
       
   966 
       
   967 	open(SEARCHUSINGDIRDOSCMD,"dir $options $what_to_look_for |");
       
   968 	
       
   969 	while(<SEARCHUSINGDIRDOSCMD>)
       
   970 	{
       
   971 		my $val = $_;
       
   972 		
       
   973 		#remove the trailing \n
       
   974 		chomp($val);
       
   975 		
       
   976 		#print "value found is <$val>\n";
       
   977 		
       
   978 		if($val =~ /.hg/)
       
   979 		{
       
   980 			#print "Discard that line!\n"
       
   981 		}
       
   982 		else
       
   983 		{
       
   984 			#print "We need to save the value <$val>\n";
       
   985 			# Push value in a table and pass it as a parameter!?
       
   986 			push(@search_result_tab,$val);
       
   987 		}
       
   988 	}
       
   989 	close(SEARCHUSINGDIRDOSCMD);
       
   990 	
       
   991 	return (@search_result_tab);
       
   992 }
       
   993 
       
   994 # Display an array with text indicating what it is
       
   995 sub display_array
       
   996 {
       
   997 	# It is important to pass variable first then table, otherwise if variable comes second, you can't find it using @_. Why?
       
   998 	my ($what_is_it,@table2display) = @_;
       
   999 
       
  1000 	#print "what_is_it: <$what_is_it>\n";
       
  1001 	print "The table containing all the ". $what_is_it ." is:\n";
       
  1002 	
       
  1003 	foreach (@table2display)
       
  1004 	{
       
  1005 		print "\t".$_."\n";
       
  1006 	}
       
  1007 	print "\n";
       
  1008 }
       
  1009 
       
  1010 # Display a 1 level deep hash array in a nice way
       
  1011 sub display_hash_array_1_level_deep
       
  1012 {
       
  1013 	# It is important to pass variable first then table, otherwise if variable comes second, you can't find it using @_. Why?
       
  1014 	my ($what_is_it,%hash_array2display) = @_;
       
  1015 	
       
  1016 	print "The hash array containing all the ". $what_is_it ." is:\n";
       
  1017 	
       
  1018 	foreach my $k (keys %hash_array2display)
       
  1019 	{
       
  1020 	   print "$k:\n";
       
  1021 	   foreach (@{$hash_array2display{$k}})
       
  1022 	   {
       
  1023 		  print "\t$_\n";
       
  1024 	   }
       
  1025 	   print "\n";
       
  1026 	}
       
  1027 }
       
  1028 
       
  1029 # Display a 2 levels deep hash array in a nice way
       
  1030 sub display_hash_array_2_levels_deep
       
  1031 {
       
  1032 	# It is important to pass variable first then table, otherwise if variable comes second, you can't find it using @_. Why?
       
  1033 	my ($what_is_it,%hash_array2display) = @_;
       
  1034 	
       
  1035 	print "The hash array containing all the ". $what_is_it ." is:\n";
       
  1036 	
       
  1037 	foreach my $k1 ( sort keys %hash_array2display )
       
  1038 	{
       
  1039 		print "$k1\n";
       
  1040 
       
  1041         foreach my $k2 ( sort keys %{$hash_array2display{ $k1 }} )
       
  1042 		{
       
  1043             print "\t$k2\n";
       
  1044 
       
  1045             foreach my $k3 ( @{$hash_array2display{ $k1 }->{ $k2 }} )
       
  1046 			{
       
  1047 				print "\t\t$k3\n";
       
  1048             }
       
  1049         }
       
  1050     }
       
  1051 }
       
  1052 
       
  1053 # Add new key to table if the key is not already present in the table
       
  1054 sub add_key_for_dynamic_hash_array
       
  1055 {
       
  1056 	my ($key2look4,@table2look_into) = @_;
       
  1057 	
       
  1058 	#print "Nb of pattern keys in table2look_into is:<".scalar(@table2look_into).">\n";
       
  1059 	if(!scalar(@table2look_into))
       
  1060 	{
       
  1061 		#print "No keys in the table right now. Add <$directory[$count]> as a new key\n";
       
  1062 		push (@table2look_into,$key2look4);
       
  1063 	}
       
  1064 	#print "table2look_into:\n\t@table2look_into\n";
       
  1065 	
       
  1066 	my $counter_found_key=0;
       
  1067 	
       
  1068 	foreach my $local_var(@table2look_into)
       
  1069 	{
       
  1070 		#print "local_var= <$local_var>\n";
       
  1071 		if($key2look4 eq $local_var)
       
  1072 		{
       
  1073 			#print "That key exists already\n";
       
  1074 			$counter_found_key++;
       
  1075 		}
       
  1076 	}
       
  1077 	#print "counter_found_key=$counter_found_key\n";
       
  1078 	if(!$counter_found_key)
       
  1079 	{
       
  1080 		#print "The key <$directory[$count]> has not be found in the list\n";
       
  1081 		# Save key in the table to detect if exit or not
       
  1082 		push (@table2look_into,$key2look4);
       
  1083 	}
       
  1084 	return (@table2look_into);
       
  1085 }
       
  1086 
       
  1087 # End section related to help