os/ossrv/genericservices/taskscheduler/Test/LongRunning/LongRunning.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericservices/taskscheduler/Test/LongRunning/LongRunning.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,160 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// TESTFIXES.CPP
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <e32base.h>
    1.22 +#include <e32test.h>
    1.23 +#include <csch_cli.h>
    1.24 +#include <f32file.h>
    1.25 +#include "Thelpers.h"
    1.26 +#include "TestUtils.h"
    1.27 +
    1.28 +// Globals
    1.29 +static RTest			TheTest(_L("TestFixes"));
    1.30 +static RScheduler		TheScheduler;
    1.31 +static RFs				TheFsSession;
    1.32 +
    1.33 +// Type definitions
    1.34 +typedef CArrayFixFlat<TScheduleEntryInfo>	CScheduleEntryInfoArray;
    1.35 +typedef CArrayFixFlat<TTaskInfo>			CTaskInfoArray;
    1.36 +
    1.37 +//***********************************************************************************
    1.38 +static TInt RegisterClient(RScheduler& aScheduler)
    1.39 +//
    1.40 +//	Utility function to simplify registering a client with the task scheduler
    1.41 +//
    1.42 +	{
    1.43 +	TFileName filename = _L("Z:\\System\\Bin\\MinimalTaskHandler.exe");
    1.44 +	return aScheduler.Register(filename, 27);
    1.45 +	}
    1.46 +
    1.47 +//***********************************************************************************
    1.48 +
    1.49 +/**
    1.50 +@SYMTestCaseID          SYSLIB-SCHSVR-CT-1023
    1.51 +@SYMTestCaseDesc	    Tests for defect EDNHLJT-4WDEJV
    1.52 +						A Kern Exec3 panic occurs 30 minutes after scheduling 300 tasks to complete at once.
    1.53 +@SYMTestPriority 	    High
    1.54 +@SYMTestActions  	    Create the schedule for the task.Create 300 tasks and enable the schedule and wait for 30 seconds.Check if any panic occurs
    1.55 +@SYMTestExpectedResults Check if any panic occurs
    1.56 +@SYMREQ                 REQ0000
    1.57 +*/
    1.58 +static void Test1L()
    1.59 +	{	
    1.60 +	// Test title
    1.61 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SCHSVR-CT-1023 \nTest for defect EDNHLJT-4WDEJV "));
    1.62 +	// A Kern Exec3 panic occurs after 30ish minutes after scheduling 300 tasks to complete at once.
    1.63 +	
    1.64 +	// Constants / vars used in this function
    1.65 +	TSchedulerItemRef itemRef;
    1.66 +
    1.67 +	TheTest.Next(_L("Connect to Scheduler"));
    1.68 +	TInt res = TheScheduler.Connect();
    1.69 +	TheTest (res==KErrNone);
    1.70 +
    1.71 +	TheTest.Next(_L("Registering Client"));
    1.72 +	TheTest (RegisterClient(TheScheduler) == KErrNone);
    1.73 +	
    1.74 +	// Create some scheduling entries
    1.75 +	CArrayFixFlat<TScheduleEntryInfo>* entries = new(ELeave) CArrayFixFlat<TScheduleEntryInfo>(10);
    1.76 +	CleanupStack::PushL(entries);
    1.77 +
    1.78 +	TScheduleEntryInfo entry1;
    1.79 +	entry1.iIntervalType	= EHourly;
    1.80 +	entry1.iStartTime		= SchSvrHelpers::TimeBasedOnOffset(1);
    1.81 +	entry1.iInterval		= 1;
    1.82 +	entry1.iValidityPeriod	= 20;
    1.83 +	entries->AppendL(entry1);
    1.84 +
    1.85 +	// Create the schedule for the task...
    1.86 +	res = TheScheduler.CreatePersistentSchedule(itemRef, *entries);
    1.87 +	TheTest(res == KErrNone);
    1.88 +
    1.89 +	// Disable the schedule straight away
    1.90 +	res = TheScheduler.DisableSchedule(itemRef.iHandle);
    1.91 +	TheTest(res == KErrNone);
    1.92 +	
    1.93 +	if	(res == KErrNone)
    1.94 +		{
    1.95 +		for(TInt i=0; i<300; i++)
    1.96 +			{
    1.97 +			// Create the tasks themselves..
    1.98 +			TTaskInfo task;
    1.99 +			task.iRepeat	= 1; // repeat once
   1.100 +			task.iName		= _L("Test Task For Defect Verification");
   1.101 +			task.iPriority	= 100;
   1.102 +			//
   1.103 +			HBufC* taskData = HBufC::NewMaxLC(100);
   1.104 +			taskData->Des().Repeat(_L(" "));
   1.105 +			//
   1.106 +			res = TheScheduler.ScheduleTask(task, *taskData, itemRef.iHandle);
   1.107 +			TheTest(res == KErrNone);
   1.108 +
   1.109 +			CleanupStack::PopAndDestroy(taskData);
   1.110 +			}
   1.111 +		}
   1.112 +
   1.113 +	res = TheScheduler.EnableSchedule(itemRef.iHandle);
   1.114 +	TheTest(res == KErrNone);
   1.115 +
   1.116 +	CleanupStack::PopAndDestroy(entries);
   1.117 +
   1.118 +	TheTest.Printf(_L("Waiting for 30 minutes\n"));
   1.119 +	// Wait for thirty minutes to see if a Kern Exec3 panic  occurs 
   1.120 +	User::After(1000000 * 60 * 30); // thirty mins
   1.121 +
   1.122 +	}
   1.123 +
   1.124 +//***********************************************************************************
   1.125 +
   1.126 +GLDEF_C TInt DoTheTestsL()
   1.127 +//
   1.128 +//	Kickoff method
   1.129 +//
   1.130 +	{
   1.131 +	// Add tests here:-
   1.132 +	Test1L();
   1.133 +
   1.134 +	return KErrNone;
   1.135 +	}
   1.136 +
   1.137 +//***********************************************************************************
   1.138 +GLDEF_C TInt E32Main()
   1.139 +//	
   1.140 +// Entry point
   1.141 +//
   1.142 +    {
   1.143 +	__UHEAP_MARK;
   1.144 +	TheTest.Title();
   1.145 +	TheTest.Start(_L("TheTest Task Scheduler Fixes"));
   1.146 +
   1.147 +	TInt error = KErrNone;
   1.148 +	CTrapCleanup* cleanup = CTrapCleanup::New();
   1.149 +	if	(!cleanup)
   1.150 +		return KErrNoMemory;
   1.151 +
   1.152 +	TheFsSession.Connect();
   1.153 +	TRAP(error, DoTheTestsL());
   1.154 +	TEST(error == KErrNone);
   1.155 +	TheFsSession.Close();
   1.156 +	TheTest(error == KErrNone);
   1.157 +	delete cleanup;	
   1.158 +
   1.159 +	TheTest.End();
   1.160 +	TheTest.Close();
   1.161 +	__UHEAP_MARKEND;
   1.162 +	return(KErrNone);
   1.163 +	}