Update contrib.
1 // Copyright (c) 2005-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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\nkern\t_nktrace.cpp
16 // Test the KTRACE macros and debug mask related functions.
18 // UserSvr::DebugMask(), User::SetDebugMask, KDebugMask(), KDebugNum()
20 // Set debug masks and verify they are as expected. Test using
21 // UserSvr::DebugMask() & User::SetDebugMask().
22 // In a kernel level LDD, test the kernel functions using
23 // KDebugMask() & KDebugNum().
30 #include "d_nktrace.h"
32 LOCAL_D RTest test(_L("T_NKTRACE"));
34 void Wait(TInt aSeconds)
44 GLDEF_C TInt E32Main()
48 test.Start(_L("Load LDD"));
49 TInt r=User::LoadLogicalDevice(_L("D_NKTRACE"));
50 test(r==KErrNone || r==KErrAlreadyExists);
51 test.Next(_L("Open channel"));
52 RNKTraceTest traceSys;
56 // verify access to debug mask 0, with and without argument
61 initial[i]= UserSvr::DebugMask(i);
63 test.Printf(_L("initial DebugMask value = 0x%08x\n"), initial[0]);
64 TUint32 m = UserSvr::DebugMask();
66 User::SetDebugMask(~m);
67 m = UserSvr::DebugMask(0);
71 // set and verify each of the 8 debug masks
72 User::SetDebugMask(0x12340000, 0);
73 User::SetDebugMask(0x12341111, 1);
74 User::SetDebugMask(0x12342222, 2);
75 User::SetDebugMask(0x12343333, 3);
76 User::SetDebugMask(0x12344444, 4);
77 User::SetDebugMask(0x12345555, 5);
78 User::SetDebugMask(0x12346666, 6);
79 User::SetDebugMask(0x12347777, 7);
81 m = UserSvr::DebugMask(0);
83 m = UserSvr::DebugMask(1);
85 m = UserSvr::DebugMask(2);
87 m = UserSvr::DebugMask(3);
89 m = UserSvr::DebugMask(4);
91 m = UserSvr::DebugMask(5);
93 m = UserSvr::DebugMask(6);
95 m = UserSvr::DebugMask(7);
98 // verify correct results when no index argument is given
99 User::SetDebugMask(0xC0000000);
100 m = UserSvr::DebugMask();
101 test.Printf(_L("UserSvr::DebugMask = 0x%08x\n"), m);
104 User::SetDebugMask(0x80000000);
105 m = UserSvr::DebugMask();
106 test.Printf(_L("UserSvr::DebugMask = 0x%08x\n"), m);
109 test.Next(_L("Test the Kernel level code..."));
110 User::SetDebugMask(0xC0000000, 0); // set bits 30 & 31
111 User::SetDebugMask(0x00000008, 1); // set bit 35
112 User::SetDebugMask(0x00000010, 2); // set bit 68
113 User::SetDebugMask(0x00000020, 3); // set bit 101
114 User::SetDebugMask(0x00000100, 4); // set bit 136
115 User::SetDebugMask(0x00001000, 5); // set bit 172
116 User::SetDebugMask(0x00000001, 6); // set bit 192
117 User::SetDebugMask(0x00000040, 7); // set bit 230
119 // test the KTRACE_OPT macros in server code
120 r=traceSys.KTrace(RNKTraceTest::ETestKTrace);
122 // test the KDebugMask() and KDebugNum() functions in server code
123 r=traceSys.KDebug(RNKTraceTest::ETestKTrace);
125 test.Printf(_L("Kern::Printf() output goes\n"));
126 test.Printf(_L("to the serial port or the \n"));
127 test.Printf(_L("file epocwind.out when \n"));
128 test.Printf(_L("tested on the emulator. \n"));
129 test.Printf(_L("The following results\n"));
130 test.Printf(_L("should be displayed:\n"));
132 test.Printf(_L("Test __KTRACE_OPT macros\n"));
133 test.Printf(_L("KALWAYS\n"));
134 test.Printf(_L("KPANIC\n"));
135 test.Printf(_L("KSCRATCH\n"));
136 test.Printf(_L("Debug bit 35 is set\n"));
137 test.Printf(_L("Debug bit 68 is set\n"));
138 test.Printf(_L("Debug bit 101 is set\n"));
139 test.Printf(_L("Debug bit 136 is set\n"));
140 test.Printf(_L("Debug bit 172 is set\n"));
141 test.Printf(_L("Debug bit 192 is set\n"));
142 test.Printf(_L("Debug bit 230 is set\n"));
143 test.Printf(_L("KTRACE_ALL returned true\n"));
145 // Wait for a while, or for a key press
146 test.Printf(_L("Press a key to continue..."));
147 TRequestStatus keyStat;
148 test.Console()->Read(keyStat);
150 test(timer.CreateLocal()==KErrNone);
151 TRequestStatus timerStat;
152 timer.After(timerStat,10*1000000);
153 User::WaitForRequest(timerStat,keyStat);
155 if(keyStat!=KRequestPending)
156 key = test.Console()->KeyCode();
158 test.Console()->ReadCancel();
159 User::WaitForAnyRequest();
161 test.Printf(_L("\n"));
162 test.Printf(_L("KDebug tests (0)\n"));
163 test.Printf(_L("KDebugMask() = 0xc0000000\n"));
164 test.Printf(_L("KDebugNum(30) = 1\n"));
165 test.Printf(_L("KDebugNum(31) = 1\n"));
166 test.Printf(_L("KDebugNum(3) = 0\n"));
167 test.Printf(_L("KDebugNum(9) = 0\n"));
168 test.Printf(_L("KDebugNum(10000) = 0\n"));
169 test.Printf(_L("KDebugNum(-1) = 1\n"));
170 test.Printf(_L("KDebugNum(-2) = 0\n"));
171 test.Printf(_L("KDebugNum(35) = 1\n"));
172 test.Printf(_L("KDebugNum(36) = 0\n"));
173 test.Printf(_L("KDebugNum(101) = 1\n"));
174 test.Printf(_L("KDebugNum(192) = 1\n"));
175 test.Printf(_L("KDebugNum(230) = 1\n"));
177 // set the debug masks back to the original state
179 User::SetDebugMask(initial[i], i);
181 m = UserSvr::DebugMask(0);
183 m = UserSvr::DebugMask(1);
185 m = UserSvr::DebugMask(2);
187 m = UserSvr::DebugMask(3);
189 m = UserSvr::DebugMask(4);
191 m = UserSvr::DebugMask(5);
193 m = UserSvr::DebugMask(6);
195 m = UserSvr::DebugMask(7);