|
1 /* |
|
2 * Copyright (c) 2010 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Include Files |
|
20 |
|
21 #include "MultipleMmpTraceErrorApp.h" |
|
22 #include <e32base.h> |
|
23 #include <e32std.h> |
|
24 #include <e32cons.h> // Console |
|
25 #include "OstTraceDefinitions.h" |
|
26 #ifdef OST_TRACE_COMPILER_IN_USE |
|
27 #include "MultipleMmpTraceErrorApp2Traces.h" |
|
28 #endif |
|
29 |
|
30 // Constants |
|
31 |
|
32 _LIT(KTextConsoleTitle, "Console"); |
|
33 _LIT(KTextFailed, " failed, leave code = %d"); |
|
34 _LIT(KTextPressAnyKey, " [press any key]\n"); |
|
35 |
|
36 // Global Variables |
|
37 |
|
38 LOCAL_D CConsoleBase* console; // write all messages to this |
|
39 |
|
40 |
|
41 // Local Functions |
|
42 |
|
43 LOCAL_C void MainL() |
|
44 { |
|
45 /****************************SHOULD GIVE ERRORS*******************************/ |
|
46 _LIT8(KTestDes,"Test Descriptor"); |
|
47 TInt32 x = 555; |
|
48 TUint32 y = 666; |
|
49 |
|
50 //In these two cases Trace Compiler should give a error that an extension macro isn't necessary: |
|
51 //"TraceErrorApp.cpp, line xx: Trace does not need to use extension macro" |
|
52 OstTraceExt1( TRACE_FLOW, TEST1_MAINL, "MainL(): x=%d" , x ); |
|
53 OstTraceExt1( TRACE_FLOW, TEST2_MAINL, "MainL(): y=%u" , y ); |
|
54 |
|
55 //This should give an error stating that the trace name is duplicated |
|
56 //"TraceErrorApp.cpp, line xx: Trace is used from multiple places" |
|
57 OstTrace0( TRACE_FLOW, TEST3_MAINL, "MainL()" ); |
|
58 OstTrace0( TRACE_FLOW, TEST3_MAINL, "MainL()" ); |
|
59 |
|
60 //This should NOT give an error stating that the arguments don't match format spec |
|
61 //OstTraceExt2( TRACE_FLOW, TEST4_MAINL, "MainL(): x=%d;KTestDes=%d", x, KTestDes ); |
|
62 |
|
63 //Wrong API i.e more parameters than it takes |
|
64 //"TraceErrorApp.cpp, line xx: Parameter count does not match the format specification" |
|
65 OstTrace0( TRACE_FLOW, TEST5_MAINL, "MainL(): x=%d" ,x); |
|
66 |
|
67 //Too many User-defined group ids should be max of 32 but there are 33 here), should get an error |
|
68 //"You have exceeded the number of Group IDs you have allocated." |
|
69 OstTrace0( MY_GROUP_ID1, TEST_MAINL6, "MainL()" ); |
|
70 OstTrace0( MY_GROUP_ID2, TEST_MAINL7, "MainL()" ); |
|
71 OstTrace0( MY_GROUP_ID3, TEST_MAINL8, "MainL()" ); |
|
72 OstTrace0( MY_GROUP_ID4, TEST_MAINL9, "MainL()" ); |
|
73 OstTrace0( MY_GROUP_ID5, TEST_MAINL10, "MainL()" ); |
|
74 OstTrace0( MY_GROUP_ID6, TEST_MAINL11, "MainL()" ); |
|
75 OstTrace0( MY_GROUP_ID7, TEST_MAINL12, "MainL()" ); |
|
76 OstTrace0( MY_GROUP_ID8, TEST_MAINL13, "MainL()" ); |
|
77 OstTrace0( MY_GROUP_ID9, TEST_MAINL14, "MainL()" ); |
|
78 OstTrace0( MY_GROUP_ID10, TEST_MAINL15, "MainL()" ); |
|
79 OstTrace0( MY_GROUP_ID11, TEST_MAINL16, "MainL()" ); |
|
80 OstTrace0( MY_GROUP_ID12, TEST_MAINL17, "MainL()" ); |
|
81 OstTrace0( MY_GROUP_ID13, TEST_MAINL18, "MainL()" ); |
|
82 OstTrace0( MY_GROUP_ID14, TEST_MAINL19, "MainL()" ); |
|
83 OstTrace0( MY_GROUP_ID15, TEST_MAINL20, "MainL()" ); |
|
84 OstTrace0( MY_GROUP_ID16, TEST_MAINL21, "MainL()" ); |
|
85 OstTrace0( MY_GROUP_ID17, TEST_MAINL22, "MainL()" ); |
|
86 OstTrace0( MY_GROUP_ID18, TEST_MAINL23, "MainL()" ); |
|
87 OstTrace0( MY_GROUP_ID19, TEST_MAINL24, "MainL()" ); |
|
88 OstTrace0( MY_GROUP_ID20, TEST_MAINL25, "MainL()" ); |
|
89 OstTrace0( MY_GROUP_ID21, TEST_MAINL26, "MainL()" ); |
|
90 OstTrace0( MY_GROUP_ID22, TEST_MAINL27, "MainL()" ); |
|
91 OstTrace0( MY_GROUP_ID23, TEST_MAINL28, "MainL()" ); |
|
92 OstTrace0( MY_GROUP_ID24, TEST_MAINL29, "MainL()" ); |
|
93 OstTrace0( MY_GROUP_ID25, TEST_MAINL30, "MainL()" ); |
|
94 OstTrace0( MY_GROUP_ID26, TEST_MAINL31, "MainL()" ); |
|
95 OstTrace0( MY_GROUP_ID27, TEST_MAINL32, "MainL()" ); |
|
96 OstTrace0( MY_GROUP_ID28, TEST_MAINL33, "MainL()" ); |
|
97 OstTrace0( MY_GROUP_ID29, TEST_MAINL34, "MainL()" ); |
|
98 OstTrace0( MY_GROUP_ID30, TEST_MAINL35, "MainL()" ); |
|
99 OstTrace0( MY_GROUP_ID31, TEST_MAINL36, "MainL()" ); |
|
100 OstTrace0( MY_GROUP_ID32, TEST_MAINL37, "MainL()" ); |
|
101 OstTrace0( MY_GROUP_ID33, TEST_MAINL38, "MainL()" ); |
|
102 /*****************************************************************************/ |
|
103 |
|
104 |
|
105 /******************************SHOULD GIVE WARNINGS***************************/ |
|
106 //Should get warnings from using deprecated GIDs |
|
107 //e.g. "Deprecated group TRACE_API detected. Updating to TRACE_BORDER in dictionary. Please update source code!" |
|
108 OstTrace0( TRACE_API, TEST_MAINL39, "MainL()" ); |
|
109 OstTrace0( TRACE_IMPORTANT, TEST_MAINL40, "MainL()" ); |
|
110 OstTrace0( TRACE_DETAILED, TEST_MAINL41, "MainL()" ); |
|
111 OstTrace0( TRACE_DEBUG, TEST_MAINL42, "MainL()" ); |
|
112 /*****************************************************************************/ |
|
113 |
|
114 CallSomeMoreTraceStatements(); |
|
115 |
|
116 console->Write(_L("Hello, world!\n")); |
|
117 } |
|
118 |
|
119 LOCAL_C void DoStartL() |
|
120 { |
|
121 // Create active scheduler (to run active objects) |
|
122 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); |
|
123 CleanupStack::PushL(scheduler); |
|
124 CActiveScheduler::Install(scheduler); |
|
125 |
|
126 MainL(); |
|
127 |
|
128 // Delete active scheduler |
|
129 CleanupStack::PopAndDestroy(scheduler); |
|
130 } |
|
131 |
|
132 // Global Functions |
|
133 |
|
134 GLDEF_C TInt E32Main() |
|
135 { |
|
136 // Create cleanup stack |
|
137 __UHEAP_MARK; |
|
138 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
139 |
|
140 // Create output console |
|
141 TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize( |
|
142 KConsFullScreen, KConsFullScreen))); |
|
143 if (createError) |
|
144 return createError; |
|
145 |
|
146 // Run application code inside TRAP harness, wait keypress when terminated |
|
147 TRAPD(mainError, DoStartL()); |
|
148 if (mainError) |
|
149 console->Printf(KTextFailed, mainError); |
|
150 console->Printf(KTextPressAnyKey); |
|
151 console->Getch(); |
|
152 |
|
153 delete console; |
|
154 delete cleanup; |
|
155 __UHEAP_MARKEND; |
|
156 return KErrNone; |
|
157 } |
|
158 |