--- a/graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanual.cpp Fri Jun 11 14:58:47 2010 +0300
+++ b/graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanual.cpp Tue Jun 22 15:21:29 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
@@ -29,14 +29,17 @@
CTSgGenericManual::~CTSgGenericManual()
{
+ iSecondProcess.Close();
+ iMsgQ.Close();
}
/**
This is intented to be used for TestStressResourceLeakL (GRAPHICS-RESOURCE-0050) test.
It creates images until the memory full situation. The images are kept in the passed RArray of RSgImage.
The returned error code is expected to be either KErrNoMemory or KErrNoGraphicsMemory.
+Optionally, it opens and closes a duplicate handle to each image in the same process and in another process.
*/
-TInt CTSgGenericManual::CreateImages(const TSgImageInfo& aInfo, RArray<RSgImage>& aTestImages)
+TInt CTSgGenericManual::CreateImages(const TSgImageInfo& aInfo, RArray<RSgImage>& aTestImages, TBool aDuplicate)
{
TInt err = KErrNone;
while(err == KErrNone)
@@ -46,8 +49,30 @@
if(err == KErrNone)
{
err = aTestImages.Append(image);
+ if (err != KErrNone)
+ {
+ image.Close();
+ return err;
+ }
+ if (aDuplicate)
+ {
+ RSgImage image2;
+ err = image2.Open(image.Id());
+ if (err != KErrNone)
+ {
+ return err;
+ }
+ // send the image ID to the second process and wait until the
+ // second process has opened and closed a handle to the image
+ TRequestStatus status;
+ iSecondProcess.Rendezvous(status);
+ iMsgQ.SendBlocking(image.Id());
+ User::WaitForRequest(status);
+ image2.Close();
+ err = status.Int();
+ }
}
- }
+ }
return err;
}
@@ -80,11 +105,12 @@
@SYMTestCaseDesc RSgImage exhaustive and resource leak test
@SYMPREQ PREQ2637
@SYMFssID RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)
- RSgImage::Close()
+ RSgImage::Open(TSgDrawableId)
+ RSgImage::Close()
@SYMTestPriority Medium
@SYMTestType CT
@SYMTestPurpose To ensure no resource leaks while creating and destroying RSgImage multiple times
-@SYMTestActions Create images until it returns no memomy error. Close the created images and
+@SYMTestActions Create images until it returns no memory error. Close the created images and
create as many images as possible until memory is full. Test the number of images
created and also for each iteration the number of images created to be the same.
@SYMTestExpectedResults There should be no panics or leaves.
@@ -92,20 +118,51 @@
void CTSgGenericManual::TestStressResourceLeakL()
{
TestOpenDriverL();
-
- const TInt KNumIterations = 100000;
+ _LIT(KSection, "TestStressResourceLeak");
+ TInt numIterations;
+ if (!GetIntFromConfig(KSection, _L("NumIterations"), numIterations))
+ {
+ numIterations = 2;
+ }
+ TInt tolerance;
+ if (!GetIntFromConfig(KSection, _L("Tolerance"), tolerance))
+ {
+ tolerance = -1;
+ }
+ TInt width;
+ if (!GetIntFromConfig(KSection, _L("ImageWidth"), width))
+ {
+ width = 1;
+ }
+ TInt height;
+ if (!GetIntFromConfig(KSection, _L("ImageHeight"), height))
+ {
+ height = 1;
+ }
TSgImageInfo info;
info.iPixelFormat = EUidPixelFormatRGB_565;
- info.iSizeInPixels = TSize(1, 1);
+ info.iSizeInPixels = TSize(width, height);
info.iUsage = ESgUsageBitOpenVgImage;
-
+ TBool duplicate;
+ if (!GetBoolFromConfig(KSection, _L("DuplicateHandle"), duplicate))
+ {
+ duplicate = EFalse;
+ }
+ if (duplicate)
+ {
+ User::LeaveIfError(iMsgQ.CreateGlobal(KSgTestMultiprocessMsgQ, 1));
+ _LIT(KProcessName, "tgraphicsresourcemanualsecondprocess.exe");
+ User::LeaveIfError(iSecondProcess.Create(KProcessName, KNullDesC));
+ iSecondProcess.Resume();
+ }
+
RArray<RSgImage> testImages;
TInt count(0);
TInt err = KErrNone;
- for(TInt i=0; i<KNumIterations && (err == KErrNone); ++i)
+ for (TInt i = 0; i < numIterations && err == KErrNone; ++i)
{
- err = CreateImages(info, testImages);
+ err = CreateImages(info, testImages, duplicate);
TInt thisCount = testImages.Count();
DestroyImages(testImages);
@@ -115,18 +172,39 @@
}
else if (err != KErrNone)
{
- ERR_PRINTF2(_L("Create images error [%d]"), err);
- SetTestStepResult(EFail);
+ WARN_PRINTF2(_L("Create images error [%d]"), err);
+ SetTestStepResult(ETestSuiteError);
}
- if(i > 0 && count != thisCount)
+ if (i == 0)
+ {
+ count = thisCount;
+ }
+ else
{
- ERR_PRINTF4(_L("Mismatch @ iteration %d : Was %d, now %d"), i, count, thisCount);
- }
- count = thisCount;
+ if (count != thisCount)
+ {
+ INFO_PRINTF4(_L("Mismatch @ iteration %d: initial %d, now %d"), i, count, thisCount);
+ }
+ if (tolerance >= 0)
+ {
+ TEST(Abs(count - thisCount) <= tolerance);
+ }
+ }
}
- INFO_PRINTF2(_L("%d images created \r\n"), count);
+ INFO_PRINTF2(_L("Last iteration: %d images created\r\n"), count);
+ if (duplicate)
+ {
+ // send a null ID to tell the second process to kill itself
+ // and wait until the second process terminates
+ TRequestStatus status;
+ iSecondProcess.Logon(status);
+ iMsgQ.SendBlocking(KSgNullDrawableId);
+ User::WaitForRequest(status);
+ iMsgQ.Close();
+ iSecondProcess.Close();
+ }
TestCloseDriver();
}