author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 18 Aug 2010 11:08:29 +0300 | |
changeset 247 | d8d70de2bd36 |
parent 0 | a41df078684a |
child 253 | d37db4dcc88d |
permissions | -rw-r--r-- |
247
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test/usb/t_usb_device/main.cpp |
|
15 |
// USB Test Program, main part. |
|
16 |
// Device-side part, to work against t_usb_host running on the host. |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
#include "general.h" |
|
21 |
#include "config.h" |
|
22 |
#include "activecontrol.h" |
|
247
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
#include "activerw.h" |
0 | 24 |
|
25 |
// --- Global Top Level Variables |
|
26 |
||
27 |
CActiveControl* gActiveControl; |
|
28 |
#ifdef USB_SC |
|
29 |
RTest test(_L("T_USB_SCDEVICE")); |
|
30 |
#else |
|
31 |
RTest test(_L("T_USB_DEVICE")); |
|
32 |
#endif |
|
247
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
|
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
#ifdef USB_SC |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
TBool gShareHandle = EFalse; |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
#endif |
0 | 37 |
TBool gVerbose = EFalse; |
38 |
TBool gSkip = EFalse; |
|
39 |
TBool gTempTest = EFalse; |
|
40 |
TBool gStopOnFail = ETrue; |
|
41 |
TBool gAltSettingOnNotify = ETrue; |
|
42 |
TInt8 gSettingNumber [128]; |
|
43 |
TInt32 gSoakCount = 1; |
|
44 |
CActiveRW* gRW[KMaxConcurrentTests]; // the USB read/write active object |
|
45 |
IFConfigPtr gInterfaceConfig [128] [KMaxInterfaceSettings]; |
|
46 |
TInt gActiveTestCount = 0; |
|
47 |
#ifdef USB_SC |
|
48 |
RChunk gChunk; |
|
49 |
#endif |
|
50 |
||
51 |
||
52 |
void RunAppL(TDes * aConfigFile, TDes * aScriptFile) |
|
53 |
{ |
|
54 |
// Construct the active scheduler |
|
55 |
CActiveScheduler* myScheduler = new (ELeave) CActiveScheduler(); |
|
56 |
||
57 |
// Push active scheduler onto the cleanup stack |
|
58 |
CleanupStack::PushL(myScheduler); |
|
59 |
||
60 |
// Install as the active scheduler |
|
61 |
CActiveScheduler::Install(myScheduler); |
|
62 |
||
63 |
// Create console handler |
|
64 |
#ifdef USB_SC |
|
65 |
CConsoleBase* myConsole = Console::NewL(_L("T_USB_SCDEVICE - USB Client Test"), TSize(KConsFullScreen, KConsFullScreen)); |
|
66 |
CleanupStack::PushL(myConsole); |
|
67 |
||
68 |
myConsole->Printf(_L("T_USB_SCDEVICE v%d.%d.%d\n"),KDeviceVersionMajor,KDeviceVersionMinor,KDeviceVersionMicro); |
|
69 |
test.Printf(_L("T_USB_SCDEVICE v%d.%d.%d\n"),KDeviceVersionMajor,KDeviceVersionMinor,KDeviceVersionMicro); |
|
70 |
#else |
|
71 |
CConsoleBase* myConsole = Console::NewL(_L("T_USB_DEVICE - USB Client Test"), TSize(KConsFullScreen, KConsFullScreen)); |
|
72 |
CleanupStack::PushL(myConsole); |
|
73 |
||
74 |
myConsole->Printf(_L("T_USB_DEVICE v%d.%d.%d\n"),KDeviceVersionMajor,KDeviceVersionMinor,KDeviceVersionMicro); |
|
75 |
test.Printf(_L("T_USB_DEVICE v%d.%d.%d\n"),KDeviceVersionMajor,KDeviceVersionMinor,KDeviceVersionMicro); |
|
76 |
#endif |
|
77 |
||
78 |
// outermost test begin |
|
79 |
test.Start(_L("Outermost test of t_usb_device\n")); |
|
80 |
||
81 |
do |
|
82 |
{ |
|
83 |
gActiveControl = CActiveControl::NewL(myConsole, aConfigFile, aScriptFile); |
|
84 |
CleanupStack::PushL(gActiveControl); |
|
85 |
||
86 |
||
87 |
// Call request function |
|
247
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
#ifdef USB_SC |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
if (!gShareHandle) |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
gActiveControl->RequestEp0ControlPacket(); |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
#else |
0 | 92 |
gActiveControl->RequestEp0ControlPacket(); |
247
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
#endif |
0 | 94 |
CActiveScheduler::Start(); |
95 |
||
96 |
test.Printf (_L("Test Run Completed\n")); |
|
97 |
||
98 |
if (gSoakCount > 0) |
|
99 |
{ |
|
100 |
gSoakCount--; |
|
101 |
} |
|
102 |
||
103 |
// Suspend thread for 2 seconds |
|
104 |
User::After(2000000); |
|
105 |
||
106 |
CleanupStack::PopAndDestroy(gActiveControl); |
|
107 |
||
108 |
} |
|
109 |
while ((gSoakCount > 0) || (gSoakCount == -1)); |
|
110 |
||
111 |
// outermost test end |
|
112 |
test.End(); |
|
113 |
test.Close(); |
|
114 |
||
115 |
CleanupStack::PopAndDestroy(myConsole); |
|
116 |
||
117 |
CleanupStack::PopAndDestroy(myScheduler); |
|
118 |
||
119 |
return; |
|
120 |
} |
|
121 |
||
122 |
void ParseCommandLine (TDes& aConfigFileName, TDes& aScriptFileName) |
|
123 |
{ |
|
124 |
TBuf<64> c; |
|
125 |
||
126 |
User::CommandLine(c); |
|
127 |
c.LowerCase(); |
|
128 |
||
129 |
aConfigFileName.SetLength(0); |
|
130 |
aScriptFileName.SetLength(0); |
|
131 |
if (c != KNullDesC) |
|
132 |
{ |
|
133 |
TLex lex(c); |
|
134 |
TPtrC token; |
|
135 |
||
136 |
while (token.Set(lex.NextToken()), token != KNullDesC) |
|
137 |
{ |
|
138 |
if (token == _L("/v")) |
|
139 |
{ |
|
140 |
RDebug::Print(_L("Verbose output enabled\n")); |
|
141 |
gVerbose = ETrue; |
|
142 |
} |
|
143 |
else if (token == _L("/s")) |
|
144 |
{ |
|
145 |
RDebug::Print(_L("Skipping some tests\n")); |
|
146 |
gSkip = ETrue; |
|
147 |
} |
|
148 |
else if (token == _L("/t")) |
|
149 |
{ |
|
150 |
RDebug::Print(_L("Temporary Test\n")); |
|
151 |
gTempTest = ETrue; |
|
152 |
} |
|
153 |
else if (token == _L("/n")) |
|
154 |
{ |
|
155 |
RDebug::Print(_L("Not Stopping on Test Fail\n")); |
|
156 |
gStopOnFail = EFalse; |
|
157 |
} |
|
247
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
158 |
#ifdef USB_SC |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
else if (token == _L("/a")) |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
{ |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
161 |
RDebug::Print(_L("share handle test\n")); |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
gShareHandle = ETrue; |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
} |
d8d70de2bd36
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
#endif |
0 | 165 |
else if (token.Left(5) == _L("/soak")) |
166 |
{ |
|
167 |
TInt equalPos; |
|
168 |
gSoakCount = -1; |
|
169 |
equalPos = token.Locate('='); |
|
170 |
if ((equalPos+1) < token.Length()) |
|
171 |
{ |
|
172 |
TLex lexNum(token.Mid(equalPos+1)); |
|
173 |
lexNum.Val(gSoakCount,EDecimal); |
|
174 |
} |
|
175 |
RDebug::Print(_L("Soak test for %d iterations\n"),gSoakCount); |
|
176 |
} |
|
177 |
else if (token.Left(8) == _L("/script=")) |
|
178 |
{ |
|
179 |
aScriptFileName = token; |
|
180 |
} |
|
181 |
else |
|
182 |
{ |
|
183 |
aConfigFileName = token; |
|
184 |
} |
|
185 |
} |
|
186 |
} |
|
187 |
||
188 |
} |
|
189 |
||
190 |
TInt E32Main() |
|
191 |
{ |
|
192 |
__UHEAP_MARK; |
|
193 |
||
194 |
CTrapCleanup* cleanup = CTrapCleanup::New(); // get clean-up stack |
|
195 |
||
196 |
TBuf<64> configFileName; |
|
197 |
TBuf<64> scriptFileName; |
|
198 |
ParseCommandLine (configFileName,scriptFileName); |
|
199 |
||
200 |
if (configFileName.Length() == 0) |
|
201 |
{ |
|
202 |
RDebug::Print(_L("(T_USB: Warning - No Configuration File.)\n")); |
|
203 |
} |
|
204 |
else |
|
205 |
{ |
|
206 |
RDebug::Print(_L("T_USB: Config File Name %s\n"),configFileName.PtrZ()); |
|
207 |
} |
|
208 |
||
209 |
if (scriptFileName.Length() != 0) |
|
210 |
{ |
|
211 |
RDebug::Print(_L("T_USB: Script File Name %s\n"),scriptFileName.PtrZ()); |
|
212 |
} |
|
213 |
||
214 |
TRAPD(error, RunAppL(& configFileName, &scriptFileName)); |
|
215 |
||
216 |
__ASSERT_ALWAYS(!error, User::Panic(_L("T_USB_DEVICE: EPOC32EX"), error)); |
|
217 |
||
218 |
delete cleanup; // destroy clean-up stack |
|
219 |
||
220 |
__UHEAP_MARKEND; |
|
221 |
||
222 |
RDebug::Print(_L("Program exit: done.\n")); |
|
223 |
return 0; // and return |
|
224 |
} |
|
225 |
||
226 |
||
227 |
// -eof- |