imgtools/imgcheck/imagechekunittest/testcode/misc.cpp
changeset 0 044383f39525
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2008-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 the License "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 #include <cppunit/config/SourcePrefix.h>
       
    20 #include "misc.h"
       
    21 
       
    22 CPPUNIT_TEST_SUITE_REGISTRATION( CTestMisc );
       
    23 
       
    24 #include "depchecker.h"
       
    25 #include "exceptionreporter.h"
       
    26 
       
    27 
       
    28 /**
       
    29 Test the misctest output(cmdline) by E32input with directory for DBG flag.
       
    30 Note: Refer the code coverage output for percentage of check.
       
    31 
       
    32 
       
    33 @internalComponent
       
    34 @released
       
    35 */
       
    36 void CTestMisc::TestForValidE32Input()
       
    37 {
       
    38 	int status = 0;
       
    39 	CmdLineHandler* cmdInput;
       
    40 	ImgCheckManager* imgCheckerPtr;
       
    41 
       
    42 	try
       
    43 	{
       
    44 		char* argvect[] = { "imgchecker", "--e32input", "--dbg", "S:/GT0415/cppunit/imgcheck_unittest/imgs/executables/UseStaticDLL.exe"};
       
    45 		cmdInput = new CmdLineHandler();
       
    46 		ReturnType val = cmdInput->ProcessCommandLine(4,argvect);
       
    47 		if(val == ESuccess)
       
    48 		{
       
    49 			imgCheckerPtr = new ImgCheckManager(cmdInput);
       
    50 			imgCheckerPtr->CreateObjects();
       
    51 			imgCheckerPtr->Execute();
       
    52             imgCheckerPtr->FillReporterData();
       
    53             imgCheckerPtr->GenerateReport();
       
    54 		}
       
    55 	}
       
    56 	catch(ExceptionReporter& aExceptionReport)
       
    57 	{
       
    58 		aExceptionReport.Report();
       
    59 		status = 0;
       
    60 	}
       
    61 	DELETE(cmdInput);
       
    62 	DELETE(imgCheckerPtr);
       
    63 	delete cmdInput;
       
    64 }
       
    65 
       
    66 /**
       
    67 Test the misctest output(cmdline) by provinding value E32 input directory for VID and DEP.
       
    68 Note: Refer the code coverage output for percentage of check.
       
    69 
       
    70 @internalComponent
       
    71 @released
       
    72 */
       
    73 void CTestMisc::TestForVidDep()
       
    74 {
       
    75 	int status = 0;
       
    76 	CmdLineHandler* cmdInput;
       
    77 	ImgCheckManager* imgCheckerPtr;
       
    78 
       
    79 	try
       
    80 	{
       
    81 		char* argvect[] = { "imgchecker", "--dep", "--vid", "--e32input", "S:/GT0415/cppunit/imgcheck_unittest/imgs/executables/helloworld.exe", "-x"};
       
    82 		cmdInput = new CmdLineHandler();
       
    83 		ReturnType val = cmdInput->ProcessCommandLine(6,argvect);
       
    84 		if(val == ESuccess)
       
    85 		{
       
    86 			imgCheckerPtr = new ImgCheckManager(cmdInput);
       
    87 			imgCheckerPtr->CreateObjects();
       
    88 			imgCheckerPtr->Execute();
       
    89             imgCheckerPtr->FillReporterData();
       
    90             imgCheckerPtr->GenerateReport();
       
    91 		}
       
    92 	}
       
    93 	catch(ExceptionReporter& aExceptionReport)
       
    94 	{
       
    95 		aExceptionReport.Report();
       
    96 		status = 0;
       
    97 	}
       
    98 	DELETE(cmdInput);
       
    99 	DELETE(imgCheckerPtr);
       
   100 	delete cmdInput;
       
   101 }
       
   102 
       
   103 /**
       
   104 Test the misctest output(cmdline) by provinding and ELF input for Dbg flag TRUE expecting an error message.
       
   105 Note: Refer the code coverage output for percentage of check.
       
   106 
       
   107 @internalComponent
       
   108 @released
       
   109 */
       
   110 void CTestMisc::TestForValidELFInput()
       
   111 {
       
   112 	int status = 0;
       
   113 	CmdLineHandler* cmdInput;
       
   114 	ImgCheckManager* imgCheckerPtr;
       
   115 
       
   116 	try
       
   117 	{
       
   118 		char* argvect[] = { "imgchecker", "--dbg=true", "S:/GT0415/cppunit/imgcheck_unittest/imgs/input/HelloWorld.exe"};
       
   119 		cmdInput = new CmdLineHandler();
       
   120 		ReturnType val = cmdInput->ProcessCommandLine(3,argvect);
       
   121 		if(val == ESuccess)
       
   122 		{
       
   123 			imgCheckerPtr = new ImgCheckManager(cmdInput);
       
   124 			imgCheckerPtr->CreateObjects();
       
   125 			imgCheckerPtr->Execute();
       
   126             imgCheckerPtr->FillReporterData();
       
   127             imgCheckerPtr->GenerateReport();
       
   128 		}
       
   129 	}
       
   130 	catch(ExceptionReporter& aExceptionReport)
       
   131 	{
       
   132 		aExceptionReport.Report();
       
   133 		status = 0;
       
   134 	}
       
   135 	DELETE(cmdInput);
       
   136 	DELETE(imgCheckerPtr);
       
   137 	delete cmdInput;
       
   138 }
       
   139 
       
   140 /**
       
   141 Test the misctest output(cmdline) by provinding extension rom image for Dbg flag TRUE.
       
   142 Note: Refer the code coverage output for percentage of check.
       
   143 
       
   144 @internalComponent
       
   145 @released
       
   146 */
       
   147 void CTestMisc::TestForValidExtnRomimage()
       
   148 {
       
   149 	int status = 0;
       
   150 	CmdLineHandler* cmdInput;
       
   151 	ImgCheckManager* imgCheckerPtr;
       
   152 
       
   153 	try
       
   154 	{
       
   155 		char* argvect[] = { "imgchecker", "--dbg=true", "S:/GT0415/cppunit/imgcheck_unittest/imgs/extrom1.img"};
       
   156 		cmdInput = new CmdLineHandler();
       
   157 		ReturnType val = cmdInput->ProcessCommandLine(3,argvect);
       
   158 		if(val == ESuccess)
       
   159 		{
       
   160 			imgCheckerPtr = new ImgCheckManager(cmdInput);
       
   161 			imgCheckerPtr->CreateObjects();
       
   162 			imgCheckerPtr->Execute();
       
   163             imgCheckerPtr->FillReporterData();
       
   164             imgCheckerPtr->GenerateReport();
       
   165 		}
       
   166 	}
       
   167 	catch(ExceptionReporter& aExceptionReport)
       
   168 	{
       
   169 		aExceptionReport.Report();
       
   170 		status = 0;
       
   171 	}
       
   172 	DELETE(cmdInput);
       
   173 	DELETE(imgCheckerPtr);
       
   174 	delete cmdInput;
       
   175 }
       
   176 
       
   177 /**
       
   178 Test the misctest output(cmdline) by provinding extension image with Dbg flag true with VID enabled and disabled VID.
       
   179 Note: Refer the code coverage output for percentage of check.
       
   180 
       
   181 @internalComponent
       
   182 @released
       
   183 */
       
   184 void CTestMisc::TestForEnableandSuppress()
       
   185 {
       
   186 	int status = 0;
       
   187 	CmdLineHandler* cmdInput;
       
   188 	ImgCheckManager* imgCheckerPtr;
       
   189 
       
   190 	try
       
   191 	{
       
   192 		char* argvect[] = { "imgchecker", "--dbg=true", "--vid", "-s=sid,vid", "S:/GT0415/cppunit/imgcheck_unittest/imgs/extrom1.img"};
       
   193 		cmdInput = new CmdLineHandler();
       
   194 		ReturnType val = cmdInput->ProcessCommandLine(5,argvect);
       
   195 		if(val == ESuccess)
       
   196 		{
       
   197 			imgCheckerPtr = new ImgCheckManager(cmdInput);
       
   198 			imgCheckerPtr->CreateObjects();
       
   199 			imgCheckerPtr->Execute();
       
   200             imgCheckerPtr->FillReporterData();
       
   201             imgCheckerPtr->GenerateReport();
       
   202 		}
       
   203 	}
       
   204 	catch(ExceptionReporter& aExceptionReport)
       
   205 	{
       
   206 		aExceptionReport.Report();
       
   207 		status = 0;
       
   208 	}
       
   209 	DELETE(cmdInput);
       
   210 	DELETE(imgCheckerPtr);
       
   211 	delete cmdInput;
       
   212 }
       
   213 
       
   214 
       
   215 /**
       
   216 Test the misctest output(cmdline) by valid E32input directory for SID, expecting the warning for SID
       
   217 Note: Refer the code coverage output for percentage of check.
       
   218 
       
   219 
       
   220 @internalComponent
       
   221 @released
       
   222 */
       
   223 void CTestMisc::TestForValidSid()
       
   224 {
       
   225 	int status = 0;
       
   226 	CmdLineHandler* cmdInput;
       
   227 	ImgCheckManager* imgCheckerPtr;
       
   228 
       
   229 	try
       
   230 	{
       
   231 		char* argvect[] = { "imgchecker", "--sid", "S:/GT0415/cppunit/imgcheck_unittest/imgs/executables", "--e32input"};
       
   232 		cmdInput = new CmdLineHandler();
       
   233 		ReturnType val = cmdInput->ProcessCommandLine(4,argvect);
       
   234 		if(val == ESuccess)
       
   235 		{
       
   236 			imgCheckerPtr = new ImgCheckManager(cmdInput);
       
   237 			imgCheckerPtr->CreateObjects();
       
   238 			imgCheckerPtr->Execute();
       
   239             imgCheckerPtr->FillReporterData();
       
   240             imgCheckerPtr->GenerateReport();
       
   241 		}
       
   242 	}
       
   243 	catch(ExceptionReporter& aExceptionReport)
       
   244 	{
       
   245 		aExceptionReport.Report();
       
   246 		status = 0;
       
   247 	}
       
   248 	DELETE(cmdInput);
       
   249 	DELETE(imgCheckerPtr);
       
   250 	delete cmdInput;
       
   251 }
       
   252