stif/TestModuleTemplates/createtestmodule.bat
changeset 0 a03f92240627
equal deleted inserted replaced
-1:000000000000 0:a03f92240627
       
     1 ::
       
     2 :: Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 :: All rights reserved.
       
     4 :: This component and the accompanying materials are made available
       
     5 :: under the terms of "Eclipse Public License v1.0"
       
     6 :: which accompanies this distribution, and is available
       
     7 :: at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 ::
       
     9 :: Initial Contributors:
       
    10 :: Nokia Corporation - initial contribution.
       
    11 ::
       
    12 :: Contributors:
       
    13 :: 
       
    14 :: Description: This file contains capsmodifier implementation.
       
    15 ::
       
    16 
       
    17 @perl -x createtestmodule.bat %*
       
    18 @goto end
       
    19 
       
    20 #!perl -w
       
    21 use strict;
       
    22 use Term::ReadLine;
       
    23 
       
    24 my $moduletype = "";
       
    25 my $modulename = "";
       
    26 my $modulepath = "";
       
    27 
       
    28 my $normal = "normal";
       
    29 my $hardcoded = "hardcoded";
       
    30 my $testclass = "testclass";
       
    31 my $kerneltestclass = "kerneltest";
       
    32 my $stifunit = "stifunit";
       
    33 my $stifunitvar2 = "stifunitvar2";
       
    34 my $capsmodifier = "capsmodifier";
       
    35 
       
    36 my $normali = "n";
       
    37 my $hardcodedi = "h";
       
    38 my $testclassi = "t";
       
    39 my $kerneltestclassi = "k";
       
    40 my $stifuniti = "s";
       
    41 my $stifunitvar2i = "d";
       
    42 my $capsmodifieri = "c";
       
    43 
       
    44 my $term = new Term::ReadLine 'Simple Perl calc';
       
    45 my $prompttype = "Enter ModuleType (name/short cut): ";
       
    46 my $promptname = "Enter ModuleName (or exit): ";  
       
    47 my $promptpath = "Enter path [default is drive root] (or exit): ";  
       
    48 my $exit = "exit";
       
    49 my $exiti = "e";   
       
    50   
       
    51 sub PrintHelp();
       
    52 
       
    53 if ( $#ARGV >= 0 )
       
    54 {
       
    55     $moduletype = $ARGV[0];
       
    56     if( $moduletype eq "help" )
       
    57     {
       
    58     PrintHelp();
       
    59     }
       
    60 }
       
    61 else
       
    62 {
       
    63     print "Enter ModuleType :\n";
       
    64 	print "\t($normali) $normal = creates an empty test module.\n";
       
    65 	print "\t($hardcodedi) $hardcoded = creates test module that uses hardcoded test cases.\n";
       
    66 	print "\t($testclassi) $testclass = creates test class which is used with TestScripter.\n";
       
    67 	print "\t($kerneltestclassi) $kerneltestclass = creates kernel test class which is used with TestScripter (only for kernel testing!).\n";
       
    68 	print "\t($capsmodifieri) $capsmodifier = creates capability modification module\n";
       
    69 	print "\t($stifuniti) $stifunit = creates test module using xUnit test pattern\n";
       
    70 	print "\t($stifunitvar2i) $stifunitvar2 = adds STIFUnit module to already existing project\n";
       
    71 	print "\t($exiti) $exit = Exit.\n";  
       
    72 
       
    73 
       
    74     $moduletype = $term->readline($prompttype);
       
    75     if( $moduletype eq $exit || $moduletype eq $exiti)
       
    76     {
       
    77         exit;
       
    78     }
       
    79 }
       
    80 if( $moduletype ne $normal && $moduletype ne $hardcoded && $moduletype ne $testclass && $moduletype ne $kerneltestclass && $moduletype ne $capsmodifier && $moduletype ne $stifunit && $moduletype ne $stifunitvar2 && $moduletype ne $normali && $moduletype ne $hardcodedi && $moduletype ne $testclassi && $moduletype ne $kerneltestclassi && $moduletype ne $capsmodifieri && $moduletype ne $stifuniti && $moduletype ne $stifunitvar2i)
       
    81     {
       
    82         print "\nInvalid module type\n";
       
    83         print "See createtestmodule help\n";
       
    84         exit;
       
    85     }
       
    86     
       
    87 if ( $#ARGV >= 1 )
       
    88 {
       
    89     $modulename = $ARGV[1];
       
    90 }
       
    91 else
       
    92 {
       
    93     
       
    94 	if( $moduletype eq $normal  || $moduletype eq $normali )
       
    95 	{   
       
    96     		print "$normal module selected.\n";
       
    97 	}
       
    98 	elsif( $moduletype eq $hardcoded || $moduletype eq $hardcodedi )
       
    99 	{
       
   100    	 	print "$hardcoded module selected.\n";
       
   101 	}
       
   102 	elsif( $moduletype eq $testclass || $moduletype eq $testclassi )
       
   103 	{
       
   104   		print "$testclass module selected.\n";
       
   105 	}
       
   106 	elsif( $moduletype eq $kerneltestclass || $moduletype eq $kerneltestclassi )
       
   107 	{
       
   108   		print "$kerneltestclass module selected.\n";
       
   109 	}
       
   110 	elsif( $moduletype eq $capsmodifier || $moduletype eq $capsmodifieri )
       
   111 	{
       
   112  		print "$capsmodifier module selected.\n";
       
   113 	}
       
   114 	elsif( $moduletype eq $stifunit || $moduletype eq $stifuniti || $moduletype eq $stifunitvar2 || $moduletype eq $stifunitvar2i )
       
   115 	{
       
   116 		print "$stifunit module selected.\n";
       
   117 	}
       
   118 	print "Enter ModuleName which has to be a valid C++ variable name.\n";
       
   119     
       
   120 	$modulename = $term->readline($promptname);
       
   121 
       
   122     if( $modulename eq $exit || $modulename eq $exiti)
       
   123     {
       
   124         exit;
       
   125     }
       
   126 }
       
   127 if ( $#ARGV >= 2 )
       
   128 {
       
   129     $modulepath = $ARGV[2];
       
   130 }
       
   131 else
       
   132 {
       
   133     $modulepath = $term->readline($promptpath);
       
   134     if( $modulepath eq $exit || $modulepath eq $exiti )
       
   135     {
       
   136         exit;
       
   137     }
       
   138 }
       
   139 
       
   140 $modulepath.= "\\";
       
   141 
       
   142 print "Create test module of type $moduletype with name $modulename ";
       
   143 
       
   144 
       
   145 if ( $modulepath eq "" )
       
   146 { 
       
   147     print "to current drive root\n";
       
   148 }
       
   149 else
       
   150 {
       
   151     print "to $modulepath\n";
       
   152 }
       
   153 
       
   154 my @args = ("$modulename", "$modulepath");
       
   155 
       
   156 if( $moduletype eq $normal  || $moduletype eq $normali )
       
   157 {   
       
   158     chdir "TestModuleXXX";
       
   159     system("perl -x createmodule.bat @args");
       
   160 }
       
   161 elsif( $moduletype eq $hardcoded || $moduletype eq $hardcodedi )
       
   162 {
       
   163     chdir "HardCodedTestModuleXXX";
       
   164     system("perl -x createhardcodedmodule.bat @args");
       
   165 }
       
   166 elsif( $moduletype eq $testclass || $moduletype eq $testclassi )
       
   167 {
       
   168     chdir "TemplateScriptXXX";
       
   169     system("perl -x CreateTestClass.bat @args");
       
   170 }
       
   171 elsif( $moduletype eq $kerneltestclass || $moduletype eq $kerneltestclassi )
       
   172 {
       
   173     chdir "TemplateKernelScriptXXX";
       
   174     system("perl -x CreateKernelTestClass.bat @args");
       
   175 }
       
   176 
       
   177 elsif( $moduletype eq $capsmodifier || $moduletype eq $capsmodifieri )
       
   178 {
       
   179     chdir "CapsModifierXXX";
       
   180     system("perl -x CreateCapsModifier.bat @args");
       
   181 }
       
   182 
       
   183 elsif( $moduletype eq $stifunit || $moduletype eq $stifuniti)
       
   184 {
       
   185     chdir "STIFUnitXXX";
       
   186     system("perl -x CreateSTIFUnitModule.bat @args");
       
   187 }
       
   188 
       
   189 elsif( $moduletype eq $stifunitvar2 || $moduletype eq $stifunitvar2i)
       
   190 {
       
   191     chdir "STIFUnitXXX";
       
   192     system("perl -x CreateSTIFUnitModuleVar2.bat @args");
       
   193 }
       
   194 
       
   195 exit;
       
   196 
       
   197 sub PrintHelp()
       
   198 {
       
   199 	print "CreateTestModule [ModuleType] [ModuleName] [path]\n";
       
   200 	print "\n";
       
   201 	print "Creates a new test module\n";
       
   202 	print "ModuleType defines the type of test module:.\n";
       
   203 	print "\tnormal = creates an empty test module.\n";
       
   204 	print "\thardcoded = creates test module that uses hardcoded test cases.\n";
       
   205 	print "\ttestclass = creates test class which is used with TestScripter.\n";
       
   206 	print "\tkerneltestclass = creates kernel test class which is used with TestScripter (only for kernel testing!).\n";
       
   207 	print "\tcapsmodifier = creates capability modification module\n";
       
   208 	print "\tstifunit = creates test module using xUnit test pattern\n";
       
   209 	print "If no arguments are given, they are asked from user.\n";
       
   210 	print "If [path] is given, it must contain the final \'\\\' in path name.\n";
       
   211 	print "Command must be executed in STIFTestFramework\\TestModuleTemplates directory\n";
       
   212 	exit;
       
   213 }
       
   214 
       
   215 __END__
       
   216 :end