sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\nkern\t_nktrace.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Test the KTRACE macros and debug mask related functions.
|
sl@0
|
17 |
// API Information:
|
sl@0
|
18 |
// UserSvr::DebugMask(), User::SetDebugMask, KDebugMask(), KDebugNum()
|
sl@0
|
19 |
// Details:
|
sl@0
|
20 |
// Set debug masks and verify they are as expected. Test using
|
sl@0
|
21 |
// UserSvr::DebugMask() & User::SetDebugMask().
|
sl@0
|
22 |
// In a kernel level LDD, test the kernel functions using
|
sl@0
|
23 |
// KDebugMask() & KDebugNum().
|
sl@0
|
24 |
//
|
sl@0
|
25 |
//
|
sl@0
|
26 |
|
sl@0
|
27 |
#include <e32test.h>
|
sl@0
|
28 |
#include <e32svr.h>
|
sl@0
|
29 |
#include "nk_trace.h"
|
sl@0
|
30 |
#include "d_nktrace.h"
|
sl@0
|
31 |
|
sl@0
|
32 |
LOCAL_D RTest test(_L("T_NKTRACE"));
|
sl@0
|
33 |
|
sl@0
|
34 |
void Wait(TInt aSeconds)
|
sl@0
|
35 |
{
|
sl@0
|
36 |
while (aSeconds>0)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
--aSeconds;
|
sl@0
|
39 |
User::After(1000000);
|
sl@0
|
40 |
test.Printf(_L("."));
|
sl@0
|
41 |
}
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
GLDEF_C TInt E32Main()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
test.Title();
|
sl@0
|
47 |
|
sl@0
|
48 |
test.Start(_L("Load LDD"));
|
sl@0
|
49 |
TInt r=User::LoadLogicalDevice(_L("D_NKTRACE"));
|
sl@0
|
50 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
51 |
test.Next(_L("Open channel"));
|
sl@0
|
52 |
RNKTraceTest traceSys;
|
sl@0
|
53 |
r=traceSys.Open();
|
sl@0
|
54 |
test(r==KErrNone);
|
sl@0
|
55 |
|
sl@0
|
56 |
// verify access to debug mask 0, with and without argument
|
sl@0
|
57 |
TUint32 initial[8];
|
sl@0
|
58 |
TInt i;
|
sl@0
|
59 |
|
sl@0
|
60 |
for (i=0; i<8; i++)
|
sl@0
|
61 |
initial[i]= UserSvr::DebugMask(i);
|
sl@0
|
62 |
|
sl@0
|
63 |
test.Printf(_L("initial DebugMask value = 0x%08x\n"), initial[0]);
|
sl@0
|
64 |
TUint32 m = UserSvr::DebugMask();
|
sl@0
|
65 |
test(m==initial[0]);
|
sl@0
|
66 |
User::SetDebugMask(~m);
|
sl@0
|
67 |
m = UserSvr::DebugMask(0);
|
sl@0
|
68 |
test(m!=initial[0]);
|
sl@0
|
69 |
test(m==~initial[0]);
|
sl@0
|
70 |
|
sl@0
|
71 |
// set and verify each of the 8 debug masks
|
sl@0
|
72 |
User::SetDebugMask(0x12340000, 0);
|
sl@0
|
73 |
User::SetDebugMask(0x12341111, 1);
|
sl@0
|
74 |
User::SetDebugMask(0x12342222, 2);
|
sl@0
|
75 |
User::SetDebugMask(0x12343333, 3);
|
sl@0
|
76 |
User::SetDebugMask(0x12344444, 4);
|
sl@0
|
77 |
User::SetDebugMask(0x12345555, 5);
|
sl@0
|
78 |
User::SetDebugMask(0x12346666, 6);
|
sl@0
|
79 |
User::SetDebugMask(0x12347777, 7);
|
sl@0
|
80 |
|
sl@0
|
81 |
m = UserSvr::DebugMask(0);
|
sl@0
|
82 |
test(m==0x12340000);
|
sl@0
|
83 |
m = UserSvr::DebugMask(1);
|
sl@0
|
84 |
test(m==0x12341111);
|
sl@0
|
85 |
m = UserSvr::DebugMask(2);
|
sl@0
|
86 |
test(m==0x12342222);
|
sl@0
|
87 |
m = UserSvr::DebugMask(3);
|
sl@0
|
88 |
test(m==0x12343333);
|
sl@0
|
89 |
m = UserSvr::DebugMask(4);
|
sl@0
|
90 |
test(m==0x12344444);
|
sl@0
|
91 |
m = UserSvr::DebugMask(5);
|
sl@0
|
92 |
test(m==0x12345555);
|
sl@0
|
93 |
m = UserSvr::DebugMask(6);
|
sl@0
|
94 |
test(m==0x12346666);
|
sl@0
|
95 |
m = UserSvr::DebugMask(7);
|
sl@0
|
96 |
test(m==0x12347777);
|
sl@0
|
97 |
|
sl@0
|
98 |
// verify correct results when no index argument is given
|
sl@0
|
99 |
User::SetDebugMask(0xC0000000);
|
sl@0
|
100 |
m = UserSvr::DebugMask();
|
sl@0
|
101 |
test.Printf(_L("UserSvr::DebugMask = 0x%08x\n"), m);
|
sl@0
|
102 |
test(m==0xC0000000);
|
sl@0
|
103 |
|
sl@0
|
104 |
User::SetDebugMask(0x80000000);
|
sl@0
|
105 |
m = UserSvr::DebugMask();
|
sl@0
|
106 |
test.Printf(_L("UserSvr::DebugMask = 0x%08x\n"), m);
|
sl@0
|
107 |
test(m==0x80000000);
|
sl@0
|
108 |
|
sl@0
|
109 |
test.Next(_L("Test the Kernel level code..."));
|
sl@0
|
110 |
User::SetDebugMask(0xC0000000, 0); // set bits 30 & 31
|
sl@0
|
111 |
User::SetDebugMask(0x00000008, 1); // set bit 35
|
sl@0
|
112 |
User::SetDebugMask(0x00000010, 2); // set bit 68
|
sl@0
|
113 |
User::SetDebugMask(0x00000020, 3); // set bit 101
|
sl@0
|
114 |
User::SetDebugMask(0x00000100, 4); // set bit 136
|
sl@0
|
115 |
User::SetDebugMask(0x00001000, 5); // set bit 172
|
sl@0
|
116 |
User::SetDebugMask(0x00000001, 6); // set bit 192
|
sl@0
|
117 |
User::SetDebugMask(0x00000040, 7); // set bit 230
|
sl@0
|
118 |
|
sl@0
|
119 |
// test the KTRACE_OPT macros in server code
|
sl@0
|
120 |
r=traceSys.KTrace(RNKTraceTest::ETestKTrace);
|
sl@0
|
121 |
|
sl@0
|
122 |
// test the KDebugMask() and KDebugNum() functions in server code
|
sl@0
|
123 |
r=traceSys.KDebug(RNKTraceTest::ETestKTrace);
|
sl@0
|
124 |
|
sl@0
|
125 |
test.Printf(_L("Kern::Printf() output goes\n"));
|
sl@0
|
126 |
test.Printf(_L("to the serial port or the \n"));
|
sl@0
|
127 |
test.Printf(_L("file epocwind.out when \n"));
|
sl@0
|
128 |
test.Printf(_L("tested on the emulator. \n"));
|
sl@0
|
129 |
test.Printf(_L("The following results\n"));
|
sl@0
|
130 |
test.Printf(_L("should be displayed:\n"));
|
sl@0
|
131 |
|
sl@0
|
132 |
test.Printf(_L("Test __KTRACE_OPT macros\n"));
|
sl@0
|
133 |
test.Printf(_L("KALWAYS\n"));
|
sl@0
|
134 |
test.Printf(_L("KPANIC\n"));
|
sl@0
|
135 |
test.Printf(_L("KSCRATCH\n"));
|
sl@0
|
136 |
test.Printf(_L("Debug bit 35 is set\n"));
|
sl@0
|
137 |
test.Printf(_L("Debug bit 68 is set\n"));
|
sl@0
|
138 |
test.Printf(_L("Debug bit 101 is set\n"));
|
sl@0
|
139 |
test.Printf(_L("Debug bit 136 is set\n"));
|
sl@0
|
140 |
test.Printf(_L("Debug bit 172 is set\n"));
|
sl@0
|
141 |
test.Printf(_L("Debug bit 192 is set\n"));
|
sl@0
|
142 |
test.Printf(_L("Debug bit 230 is set\n"));
|
sl@0
|
143 |
test.Printf(_L("KTRACE_ALL returned true\n"));
|
sl@0
|
144 |
|
sl@0
|
145 |
// Wait for a while, or for a key press
|
sl@0
|
146 |
test.Printf(_L("Press a key to continue..."));
|
sl@0
|
147 |
TRequestStatus keyStat;
|
sl@0
|
148 |
test.Console()->Read(keyStat);
|
sl@0
|
149 |
RTimer timer;
|
sl@0
|
150 |
test(timer.CreateLocal()==KErrNone);
|
sl@0
|
151 |
TRequestStatus timerStat;
|
sl@0
|
152 |
timer.After(timerStat,10*1000000);
|
sl@0
|
153 |
User::WaitForRequest(timerStat,keyStat);
|
sl@0
|
154 |
TInt key;
|
sl@0
|
155 |
if(keyStat!=KRequestPending)
|
sl@0
|
156 |
key = test.Console()->KeyCode();
|
sl@0
|
157 |
timer.Cancel();
|
sl@0
|
158 |
test.Console()->ReadCancel();
|
sl@0
|
159 |
User::WaitForAnyRequest();
|
sl@0
|
160 |
|
sl@0
|
161 |
test.Printf(_L("\n"));
|
sl@0
|
162 |
test.Printf(_L("KDebug tests (0)\n"));
|
sl@0
|
163 |
test.Printf(_L("KDebugMask() = 0xc0000000\n"));
|
sl@0
|
164 |
test.Printf(_L("KDebugNum(30) = 1\n"));
|
sl@0
|
165 |
test.Printf(_L("KDebugNum(31) = 1\n"));
|
sl@0
|
166 |
test.Printf(_L("KDebugNum(3) = 0\n"));
|
sl@0
|
167 |
test.Printf(_L("KDebugNum(9) = 0\n"));
|
sl@0
|
168 |
test.Printf(_L("KDebugNum(10000) = 0\n"));
|
sl@0
|
169 |
test.Printf(_L("KDebugNum(-1) = 1\n"));
|
sl@0
|
170 |
test.Printf(_L("KDebugNum(-2) = 0\n"));
|
sl@0
|
171 |
test.Printf(_L("KDebugNum(35) = 1\n"));
|
sl@0
|
172 |
test.Printf(_L("KDebugNum(36) = 0\n"));
|
sl@0
|
173 |
test.Printf(_L("KDebugNum(101) = 1\n"));
|
sl@0
|
174 |
test.Printf(_L("KDebugNum(192) = 1\n"));
|
sl@0
|
175 |
test.Printf(_L("KDebugNum(230) = 1\n"));
|
sl@0
|
176 |
|
sl@0
|
177 |
// set the debug masks back to the original state
|
sl@0
|
178 |
for (i=0; i<8; i++)
|
sl@0
|
179 |
User::SetDebugMask(initial[i], i);
|
sl@0
|
180 |
|
sl@0
|
181 |
m = UserSvr::DebugMask(0);
|
sl@0
|
182 |
test(m==initial[0]);
|
sl@0
|
183 |
m = UserSvr::DebugMask(1);
|
sl@0
|
184 |
test(m==initial[1]);
|
sl@0
|
185 |
m = UserSvr::DebugMask(2);
|
sl@0
|
186 |
test(m==initial[2]);
|
sl@0
|
187 |
m = UserSvr::DebugMask(3);
|
sl@0
|
188 |
test(m==initial[3]);
|
sl@0
|
189 |
m = UserSvr::DebugMask(4);
|
sl@0
|
190 |
test(m==initial[4]);
|
sl@0
|
191 |
m = UserSvr::DebugMask(5);
|
sl@0
|
192 |
test(m==initial[5]);
|
sl@0
|
193 |
m = UserSvr::DebugMask(6);
|
sl@0
|
194 |
test(m==initial[6]);
|
sl@0
|
195 |
m = UserSvr::DebugMask(7);
|
sl@0
|
196 |
test(m==initial[7]);
|
sl@0
|
197 |
|
sl@0
|
198 |
test.End();
|
sl@0
|
199 |
|
sl@0
|
200 |
return(0);
|
sl@0
|
201 |
}
|
sl@0
|
202 |
|