|
1 // Copyright (c) 1997-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 "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 // TESTFIXES.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <e32test.h> |
|
20 #include <csch_cli.h> |
|
21 #include <f32file.h> |
|
22 #include "Thelpers.h" |
|
23 #include "TestUtils.h" |
|
24 |
|
25 // Globals |
|
26 static RTest TheTest(_L("TestFixes")); |
|
27 static RScheduler TheScheduler; |
|
28 static RFs TheFsSession; |
|
29 |
|
30 // Type definitions |
|
31 typedef CArrayFixFlat<TScheduleEntryInfo> CScheduleEntryInfoArray; |
|
32 typedef CArrayFixFlat<TTaskInfo> CTaskInfoArray; |
|
33 |
|
34 //*********************************************************************************** |
|
35 static TInt RegisterClient(RScheduler& aScheduler) |
|
36 // |
|
37 // Utility function to simplify registering a client with the task scheduler |
|
38 // |
|
39 { |
|
40 TFileName filename = _L("Z:\\System\\Bin\\MinimalTaskHandler.exe"); |
|
41 return aScheduler.Register(filename, 27); |
|
42 } |
|
43 |
|
44 //*********************************************************************************** |
|
45 |
|
46 /** |
|
47 @SYMTestCaseID SYSLIB-SCHSVR-CT-1023 |
|
48 @SYMTestCaseDesc Tests for defect EDNHLJT-4WDEJV |
|
49 A Kern Exec3 panic occurs 30 minutes after scheduling 300 tasks to complete at once. |
|
50 @SYMTestPriority High |
|
51 @SYMTestActions Create the schedule for the task.Create 300 tasks and enable the schedule and wait for 30 seconds.Check if any panic occurs |
|
52 @SYMTestExpectedResults Check if any panic occurs |
|
53 @SYMREQ REQ0000 |
|
54 */ |
|
55 static void Test1L() |
|
56 { |
|
57 // Test title |
|
58 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1023 \nTest for defect EDNHLJT-4WDEJV ")); |
|
59 // A Kern Exec3 panic occurs after 30ish minutes after scheduling 300 tasks to complete at once. |
|
60 |
|
61 // Constants / vars used in this function |
|
62 TSchedulerItemRef itemRef; |
|
63 |
|
64 TheTest.Next(_L("Connect to Scheduler")); |
|
65 TInt res = TheScheduler.Connect(); |
|
66 TheTest (res==KErrNone); |
|
67 |
|
68 TheTest.Next(_L("Registering Client")); |
|
69 TheTest (RegisterClient(TheScheduler) == KErrNone); |
|
70 |
|
71 // Create some scheduling entries |
|
72 CArrayFixFlat<TScheduleEntryInfo>* entries = new(ELeave) CArrayFixFlat<TScheduleEntryInfo>(10); |
|
73 CleanupStack::PushL(entries); |
|
74 |
|
75 TScheduleEntryInfo entry1; |
|
76 entry1.iIntervalType = EHourly; |
|
77 entry1.iStartTime = SchSvrHelpers::TimeBasedOnOffset(1); |
|
78 entry1.iInterval = 1; |
|
79 entry1.iValidityPeriod = 20; |
|
80 entries->AppendL(entry1); |
|
81 |
|
82 // Create the schedule for the task... |
|
83 res = TheScheduler.CreatePersistentSchedule(itemRef, *entries); |
|
84 TheTest(res == KErrNone); |
|
85 |
|
86 // Disable the schedule straight away |
|
87 res = TheScheduler.DisableSchedule(itemRef.iHandle); |
|
88 TheTest(res == KErrNone); |
|
89 |
|
90 if (res == KErrNone) |
|
91 { |
|
92 for(TInt i=0; i<300; i++) |
|
93 { |
|
94 // Create the tasks themselves.. |
|
95 TTaskInfo task; |
|
96 task.iRepeat = 1; // repeat once |
|
97 task.iName = _L("Test Task For Defect Verification"); |
|
98 task.iPriority = 100; |
|
99 // |
|
100 HBufC* taskData = HBufC::NewMaxLC(100); |
|
101 taskData->Des().Repeat(_L(" ")); |
|
102 // |
|
103 res = TheScheduler.ScheduleTask(task, *taskData, itemRef.iHandle); |
|
104 TheTest(res == KErrNone); |
|
105 |
|
106 CleanupStack::PopAndDestroy(taskData); |
|
107 } |
|
108 } |
|
109 |
|
110 res = TheScheduler.EnableSchedule(itemRef.iHandle); |
|
111 TheTest(res == KErrNone); |
|
112 |
|
113 CleanupStack::PopAndDestroy(entries); |
|
114 |
|
115 TheTest.Printf(_L("Waiting for 30 minutes\n")); |
|
116 // Wait for thirty minutes to see if a Kern Exec3 panic occurs |
|
117 User::After(1000000 * 60 * 30); // thirty mins |
|
118 |
|
119 } |
|
120 |
|
121 //*********************************************************************************** |
|
122 |
|
123 GLDEF_C TInt DoTheTestsL() |
|
124 // |
|
125 // Kickoff method |
|
126 // |
|
127 { |
|
128 // Add tests here:- |
|
129 Test1L(); |
|
130 |
|
131 return KErrNone; |
|
132 } |
|
133 |
|
134 //*********************************************************************************** |
|
135 GLDEF_C TInt E32Main() |
|
136 // |
|
137 // Entry point |
|
138 // |
|
139 { |
|
140 __UHEAP_MARK; |
|
141 TheTest.Title(); |
|
142 TheTest.Start(_L("TheTest Task Scheduler Fixes")); |
|
143 |
|
144 TInt error = KErrNone; |
|
145 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
146 if (!cleanup) |
|
147 return KErrNoMemory; |
|
148 |
|
149 TheFsSession.Connect(); |
|
150 TRAP(error, DoTheTestsL()); |
|
151 TEST(error == KErrNone); |
|
152 TheFsSession.Close(); |
|
153 TheTest(error == KErrNone); |
|
154 delete cleanup; |
|
155 |
|
156 TheTest.End(); |
|
157 TheTest.Close(); |
|
158 __UHEAP_MARKEND; |
|
159 return(KErrNone); |
|
160 } |