108 @leave - system wide error codes |
107 @leave - system wide error codes |
109 */ |
108 */ |
110 |
109 |
111 EXPORT_C TVerdict CTestStepSmokeTest::doTestStepPostambleL() |
110 EXPORT_C TVerdict CTestStepSmokeTest::doTestStepPostambleL() |
112 { |
111 { |
113 |
|
114 //Read whether to do capability testing.. |
|
115 TPtrC captest(KNo); |
|
116 GetStringFromConfig(KDefault, KCapTest, captest); |
|
117 if( captest.Compare(_L("YES")) == 0) |
|
118 { |
|
119 INFO_PRINTF1(_L("---Capability Testing---")); |
|
120 //Gets the capabilities config file |
|
121 TBuf<KMaxTestExecuteCommandLength> scriptFile; |
|
122 scriptFile.Copy(KConfigFile); |
|
123 INFO_PRINTF2(_L("The config file %S"), &scriptFile); |
|
124 |
|
125 TBuf8<KMaxTestExecuteCommandLength> scriptSection; |
|
126 scriptSection.Copy(_L("Capabilities")); |
|
127 |
|
128 TPtrC serverName = GetServerName(); |
|
129 INFO_PRINTF2(_L("The server name is %S"), &serverName); |
|
130 HBufC8 *scriptItem = HBufC8::NewLC(serverName.Length()); |
|
131 scriptItem->Des().Copy(serverName); |
|
132 |
|
133 //Get the file server session object |
|
134 RFs rFs; |
|
135 TInt err=rFs.Connect(); |
|
136 if(err != KErrNone) |
|
137 { |
|
138 ERR_PRINTF1(_L("Failed to connect with File server")); |
|
139 SetTestStepResult(EFail); |
|
140 } |
|
141 else |
|
142 { |
|
143 CleanupClosePushL(rFs); |
|
144 //Get the config file |
|
145 CTestConfig* configFile = CTestConfig::NewLC(rFs, KNullDesC, scriptFile); |
|
146 if( configFile == NULL) |
|
147 { |
|
148 WARN_PRINTF1(_L("NO Config file found -- Plattest_capabilites.config")); |
|
149 } |
|
150 else |
|
151 { |
|
152 //Get the item value from config file |
|
153 TBuf8<KMaxTestExecuteCommandLength> itemValue; |
|
154 itemValue = configFile->Section(scriptSection)->Item(scriptItem->Des())->Value(); |
|
155 TLex8 capabilityParser(itemValue); |
|
156 TBool capCheckResult= ETrue; |
|
157 |
|
158 while(!capabilityParser.Eos()) |
|
159 { |
|
160 //Parse the capabilities |
|
161 TPtrC8 capability(capabilityParser.NextToken()); |
|
162 |
|
163 HBufC* capabilityRead = HBufC::NewLC(capability.Length()); |
|
164 capabilityRead->Des().Copy(capability); |
|
165 INFO_PRINTF2(_L("Capability Read is %S"), capabilityRead); |
|
166 |
|
167 //Get the capability value |
|
168 TCapability capabilityValue; |
|
169 TPtrC ptrCapabilty(capabilityRead->Des()); |
|
170 TInt err = GetCapability(ptrCapabilty, capabilityValue); |
|
171 if( err != KErrNone) |
|
172 { |
|
173 WARN_PRINTF1(_L("The capability is not found")); |
|
174 } |
|
175 else |
|
176 { |
|
177 //Check if the current process posses the required capability |
|
178 if( !RProcess().HasCapability(capabilityValue) ) |
|
179 { |
|
180 INFO_PRINTF2(_L("The capability %S is not possesed."), capabilityRead); |
|
181 capCheckResult=EFalse; |
|
182 } |
|
183 else |
|
184 { |
|
185 INFO_PRINTF2(_L("The capability %S is possesed."), capabilityRead); |
|
186 } |
|
187 } |
|
188 CleanupStack::PopAndDestroy(capabilityRead); |
|
189 } |
|
190 |
|
191 //read the expected capability check result |
|
192 TBool expectedCapCheckResult = ETrue; |
|
193 GetBoolFromConfig(ConfigSection(), KExpectedCapCheckResult, expectedCapCheckResult); |
|
194 INFO_PRINTF2(_L("The expected cap check result is %D"), expectedCapCheckResult); |
|
195 INFO_PRINTF2(_L("The cap check result is %D"), capCheckResult); |
|
196 |
|
197 if(expectedCapCheckResult == capCheckResult) |
|
198 { |
|
199 SetTestStepResult(EPass); |
|
200 } |
|
201 else |
|
202 { |
|
203 SetTestStepResult(EFail); |
|
204 } |
|
205 } |
|
206 CleanupStack::PopAndDestroy(2, &rFs); |
|
207 } |
|
208 CleanupStack::PopAndDestroy(scriptItem); |
|
209 if(TestStepError() == KErrPermissionDenied) |
|
210 { |
|
211 INFO_PRINTF1(_L(" The failure is due to Platform Security")); |
|
212 } |
|
213 } |
|
214 |
|
215 TVerdict ret = CTestStep::doTestStepPostambleL(); |
112 TVerdict ret = CTestStep::doTestStepPostambleL(); |
216 return ret; |
113 return ret; |
217 } |
114 } |
218 |
115 |
219 /** |
116 /** |