dbgsrv/coredumpserver/test/automatictests/tcds_unit/src/cds/CFlashDataSourceWrapper.cpp
author ravikurupati
Tue, 02 Mar 2010 10:33:16 +0530
changeset 0 c6b0df440bee
permissions -rw-r--r--
Initial contribution of EPL licensed sources
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     1
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     2
// All rights reserved.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     3
// This component and the accompanying materials are made available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     5
// which accompanies this distribution, and is available
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     7
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     8
// Initial Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    10
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    11
// Contributors:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    12
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    13
// Description:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    14
//
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    15
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    16
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    17
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    18
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    19
 @file CFlashDataSourceWrapper.cpp
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    20
 @internalTechnology 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    21
*/
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    22
#include "CFlashDataSourceWrapper.h"
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    23
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    24
using namespace Debug;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    25
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    26
//Names of functions to be tested - referenced from script file
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    27
_LIT(KNewL_Debug, "NewL");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    28
_LIT(KReadCrashLog, "ReadCrashLog");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    29
_LIT(KGetFlashBuffer, "GetFlashBuffer");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    30
_LIT(KProcessCrashHeader1, "ProcessCrashHeader1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    31
_LIT(KProcessCrashHeader2, "ProcessCrashHeader2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    32
_LIT(KGetProcessListL1, "GetProcessListL1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    33
_LIT(KGetProcessListL2, "GetProcessListL2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    34
_LIT(KGetThreadListL1, "GetThreadListL1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    35
_LIT(KGetThreadListL2, "GetThreadListL2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    36
_LIT(KGetThreadListL3, "GetThreadListL3");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    37
_LIT(KReadRegistersL1, "ReadRegistersL1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    38
_LIT(KReadMemoryL1, "ReadMemoryL1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    39
_LIT(KReadMemoryL2, "ReadMemoryL2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    40
_LIT(KGetCodeSegmentsL1, "GetCodeSegmentsL1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    41
_LIT(KGetCodeSegmentsL2, "GetCodeSegmentsL2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    42
_LIT(KGetCodeSegmentsL3, "GetCodeSegmentsL3");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    43
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    44
_LIT(KReadTraceBufferL1, "ReadTraceBufferL1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    45
_LIT(KReadTraceBufferL2, "ReadTraceBufferL2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    46
_LIT(KCalcChecksum, "CalcChecksum");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    47
_LIT(KTraceDataSize, "TraceDataSize");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    48
_LIT(KTraceDataSizeNotFound, "TraceDataSizeNotFound");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    49
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    50
_LIT8(KCrashDummyData, "This is a sample write");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    51
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    52
const TInt FLASH_ALIGN = sizeof(TInt32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    53
const TInt START_OF_FLASH = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    54
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    55
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    56
 * Constructor for test wrapper
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    57
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    58
CFlashDataSourceWrapper::CFlashDataSourceWrapper()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    59
	:iObject(NULL)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    60
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    61
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    62
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    63
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    64
 * Destructor
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    65
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    66
CFlashDataSourceWrapper::~CFlashDataSourceWrapper()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    67
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    68
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    69
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    70
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    71
 * Two phase constructor for CFlashDataSourceWrapper
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    72
 * @return CFlashDataSourceWrapper object
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    73
 * @leave
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    74
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    75
CFlashDataSourceWrapper* CFlashDataSourceWrapper::NewL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    76
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    77
	CFlashDataSourceWrapper* ret = new (ELeave) CFlashDataSourceWrapper();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    78
	CleanupStack::PushL(ret);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    79
	ret->ConstructL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    80
	CleanupStack::Pop(ret);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    81
	return ret;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    82
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    83
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    84
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    85
 * Safe construction
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    86
 * @leave
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    87
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    88
void CFlashDataSourceWrapper::ConstructL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    89
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    90
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    91
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    92
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    93
/** 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    94
 * Assign the object
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    95
 *  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    96
 * @param aObject TAny* to the object to test
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    97
 * @leave
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    98
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
    99
void CFlashDataSourceWrapper::SetObjectL(TAny* aObject)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   100
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   101
	delete iObject;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   102
	iObject = NULL;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   103
	iObject = static_cast<CFlashDataSource*> (aObject);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   104
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   105
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   106
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   107
 * Runs a test preamble
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   108
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   109
void CFlashDataSourceWrapper::PrepareTestL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   110
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   111
	SetBlockResult(EPass);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   112
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   113
	INFO_PRINTF1(_L("Connecting to DSS"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   114
	//get a session to the security server
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   115
	User::LeaveIfError(iSecSess.Connect(securityServerVersion));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   116
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   117
	INFO_PRINTF1(_L("Erasing crash log"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   118
	User::LeaveIfError(iSecSess.EraseCrashLog(0, 1));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   119
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   120
	INFO_PRINTF1(_L("Creating data source"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   121
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   122
	//Hackage: TEF doesnt support preamble/postamble and destructs iObject each time. Until they sort it out
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   123
	//or document how it is done the hackage shall have to continue. Oh for JUnit....
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   124
	delete iObject;		//to be sure
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   125
	iObject = CFlashDataSource::NewL(iSecSess);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   126
	//end of hackage
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   127
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   128
	INFO_PRINTF1(_L("Ready to start test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   129
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   130
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   131
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   132
 * Process command to see what test to run 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   133
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   134
TBool CFlashDataSourceWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   135
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   136
	__UHEAP_MARK;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   137
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   138
	PrepareTestL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   139
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   140
	if (KNewL_Debug() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   141
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   142
		RDebug::Printf("Looking at CFlashDataSource::NewL()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   143
		TRAPD(err , DoCmdCrashFlashDataSource_NewL_TestL());	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   144
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   145
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   146
			RDebug::Printf("\tFailed!");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   147
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   148
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   149
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   150
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   151
	else if (KReadCrashLog() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   152
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   153
		RDebug::Printf("Looking at CFlashDataSource::ReadCrashLog()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   154
		TRAPD(err , DoCmd_ReadCrashLog_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   155
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   156
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   157
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   158
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   159
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   160
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   161
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   162
	else if (KGetFlashBuffer() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   163
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   164
		RDebug::Printf("Looking at CFlashDataSource::GetFlashBuffer()");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   165
		TRAPD(err , DoCmd_GetFlashBuffer_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   166
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   167
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   168
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   169
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   170
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   171
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   172
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   173
	else if (KProcessCrashHeader1() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   174
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   175
		TRAPD(err , DoCmd_ProcessCrashHeader1_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   176
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   177
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   178
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   179
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   180
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   181
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   182
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   183
	else if (KProcessCrashHeader2() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   184
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   185
		RDebug::Printf("Looking at CFlashDataSource::ProcessCrashHeader() - 2nd test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   186
		TRAPD(err , DoCmd_ProcessCrashHeader2_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   187
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   188
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   189
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   190
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   191
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   192
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   193
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   194
	else if( KGetProcessListL1() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   195
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   196
		RDebug::Printf("Looking at CFlashDataSource::GetProcessListL() - 1st test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   197
		TRAPD(err , DoCmd_GetProcessListL1_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   198
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   199
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   200
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   201
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   202
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   203
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   204
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   205
	else if ( KGetProcessListL2() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   206
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   207
		RDebug::Printf("Looking at CFlashDataSource::GetProcessListL() - 2nd test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   208
		TRAPD(err , DoCmd_GetProcessListL2_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   209
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   210
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   211
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   212
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   213
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   214
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   215
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   216
	else if (KGetThreadListL1() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   217
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   218
		RDebug::Printf("Looking at CFlashDataSource::GetThreadListL() - 1st test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   219
		TRAPD(err , DoCmd_GetThreadListL1_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   220
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   221
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   222
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   223
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   224
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   225
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   226
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   227
	else if( KGetThreadListL2() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   228
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   229
		RDebug::Printf("Looking at CFlashDataSource::GetThreadListL() - 2nd test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   230
		TRAPD(err , DoCmd_GetThreadListL2_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   231
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   232
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   233
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   234
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   235
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   236
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   237
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   238
	else if( KGetThreadListL3() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   239
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   240
		RDebug::Printf("Looking at CFlashDataSource::GetThreadListL() - 3rd test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   241
		TRAPD(err , DoCmd_GetThreadListL3_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   242
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   243
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   244
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   245
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   246
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   247
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   248
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   249
	else if( KReadRegistersL1() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   250
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   251
		RDebug::Printf("Looking at CFlashDataSource::ReadRegistersL() - 1st test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   252
		TRAPD(err , DoCmd_ReadRegistersL1_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   253
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   254
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   255
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   256
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   257
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   258
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   259
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   260
	else if( KReadMemoryL1() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   261
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   262
		RDebug::Printf("Looking at CFlashDataSource::ReadMemoryL() - 1st test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   263
		TRAPD(err , DoCmd_ReadMemoryL1_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   264
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   265
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   266
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   267
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   268
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   269
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   270
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   271
	else if( KReadMemoryL2() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   272
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   273
		RDebug::Printf("Looking at CFlashDataSource::ReadMemoryL() - 2nd test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   274
		TRAPD(err , DoCmd_ReadMemoryL2_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   275
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   276
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   277
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   278
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   279
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   280
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   281
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   282
	else if( KGetCodeSegmentsL1() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   283
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   284
		RDebug::Printf("Looking at CFlashDataSource::GetCodeSegmentsL() - 1st test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   285
		TRAPD(err , DoCmd_GetCodeSegmentsL1_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   286
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   287
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   288
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   289
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   290
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   291
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   292
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   293
	else if( KGetCodeSegmentsL2() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   294
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   295
		RDebug::Printf("Looking at CFlashDataSource - Code Segment Analysis - 2nd test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   296
		TRAPD(err , DoCmd_GetCodeSegmentsL2_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   297
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   298
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   299
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   300
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   301
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   302
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   303
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   304
	else if( KGetCodeSegmentsL3() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   305
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   306
		RDebug::Printf("Looking at CFlashDataSource - Code Segment Analysis - 3rd test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   307
		TRAPD(err , DoCmd_GetCodeSegmentsL3_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   308
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   309
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   310
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   311
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   312
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   313
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   314
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   315
	else if( KReadTraceBufferL1() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   316
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   317
		RDebug::Printf("Looking at CFlashDataSource - Trace Buffer - 1st test");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   318
		TRAPD(err , DoCmd_ReadTraceBufferL1_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   319
		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   320
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   321
			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   322
			INFO_PRINTF2(_L("Failed with err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   323
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   324
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   325
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   326
  	else if(KCalcChecksum() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   327
  		{ 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   328
  		TRAPD(err , DoCmd_CalculateChecksum_TestL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   329
  		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   330
  			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   331
  			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   332
  			}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   333
  		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   334
  	else if(KTraceDataSizeNotFound() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   335
  		{ 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   336
  		TRAPD(err , DoCmd_TraceDataSizeNotFoundL_TestL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   337
  		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   338
  			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   339
  			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   340
  			}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   341
  		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   342
  	else if(KTraceDataSize() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   343
  	  		{ 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   344
  	  		TRAPD(err , DoCmd_TraceDataSizeL_TestL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   345
  	  		if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   346
  	  			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   347
  	  			RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   348
  	  			}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   349
  	  		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   350
  	else if(KReadTraceBufferL2() == aCommand)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   351
			{ 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   352
			TRAPD(err , DoCmd_ReadTraceBufferL2_Test_L());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   353
			if(BlockResult() != EPass || KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   354
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   355
				RDebug::Printf("\tFailed! [%d]", err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   356
				}		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   357
			}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   358
	else 		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   359
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   360
		RDebug::Printf("Not found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   361
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   362
		delete iObject;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   363
		iSecSess.Close();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   364
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   365
		__UHEAP_MARKEND;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   366
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   367
		return EFalse;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   368
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   369
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   370
	delete iObject;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   371
	iSecSess.Close();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   372
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   373
	__UHEAP_MARKEND;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   374
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   375
	return ETrue;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   376
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   377
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   378
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   379
 * This tests that we can succesfully construct 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   380
 * @leave
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   381
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   382
void CFlashDataSourceWrapper::DoCmdCrashFlashDataSource_NewL_TestL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   383
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   384
	//first we delete the CFlashDataSource created by our post amble to ensure we are testing a fresh object
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   385
	delete iObject;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   386
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   387
	SetBlockResult(EPass);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   388
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   389
	INFO_PRINTF1(_L("Testing: CFlashDataSource::NewL()"));		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   390
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   391
	//Try to create a flash data source object
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   392
	TRAPD(err, iObject = CFlashDataSource::NewL(iSecSess));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   393
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   394
	//Check errors
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   395
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   396
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   397
		ERR_PRINTF2(_L("Leave when creating CFlashDataSource: [%d]"),err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   398
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   399
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   400
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   401
	//make sure its not null
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   402
	if(!iObject)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   403
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   404
		ERR_PRINTF1(_L("Problems with creating CFlashDataSource object"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   405
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   406
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   407
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   408
	INFO_PRINTF1(_L("CFlashDataSource object constructed succesfully"));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   409
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   410
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   411
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   412
 * Tests the ReadCrashLog method on the flash data source
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   413
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   414
void CFlashDataSourceWrapper::DoCmd_ReadCrashLog_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   415
	{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   416
	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadCrashLog()"));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   417
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   418
	//Write some expected data to the flash partition
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   419
	TUint32 size = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   420
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   421
	INFO_PRINTF1(_L("Writing dummy data to crash log"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   422
	iSecSess.WriteCrashConfig(START_OF_FLASH, KCrashDummyData, size);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   423
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   424
	INFO_PRINTF1(_L("Reading dummy data back from crash log"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   425
	TInt err = iObject->ReadCrashLog(START_OF_FLASH, size);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   426
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   427
	//make sure we got the right data back
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   428
	if( KErrNone != err || 0 != iObject->GetFlashBuffer().Compare(KCrashDummyData) )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   429
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   430
		ERR_PRINTF2(_L("Failed to read the correct data back via flash data source: Err = [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   431
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   432
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   433
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   434
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   435
	//test the parameters	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   436
	INFO_PRINTF1(_L("Testing that reading from a negative position will fail"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   437
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   438
	TInt32 negative = -2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   439
	err = iObject->ReadCrashLog(negative, size);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   440
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   441
	if(err != KErrArgument)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   442
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   443
		ERR_PRINTF1(_L("We were able to read data from a negative position"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   444
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   445
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   446
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   447
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   448
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   449
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   450
 * Tests the flash data source get flash buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   451
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   452
void CFlashDataSourceWrapper::DoCmd_GetFlashBuffer_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   453
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   454
	INFO_PRINTF1(_L("Testing CFlashDataSource::GetFlashBuffer()"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   455
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   456
	//Ensure that the buffer has been created
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   457
	INFO_PRINTF1(_L("Ensuring the buffer has been succesfully created"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   458
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   459
	TDes8& buf = iObject->GetFlashBuffer();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   460
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   461
	if(KInitialBufferSize != buf.Size())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   462
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   463
		ERR_PRINTF1(_L("Buffer was not created"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   464
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   465
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   466
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   467
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   468
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   469
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   470
 * Tests that we correctly process the crash header
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   471
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   472
void CFlashDataSourceWrapper::DoCmd_ProcessCrashHeader1_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   473
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   474
	INFO_PRINTF1(_L("Testing CFlashDataSource::ProcessCrashHeader() - 1st Test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   475
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   476
	TInt64 tid = 22;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   477
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   478
	iContextHdr.iNumRegisters = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   479
	iInfHdr.iFlashAlign = FLASH_ALIGN;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   480
	iInfHdr.iTid = tid;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   481
	iInfHdr.iCrashId = CRASH_ID;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   482
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   483
	TInt logSz = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   484
	iInfHdr.iLogSize = logSz;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   485
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   486
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   487
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   488
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   489
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   490
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   491
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   492
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   493
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   494
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   495
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   496
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   497
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   498
	INFO_PRINTF1(_L("Writing header to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   499
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   500
	TUint32 size = 0;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   501
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data, size));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   502
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   503
	CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   504
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   505
	INFO_PRINTF1(_L("Processing crash header"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   506
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   507
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   508
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   509
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   510
		ERR_PRINTF2(_L("Failed to process crash log: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   511
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   512
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   513
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   514
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   515
	//Read the buffer back
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   516
	TDes8& buf = iObject->GetFlashBuffer();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   517
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   518
	INFO_PRINTF1(_L("Ensuring crash header read back is correct"));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   519
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   520
	//Test our getters work correctly too
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   521
	if(tid != iObject->GetCrashedThreadId())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   522
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   523
		ERR_PRINTF1(_L("Unable to Get Crashed Thread ID from header"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   524
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   525
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   526
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   527
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   528
	if(FLASH_ALIGN != iObject->GetFlashAlignment())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   529
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   530
		ERR_PRINTF1(_L("Unable to Get Correct flash alignment from header"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   531
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   532
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   533
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   534
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   535
	if(logSz != iObject->GetCrashLogSize())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   536
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   537
		ERR_PRINTF1(_L("Unable to Get correct log size from header"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   538
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   539
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   540
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   541
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   542
	INFO_PRINTF1(_L("All is good. Move along now."));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   543
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   544
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   545
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   546
 * Negative test to make sure if there is no header we get told so
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   547
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   548
void CFlashDataSourceWrapper::DoCmd_ProcessCrashHeader2_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   549
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   550
	INFO_PRINTF1(_L("Testing CFlashDataSource::ProcessCrashHeader() - 2nd Test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   551
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   552
	//write a struct that isnt TCrashInfoHeader
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   553
	TProcessData dummy;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   554
	TPtr8 data((TUint8*)&dummy, sizeof(TProcessData), sizeof(TProcessData));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   555
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   556
	TUint32 size = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   557
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   558
	INFO_PRINTF1(_L("Writing header to flash"));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   559
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data, size));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   560
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   561
	INFO_PRINTF1(_L("Processing crash header"));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   562
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   563
	if(KErrNotFound != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   564
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   565
		ERR_PRINTF2(_L("Process header should have been corrupt but wasnt [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   566
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   567
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   568
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   569
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   570
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   571
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   572
 * Tests we can succesfully read back known processes from flash
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   573
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   574
void CFlashDataSourceWrapper::DoCmd_GetProcessListL1_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   575
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   576
	INFO_PRINTF1(_L("Testing CFlashDataSource::GetProcessListL() - 1st test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   577
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   578
	//We need to write some process data (will just do 2) to the flash, and update the header with its location
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   579
	TInt64 p1id = 100;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   580
	TInt32 p1prior = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   581
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   582
	TInt64 p2id = 200;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   583
	TInt32 p2prior = 5;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   584
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   585
	//Process names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   586
	_LIT8(KProc1, "t_proc1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   587
	_LIT8(KProc2, "tproc2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   588
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   589
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   590
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + 2 * TProcessData::KSCMProcessDataMaxSize + KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   591
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   592
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   593
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   594
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   595
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   596
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   597
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   598
	TCrashOffsetsHeader hdr;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   599
	hdr.iPLstOffset = sizeof(TCrashInfoHeader) + sizeof(TCrashOffsetsHeader); //starts right after headers 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   600
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   601
	//The first process data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   602
	TProcessData proc1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   603
	proc1.iPid = p1id;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   604
	proc1.iPriority = p1prior;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   605
	proc1.iNamesize = KProc1().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   606
	proc1.iName = KProc1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   607
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   608
	//The second process data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   609
	TProcessData proc2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   610
	proc2.iPid = p2id;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   611
	proc2.iPriority = p2prior;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   612
	proc2.iNamesize = KProc2().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   613
	proc2.iName = KProc2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   614
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   615
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   616
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   617
	iOffsetsHdr.iPLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   618
	iInfHdr.iLogSize = iOffsetsHdr.iPLstOffset + proc1.GetSize() + proc2.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   619
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   620
	INFO_PRINTF1(_L("Writing known processes to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   621
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   622
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   623
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   624
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   625
	proc1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   626
	proc2.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   627
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   628
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   629
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   630
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   631
	//Now we try get these processes back via GetProcessListL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   632
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   633
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   634
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   635
		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   636
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   637
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   638
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   639
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   640
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   641
	RProcessPointerList *processList = new(ELeave)RProcessPointerList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   642
	TCleanupItem processCleanup(CFlashDataSource::CleanupProcessList, (TAny*)processList);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   643
	CleanupStack::PushL(processCleanup);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   644
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   645
	TUint wr = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   646
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   647
	INFO_PRINTF1(_L("Getting process list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   648
	TRAP(err, iObject->GetProcessListL(*processList, wr));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   649
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   650
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   651
		ERR_PRINTF2(_L("Failed to get process list: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   652
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   653
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   654
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   655
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   656
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   657
	if(processList->Count() != 2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   658
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   659
		ERR_PRINTF2(_L("Didnt find the expected 2 processes. There were [%d] instead"), processList->Count());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   660
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   661
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   662
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   663
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   664
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   665
	CProcessInfo* p1 = (*processList)[0];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   666
	CProcessInfo* p2 = (*processList)[1];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   667
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   668
	INFO_PRINTF1(_L("Retrieveing processes"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   669
	if(!p1 || !p2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   670
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   671
		ERR_PRINTF1(_L("Failed to retrieve non null processes"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   672
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   673
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   674
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   675
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   676
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   677
	INFO_PRINTF1(_L("Making sure processes are as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   678
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   679
	//Check ID's
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   680
	if(p1->Id() != proc1.iPid  ||  p2->Id() != proc2.iPid)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   681
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   682
		ERR_PRINTF1(_L("Failed to retrieve correct process ID's:"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   683
		ERR_PRINTF3(_L("P1 expected [%d] but found [%d]"), proc1.iPid, p1->Id());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   684
		ERR_PRINTF3(_L("P2 expected [%d] but found [%d]"), proc2.iPid, p2->Id());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   685
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   686
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   687
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   688
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   689
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   690
	//check names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   691
	RBuf wide;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   692
	wide.CreateL(KProc1().Size());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   693
	wide.CleanupClosePushL();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   694
	wide.Copy(KProc1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   695
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   696
	INFO_PRINTF1(_L("Checking process 1 name is ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   697
	if( p1->Name().Compare(wide) != 0 )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   698
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   699
		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KProc1, &wide);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   700
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   701
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   702
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   703
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   704
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   705
	wide.Copy(KProc2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   706
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   707
	INFO_PRINTF1(_L("Checking process 2 name is ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   708
	if( p2->Name().Compare(wide) != 0 )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   709
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   710
		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KProc2, &wide);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   711
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   712
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   713
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   714
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   715
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   716
	INFO_PRINTF1(_L("All looks good"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   717
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   718
	CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   719
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   720
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   721
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   722
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   723
 * Negative tests should the flash contain corrupt data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   724
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   725
void CFlashDataSourceWrapper::DoCmd_GetProcessListL2_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   726
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   727
	INFO_PRINTF1(_L("Testing CFlashDataSource::GetProcessList() - 2nd test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   728
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   729
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   730
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 3 * TRegisterSet::KSCMRegisterSetMaxSize + KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   731
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   732
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   733
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   734
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   735
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   736
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   737
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   738
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   739
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   740
	iOffsetsHdr.iPLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   741
	iInfHdr.iLogSize = iOffsetsHdr.iPLstOffset + 2 * iContextHdr.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   742
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   743
	INFO_PRINTF1(_L("Writing known processes to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   744
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   745
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   746
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   747
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   748
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   749
	iContextHdr.Serialize(writer);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   750
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   751
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   752
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   753
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   754
	RProcessPointerList *processList = new(ELeave)RProcessPointerList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   755
	TCleanupItem processCleanup(CFlashDataSource::CleanupProcessList, (TAny*)processList);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   756
	CleanupStack::PushL(processCleanup);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   757
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   758
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   759
	INFO_PRINTF1(_L("Getting process list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   760
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   761
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   762
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   763
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   764
		ERR_PRINTF2(_L("Unable to process header [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   765
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   766
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   767
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   768
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   769
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   770
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   771
	TUint wr = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   772
	TRAP(err, iObject->GetProcessListL( *processList, wr));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   773
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   774
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   775
		ERR_PRINTF2(_L("Should have retrieved zero sized process list"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   776
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   777
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   778
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   779
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   780
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   781
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   782
	if(processList->Count() != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   783
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   784
		ERR_PRINTF1(_L("Should have retrieved zero sized process list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   785
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   786
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   787
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   788
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   789
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   790
	INFO_PRINTF1(_L("Everything is as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   791
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   792
	CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   793
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   794
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   795
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   796
 * Tests to make sure we can get back a thread list (two here) from the flash
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   797
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   798
void CFlashDataSourceWrapper::DoCmd_GetThreadListL1_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   799
	{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   800
	INFO_PRINTF1(_L("Testing CFlashDataSource::GetThreadListL() 1st Test - System wide thread list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   801
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   802
	//We need to write some thread data (will just do 2) to the flash, and update the header with its location
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   803
	TInt64 t1id = 100;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   804
	TInt32 t1prior = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   805
	TInt32 t1SvcSp = 20;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   806
	TInt32 t1UsrStkSize = 40;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   807
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   808
	TInt64 t2id = 200;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   809
	TInt32 t2prior = 5;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   810
	TInt32 t2SvcSp = 25;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   811
	TInt32 t2UsrStkSize = 47;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   812
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   813
	//thread names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   814
	_LIT8(KThread1, "t_thread1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   815
	_LIT8(KThread2, "thread2");	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   816
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   817
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   818
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   819
						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TThreadData::KSCMThreadDataMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   820
						KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   821
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   822
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   823
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   824
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   825
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   826
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   827
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   828
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   829
	TInt owner1 = 100;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   830
	TInt owner2 = 200;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   831
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   832
	//The first thread data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   833
	TThreadData t1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   834
	t1.iTid = t1id;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   835
	t1.iPriority = t1prior;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   836
	t1.iSvcSP = t1SvcSp;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   837
	t1.iUsrStacksize = t1UsrStkSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   838
	t1.iNamesize = KThread1().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   839
	t1.iName = KThread1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   840
	t1.iOwnerId = owner1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   841
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   842
	//The second thread data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   843
	TThreadData t2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   844
	t2.iTid = t2id;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   845
	t2.iPriority = t2prior;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   846
	t2.iSvcSP = t2SvcSp;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   847
	t2.iUsrStacksize = t2UsrStkSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   848
	t2.iNamesize = KThread2().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   849
	t2.iName = KThread2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   850
	t2.iOwnerId = owner2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   851
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   852
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   853
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   854
	iOffsetsHdr.iTLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   855
	iInfHdr.iLogSize = iOffsetsHdr.iTLstOffset + t1.GetSize() + t2.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   856
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   857
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   858
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   859
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   860
	t1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   861
	t2.Serialize(writer);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   862
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   863
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   864
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   865
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   866
	//Now we try get these threads back via GetThreadListL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   867
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   868
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   869
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   870
		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   871
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   872
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   873
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   874
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   875
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   876
	RThreadPointerList *threadList = new(ELeave)RThreadPointerList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   877
	TCleanupItem threadCleanup(CFlashDataSource::CleanupThreadList, (TAny*)threadList);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   878
	CleanupStack::PushL(threadCleanup);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   879
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   880
	TUint wr = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   881
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   882
	INFO_PRINTF1(_L("Getting thread list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   883
	TRAP(err, iObject->GetThreadListL(((TUint64)-1), *threadList, wr));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   884
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   885
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   886
		ERR_PRINTF2(_L("Failed to get thread list: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   887
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   888
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   889
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   890
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   891
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   892
	if(threadList->Count() != 2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   893
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   894
		ERR_PRINTF1(_L("Retrieved wrong number of threads"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   895
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   896
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   897
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   898
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   899
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   900
	CThreadInfo* ti1 = (*threadList)[0];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   901
	CThreadInfo* ti2 = (*threadList)[1];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   902
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   903
	INFO_PRINTF1(_L("Retrieveing threads"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   904
	if(!ti1 || !ti2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   905
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   906
		ERR_PRINTF1(_L("Failed to retrieve non null threads"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   907
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   908
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   909
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   910
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   911
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   912
	INFO_PRINTF1(_L("Making sure processes are as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   913
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   914
	//Check ID's
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   915
	if(ti1->Id() != t1.iTid ||  ti2->Id() != t2.iTid)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   916
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   917
		ERR_PRINTF1(_L("Failed to retrieve correct thread ID's:"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   918
		ERR_PRINTF3(_L("T1 expected [%d] but found [%d]"), t1.iTid, ti1->Id());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   919
		ERR_PRINTF3(_L("T2 expected [%d] but found [%d]"), t2.iTid, ti2->Id());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   920
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   921
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   922
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   923
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   924
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   925
	//check names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   926
	RBuf wide;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   927
	wide.CreateL(KThread1().Size());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   928
	wide.CleanupClosePushL();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   929
	wide.Copy(KThread1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   930
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   931
	INFO_PRINTF1(_L("Checking thread 1 name is ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   932
	if( ti1->Name().Compare(wide) != 0 )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   933
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   934
		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KThread1, &wide);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   935
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   936
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   937
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   938
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   939
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   940
	if(KThread2().Size() > wide.Size())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   941
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   942
		wide.ReAllocL(KThread2().Size());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   943
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   944
	wide.Copy(KThread2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   945
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   946
	INFO_PRINTF1(_L("Checking thread 2 name is ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   947
	if( ti2->Name().Compare(wide) != 0 )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   948
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   949
		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KThread2, &wide);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   950
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   951
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   952
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   953
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   954
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   955
	INFO_PRINTF1(_L("All looks good"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   956
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   957
	CleanupStack::PopAndDestroy(3);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   958
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   959
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   960
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   961
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   962
 * Looks at a process specific thread list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   963
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   964
void CFlashDataSourceWrapper::DoCmd_GetThreadListL3_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   965
	{	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   966
	INFO_PRINTF1(_L("Testing CFlashDataSource::GetThreadListL() 3rd Test - Process specific thread list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   967
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   968
	//We need to write some thread data (will just do 2) to the flash, and update the header with its location
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   969
	TInt64 t1id = 100;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   970
	TInt32 t1prior = 4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   971
	TInt32 t1SvcSp = 20;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   972
	TInt32 t1UsrStkSize = 40;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   973
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   974
	TInt64 t2id = 200;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   975
	TInt32 t2prior = 5;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   976
	TInt32 t2SvcSp = 25;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   977
	TInt32 t2UsrStkSize = 47;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   978
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   979
	//thread names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   980
	_LIT8(KThread1, "t_thread1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   981
	_LIT8(KThread2, "thread2");	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   982
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   983
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   984
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   985
						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TThreadData::KSCMThreadDataMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   986
						KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   987
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   988
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   989
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   990
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   991
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   992
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   993
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   994
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   995
	TInt owner1 = 100;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   996
	TInt owner2 = 200;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   997
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   998
	//The first thread data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
   999
	TThreadData t1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1000
	t1.iTid = t1id;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1001
	t1.iPriority = t1prior;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1002
	t1.iSvcSP = t1SvcSp;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1003
	t1.iUsrStacksize = t1UsrStkSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1004
	t1.iNamesize = KThread1().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1005
	t1.iName = KThread1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1006
	t1.iOwnerId = owner1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1007
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1008
	//The second thread data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1009
	TThreadData t2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1010
	t2.iTid = t2id;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1011
	t2.iPriority = t2prior;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1012
	t2.iSvcSP = t2SvcSp;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1013
	t2.iUsrStacksize = t2UsrStkSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1014
	t2.iNamesize = KThread2().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1015
	t2.iName = KThread2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1016
	t2.iOwnerId = owner2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1017
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1018
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1019
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1020
	iOffsetsHdr.iTLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1021
	iInfHdr.iLogSize = iOffsetsHdr.iTLstOffset + t1.GetSize() + t2.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1022
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1023
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1024
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1025
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1026
	t1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1027
	t2.Serialize(writer);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1028
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1029
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1030
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1031
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1032
	//Now we try get these threads back via GetThreadListL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1033
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1034
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1035
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1036
		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1037
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1038
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1039
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1040
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1041
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1042
	RThreadPointerList *threadList = new(ELeave)RThreadPointerList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1043
	TCleanupItem threadCleanup(CFlashDataSource::CleanupThreadList, (TAny*)threadList);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1044
	CleanupStack::PushL(threadCleanup);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1045
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1046
	TUint wr = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1047
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1048
	INFO_PRINTF1(_L("Getting thread list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1049
	TRAP(err, iObject->GetThreadListL(owner1, *threadList, wr));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1050
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1051
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1052
		ERR_PRINTF2(_L("Failed to get thread list: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1053
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1054
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1055
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1056
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1057
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1058
	if(threadList->Count() != 1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1059
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1060
		ERR_PRINTF1(_L("Retrieved wrong number of threads"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1061
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1062
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1063
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1064
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1065
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1066
	CThreadInfo* ti1 = (*threadList)[0];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1067
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1068
	INFO_PRINTF1(_L("Retrieveing threads"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1069
	if(!ti1)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1070
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1071
		ERR_PRINTF1(_L("Failed to retrieve non null threads"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1072
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1073
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1074
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1075
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1076
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1077
	INFO_PRINTF1(_L("Making sure processes are as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1078
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1079
	//Check ID's
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1080
	if(ti1->Id() != t1.iTid)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1081
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1082
		ERR_PRINTF1(_L("Failed to retrieve correct thread ID's:"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1083
		ERR_PRINTF3(_L("T1 expected [%d] but found [%d]"), t1.iTid, ti1->Id());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1084
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1085
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1086
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1087
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1088
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1089
	//check names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1090
	RBuf wide;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1091
	wide.CreateL(KThread1().Size());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1092
	wide.CleanupClosePushL();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1093
	wide.Copy(KThread1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1094
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1095
	INFO_PRINTF1(_L("Checking thread 1 name is ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1096
	if( ti1->Name().Compare(wide) != 0 )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1097
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1098
		ERR_PRINTF3(_L("Wrong name retrieved, expected [%S] but got [%S]"), &KThread1, &wide);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1099
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1100
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1101
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1102
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1103
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1104
	INFO_PRINTF1(_L("All looks good"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1105
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1106
	CleanupStack::PopAndDestroy(3);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1107
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1108
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1109
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1110
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1111
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1112
 * Negative tests should the flash contain corrupt data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1113
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1114
void CFlashDataSourceWrapper::DoCmd_GetThreadListL2_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1115
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1116
	INFO_PRINTF1(_L("Testing CFlashDataSource::GetThreadList() - 2nd test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1117
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1118
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1119
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 3 * TRegisterSet::KSCMRegisterSetMaxSize + KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1120
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1121
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1122
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1123
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1124
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1125
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);				
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1126
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1127
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1128
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1129
	iOffsetsHdr.iTLstOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1130
	iInfHdr.iLogSize = iOffsetsHdr.iTLstOffset + 2 * iContextHdr.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1131
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1132
	INFO_PRINTF1(_L("Writing known processes to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1133
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1134
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1135
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1136
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1137
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1138
	iContextHdr.Serialize(writer);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1139
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1140
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1141
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1142
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1143
	RThreadPointerList *threadList = new(ELeave)RThreadPointerList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1144
	TCleanupItem threadCleanup(CFlashDataSource::CleanupThreadList, (TAny*)threadList);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1145
	CleanupStack::PushL(threadCleanup);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1146
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1147
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1148
	INFO_PRINTF1(_L("Getting thread list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1149
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1150
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1151
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1152
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1153
		ERR_PRINTF2(_L("Unable to process header [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1154
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1155
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1156
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1157
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1158
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1159
	TUint wr = 0;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1160
	TRAP(err, iObject->GetThreadListL(START_OF_FLASH, *threadList, wr));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1161
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1162
	if(threadList->Count() != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1163
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1164
		ERR_PRINTF1(_L("Should have retrieved zero sized thread list"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1165
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1166
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1167
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1168
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1169
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1170
	INFO_PRINTF1(_L("Everything is as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1171
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1172
	CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1173
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1174
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1175
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1176
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1177
 * Tests we can read registers back from the flash succesfully
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1178
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1179
void CFlashDataSourceWrapper::DoCmd_ReadRegistersL1_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1180
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1181
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1182
	/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1183
	 * The 3 different register sets corrospond to the 3 different register related configuration
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1184
	 * options:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1185
	 * 			ECrashedThreadFullRegisters starts from iCTFullReg
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1186
	 * 			EThreadsUsrRegisters starts from iSysSvrReg
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1187
	 * 			EThreadsSvrRegisters starts from iSysUsrReg
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1188
	 * 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1189
	 * Are going to write the following data to flash:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1190
	 * 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1191
	 * |--TCrashHeader--||--TRegisterValue--| ... |--TRegisterValue--|      at the ECrashedThreadFullRegisters point
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1192
	 * 					 <--               For a crashed thread                      -->    
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1193
	 * 					 |--TRegisterValue--| ... |--TRegisterValue--|      at the EThreadsUsrRegisters point
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1194
	 * 					 <--    For a system thread (at user registers point)        -->  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1195
	 * 					 |--TRegisterValue--| ... |--TRegisterValue--|      at the EThreadsSvrRegisters point
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1196
	 * 					 <--    For a system thread  (at svr register point)      -->        
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1197
	 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1198
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1199
	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadRegistersL() Test1"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1200
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1201
	TThreadId crashedThread = TThreadId(139); //arbitrary vals
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1202
	TThreadId otherThread = TThreadId(15);		//arbitrary vals
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1203
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1204
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1205
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 6 * TRegisterValue::KSCMRegisterValueMaxSize + KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1206
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1207
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1208
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1209
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1210
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1211
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1212
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1213
	//Headers - as much as we need	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1214
	iInfHdr.iTid = crashedThread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1215
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1216
	iOffsetsHdr.iCTFullRegOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize(); //starts right after headers	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1217
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1218
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1219
	//For this test we will put in 2 registers for each config option
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1220
	TRegisterValue r1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1221
	r1.iValue32 = 0xDEADDEAA;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1222
	r1.iOwnId = crashedThread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1223
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1224
	TRegisterValue r2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1225
	r2.iValue32 = 0xDEADEADB;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1226
	r2.iOwnId = crashedThread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1227
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1228
	TRegisterValue r3;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1229
	r3.iValue32 = 0xDEADEADC;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1230
	r3.iOwnId = otherThread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1231
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1232
	TRegisterValue r4;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1233
	r4.iValue32 = 0xDEADEADD;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1234
	r4.iOwnId = otherThread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1235
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1236
	TRegisterValue r5;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1237
	r5.iValue32 = 0xDEADEADE;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1238
	r5.iOwnId = otherThread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1239
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1240
	TRegisterValue r6;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1241
	r6.iValue32 = 0xDEADEADF;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1242
	r6.iOwnId = otherThread.Id();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1243
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1244
	iOffsetsHdr.iSysSvrRegOffset = iOffsetsHdr.iCTFullRegOffset + r1.GetSize() + r2.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1245
	iOffsetsHdr.iSysUsrRegOffset = iOffsetsHdr.iSysSvrRegOffset + r3.GetSize() + r4.GetSize();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1246
	iInfHdr.iLogSize = iOffsetsHdr.iSysUsrRegOffset + r6.GetSize() + r5.GetSize();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1247
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1248
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1249
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1250
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1251
	r1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1252
	r2.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1253
	r3.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1254
	r4.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1255
	r5.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1256
	r6.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1257
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1258
	INFO_PRINTF1(_L("Writing known registers to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1259
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1260
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1261
	User::LeaveIfError(iSecSess.WriteCrashConfig(0, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1262
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1263
	//Now we try and get them back via ReadRegistersL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1264
	RRegisterList regList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1265
	CleanupClosePushL(regList);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1266
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1267
	INFO_PRINTF1(_L("Reading back registers"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1268
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1269
	TRAPD(err, iObject->AnalyseCrashL(1));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1270
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1271
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1272
		ERR_PRINTF2(_L("Failed to analyse crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1273
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1274
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1275
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1276
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1277
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1278
	//Read for crashed thread first (hard coded in the absence of TSymbianInfo for now)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1279
	TRAP(err, iObject->ReadRegistersL(crashedThread.Id(), regList));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1280
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1281
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1282
		ERR_PRINTF2(_L("Unable to read registers: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1283
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1284
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1285
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1286
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1287
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1288
	if(regList.Count() != 2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1289
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1290
		ERR_PRINTF2(_L("Got wrong amount of registers back: [%d]"), regList.Count());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1291
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1292
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1293
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1294
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1295
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1296
	if(regList[0].iValue32 != r1.iValue32 || regList[1].iValue32 != r2.iValue32)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1297
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1298
		ERR_PRINTF1(_L("Got wrong register values back"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1299
		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r1.iValue32,regList[0].iValue32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1300
		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r2.iValue32,regList[1].iValue32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1301
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1302
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1303
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1304
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1305
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1306
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1307
	//and for "system" thread
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1308
	TRAP(err, iObject->ReadRegistersL(otherThread.Id(), regList));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1309
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1310
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1311
		ERR_PRINTF2(_L("Unable to read registers: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1312
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1313
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1314
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1315
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1316
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1317
	if(regList.Count() != 4)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1318
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1319
		ERR_PRINTF2(_L("Got wrong amount of registers back: [%d]"), regList.Count());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1320
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1321
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1322
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1323
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1324
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1325
	if(regList[0].iValue32 != r3.iValue32 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1326
			|| regList[1].iValue32 != r4.iValue32
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1327
			|| regList[2].iValue32 != r5.iValue32
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1328
			|| regList[3].iValue32 != r6.iValue32)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1329
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1330
		ERR_PRINTF1(_L("Got wrong register values back"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1331
		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r3.iValue32,regList[0].iValue32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1332
		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r4.iValue32,regList[1].iValue32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1333
		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r5.iValue32,regList[2].iValue32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1334
		ERR_PRINTF3(_L("\tExpected Expected [0x%X] but got [0x%X]"),r6.iValue32,regList[3].iValue32);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1335
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1336
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1337
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1338
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1339
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1340
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1341
	INFO_PRINTF1(_L("Got back all registers as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1342
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1343
	CleanupStack::PopAndDestroy(2);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1344
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1345
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1346
/** 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1347
 * Tests that we can read memory from the crash log
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1348
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1349
void CFlashDataSourceWrapper::DoCmd_ReadMemoryL1_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1350
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1351
	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadMemoryL() Test1"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1352
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1353
	//buffer to hold memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1354
	TInt32 numBytes = 8; //we will dump 8 bytes of memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1355
	TUint8 memoryToDump = 0xAB;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1356
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1357
	RBuf8 mem;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1358
	mem.CreateL(numBytes * sizeof(TUint8));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1359
	mem.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1360
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1361
	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1362
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1363
		mem.Append(&memoryToDump, sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1364
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1365
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1366
	//buffer to hold log
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1367
	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + numBytes + TMemoryDump::KSCMMemDumpMaxSize + TRawData::KSCMRawDataMaxSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1368
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1369
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1370
	data.CreateL(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1371
	data.SetLength(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1372
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1373
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1374
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1375
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1376
	TUint32 startAdd = 0x10000000;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1377
	TUint64 procId = 100;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1378
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1379
	TMemoryDump memDump;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1380
	memDump.iStartAddress = startAdd;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1381
	memDump.iPid = procId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1382
	memDump.iLength = mem.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1383
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1384
	TRawData rawData;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1385
	rawData.iLength = mem.Length();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1386
	rawData.iData.Set(mem.MidTPtr(0));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1387
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1388
	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + memDump.GetSize() + rawData.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1389
	iInfHdr.iLogSize = crashSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1390
	iInfHdr.iCrashId = CRASH_ID;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1391
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1392
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1393
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1394
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1395
	memDump.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1396
	rawData.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1397
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1398
	INFO_PRINTF1(_L("Writing known memory to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1399
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1400
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1401
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1402
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1403
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1404
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1405
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1406
		ERR_PRINTF2(_L("Unable to analyse crash: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1407
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1408
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1409
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1410
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1411
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1412
	RBuf8 found;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1413
	found.CreateL(mem.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1414
	found.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1415
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1416
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1417
	//We read memory by thread ID. So we will create an arbitrary thread and assign it to belong to the
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1418
	//process ID we have dumped memory for
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1419
	TInt64 threadId = 23;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1420
	iObject->AssignOwner(procId, threadId);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1421
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1422
	TRAP(err, iObject->ReadMemoryL(threadId, startAdd, mem.Length(), found));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1423
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1424
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1425
		ERR_PRINTF2(_L("Unable to read memory: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1426
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1427
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1428
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1429
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1430
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1431
	for(TInt cnt = found.Length() -1; cnt >= 0; cnt--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1432
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1433
		if(found[cnt] != memoryToDump)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1434
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1435
			ERR_PRINTF2(_L("Wrong memory returned = [0x%X]"),found[cnt]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1436
			SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1437
			CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1438
			return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1439
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1440
		}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1441
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1442
	INFO_PRINTF1(_L("Got back all memory as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1443
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1444
	CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1445
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1446
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1447
/** 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1448
 * Negative Tests to see we can handle dodgy params
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1449
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1450
void CFlashDataSourceWrapper::DoCmd_ReadMemoryL2_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1451
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1452
	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadMemoryL() Test2"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1453
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1454
	//buffer to hold memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1455
	TInt32 numBytes = 8; //we will dump 8 bytes of memory
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1456
	TUint8 memoryToDump = 0xAB;		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1457
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1458
	RBuf8 mem;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1459
	mem.CreateL(numBytes * sizeof(TUint8));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1460
	mem.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1461
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1462
	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1463
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1464
		mem.Append(&memoryToDump, sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1465
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1466
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1467
	//buffer to hold log
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1468
	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + TRegisterSet::KSCMRegisterSetMaxSize + numBytes + TMemoryDump::KSCMMemDumpMaxSize + TRawData::KSCMRawDataMaxSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1469
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1470
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1471
	data.CreateL(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1472
	data.SetLength(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1473
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1474
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1475
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1476
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1477
	TUint32 startAdd = 0x10000000;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1478
	TUint64 procId = 100;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1479
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1480
	TMemoryDump memDump;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1481
	memDump.iStartAddress = startAdd;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1482
	memDump.iPid = procId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1483
	memDump.iLength = mem.Length();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1484
	TRawData rawData;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1485
	rawData.iLength = mem.Length();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1486
	rawData.iData.Set(mem.MidTPtr(0));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1487
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1488
	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + memDump.GetSize() + rawData.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1489
	iInfHdr.iLogSize = crashSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1490
	iInfHdr.iCrashId = CRASH_ID;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1491
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1492
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1493
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1494
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1495
	memDump.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1496
	rawData.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1497
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1498
	INFO_PRINTF1(_L("Writing known memory to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1499
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1500
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1501
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1502
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1503
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1504
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1505
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1506
		ERR_PRINTF2(_L("Unable to analyse crash: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1507
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1508
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1509
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1510
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1511
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1512
	RBuf8 found;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1513
	found.CreateL(mem.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1514
	found.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1515
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1516
	//reading from address not dumped
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1517
	TRAP(err, iObject->ReadMemoryL(procId, 0xDEDEADAD, mem.Length(), found));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1518
	if(KErrNotFound != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1519
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1520
		ERR_PRINTF2(_L("Able to read memory not dumped: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1521
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1522
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1523
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1524
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1525
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1526
	//read from a thread not dumped
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1527
	TRAP(err, iObject->ReadMemoryL(50, startAdd, mem.Length(), found));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1528
	if(KErrNotFound != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1529
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1530
		ERR_PRINTF2(_L("able to read memory from thread not dumped: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1531
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1532
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1533
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1534
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1535
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1536
	INFO_PRINTF1(_L("Got back all memory as expected"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1537
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1538
	CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1539
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1540
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1541
/** 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1542
 * 	Tests CFlashDataSource::GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1543
 *  Writes known code segments to flash and ensures we can get them back
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1544
 *  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1545
 *  Description:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1546
 *  We will pretend we have a process ID of 100. We will also have a thread ID of 101.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1547
 *  We will assign ownership between these two - ie. thread ID 101 exists in process ID 100.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1548
 *  We will write a mini crash log to flash:
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1549
 *  <---Crash Header---><---Code Segment Set---><---Code Segment 1---><---Code Segment 2--->
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1550
 *  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1551
 *  The code segments will exist for process ID 100. We will then try to read the code segments 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1552
 *  for thread ID 101 and we should retrieve code seg 1 and 2.
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1553
 *  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1554
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1555
void CFlashDataSourceWrapper::DoCmd_GetCodeSegmentsL1_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1556
	{		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1557
	INFO_PRINTF1(_L("Testing CFlashDataSource::GetCodeSegmentsL() - 1st test"));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1558
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1559
	TUint64 procId = 100; //arbitrary	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1560
	TInt numSegs = 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1561
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1562
	TCodeSegmentSet segSet;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1563
	segSet.iNumSegs = 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1564
	segSet.iPid = procId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1565
	segSet.iNumSegs = numSegs;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1566
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1567
	//seg names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1568
	_LIT8(KSeg1, "seg1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1569
	_LIT8(KSeg2, "cseg2");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1570
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1571
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1572
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1573
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1574
						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1575
						KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1576
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1577
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1578
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1579
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1580
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1581
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1582
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1583
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1584
	TCodeSegment seg1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1585
	seg1.iNameLength = KSeg1().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1586
	seg1.iName = KSeg1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1587
	seg1.iCodeSegType = EExeCodeSegType;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1588
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1589
	TCodeSegment seg2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1590
	seg2.iNameLength = KSeg2().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1591
	seg2.iName = KSeg2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1592
	seg2.iCodeSegType = EExeCodeSegType;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1593
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1594
	//For code segments to make sense we need to assign thread to process ownership
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1595
	TInt64 threadId = 101;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1596
	iObject->AssignOwner(procId, threadId); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1597
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1598
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1599
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1600
	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize() + segSet.GetSize() + seg1.GetSize() + seg2.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1601
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1602
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1603
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1604
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1605
	segSet.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1606
	seg1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1607
	seg2.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1608
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1609
	INFO_PRINTF1(_L("Writing known Code Segs to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1610
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1611
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1612
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1613
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1614
	//Now we try get these threads back via GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1615
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1616
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1617
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1618
		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1619
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1620
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1621
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1622
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1623
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1624
	RCodeSegPointerList* list = new(ELeave)RCodeSegPointerList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1625
	TCleanupItem segCleanup(CFlashDataSource::CleanupCodeSegList, (TAny*)list);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1626
	CleanupStack::PushL(segCleanup);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1627
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1628
	TUint sz = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1629
	TRAP(err, iObject->GetCodeSegmentsL(threadId, *list, sz));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1630
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1631
	if(list->Count() != numSegs)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1632
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1633
		ERR_PRINTF3(_L("Failed to retrieve right amount of code segs. Expected [%d] got [%d]"),numSegs, list->Count());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1634
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1635
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1636
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1637
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1638
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1639
	TCodeSegInfo* cs1 = (*list)[0];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1640
	TCodeSegInfo* cs2 = (*list)[1];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1641
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1642
	INFO_PRINTF1(_L("Retrieveing code segs"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1643
	if(!cs1 || !cs2)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1644
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1645
		ERR_PRINTF1(_L("Failed to retrieve non null threads"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1646
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1647
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1648
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1649
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1650
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1651
	//Check types
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1652
	INFO_PRINTF1(_L("Checking code seg types are ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1653
	if(cs1->iType != EExeCodeSegType ||  cs2->iType != EExeCodeSegType)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1654
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1655
		ERR_PRINTF1(_L("Failed to retrieve correct code seg types:"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1656
		ERR_PRINTF3(_L("CS1 expected [%d] but found [%d]"), EExeCodeSegType, cs1->iType);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1657
		ERR_PRINTF3(_L("CS2 expected [%d] but found [%d]"), EExeCodeSegType, cs2->iType);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1658
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1659
		CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1660
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1661
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1662
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1663
	//check names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1664
	RBuf wide;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1665
	wide.CreateL(KSeg1().Size());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1666
	wide.CleanupClosePushL();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1667
	wide.Copy(KSeg1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1668
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1669
	INFO_PRINTF1(_L("Checking code seg name's are ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1670
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1671
	TBool passed = (cs1->iName.Compare(wide) == 0) || (cs2->iName.Compare(wide) == 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1672
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1673
	if(!passed)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1674
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1675
		ERR_PRINTF4(_L("Wrong name retrieved, expected [%S] but got [%S] and [%S]"), &wide, &cs2->iName, &cs1->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1676
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1677
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1678
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1679
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1680
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1681
	if(2 *KSeg2().Size() > wide.Size())
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1682
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1683
		wide.ReAllocL(2 * KSeg2().Size());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1684
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1685
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1686
	wide.Copy(KSeg2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1687
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1688
	INFO_PRINTF1(_L("Checking second code seg name is ok"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1689
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1690
	passed = (cs1->iName.Compare(wide) == 0) || (cs2->iName.Compare(wide) == 0);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1691
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1692
	if(!passed)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1693
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1694
		ERR_PRINTF4(_L("Wrong name retrieved, expected [%S] but got [%S] and [%S]"), &wide, &cs2->iName, &cs1->iName);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1695
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1696
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1697
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1698
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1699
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1700
	CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1701
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1702
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1703
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1704
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1705
 *  Tests CFlashDataSource::GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1706
 *  Ensure we recognise corrupt segments (ie. no segment set to describe it)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1707
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1708
void CFlashDataSourceWrapper::DoCmd_GetCodeSegmentsL2_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1709
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1710
	INFO_PRINTF1(_L("Testing CFlashDataSource() - Code Segment Analysis - 2nd test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1711
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1712
	//seg names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1713
	_LIT8(KSeg1, "seg1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1714
	_LIT8(KSeg2, "cseg2");	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1715
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1716
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1717
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1718
						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1719
						KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1720
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1721
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1722
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1723
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1724
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1725
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1726
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1727
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1728
	TCodeSegment seg1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1729
	seg1.iNameLength = KSeg1().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1730
	seg1.iName = KSeg1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1731
	seg1.iCodeSegType = EExeCodeSegType;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1732
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1733
	TCodeSegment seg2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1734
	seg2.iNameLength = KSeg2().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1735
	seg2.iName = KSeg2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1736
	seg2.iCodeSegType = EExeCodeSegType;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1737
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1738
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1739
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1740
	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize()+ seg1.GetSize() + seg2.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1741
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1742
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1743
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1744
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1745
	seg1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1746
	seg2.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1747
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1748
	INFO_PRINTF1(_L("Writing known corrupt Code Segs to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1749
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1750
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1751
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1752
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1753
	//Now we try get these threads back via GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1754
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1755
	if(KErrCorrupt != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1756
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1757
		ERR_PRINTF2(_L("Failed to recognise corrupt data: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1758
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1759
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1760
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1761
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1762
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1763
	CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1764
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1765
	INFO_PRINTF1(_L("Corrupt data recognised"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1766
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1767
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1768
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1769
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1770
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1771
 *  Tests CFlashDataSource::GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1772
 *  Ensure we do not reciev duplicate segments 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1773
 * even after we place then in flash
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1774
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1775
void CFlashDataSourceWrapper::DoCmd_GetCodeSegmentsL3_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1776
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1777
	INFO_PRINTF1(_L("Testing CFlashDataSource() - Code Segment Analysis - 3rd test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1778
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1779
	TUint64 procId = 100; //arbitrary	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1780
	const TInt KNumRepeatSegs = 3;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1781
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1782
	TCodeSegmentSet segSet;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1783
	segSet.iNumSegs = KNumRepeatSegs;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1784
	segSet.iPid = procId;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1785
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1786
	//seg names
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1787
	_LIT8(KSeg1, "seg1");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1788
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1789
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1790
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1791
						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1792
						KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1793
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1794
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1795
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1796
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1797
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1798
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1799
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1800
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1801
	TCodeSegment seg1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1802
	seg1.iNameLength = KSeg1().Size();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1803
	seg1.iName = KSeg1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1804
	seg1.iCodeSegType = EExeCodeSegType;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1805
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1806
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1807
	//For code segments to make sense we need to assign thread to process ownership
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1808
	TInt64 threadId = 101;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1809
	iObject->AssignOwner(procId, threadId); 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1810
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1811
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1812
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1813
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1814
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1815
	iInfHdr.iLogSize = 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1816
		iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize() 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1817
		+ segSet.GetSize() + ( seg1.GetSize() * KNumRepeatSegs);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1818
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1819
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1820
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1821
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1822
	segSet.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1823
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1824
	// serialize the same segment a number of times
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1825
	for(TInt i=0;i<segSet.iNumSegs;i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1826
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1827
		seg1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1828
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1829
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1830
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1831
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1832
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1833
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1834
	//Now we try get these threads back via GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1835
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1836
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1837
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1838
		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1839
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1840
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1841
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1842
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1843
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1844
	RCodeSegPointerList* list = new(ELeave)RCodeSegPointerList;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1845
	TCleanupItem segCleanup(CFlashDataSource::CleanupCodeSegList, (TAny*)list);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1846
	CleanupStack::PushL(segCleanup);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1847
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1848
	TUint sz = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1849
	TRAP(err, iObject->GetCodeSegmentsL(threadId, *list, sz));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1850
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1851
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1852
	// loop through the code seg list check that none are the same
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1853
	for(TInt i=0;i<list->Count();i++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1854
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1855
		TCodeSegInfo* csinf1 = (*list)[i];			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1856
		for(TInt j=1;j<list->Count();j++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1857
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1858
			TCodeSegInfo* csinf2 = (*list)[j];
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1859
			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1860
			// check not checking same item
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1861
			if( csinf1 != csinf2 )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1862
				{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1863
				if(csinf1->iDataRunAddr == csinf2->iDataRunAddr && 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1864
				   csinf1->iDataSize == csinf2->iDataSize )
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1865
					{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1866
					ERR_PRINTF1(_L("DUPLICATE code segs 1") );
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1867
					SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1868
					CleanupStack::PopAndDestroy(2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1869
					return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1870
					
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1871
					}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1872
				}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1873
			}	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1874
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1875
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1876
	CleanupStack::PopAndDestroy(2);  // data , list
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1877
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1878
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1879
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1880
 * Tests we can get ALL expected trace data back
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1881
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1882
void CFlashDataSourceWrapper::DoCmd_ReadTraceBufferL1_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1883
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1884
	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadTraceBufferL() Test1"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1885
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1886
	//buffer to hold trace - will do in 2 parts to simulate the circular buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1887
	TInt32 numBytes = 8; //we will dump 8 bytes of trace
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1888
	TUint8 traceToDump1 = 0xAB;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1889
	TUint8 traceToDump2 = 0xCD;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1890
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1891
	RBuf8 trace1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1892
	trace1.CreateL(numBytes * sizeof(TUint8));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1893
	trace1.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1894
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1895
	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1896
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1897
		trace1.Append(&traceToDump1, sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1898
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1899
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1900
	RBuf8 trace2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1901
	trace2.CreateL(numBytes * sizeof(TUint8));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1902
	trace2.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1903
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1904
	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1905
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1906
		trace2.Append(&traceToDump2, sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1907
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1908
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1909
	//buffer to hold log
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1910
	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1911
							TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1912
							TRegisterSet::KSCMRegisterSetMaxSize +							 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1913
							TTraceDump::KSCMTraceDumpMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1914
							2 * (TRawData::KSCMRawDataMaxSize + numBytes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1915
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1916
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1917
	data.CreateL(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1918
	data.SetLength(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1919
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1920
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1921
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1922
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1923
	TTraceDump traceDump;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1924
	traceDump.iSizeOfMemory = 2 * numBytes;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1925
	traceDump.iNumberOfParts = 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1926
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1927
	TRawData rawData1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1928
	rawData1.iLength = trace1.Length();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1929
	rawData1.iData.Set(trace1.MidTPtr(0));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1930
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1931
	TRawData rawData2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1932
	rawData2.iLength = trace2.Length();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1933
	rawData2.iData.Set(trace2.MidTPtr(0));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1934
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1935
	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + traceDump.GetSize() + rawData1.GetSize() + rawData2.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1936
	iInfHdr.iLogSize = crashSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1937
	iInfHdr.iCrashId = CRASH_ID;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1938
	iOffsetsHdr.iTraceOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1939
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1940
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1941
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1942
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1943
	traceDump.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1944
	rawData1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1945
	rawData2.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1946
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1947
	INFO_PRINTF1(_L("Writing known trace to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1948
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1949
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1950
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1951
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1952
	//Now we try get the trace data back
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1953
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1954
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1955
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1956
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1957
		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1958
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1959
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1960
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1961
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1962
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1963
	TUint traceBufferAvailable = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1964
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1965
	TRAP(err, traceBufferAvailable = iObject->GetAvailableTraceSizeL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1966
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1967
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1968
		ERR_PRINTF2(_L("Unable to read trace data size: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1969
		SetBlockResult(EFail);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1970
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1971
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1972
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1973
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1974
	RBuf8 found;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1975
	found.CreateL(traceBufferAvailable);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1976
	found.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1977
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1978
	//reading from address not dumped	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1979
	TRAP(err, iObject->ReadTraceBufferL(found));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1980
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1981
	RDebug::Printf("Printing trace found");
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1982
	for(TInt x = 0; x<found.Length(); x++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1983
		{			
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1984
		RDebug::Printf("[0x%X]", found[x]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1985
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1986
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1987
	RBuf8 totalTrace;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1988
	totalTrace.CreateL(trace1.Length() + trace2.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1989
	totalTrace.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1990
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1991
	totalTrace.Append(trace1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1992
	totalTrace.Append(trace2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1993
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1994
	if(totalTrace.Compare(found) != 0)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1995
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1996
		ERR_PRINTF1(_L("Found trace did not match expected trace"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1997
		SetBlockResult(EFail);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1998
		CleanupStack::PopAndDestroy(5);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  1999
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2000
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2001
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2002
	CleanupStack::PopAndDestroy(5);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2003
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2004
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2005
void CFlashDataSourceWrapper::DoCmd_CalculateChecksum_TestL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2006
  	{  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2007
  	// check sum is commutative - so it should add up to same value
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2008
  	// however blocks were requested
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2009
  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2010
	INFO_PRINTF1(_L("DoCmd_CalculateChecksum_TestL called"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2011
  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2012
  	TScmChecksum chksm1, chksm2;  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2013
  
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2014
  	iObject->CalculateChecksumL(0, 10, chksm1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2015
  	iObject->CalculateChecksumL(10, 10, chksm1);  	  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2016
  	iObject->CalculateChecksumL(0, 20, chksm2);  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2017
  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2018
  	SetBlockResult((chksm1 == chksm2) ? EPass : EFail );  	  	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2019
  	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2020
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2021
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2022
 * Tests we can get back the correct trace buffer size
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2023
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2024
void CFlashDataSourceWrapper::DoCmd_TraceDataSizeL_TestL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2025
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2026
	INFO_PRINTF1(_L("Testing CFlashDataSource() - Trace Size Test"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2027
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2028
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2029
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2030
						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2031
						KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2032
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2033
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2034
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2035
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2036
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2037
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2038
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2039
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2040
	TUint memSize = 1243;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2041
	TTraceDump trace;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2042
	trace.iSizeOfMemory = memSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2043
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2044
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2045
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2046
	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize()+ trace.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2047
	iOffsetsHdr.iTraceOffset = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2048
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2049
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2050
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2051
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2052
	trace.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2053
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2054
	INFO_PRINTF1(_L("Writing known trace struct to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2055
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2056
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2057
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2058
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2059
	//Now we try get these threads back via GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2060
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2061
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2062
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2063
		ERR_PRINTF2(_L("Failed to analyse crash: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2064
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2065
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2066
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2067
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2068
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2069
	CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2070
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2071
	TUint recoveredMemSize = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2072
	TRAP(err, recoveredMemSize = iObject->GetAvailableTraceSizeL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2073
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2074
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2075
		ERR_PRINTF2(_L("Failed to get back trace size: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2076
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2077
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2078
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2079
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2080
	if(recoveredMemSize != memSize)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2081
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2082
		ERR_PRINTF3(_L("Failed to get back correct trace size: Got [%d] Expected [%d]"), recoveredMemSize, memSize);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2083
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2084
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2085
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2086
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2087
	INFO_PRINTF1(_L("Trace size looks good"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2088
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2089
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2090
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2091
 * Tests we can get back the correct trace buffer size
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2092
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2093
void CFlashDataSourceWrapper::DoCmd_TraceDataSizeNotFoundL_TestL()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2094
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2095
	INFO_PRINTF1(_L("Testing CFlashDataSource() - Trace Size Test - Negative"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2096
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2097
	//buffer for data
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2098
	TInt bufLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2099
						TRegisterSet::KSCMRegisterSetMaxSize + 2 * TCodeSegment::KMaxSegmentNameSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2100
						KMaxCacheSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2101
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2102
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2103
	data.CreateL(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2104
	data.SetLength(bufLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2105
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2106
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2107
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2108
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2109
	iInfHdr.iCrashId = CRASH_ID;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2110
	iContextHdr.iNumRegisters = 0; //no context
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2111
	iInfHdr.iLogSize = iInfHdr.GetSize() + iContextHdr.GetSize() + iOffsetsHdr.GetSize();		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2112
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2113
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2114
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2115
	iContextHdr.Serialize(writer);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2116
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2117
	INFO_PRINTF1(_L("Writing known trace struct to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2118
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2119
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2120
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2121
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2122
	//Now we try get these threads back via GetCodeSegmentsL
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2123
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2124
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2125
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2126
		ERR_PRINTF2(_L("Failed to analyse crash: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2127
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2128
		CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2129
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2130
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2131
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2132
	CleanupStack::PopAndDestroy();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2133
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2134
	TRAP(err, TUint recoveredMemSize = iObject->GetAvailableTraceSizeL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2135
	if(KErrNotFound != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2136
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2137
		ERR_PRINTF2(_L("Failed to get back KErrNone for non available trace size: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2138
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2139
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2140
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2141
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2142
	INFO_PRINTF1(_L("All as expected."));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2143
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2144
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2145
/**
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2146
 * Tests we can get ALL expected trace data back
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2147
 */
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2148
void CFlashDataSourceWrapper::DoCmd_ReadTraceBufferL2_Test_L()
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2149
	{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2150
	INFO_PRINTF1(_L("Testing CFlashDataSource::ReadTraceBufferL() Test2"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2151
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2152
	//buffer to hold trace - will do in 2 parts to simulate the circular buffer
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2153
	TInt32 numBytes = 8; //we will dump 8 bytes of trace
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2154
	TUint8 traceToDump1 = 0xAB;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2155
	TUint8 traceToDump2 = 0xCD;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2156
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2157
	RBuf8 trace1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2158
	trace1.CreateL(numBytes * sizeof(TUint8));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2159
	trace1.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2160
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2161
	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2162
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2163
		trace1.Append(&traceToDump1, sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2164
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2165
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2166
	RBuf8 trace2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2167
	trace2.CreateL(numBytes * sizeof(TUint8));	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2168
	trace2.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2169
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2170
	for(TInt cnt = numBytes -1; cnt >= 0; cnt--)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2171
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2172
		trace2.Append(&traceToDump2, sizeof(TUint8));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2173
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2174
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2175
	//buffer to hold log
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2176
	TInt dataLength = TCrashInfoHeader::KSCMCrashInfoMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2177
							TCrashOffsetsHeader::KSCMCrashOffsetsMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2178
							TRegisterSet::KSCMRegisterSetMaxSize +							 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2179
							TTraceDump::KSCMTraceDumpMaxSize + 
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2180
							2 * (TRawData::KSCMRawDataMaxSize + numBytes);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2181
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2182
	RBuf8 data;	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2183
	data.CreateL(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2184
	data.SetLength(dataLength);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2185
	data.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2186
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2187
	TByteStreamWriter writer(const_cast<TUint8*>(data.Ptr()), EFalse);	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2188
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2189
	TTraceDump traceDump;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2190
	traceDump.iSizeOfMemory = 2 * numBytes;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2191
	traceDump.iNumberOfParts = 2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2192
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2193
	TRawData rawData1;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2194
	rawData1.iLength = trace1.Length();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2195
	rawData1.iData.Set(trace1.MidTPtr(0));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2196
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2197
	TRawData rawData2;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2198
	rawData2.iLength = trace2.Length();	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2199
	rawData2.iData.Set(trace2.MidTPtr(0));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2200
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2201
	TInt32 crashSize = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize() + traceDump.GetSize() + rawData1.GetSize() + rawData2.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2202
	iInfHdr.iLogSize = crashSize;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2203
	iInfHdr.iCrashId = CRASH_ID;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2204
	iOffsetsHdr.iTraceOffset = iInfHdr.GetSize() + iOffsetsHdr.GetSize() + iContextHdr.GetSize();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2205
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2206
	iInfHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2207
	iOffsetsHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2208
	iContextHdr.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2209
	traceDump.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2210
	rawData1.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2211
	rawData2.Serialize(writer);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2212
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2213
	INFO_PRINTF1(_L("Writing known trace to flash"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2214
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2215
	TUint32 written = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2216
	User::LeaveIfError(iSecSess.WriteCrashConfig(START_OF_FLASH, data ,written));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2217
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2218
	//Now we try get the trace data back
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2219
	TRAPD(err, iObject->AnalyseCrashL(CRASH_ID));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2220
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2221
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2222
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2223
		ERR_PRINTF2(_L("Failed to process crash header: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2224
		SetBlockResult(EFail);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2225
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2226
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2227
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2228
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2229
	TUint traceBufferAvailable = 0;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2230
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2231
	TRAP(err, traceBufferAvailable = iObject->GetAvailableTraceSizeL());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2232
	if(KErrNone != err)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2233
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2234
		ERR_PRINTF2(_L("Unable to read trace data size: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2235
		SetBlockResult(EFail);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2236
		CleanupStack::PopAndDestroy(3);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2237
		return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2238
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2239
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2240
	RBuf8 totalTrace;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2241
	totalTrace.CreateL(trace1.Length() + trace2.Length());
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2242
	totalTrace.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2243
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2244
	totalTrace.Append(trace1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2245
	totalTrace.Append(trace2);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2246
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2247
	//Read 1 byte at a time
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2248
	RBuf8 read;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2249
	read.CreateL(1);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2250
	read.CleanupClosePushL();
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2251
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2252
	for(TInt x = 0; x< traceBufferAvailable; x++)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2253
		{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2254
		TRAP(err, iObject->ReadTraceBufferL(read, x));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2255
		if(err != KErrNone)
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2256
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2257
			ERR_PRINTF2(_L("Unable to read trace data: [%d]"), err);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2258
			SetBlockResult(EFail);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2259
			CleanupStack::PopAndDestroy(5);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2260
			return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2261
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2262
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2263
		RDebug::Printf("Found [0x%X] expected [0x%X]", read[0], totalTrace[x]);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2264
		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2265
		if(read[0] != totalTrace[x])
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2266
			{
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2267
			ERR_PRINTF1(_L("Didnt get back expected trace"));
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2268
			SetBlockResult(EFail);		
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2269
			CleanupStack::PopAndDestroy(5);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2270
			return;
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2271
			}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2272
		}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2273
	
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2274
	CleanupStack::PopAndDestroy(5);
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2275
	}
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2276
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2277
//eof
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2278
c6b0df440bee Initial contribution of EPL licensed sources
ravikurupati
parents:
diff changeset
  2279