0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file CServerDataSourceWrapper.cpp
|
|
20 |
@internalTechnology
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include <d32btrace.h>
|
|
24 |
|
|
25 |
#include "CServerDataSourceWrapper.h"
|
|
26 |
|
|
27 |
using namespace Debug;
|
|
28 |
|
|
29 |
//Names of functions to be tested - referenced from script file
|
|
30 |
_LIT(KGetAvailableTraceSizeL, "GetAvailableTraceSizeL");
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Constructor for test wrapper
|
|
34 |
*/
|
|
35 |
CServerDataSourceWrapper::CServerDataSourceWrapper()
|
|
36 |
:iObject(NULL)
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Destructor
|
|
42 |
*/
|
|
43 |
CServerDataSourceWrapper::~CServerDataSourceWrapper()
|
|
44 |
{
|
|
45 |
}
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Two phase constructor for CFlashDataSourceWrapper
|
|
49 |
* @return CFlashDataSourceWrapper object
|
|
50 |
* @leave
|
|
51 |
*/
|
|
52 |
CServerDataSourceWrapper* CServerDataSourceWrapper::NewL()
|
|
53 |
{
|
|
54 |
CServerDataSourceWrapper* ret = new (ELeave) CServerDataSourceWrapper();
|
|
55 |
CleanupStack::PushL(ret);
|
|
56 |
ret->ConstructL();
|
|
57 |
CleanupStack::Pop(ret);
|
|
58 |
return ret;
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Safe construction
|
|
63 |
* @leave
|
|
64 |
*/
|
|
65 |
void CServerDataSourceWrapper::ConstructL()
|
|
66 |
{
|
|
67 |
|
|
68 |
}
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Assign the object
|
|
72 |
*
|
|
73 |
* @param aObject TAny* to the object to test
|
|
74 |
* @leave
|
|
75 |
*/
|
|
76 |
void CServerDataSourceWrapper::SetObjectL(TAny* aObject)
|
|
77 |
{
|
|
78 |
delete iObject;
|
|
79 |
iObject = NULL;
|
|
80 |
iObject = static_cast<CServerCrashDataSource*> (aObject);
|
|
81 |
}
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Runs a test preamble
|
|
85 |
*/
|
|
86 |
void CServerDataSourceWrapper::PrepareTestL()
|
|
87 |
{
|
|
88 |
SetBlockResult(EPass);
|
|
89 |
|
|
90 |
INFO_PRINTF1(_L("Connecting to DSS"));
|
|
91 |
//get a session to the security server
|
|
92 |
User::LeaveIfError(iSecSess.Connect(dssVersion));
|
|
93 |
|
|
94 |
INFO_PRINTF1(_L("Creating data source"));
|
|
95 |
|
|
96 |
//Hackage: TEF doesnt support preamble/postamble and destructs iObject each time. Until they sort it out
|
|
97 |
//or document how it is done the hackage shall have to continue. Oh for JUnit....
|
|
98 |
delete iObject; //to be sure
|
|
99 |
iObject = CServerCrashDataSource::NewL(iSecSess);
|
|
100 |
//end of hackage
|
|
101 |
|
|
102 |
INFO_PRINTF1(_L("Ready to start test"));
|
|
103 |
}
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Process command to see what test to run
|
|
107 |
*/
|
|
108 |
TBool CServerDataSourceWrapper::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
|
109 |
{
|
|
110 |
__UHEAP_MARK;
|
|
111 |
|
|
112 |
PrepareTestL();
|
|
113 |
|
|
114 |
if (KGetAvailableTraceSizeL() == aCommand)
|
|
115 |
{
|
|
116 |
RDebug::Printf("Looking at CServerDataSource::GetAvailableTraceSizeL()");
|
|
117 |
TRAPD(err , DoCmdGetAvailableTraceSizeL_TestL());
|
|
118 |
if(BlockResult() != EPass || KErrNone != err)
|
|
119 |
{
|
|
120 |
RDebug::Printf("\tFailed!");
|
|
121 |
INFO_PRINTF2(_L("Failed with err = [%d]"), err);
|
|
122 |
SetBlockResult(EFail);
|
|
123 |
}
|
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
|
127 |
RDebug::Printf("Not found");
|
|
128 |
|
|
129 |
delete iObject;
|
|
130 |
iSecSess.Close();
|
|
131 |
|
|
132 |
__UHEAP_MARKEND;
|
|
133 |
|
|
134 |
return EFalse;
|
|
135 |
}
|
|
136 |
|
|
137 |
delete iObject;
|
|
138 |
iSecSess.Close();
|
|
139 |
|
|
140 |
__UHEAP_MARKEND;
|
|
141 |
|
|
142 |
return ETrue;
|
|
143 |
}
|
|
144 |
|
|
145 |
void CServerDataSourceWrapper::DoCmdGetAvailableTraceSizeL_TestL()
|
|
146 |
{
|
|
147 |
//Step 1: Empty trace buffer
|
|
148 |
INFO_PRINTF1(_L("Emptying the trace buffer"));
|
|
149 |
RBTrace trace;
|
|
150 |
trace.Open();
|
|
151 |
trace.Empty();
|
|
152 |
trace.Close();
|
|
153 |
|
|
154 |
//step 1: Put our data in
|
|
155 |
INFO_PRINTF1(_L("Generating trace data"));
|
|
156 |
RProcess crashapp;
|
|
157 |
User::LeaveIfError(crashapp.Create(KCrashAppFileName, _L("-t -d1 -c13")));
|
|
158 |
|
|
159 |
TRequestStatus stat;
|
|
160 |
crashapp.Rendezvous(stat);
|
|
161 |
crashapp.Resume();
|
|
162 |
|
|
163 |
User::WaitForRequest(stat);
|
|
164 |
|
|
165 |
crashapp.Close();
|
|
166 |
|
|
167 |
//step 2: Read it
|
|
168 |
INFO_PRINTF1(_L("Getting size of trace data"));
|
|
169 |
|
|
170 |
TUint bytesFound = iObject->GetAvailableTraceSizeL();
|
|
171 |
|
|
172 |
if(bytesFound != KTraceSizeFromCrashApp)
|
|
173 |
{
|
|
174 |
ERR_PRINTF3(_L("Read the wrong amount of trace. Expected [0x%X] bytes but got [0x%X] bytes"), KTraceSizeFromCrashApp, bytesFound);
|
|
175 |
SetBlockResult(EFail);
|
|
176 |
return;
|
|
177 |
}
|
|
178 |
}
|
|
179 |
|
|
180 |
//eof
|
|
181 |
|
|
182 |
|