kerneltest/e32test/misc/t_romchk.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1998-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 the License "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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\misc\t_ramuse.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32test.h>
       
    19 #include <e32rom.h>
       
    20 #include <e32svr.h>
       
    21 
       
    22 LOCAL_D RTest test(_L("T_ROMCHK"));
       
    23 
       
    24 TUint Check(const TUint32* aPtr, TInt aSize)
       
    25 	{
       
    26 	TUint sum=0;
       
    27 	aSize/=4;
       
    28 	while (aSize-->0)
       
    29 		sum+=*aPtr++;
       
    30 	return sum;
       
    31 	}
       
    32 
       
    33 GLDEF_C TInt E32Main()
       
    34 	{
       
    35 	test.Title();
       
    36 	test.Start(_L("Checking ROM contents..."));
       
    37 
       
    38 	const TRomHeader* romHdr = (const TRomHeader*)UserSvr::RomHeaderAddress();
       
    39 	if(!romHdr)
       
    40 		test.Printf(_L("No ROM Header found!"));
       
    41 	else
       
    42 		{
       
    43 		TInt size = romHdr->iUncompressedSize;
       
    44 		const TUint32* addr = (TUint32*)romHdr;
       
    45 		test.Printf(_L("ROM at %x, size %x\n"),addr,size);
       
    46 
       
    47 		TUint checkSum = Check(addr,size);
       
    48 
       
    49 		// hack the checksum because ROMBUILD is broken
       
    50 		checkSum -= (romHdr->iRomSize-size)/4; // adjust for missing 0xffffffff
       
    51 		checkSum -= romHdr->iCompressionType;
       
    52 		checkSum -= romHdr->iCompressedSize;
       
    53 		checkSum -= romHdr->iUncompressedSize;
       
    54 	
       
    55 		TUint expectedChecksum = 0x12345678;
       
    56 		test.Printf(_L("Checksum = %8x, expected %8x\n"),checkSum,expectedChecksum);
       
    57 		test(checkSum==expectedChecksum);
       
    58 		}
       
    59 
       
    60 	test.End();
       
    61 	return 0;
       
    62 	}