tsrc/testing/tools/selgesubdirs.pl
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 #
       
     2 # Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 
       
    18 #------------------------------------------------------------------------------------
       
    19 # Includes
       
    20 #------------------------------------------------------------------------------------
       
    21 #use strict;
       
    22 use warnings;
       
    23 use Cwd; # for cwd
       
    24 use FindBin; # for FindBin:Bin
       
    25 use File::Path; # for mkpath
       
    26 use Date::Calc;
       
    27 
       
    28 #------------------------------------------------------------------------------------
       
    29 # GLOBAL CODE
       
    30 #------------------------------------------------------------------------------------
       
    31 
       
    32 my $argcount = scalar(@ARGV);
       
    33 
       
    34 if(scalar(@ARGV) > 0)
       
    35 {
       
    36     ShowHelp();
       
    37     exit();
       
    38 }
       
    39 
       
    40 print("This script deletes mobilecrashes and result directory from ./Selge.\nPress CTRL-C to quit, enter to continue.\n");
       
    41 $input = <>;
       
    42 exit if($input eq "q");
       
    43 
       
    44 my @dirs;
       
    45 my $startDir = cwd;
       
    46 
       
    47 FindFiles(".", 1, "", \@dirs, "case_*");
       
    48 
       
    49 foreach my $dir(@dirs)
       
    50 {
       
    51     $dir =~ s/\//\\/g; #whitespaces in the end
       
    52     system("del selge\\mobilecrash_*.bin\n");
       
    53 
       
    54     print("copy $dir\\mobilecrash_*.bin selge\\\n");
       
    55     system("copy $dir\\mobilecrash_*.bin selge\\");
       
    56 
       
    57     print("cd selge\n");
       
    58     chdir("selge");
       
    59 
       
    60     print("selge.exe -m\n");
       
    61     system("selge.exe -m");
       
    62 
       
    63     print("copy results\\ $dir\\\n");
       
    64     system("copy results\\ $dir\\");
       
    65 
       
    66 
       
    67     print("del mobilecrash_*.bin\n");
       
    68     system("del mobilecrash_*.bin");
       
    69 
       
    70     print("rmdir /s /q results\\\n");
       
    71     system("rmdir /s /q results\\");
       
    72 
       
    73     chdir("..");
       
    74 }
       
    75 
       
    76 chdir($startDir);
       
    77 
       
    78 exit();
       
    79 
       
    80 #------------------------------------------------------------------------------------
       
    81 # ShowHelp
       
    82 #------------------------------------------------------------------------------------
       
    83 sub ShowHelp {
       
    84 
       
    85 print <<USAGE_EOF;
       
    86 
       
    87 selgesubdirs.pl
       
    88 
       
    89 Copies the mobilecrashes from sub directories into Selge directory and runs Selge there.
       
    90 Result files are copied back to the sub directory.
       
    91 
       
    92 Only directories starting with case_ are processed. Selge and case_* must exist in the current directory.
       
    93 
       
    94 USAGE_EOF
       
    95 
       
    96 	exit();
       
    97 
       
    98 };
       
    99 
       
   100 #------------------------------------------------------------------------------------
       
   101 # RemoveWhiteSpaces
       
   102 #
       
   103 # Parameters:
       
   104 # 	$text
       
   105 #------------------------------------------------------------------------------------
       
   106 sub RemoveWhiteSpaces()
       
   107 {
       
   108 	my ($text) = @_;
       
   109 	${$text} =~ s/\s+$//; #whitespaces in the end
       
   110 	${$text} =~ s/^\s+//; #whitespaces at the start
       
   111 }
       
   112 
       
   113 #------------------------------------------------------------------------------------
       
   114 # FindFiles
       
   115 # Parameters:
       
   116 #	$goDir, where to start finding
       
   117 #   $fileType 0 = files, 1 = directories
       
   118 #	$fileSearch, filename search
       
   119 #	$refIncfiles, reference to array which will hold found files
       
   120 #------------------------------------------------------------------------------------
       
   121 sub FindFiles
       
   122 {
       
   123 	my ($godir, $fileType, $fileSearch, $refIncfiles) = @_;
       
   124 
       
   125 	my $startDir = cwd;
       
   126 
       
   127 	chdir($godir);
       
   128 
       
   129 	#print("Now in: " . cwd . "\n");
       
   130 
       
   131 	opendir(DIR, ".");
       
   132 	my @filelist = sort(readdir(DIR));
       
   133 	closedir(DIR);
       
   134 
       
   135 	foreach my $file(@filelist)
       
   136 	{
       
   137 
       
   138 		if($file eq "." or $file eq "..") {next};
       
   139 
       
   140 		if($file =~ m/$fileSearch/i)
       
   141 		{
       
   142 
       
   143     		if (!(-d $file) and $fileType == 0)
       
   144     		{
       
   145 				push @$refIncfiles, ( cwd . "/" . $file );
       
   146     		}
       
   147     		elsif (-d $file and $fileType == 1)
       
   148     		{
       
   149 				push @$refIncfiles, ( cwd . "/" . $file );
       
   150     		}
       
   151         }
       
   152 	}
       
   153 
       
   154 	chdir ($startDir);
       
   155 }
       
   156