|
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 "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "TestSystemBase.h" |
|
17 |
|
18 // Global Vars |
|
19 _LIT(KTestExecuteLog,"c:\\Logs\\TestExecute\\smoketest_system_temp.htm"); |
|
20 _LIT(KPanicText,"The following Panic has occured: Thread Name = %S Exit Reason = %d Exit Category = %S"); |
|
21 |
|
22 CSystemTestBase* CSystemTestBase::NewL() |
|
23 { |
|
24 CSystemTestBase* self=new(ELeave) CSystemTestBase; |
|
25 CleanupStack::PushL(self); |
|
26 self->ConstructL(); |
|
27 CleanupStack::Pop(); // self |
|
28 return(self); |
|
29 } |
|
30 |
|
31 void CSystemTestBase::ConstructL() |
|
32 { |
|
33 iUndertaker=CEikUndertaker::NewL(*this); |
|
34 User::LeaveIfError(iLogger.Connect()); |
|
35 User::LeaveIfError(iLogger.CreateLog(KTestExecuteLog,RTestExecuteLogServ::ELogModeAppend)); |
|
36 } |
|
37 |
|
38 CSystemTestBase::CSystemTestBase() |
|
39 { |
|
40 // do nothing |
|
41 } |
|
42 |
|
43 CSystemTestBase::~CSystemTestBase() |
|
44 { |
|
45 delete iUndertaker; |
|
46 iLogger.Close(); |
|
47 } |
|
48 |
|
49 void CSystemTestBase::HandleThreadExitL(RThread& aThread) |
|
50 { |
|
51 TExitType exitType=aThread.ExitType(); |
|
52 if (exitType==EExitPanic) |
|
53 { |
|
54 CActiveScheduler::Stop(); |
|
55 iExitReason = aThread.ExitReason(); |
|
56 iExitCategory = aThread.ExitCategory(); |
|
57 TBuf<100> iName(aThread.FullName()); |
|
58 iLogger.WriteFormat(KPanicText, &iName, iExitReason, &iExitCategory); |
|
59 User::Panic(iExitCategory,iExitReason); |
|
60 } |
|
61 } |
|
62 |
|
63 //LOCAL_C TInt PanicThread(TAny*) |
|
64 // { |
|
65 // _LIT(PanicReason, "Just, why not"); |
|
66 // TInt iPanicInt = 666; |
|
67 // User::Panic(PanicReason, iPanicInt); |
|
68 // return iPanicInt; |
|
69 // } |
|
70 |
|
71 LOCAL_C void MainL() |
|
72 { |
|
73 // Construct and install the active scheduler |
|
74 CActiveScheduler* myScheduler = new(ELeave) CActiveScheduler; |
|
75 CleanupStack::PushL(myScheduler); |
|
76 CActiveScheduler::Install(myScheduler); |
|
77 |
|
78 CSystemTestBase* iTempBase = CSystemTestBase::NewL(); |
|
79 |
|
80 // The following is just test code that spawns a thread and makes it panic |
|
81 //RThread iPanicThread; |
|
82 //_LIT(PanicThreadTest, "Undertaker Panic Thread Test"); |
|
83 |
|
84 //User::LeaveIfError(iPanicThread.Create(PanicThreadTest(), &PanicThread, KDefaultStackSize, 0x100, 0x100, NULL)); |
|
85 //iPanicThread.SetPriority(EPriorityAbsoluteHigh); |
|
86 //iPanicThread.Resume(); |
|
87 |
|
88 CActiveScheduler::Start(); |
|
89 |
|
90 for (;;) |
|
91 { |
|
92 User::After(100000); |
|
93 } |
|
94 } |
|
95 |
|
96 GLDEF_C TInt E32Main() |
|
97 /** |
|
98 * Executable Entry Point |
|
99 * Top level always creates TRAP harness. |
|
100 * Calls MainL() inside the TRAP harness |
|
101 */ |
|
102 { |
|
103 __UHEAP_MARK; |
|
104 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
105 if(cleanup == NULL) |
|
106 { |
|
107 return KErrNoMemory; |
|
108 } |
|
109 TRAPD(err,MainL()); |
|
110 // should never reach this point if some thread has panicked already |
|
111 _LIT(KTestPanicReason,"Trap"); |
|
112 __ASSERT_ALWAYS(!err, User::Panic(KTestPanicReason,err)); |
|
113 delete cleanup; |
|
114 __UHEAP_MARKEND; |
|
115 return KErrNone; |
|
116 } |