|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Implementation of the RTestServ and RTestSession API's |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 @file TestClient.cpp |
|
23 */ |
|
24 #include <test/testexecuteclient.h> |
|
25 #include <test/testexecutestepbase.h> |
|
26 |
|
27 TVersion RTestServ::Version() const |
|
28 { |
|
29 return(TVersion(KTestExecuteMajorVersionNumber,KTestExecuteMinorVersionNumber,KTestExecuteBuildVersionNumber)); |
|
30 } |
|
31 |
|
32 |
|
33 EXPORT_C TInt RTestServ::Connect(const TDesC& aServerName, TBool aDebugMode) |
|
34 /** |
|
35 * @param aServerName - Human readable name of the test server |
|
36 * @param aDebugMode - Set to true for just in time debugging |
|
37 * @return int - Standard error codes |
|
38 * Secure version of the API call. Expects the server binary to be |
|
39 * ServerXXX.exe |
|
40 */ |
|
41 { |
|
42 if(aServerName.Length() > iServerName.MaxLength()) |
|
43 return KErrTooBig; |
|
44 iServerName = aServerName; |
|
45 // Assume the server is already running and attempt to create a session |
|
46 // 4 message slots |
|
47 TInt err = CreateSession(aServerName,Version(),-1); |
|
48 if(err == KErrNotFound || err == KErrServerTerminated) |
|
49 { |
|
50 // Server not running |
|
51 // Construct the server binary name |
|
52 TBuf<KMaxTestExecuteNameLength> serverFile; |
|
53 RProcess server; |
|
54 _LIT(KEmpty,""); |
|
55 _LIT(KExe,".exe"); |
|
56 |
|
57 serverFile.Copy(aServerName); |
|
58 serverFile.Append(KExe); |
|
59 err = server.Create(serverFile,KEmpty); |
|
60 if(err != KErrNone) |
|
61 return err; |
|
62 // Synchronise with the server |
|
63 TRequestStatus reqStatus; |
|
64 server.Rendezvous(reqStatus); |
|
65 |
|
66 // Set just in time debugging for the process |
|
67 if(aDebugMode) |
|
68 server.SetJustInTime(ETrue); |
|
69 else |
|
70 server.SetJustInTime(EFalse); |
|
71 |
|
72 // Start the test harness |
|
73 server.Resume(); |
|
74 // Server will call the reciprocal static synchronise call |
|
75 User::WaitForRequest(reqStatus); |
|
76 server.Close(); |
|
77 if(reqStatus.Int() != KErrNone) |
|
78 return reqStatus.Int(); |
|
79 // Create the root server session |
|
80 err = CreateSession(aServerName,Version(),-1); |
|
81 } |
|
82 return err; |
|
83 } |
|
84 |
|
85 EXPORT_C const TDesC& RTestServ::ServerName() const |
|
86 /** |
|
87 * @return - The human readable server name |
|
88 */ |
|
89 { |
|
90 return iServerName; |
|
91 } |
|
92 |
|
93 /////// |
|
94 EXPORT_C TInt RTestSession::Open(RTestServ& aServ, const TDesC& aStepName, TBool aSharedData) |
|
95 /** |
|
96 * @param aServ - Reference to the root server session |
|
97 * @param aStepName - Reference to the name of the test step owned by the server |
|
98 * @return Standard error codes |
|
99 * Secure and Non-secure variants |
|
100 * Synchronously open a server test step session |
|
101 */ |
|
102 { |
|
103 if(aStepName.Length() > KMaxTestStepNameLength) |
|
104 return KErrTooBig; |
|
105 TIpcArgs args; |
|
106 args.Set(0,&aStepName); |
|
107 args.Set(1,aSharedData); |
|
108 return CreateSubSession(aServ,EOpenTestStep,args); |
|
109 } |
|
110 |
|
111 EXPORT_C TInt RTestSession::Open(RTestServ& aServ, TBool aSharedData) |
|
112 /** |
|
113 * @param aServ - Reference to the root server session |
|
114 * @param aStepName - Reference to the name of the test step owned by the server |
|
115 * @return Standard error codes |
|
116 * Secure and Non-secure variants |
|
117 * Synchronously open a server test step session |
|
118 */ |
|
119 { |
|
120 TIpcArgs args; |
|
121 args.Set(1,aSharedData); |
|
122 return CreateSubSession(aServ,EOpenTestBlock,args); |
|
123 } |
|
124 |
|
125 EXPORT_C void RTestSession::RunTestStep(const TDesC& aCommandString, TDes& aPanicString, TRequestStatus& aStatus) |
|
126 /** |
|
127 * |
|
128 * @param aCommandString - The arguments to the RUN_TEST_STEP command |
|
129 * @return aPanicString - If the test step panics, this member is set up with the panic string |
|
130 * @param aStatus - For completion to the caller |
|
131 * Secure and Non-secure variants |
|
132 * Send the RUN_TEST_STEP arguments to the test server |
|
133 */ |
|
134 { |
|
135 if(aCommandString.Length() > KMaxTestExecuteCommandLength) |
|
136 { |
|
137 TRequestStatus* status = &aStatus; |
|
138 User::RequestComplete(status,KErrTooBig); |
|
139 } |
|
140 TIpcArgs args; |
|
141 args.Set(0,&aCommandString); |
|
142 args.Set(1,&aPanicString); |
|
143 SendReceive(ERunTestStep,args,aStatus); |
|
144 } |
|
145 |
|
146 EXPORT_C void RTestSession::RunTestBlock(const TDesC& aCommandString, TDes& aPanicString, TDes8& aBlockArray, TRequestStatus& aStatus) |
|
147 /** |
|
148 * |
|
149 * @param aCommandString - The arguments to the test block command |
|
150 * @return aPanicString - If the test step panics, this member is set up with the panic string |
|
151 * @param aStatus - For completion to the caller |
|
152 * Secure and Non-secure variants |
|
153 * Send the RUN_TEST_STEP arguments to the test server |
|
154 */ |
|
155 { |
|
156 if(aCommandString.Length() > KMaxTestExecuteCommandLength) |
|
157 { |
|
158 TRequestStatus* status = &aStatus; |
|
159 User::RequestComplete(status,KErrTooBig); |
|
160 } |
|
161 TIpcArgs args; |
|
162 args.Set(0,&aCommandString); |
|
163 args.Set(1,&aPanicString); |
|
164 args.Set(2,&aBlockArray); |
|
165 |
|
166 SendReceive(ERunTestBlock,args,aStatus); |
|
167 } |
|
168 |
|
169 EXPORT_C TInt RTestSession::AbortTestStep() |
|
170 /** |
|
171 * |
|
172 * @return - Standard Epoc error codes |
|
173 * Secure and Non-secure variants |
|
174 * Synchronous abort of the the test step |
|
175 */ |
|
176 { |
|
177 return SendReceive(EAbortTestStep); |
|
178 } |
|
179 |
|
180 EXPORT_C void RTestSession::Close() |
|
181 { |
|
182 CloseSubSession(ECloseTestStep); |
|
183 } |