|
1 // Copyright (c) 2007-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 // Example CTestStep derived implementation |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 /** |
|
20 @file te_check_build_variability_step.cpp |
|
21 @internalTechnology |
|
22 */ |
|
23 #include <hal.h> |
|
24 #include "te_suite_defs.h" |
|
25 #include "te_check_build_variability_step.h" //opensystemtrace gets included from here |
|
26 #include "te_tracer.h" //opensystemtrace and apicaller gets included from here |
|
27 |
|
28 CCheckBuildVariabilityStep::~CCheckBuildVariabilityStep() |
|
29 /** |
|
30 * Destructor |
|
31 */ |
|
32 { |
|
33 } |
|
34 |
|
35 CCheckBuildVariabilityStep::CCheckBuildVariabilityStep() |
|
36 /** |
|
37 * Constructor |
|
38 */ |
|
39 { |
|
40 SetTestStepName(KCheckBuildVariabilityStep); |
|
41 #ifdef TE_TRACE_ENABLED |
|
42 _LIT(KLogFilename,"variability_systemenabled_traceenabled.utf"); |
|
43 #elif TE_TRACE_DISABLED |
|
44 _LIT(KLogFilename,"variability_systemenabled_tracedisabled.utf"); |
|
45 #else |
|
46 _LIT(KLogFilename,"dummy.utf"); |
|
47 #endif |
|
48 |
|
49 SetLogFilename(KLogFilename); |
|
50 } |
|
51 |
|
52 TVerdict CCheckBuildVariabilityStep::CheckBuildtimeVariability() |
|
53 { |
|
54 TBool builtIntoThisComponent = EFalse; |
|
55 TBool shouldBeBuiltIntoThisComponent = EFalse; |
|
56 |
|
57 #ifdef SYMBIAN_TRACE_EXECUTABLE_IS_INCLUDED |
|
58 builtIntoThisComponent = ETrue; |
|
59 #endif |
|
60 #ifdef TE_EXECUTABLE_SHOULD_BE_ENABLED |
|
61 shouldBeBuiltIntoThisComponent = ETrue; |
|
62 #endif |
|
63 |
|
64 iTraceData.iTracingBuiltIn = builtIntoThisComponent; |
|
65 |
|
66 INFO_PRINTF2(_L("Trace should be: built into executable = %i"), shouldBeBuiltIntoThisComponent); |
|
67 INFO_PRINTF2(_L("Trace is: built into executable = %i"), builtIntoThisComponent); |
|
68 |
|
69 if((builtIntoThisComponent != shouldBeBuiltIntoThisComponent)) |
|
70 { |
|
71 INFO_PRINTF1(_L("ERROR: Mismatched compile time variability")); |
|
72 SetTestStepResult(EFail); |
|
73 } |
|
74 |
|
75 return TestStepResult(); |
|
76 } |
|
77 |
|
78 TVerdict CCheckBuildVariabilityStep::doTestStepL() |
|
79 /** |
|
80 * @return - TVerdict code |
|
81 * Override of base class pure virtual |
|
82 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
83 * not leave. That being the case, the current test result value will be EPass. |
|
84 */ |
|
85 { |
|
86 if (TestStepResult()==EPass) |
|
87 { |
|
88 CheckBuildtimeVariability(); |
|
89 if (TestStepResult()==EPass) |
|
90 {//now check that logging occurs properly |
|
91 CheckLoggingVariability(); |
|
92 } |
|
93 } |
|
94 return TestStepResult(); |
|
95 } |
|
96 |
|
97 TVerdict CCheckBuildVariabilityStep::CheckLoggingVariability() |
|
98 { |
|
99 //test all cases when logging is enabled |
|
100 INFO_PRINTF2(_L("--- Logging enabled, tracing built in %i ---"), iTraceData.iTracingBuiltIn); |
|
101 iTraceData.iLoggingEnabled = ETrue; |
|
102 TTraceConfigsOperator::SetData(iTraceData, KData1, KData2, KAny1, KDefault8); |
|
103 TTraceConfigsOperator::SetData(iTraceData, KCharString, KCharStringSize); |
|
104 TInt error = StartLoggingL(iTraceData); |
|
105 if(error) |
|
106 { |
|
107 INFO_PRINTF2(_L("ERROR: Start logging failed, error %i "), error); |
|
108 SetTestStepResult(EFail); |
|
109 return TestStepResult(); |
|
110 } |
|
111 TBool passLogging = TestTraces(); |
|
112 //test all cases where logging is disabled |
|
113 INFO_PRINTF1(_L("--- Logging disabled ---")); |
|
114 iTraceData.iLoggingEnabled = EFalse; |
|
115 error = StopLogging(); |
|
116 if(error) |
|
117 { |
|
118 INFO_PRINTF2(_L("ERROR: Failed to stop logging, error %i "), error); |
|
119 SetTestStepResult(EFail); |
|
120 return TestStepResult(); |
|
121 } |
|
122 |
|
123 TBool passNoLogging = TestTraces(); |
|
124 |
|
125 //if any of the cases failed, fail the test step |
|
126 if((passLogging == EFalse) || (passNoLogging == EFalse)) |
|
127 { |
|
128 SetTestStepResult(EFail); |
|
129 } |
|
130 return TestStepResult(); |
|
131 } |
|
132 |
|
133 TBool CCheckBuildVariabilityStep::TestTraces() |
|
134 { |
|
135 TBool allPassed = ETrue; |
|
136 for(TInt i = 1; i <= KAPIMaxNumberOfTraceApis; i++) |
|
137 { |
|
138 if(i == EPrintTDesC8) |
|
139 INFO_PRINTF1(_L("-- Testing user side --")); |
|
140 if(i == EKernelPrintDesC8) |
|
141 INFO_PRINTF1(_L("-- Testing kernel side --")); |
|
142 if(i == EContextTClassification) |
|
143 INFO_PRINTF1(_L("-- Testing contexts --")); |
|
144 |
|
145 if(DoSendTrace((TTraceApiUsed)i)) |
|
146 INFO_PRINTF2(_L("Trace %i - ok"), i); |
|
147 else |
|
148 allPassed = EFalse; |
|
149 } |
|
150 INFO_PRINTF1(_L("Trace variability testing done")); |
|
151 |
|
152 return allPassed; |
|
153 } |
|
154 |
|
155 |
|
156 TBool CCheckBuildVariabilityStep::DoSendTrace(TTraceApiUsed aApiUsed) |
|
157 { |
|
158 iTraceData.iApiUsed = aApiUsed; |
|
159 TInt result = iTraceTester.SendTraceL(iTraceData); |
|
160 TBool pass = WasTraceVariabilitySuccessful(result); |
|
161 if(!pass) |
|
162 { |
|
163 if(iTraceData.iLoggingEnabled) |
|
164 { |
|
165 if(result == 1) |
|
166 INFO_PRINTF3(_L("Trace %i - No traces where output even though logging was ON"), aApiUsed, result); |
|
167 else |
|
168 INFO_PRINTF3(_L("Trace %i - Error %i, logging was ON"), aApiUsed, result); |
|
169 } |
|
170 else |
|
171 INFO_PRINTF3(_L("Trace %i - Error %i, logging was OFF"), aApiUsed, result); |
|
172 } |
|
173 |
|
174 return pass; |
|
175 } |
|
176 |
|
177 TBool CCheckBuildVariabilityStep::WasTraceVariabilitySuccessful(TInt aTraceResult) |
|
178 { |
|
179 TBool passed = EFalse; |
|
180 |
|
181 if(iTraceData.iTracingBuiltIn) |
|
182 { |
|
183 if(iTraceData.iLoggingEnabled == (aTraceResult == KErrNone)) |
|
184 { |
|
185 passed = ETrue; |
|
186 } |
|
187 } |
|
188 else //tracing not built in |
|
189 { |
|
190 if((aTraceResult == KInfoTraceNotOutput)) |
|
191 passed = ETrue; |
|
192 } |
|
193 return passed; |
|
194 } |