sl@0: // Copyright (c) 2006-2010 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 "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: // sl@0: sl@0: #include "cdtest.h" sl@0: #include "hashing.h" sl@0: #include "common.h" sl@0: #include sl@0: sl@0: //Constants taken from SqlSrvConfig.h sl@0: #ifdef __WINSCW__ sl@0: const TInt KDefaultSoftHeapLimitKb = 1024; sl@0: #else sl@0: const TInt KDefaultSoftHeapLimitKb = 8192; sl@0: #endif sl@0: sl@0: // Includes any code required for 'Code-Driven' testing, generally tests sl@0: // that cannot be data-driven (or not completely). sl@0: sl@0: CSQLCDT::~CSQLCDT() sl@0: { sl@0: } sl@0: sl@0: CSQLCDT::CSQLCDT() sl@0: { sl@0: SetTestStepName(KSQLCDT); sl@0: } sl@0: sl@0: sl@0: // Look at 'arg' and call whichever function is required. sl@0: void CSQLCDT::ResolveTestFunctionL(const TDesC &acfgblk, const TInt acnnum, sl@0: const TPtrC &arg ) sl@0: { sl@0: _LIT(KTestFunction, "cdtest::ResolveTestFunction"); sl@0: INFO_PRINTF3(_L("In %S, arg is %S"), &KTestFunction, &arg); sl@0: sl@0: if(arg == _L("WriteBigTable")) sl@0: WriteBigTableL(acfgblk, acnnum); sl@0: else if(arg == _L("ReadBigTable")) sl@0: ReadBigTableL(acfgblk); sl@0: sl@0: // This assumes that a ParameterIndex and ColumnIndex call has been sl@0: // set up previously - the apidxs/apicxs array access below will sl@0: // certainly PANIC if you haven't done the require preparation.. sl@0: else if(arg == _L("CopyCellsUsingStreams")) sl@0: CopyCellsUsingStreamsL(acfgblk); sl@0: else if(arg == _L("WriteIntsToStream")) sl@0: WriteIntsToStream(acfgblk, acnnum); sl@0: else if(arg == _L("NearFillDisk")) sl@0: NearFillDisk(acfgblk); sl@0: else if(arg == _L("ScalarFullSelect")) sl@0: ScalarFullSelectL(acfgblk, acnnum); sl@0: else if(arg == _L("FilesDifferBySize")) sl@0: FilesDifferBySize(acfgblk, acnnum); sl@0: else if(arg == _L("SecurityPolicyCheck")) sl@0: SecurityPolicyCheck(acfgblk, acnnum); sl@0: else if(arg == _L("CollationTest")) sl@0: CollationTest(acfgblk, acnnum); sl@0: sl@0: else User::Panic(_L("Unknown Function"), 42); sl@0: } sl@0: sl@0: // ------------------------------------------------------------------------ sl@0: // sl@0: // There's some hardwired nastiness in here - which we might be able to remove sl@0: // if we can restructure the code (with the parameter index array as a sl@0: // member variable in sqlfn), but until we can get reporting (INFO_PRINTF etc) sl@0: // working in new objects that isn't going to happen. sl@0: // There should have been a sl@0: // 'Insert into t(what, ever, whatever) values (:FInt, :FReal, :FText)' sl@0: // ... before this is called. Those on the right are the nasty hardwiring, sl@0: // and should correspond to integer, real, and text fields. sl@0: void CSQLCDT::WriteBigTableL(const TDesC &acfgblk, TInt acnnum ) sl@0: { sl@0: _LIT(KTestFunction, "WriteBigTable"); sl@0: sl@0: // Parameters for the loop. sl@0: TInt low=1, high=10, step=1, experr = KErrNone; sl@0: TReal mult; TPtrC text, experrS; sl@0: FromConfig(KTestFunction, acfgblk, _L("LowCount"), low); sl@0: FromConfig(KTestFunction, acfgblk, _L("HighCount"), high); sl@0: FromConfig(KTestFunction, acfgblk, _L("CountStep"), step); sl@0: FromConfig(KTestFunction, acfgblk, _L("Multiplier"), mult); sl@0: FromConfig(KTestFunction, acfgblk, _L("Text"), text); sl@0: if( FromConfig(KTestFunction, acfgblk, _L("EventuallyExpectedError"), experrS) ) sl@0: experr = ErrStringToEnum(experrS); sl@0: sl@0: // First work out if out text is actually a filename.. sl@0: TInt textfromfile=0; sl@0: textfromfile = BaflUtils::FileExists(irfs, text); sl@0: sl@0: // Ahoy! Nasty hardwiring ahead! sl@0: TInt pidxi = ParamIndex(_L(":FInt"), acfgblk, 0 ); sl@0: TInt pidxr = ParamIndex(_L(":FReal"), acfgblk, 0 ); sl@0: TInt pidxt = ParamIndex(_L(":FText"), acfgblk, 0 ); sl@0: sl@0: TInt i; sl@0: for(i=low ; i<=high ; i+=step) sl@0: { sl@0: TInt err=KErrNone; sl@0: // Can use a stream write for speed to write the text to the disk. Don't sl@0: // make the file too big or a memory error (server side) will result. sl@0: if(textfromfile) sl@0: SWBindTextL(pidxt, text, acfgblk, acnnum); sl@0: else sl@0: { sl@0: err = isqlst.BindText(pidxt, text); sl@0: ReportOnError( KTestFunction, _L("BindText"), acfgblk, acnnum, err ); sl@0: } sl@0: sl@0: TReal tr = i * mult; sl@0: err = isqlst.BindInt(pidxi, i); sl@0: ReportOnError( KTestFunction, _L("BindInt"), acfgblk, acnnum, err ); sl@0: err = isqlst.BindReal(pidxr, tr); sl@0: ReportOnError( KTestFunction, _L("BindReal"), acfgblk, acnnum, err); sl@0: sl@0: err = isqlst.Exec(); sl@0: if((err != KErrNone) && (err == experr)) sl@0: { sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: INFO_PRINTF3(_L("Loop dropped out with expected error %S, i=%d"), &experrS, i ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: break; sl@0: } sl@0: else if(err < 0) // <0 a real error we weren't expecting. sl@0: { sl@0: ReportOnError( KTestFunction, _L("Exec"), acfgblk, acnnum, err ); sl@0: INFO_PRINTF3(_L("%S: counter i is %d"), &KTestFunction, i ); sl@0: break; sl@0: } sl@0: sl@0: err = isqlst.Reset(); sl@0: ReportOnError( KTestFunction, _L("Reset"), acfgblk, acnnum, err ); sl@0: acnnum++; sl@0: } sl@0: isqlst.Close(); sl@0: sl@0: return; sl@0: } sl@0: void CSQLCDT::ReadBigTableL(const TDesC &acfgblk) sl@0: { sl@0: _LIT(KTestFunction, "ReadBigTable"); sl@0: sl@0: // Parameters for the loop. sl@0: TInt low=1, high=10, step=1, err; sl@0: TReal mult; TPtrC text; sl@0: FromConfig(KTestFunction, acfgblk, _L("LowCount"), low); sl@0: FromConfig(KTestFunction, acfgblk, _L("HighCount"), high); sl@0: FromConfig(KTestFunction, acfgblk, _L("CountStep"), step); sl@0: FromConfig(KTestFunction, acfgblk, _L("Multiplier"), mult); sl@0: FromConfig(KTestFunction, acfgblk, _L("Text"), text); sl@0: sl@0: // First work out if out text is actually a filename.. sl@0: TInt textfromfile=0; sl@0: textfromfile = BaflUtils::FileExists(irfs, text); sl@0: sl@0: // Ahoy! Nasty hardwiring ahead! sl@0: TInt cidxi = ColumnIndex(_L("Someint"), acfgblk, 0 ); sl@0: TInt cidxr = ColumnIndex(_L("Somereal"), acfgblk, 0 ); sl@0: TInt cidxt = ColumnIndex(_L("Sometext"), acfgblk, 0 ); sl@0: sl@0: for(TInt i=low ; i<=high ; i+=step) sl@0: { sl@0: TReal tr = i * mult; sl@0: // INFO_PRINTF3(_L("CFGBLK: %S COUNT: %d"), &acfgblk, i); sl@0: sl@0: TInt cint = isqlst.ColumnInt(cidxi); sl@0: TReal creal = isqlst.ColumnReal(cidxr); sl@0: if((cint != i) || (creal != tr)) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: ColumnInt gave %d, wanted %d"), sl@0: &KTestFunction, cint, i ); sl@0: ERR_PRINTF4(_L("%S: ColumnReal gave %f, wanted %f"), sl@0: &KTestFunction, creal, tr ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: break; sl@0: } sl@0: // Now check the text.. sl@0: if(textfromfile) sl@0: SRColumnTextL(cidxt, text, acfgblk, -1 ); sl@0: else sl@0: ColumnTextL(cidxt, text, acfgblk, -1 ); sl@0: if(isqlst.Next()==KSqlAtEnd) sl@0: { sl@0: // This expected error was for *writing* the table - we don't sl@0: // get an error reading it back, just KSqlAtEnd. But lets assume sl@0: // that an expected error on write implies a short table and sl@0: // so no failure if we get KSqlAtEnd early. sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: INFO_PRINTF3(_L("%S: Next gave KSqlAtEnd, i is %d"), sl@0: &KTestFunction, i ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if( (err = isqlst.Next()) != KSqlErrMisuse ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF3(_L("%S: Next gave %d, is there some table left? Expected KSqlErrMisuse"), &KTestFunction, err ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: return; sl@0: } sl@0: sl@0: sl@0: // Copy a single cell in a table using streams. We'll use the BindBinary sl@0: // and ColumnBinary methods of RSqlParamWriteStream and RSqlColumnReadStream sl@0: // respectively. Don't try to copy integers or reals, as the API spec sl@0: // says very clearly in a table, converting most of these to Binary sl@0: // gives KNullDesc8. sl@0: void CSQLCDT::CopyCellsUsingStreamsL(const TDesC &acfgblk) sl@0: { sl@0: _LIT(KTestFunction, "CopyCellUsingStreams"); sl@0: sl@0: // We only have one RSqlStatement around, and we must have two - a sl@0: // source and destination, so lets get another one - we'll write to sl@0: // this. sl@0: RSqlStatement sqlst2; sl@0: sl@0: // The prepare statement used to add to the second table. sl@0: TPtrC prep; sl@0: FromConfig(KTestFunction, acfgblk, _L("PrepareStatement"), prep); sl@0: // The parameter name (e.g :freddy) in the above. sl@0: TPtrC paramname; sl@0: FromConfig(KTestFunction, acfgblk, _L("ParamName"), paramname); sl@0: sl@0: // Prepare and get pidx. sl@0: TInt err = sqlst2.Prepare(isqldb, prep); sl@0: TInt pidx = sqlst2.ParameterIndex(paramname); sl@0: sl@0: // Whilst we're reading sl@0: while(isqlst.Next() == KSqlAtRow) sl@0: { sl@0: // First lets find a cell to copy. This assumes there is a single sl@0: // column selected.. sl@0: // Set up where we're reading from. ColumnIndex will be zero. sl@0: // Obviously a prepare must already have been done. sl@0: RSqlColumnReadStream sqlr; sl@0: err = sqlr.ColumnText(isqlst, 0); sl@0: sl@0: // Read a cell from the database as a stream. Pass that stream to sl@0: // another stream, an RSqlParamWriteStream to copy the cell into sl@0: // another db. sl@0: sl@0: // Get our writable stream.. sl@0: RSqlParamWriteStream sqlw; sl@0: sl@0: // Set up where we're writing to. sl@0: err = sqlw.BindText(sqlst2, pidx); sl@0: sl@0: // Write. sl@0: sqlw.WriteL(sqlr); sl@0: sqlw.Close(); sl@0: err = sqlst2.Exec(); sl@0: err = sqlst2.Reset(); sl@0: } sl@0: sqlst2.Close(); sl@0: return; sl@0: } sl@0: sl@0: // Write to 32-bit signed integers to a stream (a cell in a table) until sl@0: // the write operation Leaves with a KErrNoMem. A 'prepare' statement sl@0: // must already have been run, and a parameterindex also. We assume sl@0: // that the parameterindex is zero. sl@0: // If the user wants to do an Exec and Reset, that's up to them. That sl@0: // would end up sticking a NULL into the current cell though. sl@0: void CSQLCDT::WriteIntsToStream(const TDesC &acfgblk, const TInt acnnum) sl@0: sl@0: { sl@0: _LIT(KTestFunction, "WriteIntsToStream"); sl@0: sl@0: // Get our writable stream.. sl@0: RSqlParamWriteStream sqlw; sl@0: // Find out how many integers to write.. sl@0: TInt count; sl@0: FromConfig(KTestFunction, acfgblk, _L("Count"), count); sl@0: if(count == -1) count = 2000000000; sl@0: sl@0: // Assume only one 'ParameterIndex' has been run.. sl@0: sqlw.BindBinary(isqlst,0); sl@0: sl@0: TInt i, leavecode; sl@0: for(i=0 ; i KMaxTUint32) sl@0: { sl@0: RFile64 fillDiskFile; sl@0: fname.Copy(atdu.Name()); sl@0: fname.Append(KFillDiskName); sl@0: fname.AppendNum(count); sl@0: fname.Append(KFillDiskExt); sl@0: sl@0: if( (err = fillDiskFile.Create(irfs, fname, EFileWrite)) != KErrNone ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: Failed to open RFile64 for file %S, err %d"), sl@0: &KTestFunction, &fname, err ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: return; sl@0: } sl@0: sl@0: if( (err = fillDiskFile.SetSize(KMaxTUint32)) != KErrNone ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: Failed on RFile64::SetSize for file %S, err %d"), sl@0: &KTestFunction, &fname, err ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: fillDiskFile.Close(); sl@0: return; sl@0: } sl@0: sl@0: fillDiskFile.Close(); sl@0: atowrite-=KMaxTUint32; sl@0: count++; sl@0: } sl@0: } sl@0: sl@0: // Create a file specified by 'FillFile' in the config and write to sl@0: // it until 'DiskFree' bytes remain. Note that because files use whole sl@0: // sectors (512/1024/2048/4096 or whatever bytes), that attempting to leave sl@0: // (e.g) 1023 bytes could result in 512 bytes remaining on a file system sl@0: // with 512 byte sectors, or zero bytes remaining if the sectors are bigger. sl@0: void CSQLCDT::NearFillDisk(const TDesC &acfgblk) sl@0: { sl@0: _LIT(KTestFunction, "NearFillDisk"); sl@0: sl@0: // What file should we use? Requires a full path. sl@0: TPtrC fillfile; sl@0: (void)FromConfig(KTestFunction, acfgblk, _L("FillFile"), fillfile); sl@0: irfs.Delete(fillfile); sl@0: sl@0: // Get the drive number. This method ignores trailing text. sl@0: // Probably wants upper case. sl@0: TDriveUnit tdu(fillfile); sl@0: sl@0: // Find out how much disk we want left.. sl@0: TInt free, err; sl@0: (void)FromConfig(KTestFunction, acfgblk, _L("DiskFree"), free); sl@0: sl@0: // Find out how much disk space currently remains.. sl@0: TVolumeInfo vol; sl@0: if((err = irfs.Volume(vol, tdu )) != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: Failed to get volume info for %S, err %d"), sl@0: &KTestFunction, &fillfile, err ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: return; sl@0: } sl@0: sl@0: // So how many bytes do we need to write? sl@0: TInt64 towrite = vol.iFree - free; sl@0: INFO_PRINTF4(_L("%S: Disk writing %Ld, free %Ld"), &KTestFunction, sl@0: towrite, vol.iFree ); sl@0: INFO_PRINTF3(_L("%S: free %Ld"), &KTestFunction, vol.iFree ); sl@0: INFO_PRINTF3(_L("%S: writing %Ld"), &KTestFunction, towrite ); sl@0: sl@0: if( towrite < 0 ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF3(_L("%S: Disk wanted remaining less than current(%Ld)"), sl@0: &KTestFunction, vol.iFree ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: return; sl@0: } sl@0: sl@0: //In case the disk is large (i.e >4G -1 bytes) we need another function to sl@0: //create more files to fill it sl@0: PrepareLargeDisk(acfgblk, tdu, towrite); sl@0: sl@0: // Get a file. sl@0: RFile64 myfile; sl@0: if( (err = myfile.Create(irfs, fillfile, EFileWrite)) != KErrNone ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: Failed to open RFile64 for file %S, err %d"), sl@0: &KTestFunction, &fillfile, err ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: return; sl@0: } sl@0: // Write it. sl@0: sl@0: // We seem to hit trouble if we just try to write 'towrite' bytes, so sl@0: // here we write 50% of them and check the remainder repeatedly until sl@0: // the right amount remains. Actually it is unlikely to be exactly the sl@0: // right amount - depending on sector sizes and other factors the sl@0: // remaining space tends to be a kilobyte or two less than requested. sl@0: // Obviously this is likely to be different between file system types, sl@0: // between hardware and emulator and so on. sl@0: sl@0: sl@0: TInt64 size = 0; sl@0: while(towrite > 0) sl@0: { sl@0: if(towrite < 1024) break; sl@0: TInt64 tow = towrite/2; sl@0: if(towrite < 4096) tow = towrite; sl@0: size += tow; sl@0: if( (err = myfile.SetSize(size)) != KErrNone ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: Failed on RFile64::SetSize for file %S, err %d"), sl@0: &KTestFunction, &fillfile, err ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: break; sl@0: } sl@0: err = irfs.Volume(vol, tdu ); sl@0: if(err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF3(_L("%S: 2-RFs::Volume() has failed, err=%d"), sl@0: &KTestFunction, err); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: break; sl@0: } sl@0: towrite = vol.iFree - free; sl@0: } sl@0: sl@0: err = irfs.Volume(vol, tdu ); sl@0: if(err != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF3(_L("%S: 3-RFs::Volume() has failed, err=%d"), sl@0: &KTestFunction, err); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: INFO_PRINTF3(_L("%S: Disk remaining is %Ld"), &KTestFunction, vol.iFree ); sl@0: myfile.Close(); sl@0: return; sl@0: } sl@0: sl@0: // This method exercises the TSqlScalarFullSelectQuery class, which is sl@0: // just a wrapper. Its methods expect a select statement whose result will sl@0: // be a single cell. Perhaps this should be in sqlfn.cpp. sl@0: void CSQLCDT::ScalarFullSelectL(const TDesC &acfgblk, const TInt acnnum) sl@0: sl@0: { sl@0: _LIT(KTestFunction, "ScalarFullSelect"); sl@0: sl@0: // Look for an integer called 'Use_SetNN'. sl@0: TInt useset; sl@0: TBuf conS(_L("Use_Set")); sl@0: conS.AppendNum(acnnum); sl@0: FromConfig(KTestFunction, acfgblk, conS, useset); sl@0: // Look for a string called 'MethodNN'. sl@0: TPtrC meth; sl@0: TBuf methS(_L("Method")); sl@0: methS.AppendNum(acnnum); sl@0: FromConfig(KTestFunction, acfgblk, methS, meth); sl@0: // Look for a string called 'StatementNN'. sl@0: TPtrC stmt; sl@0: TBuf stmtS(_L("Statement")); sl@0: stmtS.AppendNum(acnnum); sl@0: FromConfig(KTestFunction, acfgblk, stmtS, stmt); sl@0: // Convert the SQL statement to an UTF-8 version. sl@0: RBuf8 stmt8; sl@0: stmt8.Create(stmt.Length()); sl@0: stmt8.Copy(stmt); sl@0: CleanupClosePushL(stmt8); sl@0: sl@0: // Look for a string called 'ResultNN'. sl@0: TPtrC res; sl@0: TBuf resS(_L("Result")); sl@0: resS.AppendNum(acnnum); sl@0: FromConfig(KTestFunction, acfgblk, resS, res); sl@0: // We may want to convert the expected result to a real or int or something sl@0: TLex conv = res; sl@0: sl@0: // Ok, now create a TSqlScalarFullSelectQuery object. sl@0: TSqlScalarFullSelectQuery *asfs; sl@0: TSqlScalarFullSelectQuery one(isqldb); sl@0: TSqlScalarFullSelectQuery two; sl@0: two.SetDatabase(isqldb); sl@0: // Use one of the above objects. sl@0: asfs = useset ? &two : &one; sl@0: sl@0: // Get the action hash for this.. sl@0: CSQLSFSTEFAction *cs = new CSQLSFSTEFAction(); sl@0: TInt action = cs->GetNumFromString(meth); sl@0: switch(action) sl@0: { sl@0: case CSQLSFSTEFAction::ESFS_SelectIntL: sl@0: { sl@0: TInt actual; sl@0: if(i8bit) sl@0: actual = asfs->SelectIntL(stmt8); sl@0: else sl@0: actual = asfs->SelectIntL(stmt); sl@0: sl@0: TInt expected; sl@0: if (res.CompareF(_L("DEFAULT_SOFT_HEAP_LIMIT")) == 0) sl@0: { sl@0: expected = KDefaultSoftHeapLimitKb; sl@0: } sl@0: else sl@0: { sl@0: conv.Val(expected); sl@0: } sl@0: sl@0: if( actual != expected ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: SelectIntL gave %d, wanted %d"), sl@0: &KTestFunction, actual, expected); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: INFO_PRINTF3(_L("%S: SelectIntL gave %d, as expected"), sl@0: &KTestFunction, actual); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: } sl@0: break; sl@0: sl@0: case CSQLSFSTEFAction::ESFS_SelectInt64L: sl@0: { sl@0: TInt64 actual; sl@0: if(i8bit) sl@0: actual = asfs->SelectInt64L(stmt8); sl@0: else sl@0: actual = asfs->SelectInt64L(stmt); sl@0: TInt64 expected; sl@0: conv.Val(expected); sl@0: if( actual != expected ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: SelectInt64L gave %d, wanted %d"), sl@0: &KTestFunction, actual, expected); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: INFO_PRINTF3(_L("%S: SelectInt64L gave %d, as expected"), sl@0: &KTestFunction, actual); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: } sl@0: break; sl@0: sl@0: case CSQLSFSTEFAction::ESFS_SelectRealL: sl@0: { sl@0: TReal actual; sl@0: if(i8bit) sl@0: actual = asfs->SelectRealL(stmt8); sl@0: else sl@0: actual = asfs->SelectRealL(stmt); sl@0: TReal expected; sl@0: conv.Val(expected); sl@0: if( actual != expected ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: SelectRealL gave %f, wanted %f"), sl@0: &KTestFunction, actual, expected); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: INFO_PRINTF3(_L("%S: SelectRealL gave %f, as expected"), sl@0: &KTestFunction, actual); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: } sl@0: break; sl@0: sl@0: case CSQLSFSTEFAction::ESFS_SelectTextL: sl@0: { sl@0: RBuf actual; sl@0: actual.Create(32768); sl@0: CleanupClosePushL(actual); sl@0: TInt rc = KErrNone; sl@0: if(i8bit) sl@0: rc = asfs->SelectTextL(stmt8, actual); sl@0: else sl@0: rc = asfs->SelectTextL(stmt, actual); sl@0: if( actual != res ) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: SelectTextL gave %S, wanted %S"), sl@0: &KTestFunction, &actual, &res); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: INFO_PRINTF3(_L("%S: SelectTextL gave %S, as expected"), sl@0: &KTestFunction, &actual); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: ReportOnError( KTestFunction, _L("SelectTextL"), acfgblk, acnnum, sl@0: rc ); sl@0: CleanupStack::PopAndDestroy(1, &actual); sl@0: } sl@0: break; sl@0: sl@0: case CSQLSFSTEFAction::ESFS_SelectBinaryL: sl@0: { sl@0: RBuf8 actual; sl@0: actual.Create(32768); sl@0: CleanupClosePushL(actual); sl@0: TInt rc = KErrNone; sl@0: if(i8bit) sl@0: rc = asfs->SelectBinaryL(stmt8, actual); sl@0: else sl@0: rc = asfs->SelectBinaryL(stmt, actual); sl@0: ReportOnError( KTestFunction, _L("SelectBinaryL"), acfgblk, acnnum, rc ); sl@0: if(!rc) sl@0: { sl@0: TInt rc2 = CompareBinaryAgainstFileL(actual, res); sl@0: if(rc2) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF3(_L("%S: File compare gave error %d"), sl@0: &KTestFunction, rc2 ); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: _LIT(KSelectBinaryStr, "SelectBinaryL"); sl@0: ERR_PRINTF3(_L("%S: File compare successful, %S"), &KTestFunction, &KSelectBinaryStr); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: sl@0: } sl@0: CleanupStack::PopAndDestroy(1, &actual); sl@0: } sl@0: break; sl@0: sl@0: default: User::Panic(_L("Unknown Function"), 49); sl@0: sl@0: } sl@0: CleanupStack::PopAndDestroy(1, &stmt8); sl@0: } sl@0: sl@0: // Verifies that two files differ by size. sl@0: void CSQLCDT::FilesDifferBySize(const TDesC &acfgblk, const TInt acnnum) sl@0: sl@0: { sl@0: _LIT(KTestFunction, "FilesDifferBySize"); sl@0: sl@0: // Look for a string called 'FileANN'. sl@0: TPtrC filea; sl@0: TBuf fileaS(_L("FileA")); sl@0: fileaS.AppendNum(acnnum); sl@0: FromConfig(KTestFunction, acfgblk, fileaS, filea); sl@0: // Look for a string called 'FileBNN'. sl@0: TPtrC fileb; sl@0: TBuf filebS(_L("FileB")); sl@0: filebS.AppendNum(acnnum); sl@0: FromConfig(KTestFunction, acfgblk, filebS, fileb); sl@0: sl@0: TInt fza = FileSize(filea); sl@0: TInt fzb = FileSize(fileb); sl@0: if(fza == fzb) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: File A %d, File B %d"), &KTestFunction, fza, fzb); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(HTML_GREEN); sl@0: INFO_PRINTF6(_L("%S: Files %S and %S differ in size as expected, %d, %d"), &KTestFunction, &fileaS, &filebS, fza, fzb); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: } sl@0: sl@0: // Tests the method that retrive security policies. sl@0: void CSQLCDT::SecurityPolicyCheck(const TDesC &/*acfgblk*/, const TInt /*acnnum*/) sl@0: { sl@0: // _LIT(KTestFunction, "SecurityPolicyCheck"); sl@0: sl@0: // The methods to be tested here have been tested in the developer test: sl@0: // t_sqlsecurityXX.cpp. The work here has been deferred because it has been sl@0: // duplicated in the unit tests. sl@0: } sl@0: sl@0: // Tests for Locale change sl@0: // This test has been deferred pending a defect fix, defect is: sl@0: // DEF091753 "Initialize locale" should be part of the system startup sl@0: void CSQLCDT::CollationTest(const TDesC &/*acfgblk*/, const TInt /*acnnum*/) sl@0: { sl@0: TExtendedLocale myExtendedLocale; sl@0: myExtendedLocale.LoadSystemSettings(); sl@0: sl@0: #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL sl@0: sl@0: TBuf<100> DllLanguage; sl@0: DllLanguage.Copy(_L("elocl_lan.003")); sl@0: sl@0: TBuf<100> DllRegion; sl@0: DllRegion.Copy(_L("elocl_reg.056")); sl@0: sl@0: TBuf<100> DllCollation; sl@0: DllCollation.Copy(_L("elocl_col.003")); sl@0: sl@0: // Change the locale sl@0: TInt err = myExtendedLocale.LoadLocale(DllLanguage, DllRegion, DllCollation); sl@0: sl@0: #else sl@0: sl@0: TBuf<100> DllName; sl@0: DllName.Copy(_L("elocl.sc")); sl@0: sl@0: // Change the locale to Scandinavian Locale sl@0: TInt err = myExtendedLocale.LoadLocale(DllName); sl@0: sl@0: #endif sl@0: if( err != KErrNone ) sl@0: { sl@0: _LIT(KTestFunction, "CollationTest"); sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(HTML_RED); sl@0: ERR_PRINTF4(_L("%S: TExtendedLocale::LoadLocale gave %d, wanted %d"), sl@0: &KTestFunction, err, KErrNone); sl@0: INFO_PRINTF1(HTML_COLOUR_OFF); sl@0: } sl@0: sl@0: // Save the changes to system settings sl@0: myExtendedLocale.SaveSystemSettings(); sl@0: sl@0: // Wait sl@0: User::After(1000000); sl@0: } sl@0: sl@0: