sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Hardware Configuration Respoitory Test Application sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "d_hcrsim.h" sl@0: #include "d_hcrsim_testdata.h" sl@0: #include "hcr_uids.h" sl@0: sl@0: _LIT8(KTestFileRepos, "filerepos.dat"); sl@0: _LIT8(KTestNandRepos, "nandrepos.dat"); sl@0: _LIT8(KTestCorrupt1, "corrupt1.dat"); sl@0: _LIT8(KTestCorrupt2, "corrupt2.dat"); sl@0: _LIT8(KTestEmpty, "empty.dat"); sl@0: _LIT8(KTestMegaLarge1, "megalarge1.dat"); sl@0: _LIT8(KTestMegaLarge2, "megalarge2.dat"); sl@0: _LIT8(KTestClearRepos, ""); sl@0: sl@0: sl@0: static const TInt KSimOwnThread = 0; sl@0: static const TInt KSimClientThread = 1; sl@0: static TInt gHcrThread = KSimOwnThread; sl@0: sl@0: //Calculation of the fraction defined by f for the number x sl@0: #define _FRACTION(x, f) (x>f ? x/f : x) sl@0: sl@0: sl@0: RTest test(_L("T_HCR")); sl@0: RHcrSimTestChannel HcrSimTest; sl@0: sl@0: //Helper function to compare two SSettingId parameters. It's used in sl@0: //GetMultipleWord settings array sl@0: TInt CompareEntries (const SSettingC& a1, const SSettingC& a2) sl@0: { sl@0: if (a1.iName.iId.iCat > a2.iName.iId.iCat) sl@0: return (1); sl@0: sl@0: if (a1.iName.iId.iCat < a2.iName.iId.iCat) sl@0: return (-1); sl@0: sl@0: // Categories are the same at this point, check keys. sl@0: if (a1.iName.iId.iKey > a2.iName.iId.iKey) sl@0: return (1); sl@0: sl@0: if (a1.iName.iId.iKey < a2.iName.iId.iKey) sl@0: return (-1); sl@0: sl@0: // Both Categories and jeys are the same here. sl@0: return (0); sl@0: } sl@0: sl@0: sl@0: sl@0: void HcrSimGetSettings(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: test.Next(_L("GetSettings")); sl@0: TInt r; sl@0: SSettingC* setting; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey); sl@0: test.Printf(_L("(0x%08x, 0x%08x)\n"), id.iCat, id.iKey); sl@0: switch (setting->iName.iType) sl@0: { sl@0: case ETypeInt32: sl@0: { sl@0: TInt32 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iInt32, val); sl@0: break; sl@0: } sl@0: case ETypeInt16: sl@0: { sl@0: TInt16 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iInt16, val); sl@0: break; sl@0: } sl@0: case ETypeInt8: sl@0: { sl@0: TInt8 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iInt8, val); sl@0: break; sl@0: } sl@0: case ETypeBool: sl@0: { sl@0: TBool val; sl@0: r = HcrSimTest.GetBool(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iBool, val); sl@0: break; sl@0: } sl@0: case ETypeUInt32: sl@0: { sl@0: TUint32 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iUInt32, val); sl@0: break; sl@0: } sl@0: case ETypeUInt16: sl@0: { sl@0: TUint16 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iUInt16, val); sl@0: break; sl@0: } sl@0: case ETypeUInt8: sl@0: { sl@0: TUint8 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iUInt8, val); sl@0: break; sl@0: } sl@0: case ETypeLinAddr: sl@0: { sl@0: TLinAddr val; sl@0: r = HcrSimTest.GetLinAddr(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(setting->iValue.iLit.iAddress, val); sl@0: break; sl@0: } sl@0: case ETypeBinData: sl@0: { sl@0: TBuf8 dval; sl@0: TUint8* pval; sl@0: pval = (TUint8*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetData(id, dval); sl@0: test_KErrNone(r); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetData(id, setting->iName.iLen, pval, actuallength); sl@0: test_KErrNone(r); sl@0: // sl@0: test_Equal(0, Mem::Compare( sl@0: setting->iValue.iPtr.iData, setting->iName.iLen, sl@0: pval, actuallength)); sl@0: test_Equal(0, Mem::Compare( sl@0: setting->iValue.iPtr.iData, setting->iName.iLen, sl@0: dval.Ptr(), dval.Length())); sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeText8: sl@0: { sl@0: TBuf8 dval; sl@0: TText8* pval; sl@0: pval = (TText8*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetString(id, dval); sl@0: test_KErrNone(r); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetString(id, setting->iName.iLen, pval, actuallength); sl@0: test_KErrNone(r); sl@0: // sl@0: test_Equal(0, Mem::Compare( sl@0: setting->iValue.iPtr.iString8, setting->iName.iLen, sl@0: pval, actuallength)); sl@0: test_Equal(0, Mem::Compare( sl@0: setting->iValue.iPtr.iString8, setting->iName.iLen, sl@0: dval.Ptr(), dval.Length())); sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeArrayInt32: sl@0: { sl@0: TInt32* pval; sl@0: pval = (TInt32*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, setting->iName.iLen, pval, actuallength); sl@0: test_KErrNone(r); sl@0: // sl@0: test_Equal(setting->iName.iLen, actuallength); sl@0: TInt32* pexpected = setting->iValue.iPtr.iArrayInt32; sl@0: TUint i; sl@0: for (i = 0; i < setting->iName.iLen / sizeof(TInt32); i++) sl@0: { sl@0: test_Equal(*(pexpected + i), *(pval + i)); sl@0: } sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeArrayUInt32: sl@0: { sl@0: TUint32* pval; sl@0: pval = (TUint32*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, setting->iName.iLen, pval, actuallength); sl@0: test_KErrNone(r); sl@0: // sl@0: test_Equal(setting->iName.iLen, actuallength); sl@0: TUint32* pexpected = setting->iValue.iPtr.iArrayUInt32; sl@0: TUint i; sl@0: for (i = 0; i < setting->iName.iLen / sizeof(TUint32); i++) sl@0: { sl@0: test_Equal(*(pexpected + i), *(pval + i)); sl@0: } sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeInt64: sl@0: { sl@0: TInt64 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(*setting->iValue.iPtr.iInt64, val); sl@0: break; sl@0: } sl@0: case ETypeUInt64: sl@0: { sl@0: TUint64 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test_Equal(*setting->iValue.iPtr.iUInt64, val); sl@0: break; sl@0: } sl@0: default: sl@0: test(EFalse); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void HcrSimGetSettingsNegative(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: test.Next(_L("GetSettingsNegative")); sl@0: TInt r; sl@0: SSettingC* setting; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey); sl@0: test.Printf(_L("(0x%08x, 0x%08x)\n"), id.iCat, id.iKey); sl@0: if (setting->iName.iType != ETypeInt32) sl@0: { sl@0: TInt32 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeInt16) sl@0: { sl@0: TInt16 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeInt8) sl@0: { sl@0: TInt8 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeBool) sl@0: { sl@0: TBool val; sl@0: r = HcrSimTest.GetBool(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeUInt32) sl@0: { sl@0: TUint32 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeUInt16) sl@0: { sl@0: TUint16 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeUInt8) sl@0: { sl@0: TUint8 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeLinAddr) sl@0: { sl@0: TLinAddr val; sl@0: r = HcrSimTest.GetLinAddr(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeBinData) sl@0: { sl@0: TBuf8 dval; sl@0: TUint8* pval; sl@0: pval = (TUint8*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetData(id, dval); sl@0: test_Equal(KErrArgument, r); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetData(id, setting->iName.iLen, pval, actuallength); sl@0: test_Equal(KErrArgument, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: else if (setting->iName.iLen > 1) sl@0: { sl@0: RBuf8 dval; sl@0: r = dval.Create(setting->iName.iLen - 1); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.GetData(id, dval); sl@0: test_Equal(KErrTooBig, r); sl@0: dval.Close(); sl@0: sl@0: TUint8* pval; sl@0: pval = (TUint8*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetData(id, (unsigned short)( setting->iName.iLen - 1), pval, actuallength); sl@0: test_Equal(KErrTooBig, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: if (setting->iName.iType != ETypeText8) sl@0: { sl@0: TBuf8 dval; sl@0: TText8* pval; sl@0: pval = (TText8*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetString(id, dval); sl@0: test_Equal(KErrArgument, r); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetString(id, setting->iName.iLen, pval, actuallength); sl@0: test_Equal(KErrArgument, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: else if (setting->iName.iLen > 1) sl@0: { sl@0: RBuf8 dval; sl@0: r = dval.Create(setting->iName.iLen - 1); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.GetString(id, dval); sl@0: test_Equal(KErrTooBig, r); sl@0: dval.Close(); sl@0: sl@0: TText8* pval; sl@0: pval = (TText8*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetString(id, (unsigned short)(setting->iName.iLen >> 1), pval, actuallength); sl@0: test_Equal(KErrTooBig, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: if (setting->iName.iType != ETypeArrayInt32) sl@0: { sl@0: TInt32* pval; sl@0: pval = (TInt32*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, setting->iName.iLen, pval, actuallength); sl@0: test_Equal(KErrArgument, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: else sl@0: { sl@0: TInt32* pval; sl@0: pval = (TInt32*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, (TUint16) (setting->iName.iLen >> 1), pval, actuallength); sl@0: test_Equal(KErrTooBig, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: if (setting->iName.iType != ETypeArrayUInt32) sl@0: { sl@0: TUint32* pval; sl@0: pval = (TUint32*) User::Alloc(setting->iName.iLen); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, setting->iName.iLen, pval, actuallength); sl@0: test_Equal(KErrArgument, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: if (setting->iName.iType != ETypeInt64) sl@0: { sl@0: TInt64 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: if (setting->iName.iType != ETypeUInt64) sl@0: { sl@0: TUint64 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void HcrSimSettingProperties(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: test.Next(_L("SettingProperties")); sl@0: TInt r; sl@0: SSettingC* setting; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: TSettingId id(setting->iName.iId.iCat, setting->iName.iId.iKey); sl@0: test.Printf(_L("(0x%08x, 0x%08x)\n"), id.iCat, id.iKey); sl@0: TSettingType type = ETypeUndefined; sl@0: TUint16 size = KMaxSettingLength + 1; sl@0: r = HcrSimTest.GetTypeAndSize(id, type, size); sl@0: test_KErrNone(r); sl@0: switch (setting->iName.iType) sl@0: { sl@0: case ETypeInt32: sl@0: case ETypeInt16: sl@0: case ETypeInt8: sl@0: case ETypeBool: sl@0: case ETypeUInt32: sl@0: case ETypeUInt16: sl@0: case ETypeUInt8: sl@0: case ETypeLinAddr: sl@0: test_Equal(setting->iName.iType, type); sl@0: test_Equal(0, size); sl@0: break; sl@0: // Fall-through sl@0: case ETypeBinData: sl@0: case ETypeText8: sl@0: case ETypeArrayInt32: sl@0: case ETypeArrayUInt32: sl@0: case ETypeInt64: sl@0: case ETypeUInt64: sl@0: test_Equal(setting->iName.iType, type); sl@0: test_Equal(setting->iName.iLen, size); sl@0: break; sl@0: default: sl@0: test(EFalse); sl@0: } sl@0: test.Printf(_L(".")); sl@0: } sl@0: test.Printf(_L("\n")); sl@0: } sl@0: sl@0: void HcrSimMultipleGet(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: test.Next(_L("MultipleGet")); sl@0: TInt r; sl@0: SSettingId largesetting; sl@0: largesetting.iCat = 0; sl@0: largesetting.iKey = 0; sl@0: sl@0: SSettingC* setting; sl@0: SSettingId id; sl@0: id.iCat = 0; sl@0: id.iKey = 0; sl@0: sl@0: sl@0: sl@0: test.Start(_L("Multiple Get on individual settings")); sl@0: sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: test.Printf(_L("(0x%08x, 0x%08x)\n"), id.iCat, id.iKey); sl@0: TInt i; sl@0: sl@0: TInt32 val; sl@0: TSettingType type; sl@0: TInt err; sl@0: sl@0: sl@0: test.Next(_L("Multiple Get, with non-existing category or element id")); sl@0: sl@0: // Try all permutations of optional values sl@0: // i == 0 || i == 1 Just a single setting from the repostitory sl@0: // i == 2 || i == 3 Valid category and invalid element id sl@0: // i == 4 || i == 5 Invalid category and valid element id sl@0: // i == 6 || i == 7 Invalid category and element id sl@0: for (i = 0; i < 8; i++) sl@0: { sl@0: //Just a single setting from the repository sl@0: if(i == 0 || i == 1) sl@0: { sl@0: //test.Printf(_L("Single setting, valid element && valid category\n")); sl@0: id.iCat = setting->iName.iId.iCat; sl@0: id.iKey = setting->iName.iId.iKey; sl@0: sl@0: //test.Printf(_L("-Permutation %02x\n"), i); sl@0: r = HcrSimTest.GetWordSettings(1, &id, &val, sl@0: (i & 0x1 ? &type : NULL), &err); sl@0: //HCR should return 1 sl@0: test_Equal(1, r); sl@0: test_Equal(setting->iValue.iLit.iInt32, val); sl@0: if (i & 0x1) sl@0: { sl@0: test_Equal(setting->iName.iType, type); sl@0: } sl@0: sl@0: test_KErrNone(err); sl@0: } sl@0: sl@0: //Valid category and invalid element id sl@0: if(i == 2 || i == 3) sl@0: { sl@0: //test.Printf(_L("Single setting, invalid element && valid category\n")); sl@0: id.iCat = setting->iName.iId.iCat; sl@0: id.iKey = KTestInvalidSettingId; sl@0: sl@0: sl@0: r = HcrSimTest.GetWordSettings(1, &id, &val, sl@0: (i & 0x1 ? &type : NULL), &err); sl@0: sl@0: //HCR should return 0 sl@0: test_Equal(0, r); sl@0: test_Equal(0, val); sl@0: if (i & 0x1) sl@0: { sl@0: //HCR returns ETypeUndefined sl@0: test_Equal(0, type); sl@0: } sl@0: sl@0: test_Equal(KErrNotFound,err); sl@0: } sl@0: sl@0: //Invalid category and valid element id sl@0: if(i == 4 || i == 5) sl@0: { sl@0: id.iCat = KTestInvalidCategory; sl@0: id.iKey = setting->iName.iId.iKey; sl@0: sl@0: //test.Printf(_L("Single setting, invalid element && valid category\n")); sl@0: r = HcrSimTest.GetWordSettings(1, &id, &val, sl@0: (i & 0x1 ? &type : NULL), &err); sl@0: //HCR should return 1 sl@0: test_Equal(0, r); sl@0: test_Equal(0, val); sl@0: if (i & 0x1) sl@0: { sl@0: //HCR returns ETypeUndefined sl@0: test_Equal(0, type); sl@0: } sl@0: sl@0: test_Equal(KErrNotFound, err); sl@0: } sl@0: sl@0: //Invalid category and element id sl@0: if(i == 6 || i == 7) sl@0: { sl@0: id.iCat = KTestInvalidCategory; sl@0: id.iKey = KTestInvalidSettingId; sl@0: sl@0: //test.Printf(_L("Single setting, invalid element && valid category\n")); sl@0: r = HcrSimTest.GetWordSettings(1, &id, &val, sl@0: (i & 0x1 ? &type : NULL), &err); sl@0: //HCR should return 1 sl@0: test_Equal(0, r); sl@0: test_Equal(0, val); sl@0: if (i & 0x1) sl@0: { sl@0: //HCR returns ETypeUndefined sl@0: test_Equal(0, type); sl@0: } sl@0: test_Equal(KErrNotFound, err); sl@0: } sl@0: } sl@0: } sl@0: else if (largesetting.iKey == 0) sl@0: { sl@0: // save for later sl@0: largesetting.iCat = setting->iName.iId.iCat; sl@0: largesetting.iKey = setting->iName.iId.iKey; sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: test.Next(_L("Multiple Get, some user input parameters are wrong")); sl@0: sl@0: sl@0: TInt nosettings = 0; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: nosettings++; sl@0: } sl@0: test_Compare(0, <, nosettings); sl@0: } sl@0: sl@0: sl@0: SSettingId* ids; sl@0: TInt32* vals; sl@0: TSettingType* types; sl@0: TInt* errs; sl@0: sl@0: sl@0: ids = (SSettingId*) User::Alloc(sizeof(SSettingId) * nosettings); sl@0: test_NotNull(ids); sl@0: vals = (TInt32*) User::Alloc(sizeof(TInt32) * nosettings); sl@0: test_NotNull(vals); sl@0: types = (TSettingType*) User::Alloc(sizeof(TSettingType) * nosettings); sl@0: test_NotNull(types); sl@0: errs = (TInt*) User::Alloc(sizeof(TInt) * nosettings); sl@0: test_NotNull(errs); sl@0: sl@0: TUint n = 0; sl@0: sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: ids[n].iCat = setting->iName.iId.iCat; sl@0: ids[n].iKey = setting->iName.iId.iKey; sl@0: n++; sl@0: } sl@0: } sl@0: test_Equal(nosettings, n); sl@0: sl@0: sl@0: sl@0: test.Next(_L("Number of settings is negative \n")); sl@0: r = HcrSimTest.GetWordSettings(-1 * nosettings, ids, vals, types, errs); sl@0: sl@0: //HCR returns KErrArgument sl@0: test_Equal(KErrArgument, r); sl@0: sl@0: sl@0: test.Printf(_L("Pointer to errors array is NULL \n")); sl@0: r = HcrSimTest.GetWordSettings(nosettings, ids, vals, types, NULL); sl@0: sl@0: //HCR returns KErrArgument sl@0: test_Equal(KErrArgument, r); sl@0: sl@0: sl@0: test.Printf(_L("Pointer to ids is NULL \n")); sl@0: r = HcrSimTest.GetWordSettings(nosettings, NULL, vals, types, errs); sl@0: sl@0: //HCR returns KErrArgument sl@0: test_Equal(KErrArgument, r); sl@0: sl@0: User::Free(ids); sl@0: User::Free(vals); sl@0: User::Free(types); sl@0: User::Free(errs); sl@0: sl@0: sl@0: sl@0: test.Next(_L("Multiple Get on all settings")); sl@0: nosettings = 0; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: nosettings++; sl@0: } sl@0: test_Compare(0, <, nosettings); sl@0: } sl@0: sl@0: ids = (SSettingId*) User::Alloc(sizeof(SSettingId) * nosettings); sl@0: test_NotNull(ids); sl@0: vals = (TInt32*) User::Alloc(sizeof(TInt32) * nosettings); sl@0: test_NotNull(vals); sl@0: types = (TSettingType*) User::Alloc(sizeof(TSettingType) * nosettings); sl@0: test_NotNull(types); sl@0: errs = (TInt*) User::Alloc(sizeof(TInt) * nosettings); sl@0: test_NotNull(errs); sl@0: sl@0: n = 0; sl@0: sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: ids[n].iCat = setting->iName.iId.iCat; sl@0: ids[n].iKey = setting->iName.iId.iKey; sl@0: n++; sl@0: } sl@0: } sl@0: test_Equal(nosettings, n); sl@0: sl@0: sl@0: // Try all permutations of optional values sl@0: TInt i; sl@0: for (i = 0; i < 2; i++) sl@0: { sl@0: r = HcrSimTest.GetWordSettings(nosettings, ids, vals, sl@0: (i & 0x1 ? types : NULL), errs); sl@0: //HCR returns number of found elements sl@0: test_Equal(nosettings, r); sl@0: sl@0: // Check values sl@0: n = 0; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: test_Equal(setting->iValue.iLit.iInt32, vals[n]); sl@0: if (i & 0x1) sl@0: { sl@0: test_Equal(setting->iName.iType,types[n]); sl@0: } sl@0: test_KErrNone(errs[n]); sl@0: n++; sl@0: } sl@0: } sl@0: test_Equal(nosettings, n); sl@0: } sl@0: User::Free(ids); sl@0: User::Free(vals); sl@0: User::Free(types); sl@0: User::Free(errs); sl@0: sl@0: test.Next(_L("Multiple Get on all settings + inexistent")); sl@0: nosettings = 1; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: nosettings++; sl@0: } sl@0: test_Compare(0, <, nosettings); sl@0: } sl@0: ids = (SSettingId*) User::Alloc(sizeof(SSettingId) * nosettings); sl@0: test_NotNull(ids); sl@0: vals = (TInt32*) User::Alloc(sizeof(TInt32) * nosettings); sl@0: test_NotNull(vals); sl@0: types = (TSettingType*) User::Alloc(sizeof(TSettingType) * nosettings); sl@0: test_NotNull(types); sl@0: errs = (TInt*) User::Alloc(sizeof(TInt) * nosettings); sl@0: test_NotNull(errs); sl@0: ids[0].iCat = KTestInvalidCategory; sl@0: ids[0].iKey = KTestInvalidSettingId; sl@0: sl@0: sl@0: n = 1; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: ids[n].iCat = setting->iName.iId.iCat; sl@0: ids[n].iKey = setting->iName.iId.iKey; sl@0: n++; sl@0: } sl@0: } sl@0: sl@0: test_Equal(nosettings, n); sl@0: sl@0: // Try all permutations of optional values sl@0: for (i = 0; i < 2; i++) sl@0: { sl@0: r = HcrSimTest.GetWordSettings(nosettings, ids, vals, sl@0: (i & 0x1 ? types : NULL), errs); sl@0: test_Equal(nosettings - 1, r); sl@0: sl@0: // Check values sl@0: if (i & 0x1) sl@0: { sl@0: test_Equal(ETypeUndefined, types[0]); sl@0: } sl@0: test_Equal(KErrNotFound, errs[0]); sl@0: sl@0: n = 1; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if (setting->iName.iType < 0x00010000) sl@0: { sl@0: test_Equal(setting->iValue.iLit.iInt32, vals[n]); sl@0: if (i & 0x1) sl@0: { sl@0: test_Equal(setting->iName.iType, types[n]); sl@0: } sl@0: sl@0: test_KErrNone(errs[n]); sl@0: sl@0: n++; sl@0: } sl@0: } sl@0: test_Equal(nosettings, n); sl@0: } sl@0: User::Free(ids); sl@0: User::Free(vals); sl@0: User::Free(types); sl@0: User::Free(errs); sl@0: sl@0: test.Next(_L("Multiple Get on a large setting")); sl@0: if (largesetting.iKey) sl@0: { sl@0: TInt32 value; sl@0: TSettingType type; sl@0: TInt theerror = 1; sl@0: r = HcrSimTest.GetWordSettings(1, &largesetting, &value, &type, &theerror); sl@0: test_Equal(0, r); sl@0: test_Equal(KErrArgument, theerror); sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("No large setting found in repositories!\n")); sl@0: } sl@0: test.End(); sl@0: } sl@0: sl@0: void HcrSimNumSettingsInCategory(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: test.Next(_L("NumSettingsInCategory")); sl@0: TInt r; sl@0: // Build a hash table with number of settings for each category sl@0: RHashMap numsettings; sl@0: SSettingC* setting; sl@0: TInt* pV = NULL; sl@0: TInt value = 0; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: pV = numsettings.Find(setting->iName.iId.iCat); sl@0: if(pV) sl@0: value = *pV; sl@0: if (!pV) sl@0: { sl@0: r = numsettings.Insert(setting->iName.iId.iCat, 1); sl@0: test_KErrNone(r); sl@0: } sl@0: else sl@0: { sl@0: r = numsettings.Remove(setting->iName.iId.iCat); sl@0: test_KErrNone(r); sl@0: r = numsettings.Insert(setting->iName.iId.iCat, value + 1); sl@0: test_KErrNone(r); sl@0: } sl@0: } sl@0: sl@0: // Now compare hash table with values returned by FindNumSettingsInCategory sl@0: RHashMap::TIter catiter(numsettings); sl@0: for (;;) sl@0: { sl@0: const TUint32* nextcat = catiter.NextKey(); sl@0: if (!nextcat) sl@0: { sl@0: break; sl@0: } sl@0: test.Printf(_L("Category %08x\n"), *nextcat); sl@0: const TInt* v = numsettings.Find(*nextcat); sl@0: test_NotNull(v); sl@0: r = HcrSimTest.FindNumSettingsInCategory(*nextcat); sl@0: test_Equal(*v, r); sl@0: } sl@0: numsettings.Close(); sl@0: } sl@0: sl@0: sl@0: sl@0: void HcrSimFindSettingsCategory(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: test.Next(_L("FindSettingsCategory")); sl@0: TInt r; sl@0: sl@0: // Build a hash table with number of settings for each category sl@0: RHashMap numsettings; sl@0: SSettingC* setting; sl@0: TInt* pV = NULL; sl@0: TInt value = 0; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: pV = numsettings.Find(setting->iName.iId.iCat); sl@0: if(pV) sl@0: value = *pV; sl@0: if (!pV) sl@0: { sl@0: r = numsettings.Insert(setting->iName.iId.iCat, 1); sl@0: test_KErrNone(r); sl@0: } sl@0: else sl@0: { sl@0: r = numsettings.Remove(setting->iName.iId.iCat); sl@0: test_KErrNone(r); sl@0: r = numsettings.Insert(setting->iName.iId.iCat, value + 1); sl@0: test_KErrNone(r); sl@0: } sl@0: } sl@0: sl@0: // sl@0: RHashMap::TIter catiter(numsettings); sl@0: for (;;) sl@0: { sl@0: const TUint32* nextcat = catiter.NextKey(); sl@0: if (!nextcat) sl@0: { sl@0: break; sl@0: } sl@0: test.Printf(_L("Category %08x"), *nextcat); sl@0: const TInt* v = numsettings.Find(*nextcat); sl@0: test_NotNull(v); sl@0: sl@0: // Allocate memory for holding array of settings sl@0: TElementId* elids; sl@0: TSettingType* types; sl@0: TUint16* lens; sl@0: sl@0: TInt maxNum; sl@0: sl@0: sl@0: // Try all permutations of optional values sl@0: TInt i; sl@0: for (i = 0; i < 3; i++) sl@0: { sl@0: test.Printf(_L(".")); sl@0: sl@0: TUint32 numfound; sl@0: sl@0: //maxNum is equal: sl@0: //0 - 1, the total elements from the category sl@0: //1 - 1/2 of total number of elements from the category sl@0: //2 - 1 + 1/2 of total number of element from the category sl@0: sl@0: if(i == 0) sl@0: maxNum = *v; sl@0: else if(i == 1) sl@0: maxNum = _FRACTION((*v), 2); sl@0: else sl@0: maxNum = *v + _FRACTION((*v), 2); sl@0: sl@0: sl@0: elids = (TElementId*) User::Alloc(maxNum * sizeof(TElementId)); sl@0: test_NotNull(elids); sl@0: types = (TSettingType*) User::Alloc(maxNum * sizeof(TSettingType)); sl@0: test_NotNull(types); sl@0: lens = (TUint16*) User::Alloc(maxNum * sizeof(TUint16)); sl@0: test_NotNull(lens); sl@0: sl@0: Mem::Fill(elids, maxNum * sizeof(TElementId), 0xcc); sl@0: Mem::Fill(types, maxNum * sizeof(TSettingType), 0xcc); sl@0: Mem::Fill(lens, maxNum * sizeof(TUint16), 0xcc); sl@0: sl@0: sl@0: r = HcrSimTest.FindSettings(*nextcat, sl@0: maxNum, elids, sl@0: i & 0x1 ? types : NULL, sl@0: i & 0x2 ? lens : NULL); sl@0: numfound = r; sl@0: test_Compare(0, <=, r); sl@0: sl@0: if(i < 2) sl@0: { sl@0: //for 0 & 1 the number of settings returned must be equal maxNum sl@0: test_Equal(maxNum, r); sl@0: } sl@0: else sl@0: { sl@0: //for 2, it's equal the real number of settings sl@0: test_Equal((*v), r); sl@0: } sl@0: sl@0: sl@0: sl@0: // Check returned list of element ids sl@0: TUint j; sl@0: for (j = 0; j < numfound; j++) sl@0: { sl@0: // Find current element in the test array sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if ((setting->iName.iId.iCat == *nextcat) && (setting->iName.iId.iKey == elids[j])) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: test_Compare(setting,<,aRepository+aNumberOfSettings); // Fail if element not found sl@0: switch (setting->iName.iType) sl@0: { sl@0: case ETypeInt32: sl@0: case ETypeInt16: sl@0: case ETypeInt8: sl@0: case ETypeBool: sl@0: case ETypeUInt32: sl@0: case ETypeUInt16: sl@0: case ETypeUInt8: sl@0: case ETypeLinAddr: sl@0: if (i & 0x1) sl@0: { sl@0: test_Equal(setting->iName.iType, types[j]); sl@0: } sl@0: if (i & 0x2) sl@0: { sl@0: test_Equal(0, lens[j]); sl@0: } sl@0: break; sl@0: // Fall-through sl@0: case ETypeBinData: sl@0: case ETypeText8: sl@0: case ETypeArrayInt32: sl@0: case ETypeArrayUInt32: sl@0: case ETypeInt64: sl@0: case ETypeUInt64: sl@0: if (i & 0x1) sl@0: { sl@0: test_Equal(setting->iName.iType, types[j]); sl@0: } sl@0: if (i & 0x2) sl@0: { sl@0: test_Equal(setting->iName.iLen, lens[j]); sl@0: } sl@0: break; sl@0: default: sl@0: test(EFalse); sl@0: } sl@0: } sl@0: // Check all expected elements are in the returned list of element ids sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if ((setting->iName.iId.iCat == *nextcat)) sl@0: { sl@0: for (j = 0; j < numfound; j++) sl@0: { sl@0: if (elids[j] == setting->iName.iId.iKey) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: test_Compare(j, <=, numfound); sl@0: } sl@0: } sl@0: sl@0: User::Free(elids); sl@0: User::Free(types); sl@0: User::Free(lens); sl@0: } sl@0: sl@0: test.Printf(_L("\n")); sl@0: } sl@0: numsettings.Close(); sl@0: } sl@0: sl@0: struct TTestFindSettingsPatternArgs sl@0: { sl@0: TUint32 iMask; sl@0: TUint32 iPattern; sl@0: }; sl@0: sl@0: const TTestFindSettingsPatternArgs KTestFindSettingsPatternArgs[] = { sl@0: // iMask iPattern sl@0: {0x00000000, 0x00000000}, sl@0: {0xfffffff0, 0x00000000}, sl@0: {0xffffffff, 0x00000001} sl@0: }; sl@0: sl@0: void HcrSimFindSettingsPattern(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: test.Next(_L("FindSettingsPattern")); sl@0: TInt r; sl@0: TUint i; sl@0: sl@0: // Allocate memory for holding array of settings sl@0: TElementId* elids; sl@0: TSettingType* types; sl@0: TUint16* lens; sl@0: TInt maxNum; sl@0: sl@0: // Build a hash table with number of settings for each category sl@0: RHashMap numsettings; sl@0: SSettingC* setting; sl@0: TInt* pV = NULL; sl@0: TInt value = 0; sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: pV = numsettings.Find(setting->iName.iId.iCat); sl@0: if(pV) sl@0: value = *pV; sl@0: if (!pV) sl@0: { sl@0: r = numsettings.Insert(setting->iName.iId.iCat, 1); sl@0: test_KErrNone(r); sl@0: } sl@0: else sl@0: { sl@0: r = numsettings.Remove(setting->iName.iId.iCat); sl@0: test_KErrNone(r); sl@0: r = numsettings.Insert(setting->iName.iId.iCat, value + 1); sl@0: test_KErrNone(r); sl@0: } sl@0: } sl@0: sl@0: // Hash map includes the number of settings of each category sl@0: RHashMap::TIter catiter(numsettings); sl@0: for (;;) sl@0: { sl@0: const TUint32* nextcat = catiter.NextKey(); sl@0: if (!nextcat) sl@0: { sl@0: break; sl@0: } sl@0: test.Printf(_L("Category %08x"), *nextcat); sl@0: const TInt* v = numsettings.Find(*nextcat); sl@0: test_NotNull(v); sl@0: sl@0: sl@0: sl@0: for (i = 0; i < sizeof(KTestFindSettingsPatternArgs) / sizeof(TTestFindSettingsPatternArgs); i++) sl@0: { sl@0: test.Printf(_L("iMask=0x%08x iPattern=0x%08x\n"), sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern); sl@0: sl@0: TUint k; sl@0: for (k = 0; k < 3; k++) sl@0: { sl@0: TUint32 numfound; sl@0: sl@0: // aMaxNum is less than the total number of settings in the sl@0: // category sl@0: //0 - all elements from the category are requested sl@0: //1 - 1/2 of total number of elements from the category sl@0: //2 - 1 + 1/2 of total number of element from the category sl@0: if(k == 0) sl@0: maxNum = *v; sl@0: else if(k == 1) sl@0: maxNum = _FRACTION((*v), 2); sl@0: else sl@0: maxNum = (*v) + _FRACTION((*v), 2); sl@0: sl@0: elids = (TElementId*) User::Alloc(maxNum * sizeof(TElementId)); sl@0: test_NotNull(elids); sl@0: types = (TSettingType*) User::Alloc(maxNum * sizeof(TSettingType)); sl@0: test_NotNull(types); sl@0: lens = (TUint16*) User::Alloc(maxNum * sizeof(TUint16)); sl@0: test_NotNull(lens); sl@0: sl@0: sl@0: // Actual API call sl@0: r = HcrSimTest.FindSettings( sl@0: *nextcat, sl@0: maxNum, sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern, sl@0: elids, sl@0: (k & 0x1 ? types : NULL), sl@0: (k & 0x2 ? lens : NULL)); sl@0: test_Compare(0, <=, r); sl@0: test_Compare(maxNum, >=, r); sl@0: sl@0: numfound = r; sl@0: test.Printf(_L("%d match(es)\n"), r); sl@0: sl@0: // Check that all returned element ids satisfy the conditions sl@0: TUint32 l; sl@0: for (l = 0; l < numfound; l++) sl@0: { sl@0: test_Assert( sl@0: (KTestFindSettingsPatternArgs[i].iMask & KTestFindSettingsPatternArgs[i].iPattern) == sl@0: (KTestFindSettingsPatternArgs[i].iMask & elids[l]), test.Printf(_L("!!%08x!!\n"), elids[l]) sl@0: ); sl@0: sl@0: //Somehow the macro test_Compare consider TInt32 instead TUint32 sl@0: //as a result comparasion is done by this way: sl@0: //RTEST: (0x0 (0) < 0x80000000 (-2147483648)) == EFalse at line 1038 sl@0: //althought 0x80000000 > 0, with the signed form this number will be sl@0: //-2147483648. sl@0: //test_Compare(KTestFindSettingsPatternArgs[i].iAtId, <=, elids[l]); sl@0: } sl@0: sl@0: // Check that all elements that satisfy the conditions have been returned sl@0: SSettingC* setting; sl@0: TUint32 numsettings = 0; sl@0: sl@0: //Flag indicates that the element is found sl@0: TBool fFlag = EFalse; sl@0: sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: if ((setting->iName.iId.iCat == *nextcat) sl@0: && ((KTestFindSettingsPatternArgs[i].iMask & KTestFindSettingsPatternArgs[i].iPattern) == sl@0: (KTestFindSettingsPatternArgs[i].iMask & setting->iName.iId.iKey))) sl@0: { sl@0: for (l = 0; l < numfound; l++) sl@0: { sl@0: if (setting->iName.iId.iKey == elids[l]) sl@0: { sl@0: fFlag = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if(fFlag) sl@0: { sl@0: test_Assert(l < numfound, test.Printf(_L("!!%08x!!\n"), elids[l])); sl@0: sl@0: // Check type and size returned sl@0: switch (setting->iName.iType) sl@0: { sl@0: case ETypeInt32: sl@0: case ETypeInt16: sl@0: case ETypeInt8: sl@0: case ETypeBool: sl@0: case ETypeUInt32: sl@0: case ETypeUInt16: sl@0: case ETypeUInt8: sl@0: case ETypeLinAddr: sl@0: if (k & 0x1) sl@0: { sl@0: test_Equal(setting->iName.iType, types[l]); sl@0: } sl@0: if (k & 0x2) sl@0: { sl@0: test_Equal(0, lens[l]); sl@0: } sl@0: break; sl@0: // Fall-through sl@0: case ETypeBinData: sl@0: case ETypeText8: sl@0: case ETypeArrayInt32: sl@0: case ETypeArrayUInt32: sl@0: case ETypeInt64: sl@0: case ETypeUInt64: sl@0: if (k & 0x1) sl@0: { sl@0: test_Equal(setting->iName.iType, types[l]); sl@0: } sl@0: if (k & 0x2) sl@0: { sl@0: test_Equal(setting->iName.iLen, lens[l]); sl@0: } sl@0: break; sl@0: default: sl@0: test(EFalse); sl@0: } sl@0: numsettings++; sl@0: fFlag = EFalse; sl@0: } sl@0: } sl@0: } sl@0: sl@0: test_Equal(numsettings, numfound); sl@0: sl@0: // Free memory sl@0: User::Free(elids); sl@0: User::Free(types); sl@0: User::Free(lens); sl@0: sl@0: } sl@0: } sl@0: } sl@0: numsettings.Close(); sl@0: } sl@0: sl@0: sl@0: sl@0: void HcrSimFindSettingsCategoryNegative(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: sl@0: TInt r; sl@0: // Build a hash table with number of settings for each category sl@0: RHashMap numsettings; sl@0: SSettingC* setting; sl@0: TInt* pV = NULL; sl@0: TInt value = 0; sl@0: //Iterator object of the number of elements in the category sl@0: RHashMap::TIter catiter(numsettings); sl@0: sl@0: sl@0: test.Next(_L("FindSettingsCategoryNegative invalid user parameters")); sl@0: for (setting = aRepository; setting < aRepository + aNumberOfSettings; setting++) sl@0: { sl@0: pV = numsettings.Find(setting->iName.iId.iCat); sl@0: if(pV) sl@0: value = *pV; sl@0: if (!pV) sl@0: { sl@0: r = numsettings.Insert(setting->iName.iId.iCat, 1); sl@0: test_KErrNone(r); sl@0: } sl@0: else sl@0: { sl@0: r = numsettings.Remove(setting->iName.iId.iCat); sl@0: test_KErrNone(r); sl@0: r = numsettings.Insert(setting->iName.iId.iCat, value + 1); sl@0: test_KErrNone(r); sl@0: } sl@0: } sl@0: sl@0: // sl@0: for (;;) sl@0: { sl@0: const TUint32* nextcat = catiter.NextKey(); sl@0: if (!nextcat) sl@0: { sl@0: break; sl@0: } sl@0: test.Printf(_L("Category %08x"), *nextcat); sl@0: const TInt* v = numsettings.Find(*nextcat); sl@0: test_NotNull(v); sl@0: sl@0: // Allocate memory for holding array of settings sl@0: TElementId* elids; sl@0: TSettingType* types; sl@0: TUint16* lens; sl@0: elids = (TElementId*) User::Alloc(*v * sizeof(TElementId)); sl@0: test_NotNull(elids); sl@0: types = (TSettingType*) User::Alloc(*v * sizeof(TSettingType)); sl@0: test_NotNull(types); sl@0: lens = (TUint16*) User::Alloc(*v * sizeof(TUint16)); sl@0: test_NotNull(lens); sl@0: sl@0: sl@0: test.Printf(_L(".")); sl@0: Mem::Fill(elids, *v * sizeof(TElementId), 0xcc); sl@0: Mem::Fill(types, *v * sizeof(TSettingType), 0xcc); sl@0: Mem::Fill(lens, *v * sizeof(TUint16), 0xcc); sl@0: sl@0: TInt i; sl@0: for (i = 0; i < 3; i++) sl@0: { sl@0: //Perform the following permutations: sl@0: // 0 - negative aMaxNum AND aElIds != NULL sl@0: // 1 - positive aMaxNum AND aElIds == NULL sl@0: // 2 - negative aMaxNum AND aElIds == NULL sl@0: sl@0: switch(i) sl@0: { sl@0: case 0: sl@0: r = HcrSimTest.FindSettings(*nextcat, sl@0: (-1)*(*v), elids, types, lens); sl@0: sl@0: test_Equal(KErrArgument, r); sl@0: break; sl@0: sl@0: case 1: sl@0: r = HcrSimTest.FindSettings(*nextcat, sl@0: *v, NULL, types, lens); sl@0: sl@0: test_Equal(KErrArgument, r); sl@0: break; sl@0: sl@0: case 2: sl@0: r = HcrSimTest.FindSettings(*nextcat, sl@0: (-1)*(*v), NULL, types, lens); sl@0: sl@0: test_Equal(KErrArgument, r); sl@0: break; sl@0: sl@0: } sl@0: } sl@0: sl@0: sl@0: User::Free(elids); sl@0: User::Free(types); sl@0: User::Free(lens); sl@0: test.Printf(_L("\n")); sl@0: } sl@0: numsettings.Close(); sl@0: sl@0: } sl@0: sl@0: sl@0: void HcrSimFindSettingsPatternNegative(TUint aNumberOfSettings) sl@0: { sl@0: sl@0: TInt r; sl@0: TUint i; sl@0: sl@0: // Allocate memory for holding array of settings sl@0: TElementId* elids; sl@0: TSettingType* types; sl@0: TUint16* lens; sl@0: elids = (TElementId*) User::Alloc(aNumberOfSettings * sizeof(TElementId)); sl@0: test_NotNull(elids); sl@0: types = (TSettingType*) User::Alloc(aNumberOfSettings * sizeof(TSettingType)); sl@0: test_NotNull(types); sl@0: lens = (TUint16*) User::Alloc(aNumberOfSettings * sizeof(TUint16)); sl@0: test_NotNull(lens); sl@0: sl@0: test.Next(_L("FindSettingsPattern, invalid user parameters")); sl@0: for (i = 0; i < sizeof(KTestFindSettingsPatternArgs) / sizeof(TTestFindSettingsPatternArgs); i++) sl@0: { sl@0: test.Printf(_L("iMask=0x%08x iPattern=0x%08x\n"), sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern); sl@0: sl@0: // Test each category sl@0: TUint j; sl@0: for (j = 0; j < sizeof(KTestCategories) / sizeof(TCategoryUid); j++) sl@0: { sl@0: test.Printf(_L("Category 0x%08x: "), KTestCategories[j]); sl@0: sl@0: // Test all possible permutations of optional arguments sl@0: TInt k; sl@0: for (k = 0; k < 3; k++) sl@0: { sl@0: //Perform the following permutations: sl@0: // 0 - negative aMaxNum AND aElIds != NULL sl@0: // 1 - positive aMaxNum AND aElIds == NULL sl@0: // 2 - negative aMaxNum AND aElIds == NULL sl@0: sl@0: switch(k) sl@0: { sl@0: case 0: sl@0: // Actual API call sl@0: r = HcrSimTest.FindSettings( sl@0: KTestCategories[j], sl@0: (-1) * static_cast(aNumberOfSettings), sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern, sl@0: elids, sl@0: types, lens); sl@0: test_Equal(KErrArgument,r); sl@0: break; sl@0: sl@0: sl@0: case 1: sl@0: // Actual API call sl@0: r = HcrSimTest.FindSettings( sl@0: KTestCategories[j], sl@0: aNumberOfSettings, sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern, sl@0: NULL, sl@0: types, lens); sl@0: test_Equal(KErrArgument,r); sl@0: break; sl@0: sl@0: sl@0: case 2: sl@0: // Actual API call sl@0: r = HcrSimTest.FindSettings( sl@0: KTestCategories[j], sl@0: (-1) * static_cast(aNumberOfSettings), sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern, sl@0: NULL, sl@0: types, lens); sl@0: test_Equal(KErrArgument,r); sl@0: break; sl@0: sl@0: } sl@0: sl@0: } sl@0: } sl@0: } sl@0: sl@0: // Free memory sl@0: User::Free(elids); sl@0: User::Free(types); sl@0: User::Free(lens); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: void HcrSimFindSettingsPatternMemAllocFails(TUint aNumberOfSettings) sl@0: { sl@0: TInt r; sl@0: TUint i; sl@0: sl@0: // Allocate memory for holding array of settings sl@0: TElementId* elids; sl@0: TSettingType* types; sl@0: TUint16* lens; sl@0: elids = (TElementId*) User::Alloc(aNumberOfSettings * sizeof(TElementId)); sl@0: test_NotNull(elids); sl@0: types = (TSettingType*) User::Alloc(aNumberOfSettings * sizeof(TSettingType)); sl@0: test_NotNull(types); sl@0: lens = (TUint16*) User::Alloc(aNumberOfSettings * sizeof(TUint16)); sl@0: test_NotNull(lens); sl@0: sl@0: test.Next(_L("FindSettingsPattern, memory allocation failure")); sl@0: for (i = 0; i < sizeof(KTestFindSettingsPatternArgs) / sizeof(TTestFindSettingsPatternArgs); i++) sl@0: { sl@0: test.Printf(_L("iMask=0x%08x iPattern=0x%08x\n"), sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern); sl@0: sl@0: // Test each category sl@0: TUint j; sl@0: for (j = 0; j < sizeof(KTestCategories) / sizeof(TCategoryUid); j++) sl@0: { sl@0: test.Printf(_L("Category 0x%08x: "), KTestCategories[j]); sl@0: //Memory allocation fail test. By this code we simulate the memory sl@0: //allocation failure at place defined by allocFactor. The loop will sl@0: //continue until the next allocation is not failed. When we reached sl@0: //this point it means we've gone through all possible allocations in sl@0: //the tested method below. sl@0: TInt allocFactor = 1; sl@0: //Memory allocation fails sl@0: do sl@0: { sl@0: __KHEAP_MARK; sl@0: __KHEAP_SETFAIL(RAllocator::EFailNext, allocFactor); sl@0: r = HcrSimTest.FindSettings( sl@0: KTestCategories[j], sl@0: aNumberOfSettings, sl@0: KTestFindSettingsPatternArgs[i].iMask, sl@0: KTestFindSettingsPatternArgs[i].iPattern, sl@0: elids, sl@0: types, lens); sl@0: __KHEAP_MARKEND; sl@0: sl@0: __KHEAP_RESET; sl@0: sl@0: //Let's arrise the memory allocation failure at another place sl@0: allocFactor ++; sl@0: sl@0: }while(r == KErrNoMemory); sl@0: sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: // Free memory sl@0: User::Free(elids); sl@0: User::Free(types); sl@0: User::Free(lens); sl@0: sl@0: } sl@0: sl@0: sl@0: void HcrSimApiNegative(const TInt aExpectedErrorCode, const TUint32 aCategory, const TUint32 aSettingId) sl@0: { sl@0: test.Next(_L("ApiNegative")); sl@0: test.Printf(_L("Expected error: %d\nSetting (%08x, %08x)\n"), aExpectedErrorCode, aCategory, aSettingId); sl@0: TSettingId id(aCategory, aSettingId); sl@0: TInt r; sl@0: { sl@0: TInt32 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TInt16 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TInt8 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TBool val; sl@0: r = HcrSimTest.GetBool(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TUint32 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TUint16 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TUint8 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TLinAddr val; sl@0: r = HcrSimTest.GetLinAddr(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TBuf8 dval; sl@0: TUint8* pval; sl@0: pval = (TUint8*) User::Alloc(KMaxSettingLength); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetData(id, dval); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetData(id, KMaxSettingLength, pval, actuallength); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: { sl@0: TBuf8 dval; sl@0: TText8* pval; sl@0: pval = (TText8*) User::Alloc(KMaxSettingLength); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetString(id, dval); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetString(id, KMaxSettingLength, pval, actuallength); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: { sl@0: TInt32* pval; sl@0: pval = (TInt32*) User::Alloc(KMaxSettingLength); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, KMaxSettingLength, pval, actuallength); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: { sl@0: TUint32* pval; sl@0: pval = (TUint32*) User::Alloc(KMaxSettingLength); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, KMaxSettingLength, pval, actuallength); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: // sl@0: User::Free(pval); sl@0: } sl@0: { sl@0: TInt64 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: { sl@0: TUint64 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: sl@0: { sl@0: TSettingType type = ETypeUndefined; sl@0: TUint16 len = 0; sl@0: TElementId elid = 0; sl@0: sl@0: sl@0: // sl@0: r = HcrSimTest.GetTypeAndSize(id, type, len); sl@0: test_Equal(aExpectedErrorCode, r); sl@0: sl@0: // sl@0: r = HcrSimTest.FindNumSettingsInCategory(id.iCat); sl@0: if (aExpectedErrorCode == KErrNotFound) sl@0: { sl@0: test_Equal(0, r); sl@0: } sl@0: else sl@0: { sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: sl@0: // sl@0: r = HcrSimTest.FindSettings(id.iCat, 1, &elid, &type, &len); sl@0: if (aExpectedErrorCode == KErrNotFound) sl@0: { sl@0: test_Equal(0, r); sl@0: } sl@0: else sl@0: { sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: sl@0: // sl@0: r = HcrSimTest.FindSettings(id.iCat, 1, 0, 0, &elid, &type, &len); sl@0: if (aExpectedErrorCode == KErrNotFound) sl@0: { sl@0: test_Equal(0, r); sl@0: } sl@0: else sl@0: { sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: } sl@0: { sl@0: SSettingId settingid; sl@0: settingid.iCat = id.iCat; sl@0: settingid.iKey = id.iKey; sl@0: sl@0: TInt32 val; sl@0: TInt err; sl@0: TSettingType type; sl@0: TInt i; sl@0: sl@0: for(i = 0; i < 5; ++i) sl@0: { sl@0: // test parameter combinations where aIds[], aValues[], aErrors[] are NULL sl@0: r = HcrSimTest.GetWordSettings((i==1)?0:1, (i==2)?NULL:&settingid, (i==3)?NULL:&val, &type, (i==4)?NULL:&err); sl@0: if (aExpectedErrorCode != KErrNotFound) sl@0: { sl@0: // HCR did not initialise properly - HCR will not bother checking validity of arguments sl@0: test_Equal(aExpectedErrorCode, r); sl@0: } sl@0: else if (i > 0) sl@0: { sl@0: // One of the arguments is invalid sl@0: test_Equal(KErrArgument, r); sl@0: } sl@0: else sl@0: { sl@0: // Arguments are fine but element does not exist sl@0: test_Equal(0, r); sl@0: } sl@0: } sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: void HcrSimTestApiTests(SSettingC* aRepository, TUint aNumberOfSettings) sl@0: { sl@0: if (aRepository && aNumberOfSettings > 0) sl@0: { sl@0: HcrSimGetSettings(aRepository, aNumberOfSettings); sl@0: HcrSimGetSettingsNegative(aRepository, aNumberOfSettings); sl@0: HcrSimSettingProperties(aRepository, aNumberOfSettings); sl@0: HcrSimMultipleGet(aRepository, aNumberOfSettings); sl@0: HcrSimNumSettingsInCategory(aRepository, aNumberOfSettings); sl@0: HcrSimFindSettingsCategory(aRepository, aNumberOfSettings); sl@0: HcrSimFindSettingsPattern(aRepository, aNumberOfSettings); sl@0: sl@0: HcrSimFindSettingsCategoryNegative(aRepository, aNumberOfSettings); sl@0: HcrSimFindSettingsPatternNegative(aNumberOfSettings); sl@0: if(gHcrThread == KSimOwnThread) sl@0: HcrSimFindSettingsPatternMemAllocFails(aNumberOfSettings); sl@0: } sl@0: sl@0: HcrSimApiNegative(KErrNotFound, KTestInvalidCategory, KTestInvalidSettingId); sl@0: HcrSimApiNegative(KErrNotFound, KTestInvalidCategory, 1); sl@0: } sl@0: sl@0: void HcrPslTests(const TDesC& aDriver) sl@0: { sl@0: test.Next(_L("PSL tests")); sl@0: test.Start(_L("Load Device Driver")); sl@0: test.Printf(_L("%S\n"), &aDriver); sl@0: TInt r; sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: if (r == KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("Unload Device Driver and load it again\n")); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: } sl@0: else sl@0: { sl@0: test_KErrNone(r); sl@0: } sl@0: sl@0: test.Next(_L("Open test channel")); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Fail PSL object creation")); sl@0: r = HcrSimTest.InitExtension(ETestVariantObjectCreateFail); sl@0: test_Equal(KErrNoMemory, r); sl@0: HcrSimApiNegative(KErrNotReady, 1, 1); sl@0: sl@0: test.Next(_L("Fail PSL initialisation")); sl@0: r = HcrSimTest.InitExtension(ETestInitialisationFail); sl@0: test_Equal(KErrBadPower, r); // the random error code used in the test PSL sl@0: HcrSimApiNegative(KErrNotReady, 1, 1); sl@0: sl@0: test.Next(_L("PSL's GetCompiledRepositoryAddress negative tests")); sl@0: r = HcrSimTest.InitExtension(ETestNullRepositoryKErrNone); // *** Null Repository but returns KErrNone sl@0: test_Equal(KErrArgument, r); sl@0: sl@0: test.Next(_L("PSL's GetCompiledRepositoryAddress return wrong error code")); sl@0: r = HcrSimTest.InitExtension(ETestBadErrorCode); // *** Null Repository but returns KErrNone sl@0: test_Equal(KErrCommsParity, r); sl@0: sl@0: test.Next(_L("Close test channel and unload device driver")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: test.End(); sl@0: } sl@0: sl@0: void HcrSimTests(const TDesC& aDriver) sl@0: { sl@0: test.Next(_L("HCR Simulator tests")); sl@0: test.Start(_L("Load Device Driver")); sl@0: test.Printf(_L("%S\n"), &aDriver); sl@0: TInt r; sl@0: sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: if (r == KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("Unload Device Driver and load it again\n")); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: } sl@0: else sl@0: { sl@0: test_KErrNone(r); sl@0: } sl@0: sl@0: test.Next(_L("Open test channel")); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: HcrSimApiNegative(KErrNotReady, 1, 1); sl@0: sl@0: test.Next(_L("Initialise HCR")); sl@0: r = HcrSimTest.InitExtension(); sl@0: test_KErrNone(r); sl@0: sl@0: //Initialize static variable with the right HCR client type sl@0: if(aDriver.Compare(KTestHcrSimOwn) == 0) sl@0: gHcrThread = KSimOwnThread; sl@0: else if(aDriver.Compare(KTestHcrSimClient) == 0) sl@0: gHcrThread = KSimClientThread; sl@0: else sl@0: test(EFalse); sl@0: sl@0: test.Next(_L("Compiled")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList, sizeof(SettingsList) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Compiled+File")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestFileRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList2, sizeof(SettingsList2) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Compiled+File+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestNandRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList3, sizeof(SettingsList3) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Compiled+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList4, sizeof(SettingsList4) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Compiled+Empty+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestEmpty, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList4, sizeof(SettingsList4) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: // Reload device driver without a compiled repository this time sl@0: test.Next(_L("Reload Device Driver")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(ETestNullRepository); // *** The NULL Repository *** sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("NULL+File")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList7, sizeof(SettingsList7) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("NULL+File+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestNandRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList6, sizeof(SettingsList6) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("NULL+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList5, sizeof(SettingsList5) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Reload Device Driver")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(ETestEmptyRepository); // *** The Empty Repository *** sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Empty+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestNandRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList5, sizeof(SettingsList5) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Empty+File+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestFileRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList6, sizeof(SettingsList6) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Empty+File")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList7, sizeof(SettingsList7) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Empty+File+Empty")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestEmpty, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList7, sizeof(SettingsList7) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("No Repository (Empty)")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(NULL, 0); sl@0: test.End(); sl@0: sl@0: test.Next(_L("All Repositories Empty")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestEmpty, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestEmpty, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(NULL, 0); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Reload Device Driver")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(ETestIgnoreCoreImgRepository); // *** Ignore Core Image Repository *** sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Compiled+File(Ignored)+Nand")); // Should be same as Compiled+Nand sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestNandRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: HcrSimTestApiTests(SettingsList4, sizeof(SettingsList4) / sizeof(SSettingC)); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Reload Device Driver (Corrupt1)")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(ETestCorruptRepository1); // *** Repository not ordered *** sl@0: #ifdef _DEBUG sl@0: test_Equal(KErrCorrupt, r); sl@0: #else sl@0: test_KErrNone(r); sl@0: #endif // _DEBUG sl@0: sl@0: test.Next(_L("Reload Device Driver (Corrupt2)")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(ETestCorruptRepository2); // *** Repository with duplicates *** sl@0: #ifdef _DEBUG sl@0: test_Equal(KErrAlreadyExists, r); sl@0: #else sl@0: test_KErrNone(r); sl@0: #endif // _DEBUG sl@0: sl@0: test.Next(_L("Reload Device Driver (NULL ordered list)")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(ETestNullOrderedList); // *** Repository where iOrderedSettingList==NULL *** sl@0: #ifdef _DEBUG sl@0: test_Equal(KErrNotFound, r); sl@0: #else sl@0: test_KErrNone(r); sl@0: #endif // _DEBUG sl@0: sl@0: test.Next(_L("Reload Device Driver (Default)")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(); // *** Default Repository *** sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Compiled+Corrupt1+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestCorrupt1, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestNandRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_Equal(KErrCorrupt, r); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Compiled+Corrupt2+Nand")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestCorrupt2, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_Equal(KErrAlreadyExists, r); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Compiled+File+Corrupt1")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestFileRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestCorrupt1, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_Equal(KErrCorrupt, r); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Compiled+File+Corrupt2")); sl@0: test.Start(_L("Initialisation")); sl@0: r = HcrSimTest.SwitchRepository(KTestCorrupt2, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_Equal(KErrAlreadyExists, r); sl@0: test.End(); sl@0: sl@0: test.Next(_L("Close test channel and unload device driver")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: test.End(); sl@0: } sl@0: sl@0: void RomHeaderTests() sl@0: { sl@0: test.Next(_L("Rom Header")); sl@0: #ifdef __WINS__ sl@0: test.Printf(_L("Not available on the emulator.\n")); sl@0: #else sl@0: const TRomHeader* romheader = (TRomHeader*) UserSvr::RomHeaderAddress(); sl@0: test.Printf(_L("HCR File Address: %08x\n"), romheader->iHcrFileAddress); sl@0: test(romheader->iHcrFileAddress); sl@0: if (romheader->iPageableRomStart) sl@0: { sl@0: // If this is a paged ROM, HCR file must be in the unpaged area sl@0: test_Compare(romheader->iRomBase + romheader->iPageableRomStart, >, romheader->iHcrFileAddress); sl@0: } sl@0: #endif // __WINS__ sl@0: } sl@0: sl@0: void HcrRealSettingDiscovery() sl@0: { sl@0: test.Next(_L("Setting Discovery")); sl@0: TInt r; sl@0: TCategoryUid cat; sl@0: test.Printf(_L("Category Element Type Len Value\n")); sl@0: test.Printf(_L("--------------------------------------------------\n")); sl@0: for (cat = KHCRUID_ALLOCATED_MIN; cat <= KHCRUID_ALLOCATED_MAX; cat++) sl@0: { sl@0: TInt nosettings; sl@0: nosettings = HcrSimTest.FindNumSettingsInCategory(cat); sl@0: test_Compare(0, <=, nosettings); sl@0: if (nosettings > 0) sl@0: { sl@0: TElementId* elids; sl@0: TSettingType* types; sl@0: TUint16* lens; sl@0: elids = (TElementId*) User::Alloc(nosettings * sizeof(TElementId)); sl@0: test_NotNull(elids); sl@0: types = (TSettingType*) User::Alloc(nosettings * sizeof(TSettingType)); sl@0: test_NotNull(types); sl@0: lens = (TUint16*) User::Alloc(nosettings * sizeof(TUint16)); sl@0: test_NotNull(lens); sl@0: r = HcrSimTest.FindSettings(cat, nosettings, elids, types, lens); sl@0: test_Equal(nosettings, r); sl@0: sl@0: TInt i; sl@0: for (i = 0; i < nosettings; i++) sl@0: { sl@0: TSettingId id(cat, *(elids + i)); sl@0: test.Printf(_L("%08x %08x %08x %04x "), cat, *(elids + i), *(types + i), *(lens + i)); sl@0: switch (*(types + i)) sl@0: { sl@0: case ETypeInt32: sl@0: { sl@0: TInt32 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%08x"), val); sl@0: break; sl@0: } sl@0: case ETypeInt16: sl@0: { sl@0: TInt16 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%04x"), val); sl@0: break; sl@0: } sl@0: case ETypeInt8: sl@0: { sl@0: TInt8 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%02x"), val); sl@0: break; sl@0: } sl@0: case ETypeBool: sl@0: { sl@0: TBool val; sl@0: r = HcrSimTest.GetBool(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%b"), val ? 1 : 0); sl@0: break; sl@0: } sl@0: case ETypeUInt32: sl@0: { sl@0: TUint32 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%08x"), val); sl@0: break; sl@0: } sl@0: case ETypeUInt16: sl@0: { sl@0: TUint16 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%04x"), val); sl@0: break; sl@0: } sl@0: case ETypeUInt8: sl@0: { sl@0: TUint8 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%02x"), val); sl@0: break; sl@0: } sl@0: case ETypeLinAddr: sl@0: { sl@0: TLinAddr val; sl@0: r = HcrSimTest.GetLinAddr(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%08x"), val); sl@0: break; sl@0: } sl@0: case ETypeBinData: sl@0: { sl@0: TBuf8 dval; sl@0: TUint8* pval; sl@0: pval = (TUint8*) User::Alloc(*(lens + i)); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetData(id, dval); sl@0: test_KErrNone(r); sl@0: test_Equal(*(lens + i), dval.Length()); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetData(id, *(lens + i), pval, actuallength); sl@0: test_KErrNone(r); sl@0: test_Equal(*(lens + i), actuallength); sl@0: // sl@0: TInt j; sl@0: for (j = 0; j < 6 && j < dval.Length(); j++) sl@0: { sl@0: test.Printf(_L("%02x "), dval[j]); sl@0: } sl@0: sl@0: // sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeText8: sl@0: { sl@0: TBuf8 dval; sl@0: TText8* pval; sl@0: pval = (TText8*) User::Alloc(*(lens + i)); sl@0: test_NotNull(pval); sl@0: // sl@0: r = HcrSimTest.GetString(id, dval); sl@0: test_KErrNone(r); sl@0: test_Equal(*(lens + i), dval.Length()); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetString(id, *(lens + i), pval, actuallength); sl@0: test_KErrNone(r); sl@0: test_Equal(*(lens + i), actuallength); sl@0: // sl@0: TInt j; sl@0: for (j = 0; j < 15 && j < dval.Length(); j++) sl@0: { sl@0: test.Printf(_L("%c "), dval[j]); sl@0: } sl@0: // sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeArrayInt32: sl@0: { sl@0: TInt32* pval; sl@0: pval = (TInt32*) User::Alloc(*(lens + i)); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, *(lens + i), pval, actuallength); sl@0: test_KErrNone(r); sl@0: // sl@0: test_Equal(*(lens + i), actuallength); sl@0: // sl@0: TUint j; sl@0: for (j = 0; j < 2 && j < actuallength / sizeof(TInt32); j++) sl@0: { sl@0: test.Printf(_L("%08x "), pval[0]); sl@0: } sl@0: // sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeArrayUInt32: sl@0: { sl@0: TUint32* pval; sl@0: pval = (TUint32*) User::Alloc(*(lens + i)); sl@0: test_NotNull(pval); sl@0: // sl@0: TUint16 actuallength; sl@0: r = HcrSimTest.GetArray(id, *(lens + i), pval, actuallength); sl@0: test_KErrNone(r); sl@0: // sl@0: TUint j; sl@0: for (j = 0; j < 2 && j < actuallength / sizeof(TUint32); j++) sl@0: { sl@0: test.Printf(_L("%08x "), pval[0]); sl@0: } sl@0: // sl@0: test_Equal(*(lens + i), actuallength); sl@0: User::Free(pval); sl@0: break; sl@0: } sl@0: case ETypeInt64: sl@0: { sl@0: TInt64 val; sl@0: r = HcrSimTest.GetInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%016lx"), val); sl@0: sl@0: break; sl@0: } sl@0: case ETypeUInt64: sl@0: { sl@0: TUint64 val; sl@0: r = HcrSimTest.GetUInt(id, val); sl@0: test_KErrNone(r); sl@0: test.Printf(_L("%016lx"), val); sl@0: break; sl@0: } sl@0: default: sl@0: test(EFalse); sl@0: } sl@0: test.Printf(_L("\n")); sl@0: } sl@0: User::Free(elids); sl@0: User::Free(types); sl@0: User::Free(lens); sl@0: } sl@0: } sl@0: } sl@0: void HcrRealRetrieveKernelExtensionTestResults() sl@0: { sl@0: test.Next(_L("Retrieve kernel extension test results")); sl@0: TInt r; sl@0: TInt kextline; sl@0: TInt kexterror; sl@0: r = HcrSimTest.GetInitExtensionTestResults(kextline, kexterror); sl@0: test_KErrNone(r); sl@0: if (kextline == -1) sl@0: { sl@0: test.Printf(_L("Test not run\n")); sl@0: } sl@0: else if (kextline == 0) sl@0: { sl@0: test.Printf(_L("Test passed\n")); sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("Test kernel extension error at line %d (error %d)\n"), kextline, kexterror); sl@0: test(EFalse); sl@0: } sl@0: } sl@0: sl@0: void HcrRealTests(const TDesC& aDriver) sl@0: { sl@0: test.Next(_L("HCR real tests")); sl@0: test.Start(_L("Load LDD")); sl@0: test.Printf(_L("%S\n"), &aDriver); sl@0: TInt r; sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: if (r == KErrNotFound) sl@0: { sl@0: test.Printf(_L("%S not found. Skipping tests.\n"), &aDriver); sl@0: } sl@0: else sl@0: { sl@0: if (r == KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("Unload Device Driver and load it again\n")); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: } sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: // sl@0: HcrRealRetrieveKernelExtensionTestResults(); sl@0: HcrRealSettingDiscovery(); sl@0: sl@0: // Initialize static variable with the right HCR client type sl@0: if(aDriver.Compare(KTestHcrRealOwn) == 0) sl@0: gHcrThread = KSimOwnThread; sl@0: else if(aDriver.Compare(KTestHcrRealClient) == 0) sl@0: gHcrThread = KSimClientThread; sl@0: else sl@0: test(EFalse); sl@0: // sl@0: TBool smr; sl@0: TBool smrrep; sl@0: r = HcrSimTest.HasRepositoryInSmr(smr, smrrep); sl@0: test_KErrNone(r); sl@0: if (smrrep) sl@0: { sl@0: // File + NAND sl@0: HcrSimTestApiTests(SettingsList6, sizeof(SettingsList6) / sizeof(SSettingC)); sl@0: } sl@0: else sl@0: { sl@0: // File sl@0: HcrSimTestApiTests(SettingsList7, sizeof(SettingsList7) / sizeof(SSettingC)); sl@0: } sl@0: // sl@0: test.Next(_L("Close LDD")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: } sl@0: test.End(); sl@0: } sl@0: sl@0: void HcrSimBenchmarkTests(const TDesC& aDriver) sl@0: { sl@0: test.Next(_L("Simulated HCR Benchmark")); sl@0: test.Start(_L("Initialisation")); sl@0: test.Printf(_L("%S\n"), &aDriver); sl@0: TInt r; sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: if (r == KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("Unload Device Driver and load it again\n")); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: } sl@0: else sl@0: { sl@0: test_KErrNone(r); sl@0: } sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.InitExtension(); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Get Setting")); sl@0: // Timings in ms sl@0: TUint32 int1 = 0; sl@0: TUint32 int1000 = 0; sl@0: TUint32 array1 = 0; sl@0: TUint32 array1000 = 0; sl@0: TUint32 des1 = 0; sl@0: TUint32 des1000 = 0; sl@0: TUint32 fns = 0; sl@0: TUint32 fs = 0; sl@0: TUint32 gts = 0; sl@0: TUint32 gws = 0; sl@0: _LIT(KTestBenchLine, "%-6d %-6d %-6d %-6d %-6d %-6d %-6d %-6d %-6d %-6d\n"); sl@0: test.Printf(_L("HCR Int1 Int1000 Arr1 Arr1000 Des1 Des1000 FNS FS GTS GWS\n")); sl@0: // Default configuration sl@0: TSettingId idint1(1, 1); sl@0: TSettingId idstring1(KTestCategories[2], 0x6000); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1, int1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1, array1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1, des1)); sl@0: test.Printf(_L("C?? ")); sl@0: test.Printf(KTestBenchLine, int1, int1000, array1, array1000, des1, des1000, fns, fs, gts, gws); sl@0: sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1, int1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1, array1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1, des1)); sl@0: test.Printf(_L("C__ ")); sl@0: test.Printf(KTestBenchLine, int1, int1000, array1, array1000, des1, des1000, fns, fs, gts, gws); sl@0: // sl@0: TSettingId idint1000(KTestBenchmarkCategoryId, 1000); sl@0: TSettingId idstring1000(KTestBenchmarkCategoryId, 1001); sl@0: r = HcrSimTest.SwitchRepository(KTestMegaLarge1, HCRInternal::ECoreRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1, int1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1000, int1000)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1, array1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1000, array1000)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1, des1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1000, des1000)); sl@0: sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory, HcrSimTest.BenchmarkFindNumSettingsInCategory(KTestBenchmarkCategoryId, fns)); sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory, HcrSimTest.BenchmarkFindSettings(KTestBenchmarkCategoryId, fs)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetTypeAndSize(idstring1000, gts)); sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory - 1, HcrSimTest.BenchmarkGetWordSettings(KTestBenchmarkCategoryId, gws)); sl@0: sl@0: test.Printf(_L("CF_ ")); sl@0: test.Printf(KTestBenchLine, int1, int1000, array1, array1000, des1, des1000, fns, fs, gts, gws); sl@0: // sl@0: r = HcrSimTest.SwitchRepository(KTestMegaLarge2, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1, int1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1000, int1000)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1, array1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1000, array1000)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1, des1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1000, des1000)); sl@0: sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory, HcrSimTest.BenchmarkFindNumSettingsInCategory(KTestBenchmarkCategoryId, fns)); sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory, HcrSimTest.BenchmarkFindSettings(KTestBenchmarkCategoryId, fs)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetTypeAndSize(idstring1000, gts)); sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory - 1, HcrSimTest.BenchmarkGetWordSettings(KTestBenchmarkCategoryId, gws)); sl@0: sl@0: test.Printf(_L("CFN ")); sl@0: test.Printf(KTestBenchLine, int1, int1000, array1, array1000, des1, des1000, fns, fs, gts, gws); sl@0: // sl@0: r = HcrSimTest.SwitchRepository(KTestClearRepos, HCRInternal::EOverrideRepos); sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.CheckIntegrity(); sl@0: test_KErrNone(r); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1, int1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingInt(idint1000, int1000)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1, array1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingArray(idstring1000, array1000)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1, des1)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetSettingDes(idstring1000, des1000)); sl@0: sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory, HcrSimTest.BenchmarkFindNumSettingsInCategory(KTestBenchmarkCategoryId, fns)); sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory, HcrSimTest.BenchmarkFindSettings(KTestBenchmarkCategoryId, fs)); sl@0: test_KErrNone(HcrSimTest.BenchmarkGetTypeAndSize(idstring1000, gts)); sl@0: test_Equal(KTestBenchmarkNumberOfSettingsInCategory - 1, HcrSimTest.BenchmarkGetWordSettings(KTestBenchmarkCategoryId, gws)); sl@0: sl@0: test.Printf(_L("C_N ")); sl@0: test.Printf(KTestBenchLine, int1, int1000, array1, array1000, des1, des1000, fns, fs, gts, gws); sl@0: sl@0: test.Next(_L("Unload LDD")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: test.End(); sl@0: } sl@0: sl@0: void HcrRealBenchmarkTests(const TDesC& aDriver) sl@0: { sl@0: TInt r; sl@0: test.Next(_L("Real HCR Benchmark")); sl@0: test.Start(_L("Initialisation")); sl@0: test.Printf(_L("%S\n"), &aDriver); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: if (r == KErrNotFound) sl@0: { sl@0: test.Printf(_L("%S not found. Skipping tests.\n"), &aDriver); sl@0: } sl@0: else sl@0: { sl@0: if (r == KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("Unload Device Driver and load it again\n")); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: r = User::LoadLogicalDevice(aDriver); sl@0: } sl@0: test_KErrNone(r); sl@0: r = HcrSimTest.Open(aDriver); sl@0: test_KErrNone(r); sl@0: // sl@0: test.Next(_L("Close LDD")); sl@0: HcrSimTest.Close(); sl@0: r = User::FreeLogicalDevice(aDriver); sl@0: test_KErrNone(r); sl@0: } sl@0: test.End(); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: test.Title(); sl@0: test.Start(_L("HCR Test Suite")); sl@0: sl@0: sl@0: //Order the the test lists in descend(the setting with the smallest sl@0: //setting Id is first) sl@0: TLinearOrder order(CompareEntries); sl@0: //Build the ordered ids arrays sl@0: RArray rSettingsList(sizeof(SSettingC), SettingsList, sl@0: sizeof(SettingsList)/sizeof(SettingsList[0])); sl@0: sl@0: rSettingsList.Sort(order); sl@0: sl@0: RArray rSettingsList2(sizeof(SSettingC), SettingsList2, sl@0: sizeof(SettingsList2)/sizeof(SettingsList2[0])); sl@0: rSettingsList2.Sort(order); sl@0: sl@0: RArray rSettingsList3(sizeof(SSettingC), SettingsList3, sl@0: sizeof(SettingsList3)/sizeof(SettingsList3[0])); sl@0: rSettingsList3.Sort(order); sl@0: sl@0: RArray rSettingsList4(sizeof(SSettingC), SettingsList4, sl@0: sizeof(SettingsList4)/sizeof(SettingsList4[0])); sl@0: rSettingsList4.Sort(order); sl@0: sl@0: RArray rSettingsList5(sizeof(SSettingC), SettingsList5, sl@0: sizeof(SettingsList5)/sizeof(SettingsList5[0])); sl@0: rSettingsList5.Sort(order); sl@0: sl@0: RArray rSettingsList6(sizeof(SSettingC), SettingsList6, sl@0: sizeof(SettingsList6)/sizeof(SettingsList6[0])); sl@0: rSettingsList6.Sort(order); sl@0: sl@0: RArray rSettingsList7(sizeof(SSettingC), SettingsList7, sl@0: sizeof(SettingsList7)/sizeof(SettingsList7[0])); sl@0: rSettingsList7.Sort(order); sl@0: sl@0: sl@0: //Functional API test sl@0: RomHeaderTests(); sl@0: HcrRealTests(KTestHcrRealOwn); sl@0: HcrRealTests(KTestHcrRealClient); sl@0: HcrPslTests(KTestHcrSimOwn); sl@0: HcrPslTests(KTestHcrSimClient); sl@0: HcrSimTests(KTestHcrSimOwn); sl@0: HcrSimTests(KTestHcrSimClient); sl@0: sl@0: sl@0: //Benchmark tests sl@0: HcrSimBenchmarkTests(KTestHcrSimOwn); sl@0: HcrSimBenchmarkTests(KTestHcrSimClient); sl@0: HcrRealBenchmarkTests(KTestHcrRealOwn); sl@0: HcrRealBenchmarkTests(KTestHcrRealClient); sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return KErrNone; sl@0: }