|
1 // Copyright (c) 2005-2010 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 // t_tracecore_wdp.cpp |
|
15 // Overview: |
|
16 // Tests WDP TraceCore |
|
17 // kernel - side APIs |
|
18 // |
|
19 |
|
20 #define __E32TEST_EXTENSION__ |
|
21 #include <e32std.h> |
|
22 #include <dptest.h> |
|
23 #include "t_tracecore_wdp.h" |
|
24 #include "t_rtest_panic.h" |
|
25 |
|
26 |
|
27 RTest test(_L("T_TRACECORE_WDP")); |
|
28 |
|
29 TInt CreateProcess (const TDesC &aProcessName, const TDesC &aCommand, RProcess &aProcess) |
|
30 { |
|
31 TInt err = aProcess.Create(aProcessName,aCommand); |
|
32 |
|
33 if (err != KErrNone) |
|
34 test.Printf(_L("Unable to create process handle. Error: %d"),err); |
|
35 |
|
36 return err; |
|
37 } |
|
38 |
|
39 void StartProcess (RProcess &aProcess, TRequestStatus &aStatus) |
|
40 { |
|
41 aProcess.Logon(aStatus); |
|
42 aProcess.Resume(); |
|
43 } |
|
44 |
|
45 TInt CreateAndStartProcess (const TDesC &aProcessName, const TDesC &aCommand, RProcess &aProcess, TRequestStatus &aStatus) |
|
46 { |
|
47 TInt err = CreateProcess(aProcessName,aCommand,aProcess); |
|
48 if (err != KErrNone) |
|
49 return err; |
|
50 |
|
51 StartProcess(aProcess,aStatus); |
|
52 return KErrNone; |
|
53 } |
|
54 |
|
55 TInt ContinueFlushingPageCache(TRequestStatus &aTestStatus) |
|
56 { |
|
57 while (aTestStatus==KRequestPending) |
|
58 { |
|
59 //Flush the cache |
|
60 DPTest::FlushCache(); |
|
61 //wait for 100 microseconds |
|
62 User::After(100); |
|
63 } |
|
64 return KErrNone; |
|
65 } |
|
66 |
|
67 TInt CheckExecutableReturn(const TDesC &aProcessName, RProcess &aTestProcess) |
|
68 { |
|
69 TInt exitreason = aTestProcess.ExitReason(); |
|
70 TPtrC exitcategory(KExitCategoryUser); |
|
71 |
|
72 //if the test didn't complete with error, just return KErrNone |
|
73 if (exitreason == KErrNone) |
|
74 return exitreason; |
|
75 |
|
76 //most of this next bit will not be needed tests pass |
|
77 |
|
78 //if it completed with error ensure it wasn't t_tracecore.exe because |
|
79 //that test should pass. If it was t_tracecore.exe return the exit reason |
|
80 //and fail the test. |
|
81 if (((aProcessName.Compare(KTTraceCore))==0)||((aProcessName.Compare(KTRTraceBuffer))==0)||((aProcessName.Compare(KTOstBuffer))==0) |
|
82 ||((aProcessName.Compare(KTOstBufferStress))==0)||((aProcessName.Compare(KTMultipart))==0)||((aProcessName.Compare(KTTraceCoreOstLdd))==0)) |
|
83 { |
|
84 test.Printf(_L("Test completed with error where it shouldn't: Category: %S, Code: %d"),&exitcategory,exitreason); |
|
85 return exitreason; |
|
86 } |
|
87 |
|
88 //if it was any of the other executables i.e t_tracecoreostldd.exe |
|
89 //or TraceCoreTestApp.exe that completed with error check it's USER 84 |
|
90 //because that is what is expected at the moment. If that wasn't the panic |
|
91 //return the exit reason and fail the test. Else return KErrNone. |
|
92 if ((exitreason==84)&&((exitcategory.Compare(KExitCategoryUser))==0)) |
|
93 return KErrNone; |
|
94 else |
|
95 { |
|
96 test.Printf(_L("Test completed with unknown error: Category: %S, Code: %d"),&exitcategory,exitreason); |
|
97 } |
|
98 return exitreason; |
|
99 } |
|
100 |
|
101 TInt RunTestExecutable(const TDesC &aProcessName) |
|
102 { |
|
103 TInt err = KErrNone; |
|
104 RProcess testprocess; |
|
105 TRequestStatus teststatus; |
|
106 |
|
107 //Create and start the test process |
|
108 err = CreateAndStartProcess(aProcessName,KNullCmd,testprocess,teststatus); |
|
109 if (err!=KErrNone) |
|
110 { |
|
111 testprocess.Close(); |
|
112 return err; |
|
113 } |
|
114 |
|
115 //Flush Cache every 100us until test finishes running |
|
116 err = ContinueFlushingPageCache(teststatus); |
|
117 if (err!=KErrNone) |
|
118 { |
|
119 testprocess.Close(); |
|
120 return err; |
|
121 } |
|
122 |
|
123 //Check return from test executable |
|
124 err = CheckExecutableReturn(aProcessName,testprocess); |
|
125 if (err!=KErrNone) |
|
126 { |
|
127 TExitCategoryName exitCategory = testprocess.ExitCategory(); |
|
128 testprocess.Close(); |
|
129 if ((err==84)&&((exitCategory.Compare(KExitCategoryUser))==0)) |
|
130 { |
|
131 // If process exited with RTest panic, then use process name as panic category |
|
132 User::Panic(aProcessName, err); |
|
133 } |
|
134 else |
|
135 { |
|
136 // If process exited with any other panic, use that as the panic category |
|
137 User::Panic(exitCategory, err); |
|
138 } |
|
139 } |
|
140 |
|
141 return err; |
|
142 } |
|
143 |
|
144 GLDEF_C TInt E32Main() |
|
145 { |
|
146 |
|
147 test.Title(); |
|
148 test.Start(_L("Trace Core WDP tests")); |
|
149 TInt err = KErrNone; |
|
150 |
|
151 test.Next(_L("Run t_tracecore.exe while repeatedly flushing the page cache")); |
|
152 err = RunTestExecutable(KTTraceCore); |
|
153 TEST_KErrNone(err); |
|
154 |
|
155 test.Next(_L("Run t_ostbuffer_stress.exe while repeatedly flushing the page cache")); |
|
156 err = RunTestExecutable(KTOstBufferStress); |
|
157 TEST_KErrNone(err); |
|
158 |
|
159 test.Next(_L("Run t_multipart.exe while repeatedly flushing the page cache")); |
|
160 err = RunTestExecutable(KTMultipart); |
|
161 TEST_KErrNone(err); |
|
162 |
|
163 test.Next(_L("Run t_rtracebuffer.exe while repeatedly flushing the page cache")); |
|
164 err = RunTestExecutable(KTRTraceBuffer); |
|
165 TEST_KErrNone(err); |
|
166 |
|
167 test.Next(_L("Run t_ostbuffer.exe while repeatedly flushing the page cache")); |
|
168 err = RunTestExecutable(KTOstBuffer); |
|
169 TEST_KErrNone(err); |
|
170 |
|
171 // test.Next(_L("Run t_tracecoreostldd.exe while repeatedly flushing the page cache")); |
|
172 // err = RunTestExecutable(KTTraceCoreOstLdd); |
|
173 // TEST_KErrNone(err); |
|
174 // |
|
175 // test.Next(_L("Run TraceCoreTestApp.exe while repeatedly flushing the page cache")); |
|
176 // err = RunTestExecutable(KTraceCoreTestApp); |
|
177 // TEST_KErrNone(err); |
|
178 |
|
179 |
|
180 test.Printf(_L("\nFinished Trace Core WDP tests!!!")); |
|
181 |
|
182 test.End(); |
|
183 test.Close(); |
|
184 return (0); |
|
185 } |