1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
17 #include <e32test.h> |
17 #include <e32test.h> |
18 #include <e32math.h> |
18 #include <e32math.h> |
19 #include "LogCliServShared.h" |
19 #include "LogCliServShared.h" |
20 #include "logservpanic.h" |
20 #include "logservpanic.h" |
21 #include "logpackage.h" |
21 #include "logpackage.h" |
22 |
22 #include "t_logutil.h" |
23 LOCAL_D RTest TheTest(_L("T_LogServIPC")); |
23 |
|
24 RTest TheTest(_L("t_logservipc")); |
24 |
25 |
25 _LIT(KServerName, "!LogServ"); |
26 _LIT(KServerName, "!LogServ"); |
26 _LIT(KServerProcess, "LogServ"); |
27 _LIT(KServerProcess, "LogServ"); |
27 |
28 |
28 //=========================================================================================== |
|
29 |
|
30 static TPtrC FileName(const TText* aFile) |
|
31 { |
|
32 TPtrC p(aFile); |
|
33 TInt ix=p.LocateReverse('\\'); |
|
34 if (ix<0) |
|
35 ix=p.LocateReverse('/'); |
|
36 if (ix>=0) |
|
37 p.Set(p.Mid(1+ix)); |
|
38 return p; |
|
39 } |
|
40 |
|
41 void LogLeave(TInt aErr, const TText* aFile, TInt aLine) |
|
42 { |
|
43 TPtrC fname(FileName(aFile)); |
|
44 RDebug::Print(_L("*** LogEng test leave, err=%d, file: %S-%d\r\n"), aErr, &fname, aLine); |
|
45 User::Leave(aErr); |
|
46 } |
|
47 |
|
48 #undef TEST_STRING |
|
49 #define TEST_STRING(s) _S(s) |
|
50 |
|
51 #undef LEAVE |
|
52 #undef LEAVE_IF_ERROR |
|
53 #define LEAVE(err) LogLeave(err, TEST_STRING(__FILE__), __LINE__) |
|
54 #define LEAVE_IF_ERROR(err) (err < KErrNone ? LogLeave(err, TEST_STRING(__FILE__), __LINE__) : void(0)) |
|
55 |
|
56 //=========================================================================================== |
|
57 |
|
58 /////////////////////////////////////////////////////////////////////////////////////// |
|
59 /////////////////////////////////////////////////////////////////////////////////////// |
|
60 //Test macross and functions |
|
61 |
|
62 static void Check(TInt aValue, TInt aLine) |
|
63 { |
|
64 if(!aValue) |
|
65 { |
|
66 TheTest(EFalse, aLine); |
|
67 } |
|
68 } |
|
69 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
70 { |
|
71 if(aValue != aExpected) |
|
72 { |
|
73 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
74 TheTest(EFalse, aLine); |
|
75 } |
|
76 } |
|
77 #define TEST(arg) ::Check((arg), __LINE__) |
|
78 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
79 |
|
80 /////////////////////////////////////////////////////////////////////////////////////// |
29 /////////////////////////////////////////////////////////////////////////////////////// |
81 // |
30 // |
82 |
31 |
83 struct TTestInfo |
32 struct TTestInfo |
84 { |
33 { |
278 case 2: |
227 case 2: |
279 FuzzL(aFunc,aArgCount); |
228 FuzzL(aFunc,aArgCount); |
280 break; |
229 break; |
281 } |
230 } |
282 } |
231 } |
283 |
|
284 TInt KillProcess(const TDesC& aProcessName) |
|
285 { |
|
286 TFullName name; |
|
287 |
|
288 RDebug::Print(_L("Find and kill \"%S\" process.\n"), &aProcessName); |
|
289 |
|
290 TBuf<64> pattern(aProcessName); |
|
291 TInt length = pattern.Length(); |
|
292 pattern += _L("*"); |
|
293 TFindProcess procFinder(pattern); |
|
294 |
|
295 while (procFinder.Next(name) == KErrNone) |
|
296 { |
|
297 if (name.Length() > length) |
|
298 {//If found name is a string containing aProcessName string. |
|
299 TChar c(name[length]); |
|
300 if (c.IsAlphaDigit() || |
|
301 c == TChar('_') || |
|
302 c == TChar('-')) |
|
303 { |
|
304 // If the found name is other valid application name |
|
305 // starting with aProcessName string. |
|
306 RDebug::Print(_L(":: Process name: \"%S\".\n"), &name); |
|
307 continue; |
|
308 } |
|
309 } |
|
310 RProcess proc; |
|
311 if (proc.Open(name) == KErrNone) |
|
312 { |
|
313 proc.Kill(0); |
|
314 RDebug::Print(_L("\"%S\" process killed.\n"), &name); |
|
315 } |
|
316 proc.Close(); |
|
317 } |
|
318 return KErrNone; |
|
319 } |
|
320 |
|
321 |
232 |
322 TInt FuzzServerL(TAny* aTestInfo) |
233 TInt FuzzServerL(TAny* aTestInfo) |
323 { |
234 { |
324 CTrapCleanup* cleanup=CTrapCleanup::New(); |
235 CTrapCleanup* cleanup=CTrapCleanup::New(); |
325 TInt err=KErrNoMemory; |
236 TInt err=KErrNoMemory; |