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\debug\t_debugapi.cpp
15 // User-side harness for LDD-based debug agent that checks debug API
16 // interface provided by kernel extension kdebug.dll (ARMv5) or kdebugv6 (ARMv6).
17 // It uses debug port to print the list of processes, threads, etc.
18 // Usage: t_debugapi [process] [thread] [chunk] [ipaccess]
19 // Performs all steps if there are no input arguments.
20 // The test is automated (does not require any input argument or manual assistance, but needs
21 // non-standard image file that includes kdebug.dll (ARMv5 based target) or kdebugV6.dll
22 // (ARMv6 based target). It can be achieved by adding: #define STOP_MODE_DEBUGGING in .oby/iby file.
23 // Supported and tested on H2 (ARMv5) and integrator_1136 (ARMv6) platforms.
24 // It requires D_DEBUGAPI.DLL as well.
25 // Using debug interfaca only, it completes (prints) the list of:
29 // in the system. On multiple-memory-model based target (ARMv6 architecture),
30 // it also reads from address space of another process. This part is not checked
31 // on moving-memory-model target (ARMv5) (e.g. always passes).
32 // Note: The test may cause system fail on ARM1136(r0p2) with L210 cache due to Erratum 317041.
33 // In that case, uncomment two relevant lines in DDebugAPIChecker::ReadFromOtherProcessArmv6 (in
34 // d_debugapi.cia) and rebuild d_debugapi.ldd.
38 //! @file t_debugapi.h
39 //! @SYMTestCaseID KBASE/T_DEBUGAPI
44 //! @SYMTestExpectedResults Test program completes with no errors.
45 //! @SYMTestPriority Low
46 //! @SYMTestStatus Defined
50 #include "d_debugapi.h"
52 RTest test(_L("T_DebugAPI"));
54 _LIT(KProcessName,"t_DebugAPI.exe");
55 _LIT(KProcess,"Process");
57 _LIT(KThread,"Thread");
58 _LIT(KIPAccess,"IPAccess");
59 _LIT(KIPAccessStep2,"IPAccessStep2");
63 //The main program for the first instance of the process.
66 RDebugAPIChecker debugAPI;
68 TBool checkAll = EFalse;
70 if (command.Length() == 0)
73 r = User::LoadLogicalDevice(_L("D_DebugAPI.LDD"));
74 test(r == KErrNone || r == KErrAlreadyExists);
75 test (debugAPI.Open() == KErrNone);
77 if (checkAll || command.FindF(KProcess) >= 0)
79 test.Next(_L("Printing process info"));
80 test(debugAPI.Process() == KErrNone);
83 if (checkAll || command.FindF(KChunk) >= 0)
85 test.Next(_L("Printing chunk info"));
86 test(debugAPI.Chunk() == KErrNone);
89 if (checkAll || command.FindF(KThread) >= 0)
91 test.Next(_L("Printing thread info"));
92 test(debugAPI.Thread() == KErrNone);
95 if (checkAll || command.FindF(KIPAccess) >= 0)
97 test.Next(_L("KIPAccess"));
100 TRequestStatus status;
102 //The other process will try to read this variable.
103 TInt probeVariable = 0x55555555;
104 TUint id = process.Id();
106 command.Format(_L("%08x %08x %08x IPAccessStep2"), id, &probeVariable, probeVariable);
108 test(process.Create(KProcessName, command) == KErrNone);
109 process.Logon(status);
111 User::WaitForRequest(status);
112 test(process.ExitType() == EExitKill);
113 test(process.ExitReason() == KErrNone);
116 //Now try another value.
117 probeVariable = 0xaaaaaaaa;
118 command.Format(_L("%08x %08x %08x IPAccessStep2"), id, &probeVariable, probeVariable);
120 test(process.Create(KProcessName, command) == KErrNone);
121 process.Logon(status);
123 User::WaitForRequest(status);
124 test(process.ExitType() == EExitKill);
125 test(process.ExitReason() == KErrNone);
130 r = User::FreeLogicalDevice(KTestLddName);
131 test(r == KErrNone || r == KErrNotFound);
135 The main program for the second instance of the process.
136 We need two processes two check inter-process data access.
138 void SecondProcessMain()
140 RDebugAPIChecker debugAPI;
143 r = User::LoadLogicalDevice(_L("D_DebugAPI.LDD"));
144 test(r == KErrNone || r == KErrAlreadyExists);
145 test (debugAPI.Open() == KErrNone);
147 if (command.FindF(KIPAccessStep2) >= 0)
149 RDebugAPIChecker::IPAccessArgs args;
151 TPtrC ptr = command.Mid(0,8);
153 lex.Val(args.iProcessID, EHex);
155 ptr.Set(command.Mid(9,8));
157 lex.Val(args.iAddress, EHex);
159 ptr.Set(command.Mid(18,8));
161 lex.Val(args.iValue, EHex);
163 r = debugAPI.IPAccess(&args);
164 test(r == KErrNone || r==KErrNotSupported);
168 r = User::FreeLogicalDevice(KTestLddName);
176 User::CommandLine(command);
178 if (command.FindF(KIPAccessStep2) < 0) //The second process is recognized by the specific input parameter
180 //This is the first instance of the running process.
181 test.Start(_L("Testing Debug API"));
187 //This is the second instance of the running process.