1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/mmu/t_dchunk.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,75 @@
1.4 +// Copyright (c) 1995-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 the License "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 +// e32test\mmu\t_dchunk.cpp
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32test.h>
1.22 +#include <e32hal.h>
1.23 +#include <e32panic.h>
1.24 +#include <e32def.h>
1.25 +#include <e32def_private.h>
1.26 +
1.27 +LOCAL_D RTest test(_L("T_DCHUNK"));
1.28 +
1.29 +TInt E32Main()
1.30 +//
1.31 +// Test RChunk class
1.32 +//
1.33 + {
1.34 +
1.35 + test.Title();
1.36 + test.Start(_L("Test double-ended chunks"));
1.37 + __KHEAP_MARK;
1.38 + TMemoryInfoV1Buf meminfo1,meminfo2;
1.39 + TInt r=UserHal::MemoryInfo(meminfo1);
1.40 + test(r==KErrNone);
1.41 + test.Printf(_L("Free RAM %08X bytes\n"),meminfo1().iFreeRamInBytes);
1.42 +
1.43 + RChunk chunk1;
1.44 + r=chunk1.CreateDoubleEndedLocal(0x1000,0x3000,2*meminfo1().iFreeRamInBytes);
1.45 + test(r==KErrNone);
1.46 + TInt size = chunk1.Size();
1.47 + TInt bottom = chunk1.Bottom();
1.48 + TInt top = chunk1.Top();
1.49 + Mem::FillZ((TAny*)(chunk1.Base()+chunk1.Bottom()),chunk1.Size());
1.50 +
1.51 + r=UserHal::MemoryInfo(meminfo1);
1.52 + test (r==KErrNone);
1.53 + test.Printf(_L("Free RAM %08X bytes\n"),meminfo1().iFreeRamInBytes);
1.54 +
1.55 + r=chunk1.AdjustDoubleEnded(0,2*meminfo1().iFreeRamInBytes);
1.56 + test(r==KErrNoMemory);
1.57 + test(size==chunk1.Size());
1.58 + test(bottom==chunk1.Bottom());
1.59 + test(top==chunk1.Top());
1.60 +
1.61 + r=UserHal::MemoryInfo(meminfo2);
1.62 + test(r==KErrNone);
1.63 + test.Printf(_L("Free RAM %08X bytes\n"),meminfo2().iFreeRamInBytes);
1.64 + test(meminfo1().iFreeRamInBytes==meminfo2().iFreeRamInBytes);
1.65 +
1.66 + r=chunk1.AdjustDoubleEnded(0,0x6000);
1.67 + test(r==KErrNone);
1.68 + Mem::FillZ((TAny*)(chunk1.Base()+chunk1.Bottom()),chunk1.Size());
1.69 +
1.70 + chunk1.Close();
1.71 +
1.72 + test.End();
1.73 + test.Close();
1.74 + __KHEAP_MARKEND;
1.75 + return(KErrNone);
1.76 + }
1.77 +
1.78 +