kerneltest/e32test/smr/t_smr.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Bootstrap Shadow Memory Region Test Application
       
    15 //
       
    16 
       
    17 #define __E32TEST_EXTENSION__
       
    18 #include <e32test.h>
       
    19 #include <e32svr.h>
       
    20 #include <u32hal.h>
       
    21 #include <hal.h>
       
    22 #include <hal_data.h>
       
    23 #include "d_smr.h"
       
    24 
       
    25 #define __TRACE_LINE__()	test.Printf(_L("%d\n"),__LINE__)
       
    26 
       
    27 RTest test(_L("T_SMR"));
       
    28 
       
    29 RSMRTest SMRTest;
       
    30 
       
    31 
       
    32 //---------------------------------------------
       
    33 //! @SYMTestCaseID 
       
    34 //! @SYMTestType
       
    35 //! @SYMPREQ 
       
    36 //! @SYMTestCaseDesc
       
    37 //! @SYMTestActions 
       
    38 //!
       
    39 //! @SYMTestExpectedResults 
       
    40 //!		
       
    41 //! @SYMTestPriority 
       
    42 //! @SYMTestStatus
       
    43 //---------------------------------------------
       
    44 TInt TestSMRIBPtr (TBool aEnforce)
       
    45     {
       
    46     /* These tests assume that the Core Loader does not load and user data areas
       
    47 	* as they are too large (>8Mb). Leaving the SMRIB undefined (==0) on NE1 and
       
    48 	* H4. 
       
    49     */
       
    50     
       
    51 	/* Print out the SMRIB Pointer in the Super Page. 
       
    52     *  When enforce, zero entries will lead to a test failure.    
       
    53     */	  
       
    54     test.Next(_L("SMR Test: Test_CheckSMRIBPtr"));   
       
    55     test.Printf(_L("\n"));
       
    56 	test_KErrNone( SMRTest.Test_CheckSMRIBPtr(aEnforce)); 
       
    57 
       
    58     return KErrNone;
       
    59     }
       
    60     
       
    61 TInt TestSMRAccess (TBool aEnforce)
       
    62     {
       
    63     /* These tests assume that the Core Loader has been modified to treat the
       
    64     *  user data partitions as SMR partitions and load them into SMR memory area
       
    65     *  and updated teh SMRIB. Two SMRs are expected, each of 4Mb in size.    
       
    66     */
       
    67     
       
    68     
       
    69 	/* Print out the SMRIB in the Super Page. 
       
    70     *  When enforce, zero entries will lead to a test failure.    
       
    71     */	  
       
    72     test.Next(_L("SMR Test: Test_PrintSMRIB"));   
       
    73     test.Printf(_L("\n"));
       
    74     test_KErrNone( SMRTest.Test_PrintSMRIB(aEnforce));
       
    75     
       
    76 	/* Print out the SMRIB and access and dump 1Kb of memory in each SMR. 
       
    77     *  When enforce, zero SMR entries will lead to a test failure.    
       
    78     */	  
       
    79     test.Next(_L("SMR Test: Test_AccessAllSMRs"));   
       
    80     test.Printf(_L("\n"));
       
    81 	test_KErrNone( SMRTest.Test_AccessAllSMRs(aEnforce));
       
    82 
       
    83 	/* Print out the SMRIB in the Super Page. 
       
    84     *  When enforce, zero entries will lead to a test failure.    
       
    85     */	  
       
    86 
       
    87     return KErrNone;
       
    88     }
       
    89     
       
    90 
       
    91 TInt TestSMRAccessAndRAMFree (TBool aEnforce)
       
    92     {
       
    93     /* These tests assume that the Core Loader has been modified to treat the
       
    94     *  user data partitions as SMR partitions and load them into SMR memory area
       
    95     *  and updated teh SMRIB. Two SMRs are expected, each of 4Mb in size.    
       
    96     */
       
    97     
       
    98     
       
    99 	/* Print out the SMRIB in the Super Page. 
       
   100     *  When enforce, zero entries will lead to a test failure.    
       
   101     */	  
       
   102     test.Next(_L("SMR Test: Test_PrintSMRIB"));   
       
   103     test.Printf(_L("\n"));
       
   104     test_KErrNone( SMRTest.Test_PrintSMRIB(aEnforce));
       
   105     
       
   106 	/* Print out the SMRIB and access and dump 1Kb of memory in each SMR. 
       
   107     *  When enforce, zero SMR entries will lead to a test failure.    
       
   108     */	  
       
   109     test.Next(_L("SMR Test: Test_AccessAllSMRs"));   
       
   110     test.Printf(_L("\n"));
       
   111 	test_KErrNone( SMRTest.Test_AccessAllSMRs(aEnforce));
       
   112 
       
   113 	/* Print out the SMRIB in the Super Page. 
       
   114     *  When enforce, zero entries will lead to a test failure.    
       
   115     */	  
       
   116     test.Next(_L("SMR Test: Test_FreeHalfSMR1PhysicalRam"));   
       
   117     test.Printf(_L("\n"));
       
   118     test_KErrNone( SMRTest.Test_FreeHalfSMR1PhysicalRam(aEnforce));
       
   119 
       
   120 	/* Print out the SMRIB in the Super Page. 
       
   121     *  When enforce, zero entries will lead to a test failure.    
       
   122     */	  
       
   123     test.Next(_L("SMR Test: Test_FreeAllSMR2PhysicalRam"));   
       
   124     test.Printf(_L("\n"));
       
   125     test_KErrNone( SMRTest.Test_FreeAllSMR2PhysicalRam(aEnforce));
       
   126 
       
   127 
       
   128 
       
   129 	/* Print out the SMRIB in the Super Page to see how it has been modified.
       
   130     *  When enforce, zero entries will lead to a test failure.    
       
   131     */	  
       
   132     test.Next(_L("SMR Test: Test_PrintSMRIB"));   
       
   133     test.Printf(_L("\n"));
       
   134     test_KErrNone( SMRTest.Test_PrintSMRIB(aEnforce));
       
   135 
       
   136     return KErrNone;
       
   137     }
       
   138 
       
   139 
       
   140 GLDEF_C TInt E32Main()
       
   141     {
       
   142 	TInt r;
       
   143 	TBuf<256> args;
       
   144 	TInt arglen = 0;
       
   145 	TBool enforce = EFalse;
       
   146 	TBool getch = EFalse;
       
   147 	TInt testcase = 0;
       
   148 	
       
   149     test.Title();
       
   150 
       
   151 	test.Start(_L("=== SMR Test Suite"));
       
   152 
       
   153 	arglen = User::CommandLineLength();
       
   154 	if (arglen > 0)
       
   155 	{
       
   156 		/** Process command arguments */
       
   157 		test_Compare(arglen,<,256);	
       
   158 		User::CommandLine(args);
       
   159 		
       
   160 		test.Printf(_L("Arguments: %S\n"), &args);
       
   161 		
       
   162 		if (args.Find(_L("-1")) >= 0)
       
   163 			testcase = 1;
       
   164 		if (args.Find(_L("-2")) >= 0)
       
   165 			testcase = 2;
       
   166 		if (args.Find(_L("-3")) >= 0)
       
   167 			testcase = 3;
       
   168 		if (args.Find(_L("-4")) >= 0)
       
   169 			testcase = 4;
       
   170 			
       
   171 		if (args.Find(_L("-e")) >= 0)
       
   172 			enforce = ETrue;
       
   173 
       
   174 		if (args.Find(_L("-g")) >= 0)
       
   175 			getch = ETrue;
       
   176 		
       
   177 		if (args.Find(_L("-h")) >= 0)
       
   178 			{
       
   179 			test.Printf(_L("usage: t_smr [-1|-2|-3|-4] [-e] [-h] [-g]\n"));
       
   180 			goto done;
       
   181 			}
       
   182 	}
       
   183 		
       
   184 	TInt muid = 0;   
       
   185    	r = HAL::Get(HAL::EMachineUid, muid);
       
   186 	test_KErrNone(r);
       
   187    	if ((muid != HALData::EMachineUid_NE1_TB) && (testcase != 1))
       
   188    		{
       
   189    		test.Printf (_L("Testing skipped as test only applies to NaviEngine platform\n"));
       
   190    		goto done;
       
   191    		}
       
   192 
       
   193 	test.Next(_L("=== Open test LDD"));
       
   194 	r = User::LoadLogicalDevice(RSMRTest::Name());
       
   195 	test_Assert((r==KErrNone || r==KErrAlreadyExists),void (0));
       
   196 		
       
   197 	r = SMRTest.Open();
       
   198 	test_KErrNone(r);
       
   199 
       
   200 
       
   201     // Do test cases
       
   202     //
       
   203     if (testcase == 1) 
       
   204     	{
       
   205     	TestSMRAccess(enforce);
       
   206     	}
       
   207     else if (testcase == 2)
       
   208     	{
       
   209     	TestSMRAccessAndRAMFree(enforce);
       
   210 		}
       
   211 	else if (testcase == 3)
       
   212 		{
       
   213     	TestSMRIBPtr(enforce);		
       
   214 		}
       
   215 	else if (testcase == 4)
       
   216 		{
       
   217     	TestSMRIBPtr(enforce);		
       
   218 		}
       
   219 	else
       
   220 		{
       
   221 		test.Printf (_L("Just open and closing test driver, no test case argument supplied."));
       
   222 		}
       
   223 
       
   224 	test.Next(_L("=== Close LDD"));
       
   225 	SMRTest.Close();
       
   226 	
       
   227 	r = User::FreeLogicalDevice(RSMRTest::Name());
       
   228     test_KErrNone(r);
       
   229 
       
   230 done:
       
   231 	test.End();
       
   232 	
       
   233 	if (getch)
       
   234 		{
       
   235 		test.Printf(_L("Press any key to continue...\n"));
       
   236 		(void) test.Getch();
       
   237 		}
       
   238 	return(0);
       
   239     }
       
   240