diff -r 000000000000 -r a41df078684a kerneltest/e32test/system/t_regram.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/system/t_regram.cpp Mon Oct 19 15:55:17 2009 +0100 @@ -0,0 +1,346 @@ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\system\t_regram.cpp +// +// + +#include +#include + +// +// This test takes forever to run and destroys the internal Ram drive. +// + +LOCAL_D RTest test(_L("T_REGRAM")); + +void deleteReg() +// +// Delete everything from the registry +// + { + TUid uid; + TRegistryIter riter; + riter.Reset(); + while (riter.Next(uid)==KErrNone) + { + TRegistryCategory cat(uid); + cat.DeleteAllItems(); + } + } + +TInt fillReg(const TDesC8 &aDes, TInt aEntries) +// +// Fill the registry with big nasty monsters +// returns the number of entries made. +// + { + TBuf8<0x100> buf=_L8(""); + TInt i; + for (i=0; i<8; i++) + buf.Append(_L8("Big_ nasty_ monster_ chasing_ me")); + + TUid uid; + uid=TUid::Uid(0x12345678); + TRegistryCategory cat(uid); + i=0; + TBuf8<0x20> item; + while (i item; + TInt i=aEntries-1; + while (i>=0) + { + item.Format(_L8("%S %08x"),&aDes,i); + TInt r=cat.DeleteItem(item); + if (r!=KErrNone) + break; + i--; + } + return aEntries-i-1; + } + +TInt testReg(const TDesC8 &aDes, TInt aEntries) +// +// Test the first aEntries entries are set correctly +// + { + TBuf8<0x100> buf=_L8(""); + TInt i; + for (i=0; i<8; i++) + buf.Append(_L8("Big_ nasty_ monster_ chasing_ me")); + + TUid uid; + uid=TUid::Uid(0x12345678); + TRegistryCategory cat(uid); + + TBuf8<0x20> item; + TBuf8<0x100> res; + i=0; + while (i infoPckg(info); + test(aRamDrive.Caps(infoPckg)==KErrNone); + TInt size=info.iSize.Low(); + TInt i; + TPckgBuf dataBuf; + TInt &data=dataBuf(); + for (i=0; i infoPckg(info); + test(aRamDrive.Caps(infoPckg)==KErrNone); + TInt size=info.iSize.Low(); + TInt i; + TPckgBuf dataBuf; + TInt &data=dataBuf(); + for (i=0; i infoPckg(info); + test(aRamDrive.Caps(infoPckg)==KErrNone); + TInt oldsize=info.iSize.Low(); + if (aSize>oldsize) + test(aRamDrive.Enlarge(aSize-oldsize)==KErrNone); + else + test(aRamDrive.ReduceSize(0,oldsize-aSize)==KErrNone); + } + +GLDEF_C TInt E32Main(void) +// +// Test the Ram Drive and the Registry +// + { + + test.Title(); + + test.Start(_L("Connect to the Local Drive")); + TBool changedFlag; + TBusLocalDrive ramDrive; + TInt r=ramDrive.Connect(0,changedFlag); + test(r==KErrNone); + + test.Next(_L("Test testing the ram drive")); + fillRamDrive(ramDrive); + testRamDrive(ramDrive); + + test.Next(_L("Simple grow test")); + fillRamDrive(ramDrive); + testGrow(); + testRamDrive(ramDrive); + test.Next(_L("Shrink")); + deleteReg(); + testRamDrive(ramDrive); + + { + deleteReg(); + test.Next(_L("Grow the registry a bit")); + TInt n=fillReg(_L8("Run Away"),40); + test.Next(_L("Test the content of the registry")); + TInt m=testReg(_L8("Run Away"),n); + test(n==m); + test.Next(_L("Shrink it a bit")); + m=shrinkReg(_L8("Run Away"),n); + test(n==m); + test.Next(_L("test ram drive")); + testRamDrive(ramDrive); + } + +/* test.Next(_L("Run the tests with the current ram drive size")); + fillRamDrive(ramDrive); + test1(); + testRamDrive(ramDrive);*/ + + test.Next(_L("Run the tests with no Ram Drive")); + setRamDriveSize(ramDrive, 0); + test1(); + + test.Next(_L("Run the tests with small ram drive")); + setRamDriveSize(ramDrive, 0x3000); + fillRamDrive(ramDrive); + test1(); + testRamDrive(ramDrive); + + test.Next(_L("Clear the registry")); + deleteReg(); + +/* test.Next(_L("Run the tests with a big ram drive")); + r=KErrGeneral; + while (r==KErrNone) + r=ramDrive.Enlarge(0x1000); + test.Printf(_L("%d"), r); +// test(r==KErrDiskFull); + r=ramDrive.ReduceSize(0, 0x2000); + test(r==KErrNone); + fillRamDrive(ramDrive); + test1(); + testRamDrive(ramDrive);*/ + + ramDrive.Disconnect(); + + test.End(); + return(KErrNone); + } +