Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
23 #include "TestUtils.h"
26 static RTest TheTest(_L("TestFixes"));
27 static RScheduler TheScheduler;
28 static RFs TheFsSession;
31 typedef CArrayFixFlat<TScheduleEntryInfo> CScheduleEntryInfoArray;
32 typedef CArrayFixFlat<TTaskInfo> CTaskInfoArray;
34 //***********************************************************************************
35 static TInt RegisterClient(RScheduler& aScheduler)
37 // Utility function to simplify registering a client with the task scheduler
40 TFileName filename = _L("Z:\\System\\Bin\\MinimalTaskHandler.exe");
41 return aScheduler.Register(filename, 27);
44 //***********************************************************************************
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.
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
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.
61 // Constants / vars used in this function
62 TSchedulerItemRef itemRef;
64 TheTest.Next(_L("Connect to Scheduler"));
65 TInt res = TheScheduler.Connect();
66 TheTest (res==KErrNone);
68 TheTest.Next(_L("Registering Client"));
69 TheTest (RegisterClient(TheScheduler) == KErrNone);
71 // Create some scheduling entries
72 CArrayFixFlat<TScheduleEntryInfo>* entries = new(ELeave) CArrayFixFlat<TScheduleEntryInfo>(10);
73 CleanupStack::PushL(entries);
75 TScheduleEntryInfo entry1;
76 entry1.iIntervalType = EHourly;
77 entry1.iStartTime = SchSvrHelpers::TimeBasedOnOffset(1);
79 entry1.iValidityPeriod = 20;
80 entries->AppendL(entry1);
82 // Create the schedule for the task...
83 res = TheScheduler.CreatePersistentSchedule(itemRef, *entries);
84 TheTest(res == KErrNone);
86 // Disable the schedule straight away
87 res = TheScheduler.DisableSchedule(itemRef.iHandle);
88 TheTest(res == KErrNone);
92 for(TInt i=0; i<300; i++)
94 // Create the tasks themselves..
96 task.iRepeat = 1; // repeat once
97 task.iName = _L("Test Task For Defect Verification");
100 HBufC* taskData = HBufC::NewMaxLC(100);
101 taskData->Des().Repeat(_L(" "));
103 res = TheScheduler.ScheduleTask(task, *taskData, itemRef.iHandle);
104 TheTest(res == KErrNone);
106 CleanupStack::PopAndDestroy(taskData);
110 res = TheScheduler.EnableSchedule(itemRef.iHandle);
111 TheTest(res == KErrNone);
113 CleanupStack::PopAndDestroy(entries);
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
121 //***********************************************************************************
123 GLDEF_C TInt DoTheTestsL()
134 //***********************************************************************************
135 GLDEF_C TInt E32Main()
142 TheTest.Start(_L("TheTest Task Scheduler Fixes"));
144 TInt error = KErrNone;
145 CTrapCleanup* cleanup = CTrapCleanup::New();
149 TheFsSession.Connect();
150 TRAP(error, DoTheTestsL());
151 TEST(error == KErrNone);
152 TheFsSession.Close();
153 TheTest(error == KErrNone);