|
1 // Copyright (c) 2003-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 @file TestSteps.cpp |
|
18 */ |
|
19 |
|
20 |
|
21 #include <e32math.h> |
|
22 #include <c32comm.h> |
|
23 #include <in_sock.h> |
|
24 |
|
25 |
|
26 #include <test/testexecutelog.h> |
|
27 #include "TestSteps.h" |
|
28 #include "te_pppsize_server.h" |
|
29 |
|
30 // |
|
31 // Construction/Destruction |
|
32 // |
|
33 |
|
34 CPPPMinMaxMMU::CPPPMinMaxMMU() |
|
35 { |
|
36 SetTestStepName(KPPPMinMaxMMU); |
|
37 } |
|
38 |
|
39 CPPPMinMaxMMU::~CPPPMinMaxMMU() |
|
40 { } |
|
41 |
|
42 void CPPPMinMaxMMU::CommInitL(TBool aEnhanced) |
|
43 { |
|
44 TInt err; |
|
45 TPtrC pdd_name, ldd_name,ldd_fname; |
|
46 INFO_PRINTF1(_L("Loading Comms driver")); |
|
47 #if defined (__WINS__) |
|
48 TEST(GetStringFromConfig(_L("CommsDrivers"), _L("WinsPDDname"), pdd_name)); |
|
49 TEST(GetStringFromConfig(_L("CommsDrivers"), _L("WinsLDDname"), ldd_name)); |
|
50 TEST(GetStringFromConfig(_L("CommsDrivers"), _L("WinsLDDFname"), ldd_fname)); |
|
51 #else |
|
52 TEST(GetStringFromConfig(_L("CommsDrivers"), _L("ThumbPDDname"), pdd_name)); |
|
53 TEST(GetStringFromConfig(_L("CommsDrivers"), _L("ThumbLDDname"), ldd_name)); |
|
54 TEST(GetStringFromConfig(_L("CommsDrivers"), _L("ThumbLDDFname"), ldd_fname)); |
|
55 #endif |
|
56 err=User::LoadPhysicalDevice(pdd_name); |
|
57 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
58 { |
|
59 User::Leave(err); |
|
60 } |
|
61 |
|
62 if (aEnhanced) |
|
63 { |
|
64 err=User::LoadLogicalDevice(ldd_fname); |
|
65 } |
|
66 else |
|
67 { |
|
68 err=User::LoadLogicalDevice(ldd_name); |
|
69 } |
|
70 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
71 { |
|
72 User::Leave(err); |
|
73 } |
|
74 } |
|
75 |
|
76 TVerdict CPPPMinMaxMMU::doTestStepL() |
|
77 { |
|
78 const TInt KMaxMMU = 4000; |
|
79 const TInt KMinMMU = 1; |
|
80 |
|
81 TBuf8<KMaxMMU> *sendBuf = new(ELeave) TBuf8<KMaxMMU>(); |
|
82 CleanupStack::PushL(sendBuf); |
|
83 |
|
84 TBuf8<KMaxMMU> *recvBuf = new(ELeave) TBuf8<KMaxMMU>(); |
|
85 CleanupStack::PushL(recvBuf); |
|
86 |
|
87 TBuf8<KMaxMMU> *recvBuf2 = new(ELeave) TBuf8<KMaxMMU>(); |
|
88 CleanupStack::PushL(recvBuf2); |
|
89 |
|
90 //initialize COMM |
|
91 //CommInitL(EFalse); |
|
92 |
|
93 //Start Comms server |
|
94 // _LIT(KPhbkSyncCMI, "phbsync.cmi"); |
|
95 // (void)StartC32WithCMISuppressions(KPhbkSyncCMI); |
|
96 |
|
97 SetTestStepResult(EPass); |
|
98 INFO_PRINTF1(_L("Starting: Socket Server\n")); |
|
99 |
|
100 RSocketServ ss; |
|
101 |
|
102 // Start the socket server |
|
103 TEST(KErrNone == ss.Connect()); |
|
104 RSocket sock; |
|
105 TRequestStatus sta; |
|
106 INFO_PRINTF1(_L("Open a socket\n")); |
|
107 |
|
108 // Get the test address |
|
109 TInetAddr RemAddr(7); |
|
110 TPtrC testAddr; |
|
111 TEST(GetStringFromConfig(_L("AddressInfo"), _L("TestPPPIPAddr"), testAddr)); |
|
112 |
|
113 if(testAddr.Length()) |
|
114 { |
|
115 RemAddr.Input(testAddr); |
|
116 } |
|
117 else |
|
118 { |
|
119 INFO_PRINTF1(_L("Test FAILED\nMissing address information in config file: ")); |
|
120 return EFail; |
|
121 } |
|
122 |
|
123 // Open a socket |
|
124 TEST(KErrNone == sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp)); |
|
125 INFO_PRINTF1(_L("Connecting Socket to:")); |
|
126 |
|
127 TBuf<30> printAddr; |
|
128 RemAddr.Output(printAddr); |
|
129 |
|
130 INFO_PRINTF1(printAddr); |
|
131 |
|
132 // Connect a socket |
|
133 sock.Connect(RemAddr,sta); |
|
134 |
|
135 // Wait for Connect to complete |
|
136 User::WaitForRequest(sta); |
|
137 TEST(sta.Int() == 0); |
|
138 |
|
139 TInt iterEnd; |
|
140 GetIntFromConfig(_L("MMUInfo"), _L("TestPPPmaxMMU"), iterEnd); |
|
141 if (iterEnd > KMaxMMU) |
|
142 iterEnd = KMaxMMU; |
|
143 |
|
144 TInt iterStart; |
|
145 GetIntFromConfig(_L("MMUInfo"), _L("TestPPPminMMU"), iterStart); |
|
146 if (iterStart < KMinMMU) |
|
147 iterStart = KMinMMU; |
|
148 |
|
149 TInt i,j; |
|
150 TSockXfrLength recvLen; |
|
151 INFO_PRINTF1(_L("Send/Recv frames")); |
|
152 for(j=iterStart;j<=iterEnd;j++) |
|
153 { |
|
154 sendBuf->Zero(); |
|
155 |
|
156 for (i=0;i<j;i++) |
|
157 sendBuf->Append(Math::Random() & 0x7f); |
|
158 |
|
159 INFO_PRINTF2(_L("Sending Packet of Size: %d"),j); |
|
160 // Send data to echo port |
|
161 sock.Write(*sendBuf,sta); |
|
162 User::WaitForRequest(sta); |
|
163 TEST(sta.Int() == 0); |
|
164 i=0; |
|
165 recvBuf->Zero(); |
|
166 |
|
167 while(i<j) |
|
168 { |
|
169 // Receive data from echo port |
|
170 sock.RecvOneOrMore(*recvBuf2,0,sta,recvLen); |
|
171 User::WaitForRequest(sta); |
|
172 TEST(sta.Int() == 0); |
|
173 i += recvBuf2->Length(); |
|
174 recvBuf->Append(*recvBuf2); |
|
175 } |
|
176 |
|
177 TEST(KErrNone == recvBuf->Compare(*sendBuf)); |
|
178 INFO_PRINTF1(_L(" Received echoed Packet")); |
|
179 } |
|
180 |
|
181 sock.Shutdown(RSocket::EStopOutput,sta); |
|
182 User::WaitForRequest(sta); |
|
183 TEST(sta.Int() == 0); |
|
184 sock.Close(); |
|
185 ss.Close(); |
|
186 |
|
187 CleanupStack::PopAndDestroy(3); |
|
188 |
|
189 return TestStepResult(); |
|
190 } |
|
191 |