os/persistentdata/persistentstorage/sql/TEST/testexecute/SQLite/src/cdtest.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "cdtest.h"
    17 #include "hashing.h"
    18 #include "common.h"
    19 #include<bautils.h>
    20 
    21 //Constants taken from SqlSrvConfig.h
    22 #ifdef __WINSCW__
    23 		const TInt KDefaultSoftHeapLimitKb = 1024;
    24 #else
    25 		const TInt KDefaultSoftHeapLimitKb = 8192;
    26 #endif	
    27 
    28 // Includes any code required for 'Code-Driven' testing, generally tests
    29 // that cannot be data-driven (or not completely).
    30 
    31 CSQLCDT::~CSQLCDT()
    32     {
    33     }
    34 
    35 CSQLCDT::CSQLCDT()
    36     {
    37     SetTestStepName(KSQLCDT);
    38     }
    39 
    40 
    41 // Look at 'arg' and call whichever function is required.
    42 void CSQLCDT::ResolveTestFunctionL(const TDesC &acfgblk, const TInt acnnum,
    43                                   const TPtrC &arg )
    44     {
    45     _LIT(KTestFunction, "cdtest::ResolveTestFunction");
    46     INFO_PRINTF3(_L("In %S, arg is %S"), &KTestFunction, &arg);
    47 
    48     if(arg == _L("WriteBigTable"))
    49         WriteBigTableL(acfgblk, acnnum);
    50     else if(arg == _L("ReadBigTable"))
    51         ReadBigTableL(acfgblk);
    52 
    53     // This assumes that a ParameterIndex and ColumnIndex call has been
    54     // set up previously - the apidxs/apicxs array access below will
    55     // certainly PANIC if you haven't done the require preparation..
    56     else if(arg == _L("CopyCellsUsingStreams"))
    57         CopyCellsUsingStreamsL(acfgblk);
    58     else if(arg == _L("WriteIntsToStream"))
    59         WriteIntsToStream(acfgblk, acnnum);
    60     else if(arg == _L("NearFillDisk"))
    61         NearFillDisk(acfgblk);
    62     else if(arg == _L("ScalarFullSelect"))
    63         ScalarFullSelectL(acfgblk, acnnum);
    64     else if(arg == _L("FilesDifferBySize"))
    65         FilesDifferBySize(acfgblk, acnnum);
    66     else if(arg == _L("SecurityPolicyCheck"))
    67         SecurityPolicyCheck(acfgblk, acnnum);
    68     else if(arg == _L("CollationTest"))
    69         CollationTest(acfgblk, acnnum);
    70     
    71     else User::Panic(_L("Unknown Function"), 42);
    72     }
    73 
    74 // ------------------------------------------------------------------------ 
    75 //
    76 // There's some hardwired nastiness in here - which we might be able to remove
    77 // if we can restructure the code (with the parameter index array as a
    78 // member variable in sqlfn), but until we can get reporting (INFO_PRINTF etc)
    79 // working in new objects that isn't going to happen.
    80 // There should have been a 
    81 // 'Insert into t(what, ever, whatever) values (:FInt, :FReal, :FText)'
    82 // ... before this is called. Those on the right are the nasty hardwiring,
    83 // and should correspond to integer, real, and text fields.
    84 void CSQLCDT::WriteBigTableL(const TDesC &acfgblk, TInt acnnum )
    85     {
    86     _LIT(KTestFunction, "WriteBigTable");
    87 
    88     // Parameters for the loop.
    89     TInt low=1, high=10, step=1, experr = KErrNone;
    90     TReal mult; TPtrC text, experrS;
    91     FromConfig(KTestFunction, acfgblk, _L("LowCount"), low);
    92     FromConfig(KTestFunction, acfgblk, _L("HighCount"), high);
    93     FromConfig(KTestFunction, acfgblk, _L("CountStep"), step);
    94     FromConfig(KTestFunction, acfgblk, _L("Multiplier"), mult);
    95     FromConfig(KTestFunction, acfgblk, _L("Text"), text);
    96     if( FromConfig(KTestFunction, acfgblk, _L("EventuallyExpectedError"), experrS) )
    97         experr = ErrStringToEnum(experrS);
    98 
    99     // First work out if out text is actually a filename..
   100     TInt textfromfile=0;
   101     textfromfile = BaflUtils::FileExists(irfs, text);
   102 
   103     // Ahoy! Nasty hardwiring ahead!
   104     TInt pidxi = ParamIndex(_L(":FInt"), acfgblk, 0 );
   105     TInt pidxr = ParamIndex(_L(":FReal"), acfgblk, 0 );
   106     TInt pidxt = ParamIndex(_L(":FText"), acfgblk, 0 );
   107 
   108     TInt i;
   109     for(i=low ; i<=high ; i+=step)
   110         {
   111         TInt err=KErrNone;
   112         // Can use a stream write for speed to write the text to the disk. Don't
   113         // make the file too big or a memory error (server side) will result.
   114         if(textfromfile)
   115             SWBindTextL(pidxt, text, acfgblk, acnnum);
   116         else
   117             {
   118             err = isqlst.BindText(pidxt, text);
   119             ReportOnError( KTestFunction, _L("BindText"), acfgblk, acnnum, err );
   120             }
   121 
   122         TReal tr = i * mult;
   123         err = isqlst.BindInt(pidxi, i);
   124         ReportOnError( KTestFunction, _L("BindInt"), acfgblk, acnnum, err );
   125         err = isqlst.BindReal(pidxr, tr);
   126         ReportOnError( KTestFunction, _L("BindReal"), acfgblk, acnnum, err);
   127 
   128         err = isqlst.Exec();
   129         if((err != KErrNone) && (err == experr))
   130             {
   131             INFO_PRINTF1(HTML_GREEN);
   132             INFO_PRINTF3(_L("Loop dropped out with expected error %S, i=%d"), &experrS, i );
   133             INFO_PRINTF1(HTML_COLOUR_OFF);
   134             break;
   135             }
   136         else if(err < 0)  // <0 a real error we weren't expecting.
   137             {
   138             ReportOnError( KTestFunction, _L("Exec"), acfgblk, acnnum, err );
   139             INFO_PRINTF3(_L("%S: counter i is %d"), &KTestFunction, i );
   140             break;
   141             }
   142 
   143         err = isqlst.Reset();
   144         ReportOnError( KTestFunction, _L("Reset"), acfgblk, acnnum, err );
   145         acnnum++;
   146         }
   147     isqlst.Close();
   148 
   149     return;
   150     }
   151 void CSQLCDT::ReadBigTableL(const TDesC &acfgblk)
   152     {
   153     _LIT(KTestFunction, "ReadBigTable");
   154 
   155     // Parameters for the loop.
   156     TInt low=1, high=10, step=1, err;
   157     TReal mult; TPtrC text;
   158     FromConfig(KTestFunction, acfgblk, _L("LowCount"), low);
   159     FromConfig(KTestFunction, acfgblk, _L("HighCount"), high);
   160     FromConfig(KTestFunction, acfgblk, _L("CountStep"), step);
   161     FromConfig(KTestFunction, acfgblk, _L("Multiplier"), mult);
   162     FromConfig(KTestFunction, acfgblk, _L("Text"), text);
   163 
   164     // First work out if out text is actually a filename..
   165     TInt textfromfile=0;
   166     textfromfile = BaflUtils::FileExists(irfs, text);
   167 
   168     // Ahoy! Nasty hardwiring ahead!
   169     TInt cidxi = ColumnIndex(_L("Someint"), acfgblk, 0 );
   170     TInt cidxr = ColumnIndex(_L("Somereal"), acfgblk, 0 );
   171     TInt cidxt = ColumnIndex(_L("Sometext"), acfgblk, 0 );
   172 
   173     for(TInt i=low ; i<=high ; i+=step)
   174         {
   175         TReal tr = i * mult;
   176 // INFO_PRINTF3(_L("CFGBLK: %S        COUNT: %d"), &acfgblk, i);
   177 
   178         TInt cint = isqlst.ColumnInt(cidxi);
   179         TReal creal = isqlst.ColumnReal(cidxr);
   180         if((cint != i) || (creal != tr))
   181             {
   182             SetTestStepResult(EFail);
   183             INFO_PRINTF1(HTML_RED);
   184             ERR_PRINTF4(_L("%S: ColumnInt gave %d, wanted %d"),
   185                            &KTestFunction, cint, i );
   186             ERR_PRINTF4(_L("%S: ColumnReal gave %f, wanted %f"),
   187                            &KTestFunction, creal, tr );
   188             INFO_PRINTF1(HTML_COLOUR_OFF);
   189             break;
   190             }
   191         // Now check the text..
   192         if(textfromfile)
   193             SRColumnTextL(cidxt, text, acfgblk, -1 );
   194         else
   195             ColumnTextL(cidxt, text, acfgblk, -1 );
   196         if(isqlst.Next()==KSqlAtEnd)
   197             {
   198             // This expected error was for *writing* the table - we don't
   199             // get an error reading it back, just KSqlAtEnd. But lets assume
   200             // that an expected error on write implies a short table and
   201             // so no failure if we get KSqlAtEnd early.
   202             INFO_PRINTF1(HTML_GREEN);
   203             INFO_PRINTF3(_L("%S: Next gave KSqlAtEnd, i is %d"),
   204                                                    &KTestFunction, i );
   205             INFO_PRINTF1(HTML_COLOUR_OFF);
   206             break;
   207             }
   208         }
   209 
   210     if( (err = isqlst.Next()) != KSqlErrMisuse )
   211         {
   212         SetTestStepResult(EFail);
   213         INFO_PRINTF1(HTML_RED);
   214         ERR_PRINTF3(_L("%S: Next gave %d, is there some table left? Expected KSqlErrMisuse"), &KTestFunction, err );
   215         INFO_PRINTF1(HTML_COLOUR_OFF);
   216         }
   217     return;
   218     }
   219 
   220 
   221 // Copy a single cell in a table using streams. We'll use the BindBinary
   222 // and ColumnBinary methods of RSqlParamWriteStream and RSqlColumnReadStream
   223 // respectively. Don't try to copy integers or reals, as the API spec
   224 // says very clearly in a table, converting most of these to Binary
   225 // gives KNullDesc8.
   226 void CSQLCDT::CopyCellsUsingStreamsL(const TDesC &acfgblk) 
   227     {
   228     _LIT(KTestFunction, "CopyCellUsingStreams");
   229 
   230     // We only have one RSqlStatement around, and we must have two - a
   231     // source and destination, so lets get another one - we'll write to
   232     // this.
   233     RSqlStatement sqlst2;
   234     
   235     // The prepare statement used to add to the second table.
   236     TPtrC prep;
   237     FromConfig(KTestFunction, acfgblk, _L("PrepareStatement"), prep);
   238     // The parameter name (e.g :freddy) in the above.
   239     TPtrC paramname;
   240     FromConfig(KTestFunction, acfgblk, _L("ParamName"), paramname);
   241 
   242     // Prepare and get pidx.
   243     TInt err = sqlst2.Prepare(isqldb, prep);
   244     TInt pidx = sqlst2.ParameterIndex(paramname);
   245 
   246     // Whilst we're reading 
   247     while(isqlst.Next() == KSqlAtRow)
   248         {
   249         // First lets find a cell to copy. This assumes there is a single
   250         // column selected..
   251         // Set up where we're reading from. ColumnIndex will be zero.
   252         // Obviously a prepare must already have been done.
   253         RSqlColumnReadStream sqlr;
   254         err = sqlr.ColumnText(isqlst, 0);
   255     
   256         // Read a cell from the database as a stream. Pass that stream to
   257         // another stream, an RSqlParamWriteStream to copy the cell into
   258         // another db.
   259     
   260         // Get our writable stream..
   261         RSqlParamWriteStream sqlw;
   262     
   263         // Set up where we're writing to.
   264         err = sqlw.BindText(sqlst2, pidx);
   265     
   266         // Write.
   267         sqlw.WriteL(sqlr);
   268         sqlw.Close();
   269         err = sqlst2.Exec();
   270         err = sqlst2.Reset();
   271         }
   272     sqlst2.Close();
   273     return;
   274     }
   275 
   276 // Write to 32-bit signed integers to a stream (a cell in a table) until
   277 // the write operation Leaves with a KErrNoMem. A 'prepare' statement
   278 // must already have been run, and a parameterindex also. We assume
   279 // that the parameterindex is zero.
   280 // If the user wants to do an Exec and Reset, that's up to them. That
   281 // would end up sticking a NULL into the current cell though.
   282 void CSQLCDT::WriteIntsToStream(const TDesC &acfgblk, const TInt acnnum)
   283                                    
   284     {
   285     _LIT(KTestFunction, "WriteIntsToStream");
   286 
   287     // Get our writable stream..
   288     RSqlParamWriteStream sqlw;
   289     // Find out how many integers to write..
   290     TInt count;
   291     FromConfig(KTestFunction, acfgblk, _L("Count"), count);
   292     if(count == -1) count = 2000000000;
   293 
   294     // Assume only one 'ParameterIndex' has been run..
   295     sqlw.BindBinary(isqlst,0);
   296 
   297     TInt i, leavecode;
   298     for(i=0 ; i<count ; i++)
   299         {
   300         // A fast way to send a lot of data down a stream..
   301         TRAP(leavecode, sqlw.WriteInt32L(i));
   302         if(leavecode != KErrNone) break;
   303         }
   304     // Close the stream immediately. If we've run out of memory (a common test)
   305     // this will free it up and allow (e.g) LogEngine to function so we get
   306     // proper error reports.
   307     sqlw.Close();
   308 
   309     ReportOnError( KTestFunction, _L("Stream Write"), acfgblk, acnnum, leavecode );
   310     INFO_PRINTF3(_L("%S bound %d integers"), &KTestFunction, i );
   311 
   312     return;
   313     }
   314 
   315 //This function is needed for drives with more free space than KMaxTUint32 (4GB -1) 
   316 //This is because in a FAT32 file system, the maximum file size is (4GB-1)
   317 //In the case where the free space is larger than this limit, this function will create additional 
   318 //file(s)until the disk is under the (4GB-1) limit. After that CSQLCDT::NearFillDisk will fill the 
   319 //disk up to the required amount.
   320 void CSQLCDT::PrepareLargeDisk(const TDesC& /*acfgblk*/, const TDriveUnit atdu, TInt64 &atowrite)
   321     {
   322     _LIT(KTestFunction, "PrepareLargeDisk");
   323     _LIT(KFillDiskName,"\\FillDisk");
   324     _LIT(KFillDiskExt,".txt");
   325     TFileName fname;
   326     TInt count = 1;
   327     TInt err = 0;
   328     
   329     while(atowrite > KMaxTUint32)
   330         {
   331         RFile64 fillDiskFile;
   332         fname.Copy(atdu.Name());
   333         fname.Append(KFillDiskName);
   334         fname.AppendNum(count);
   335         fname.Append(KFillDiskExt);
   336         
   337         if( (err = fillDiskFile.Create(irfs, fname, EFileWrite)) != KErrNone )
   338             {
   339             SetTestStepResult(EFail);
   340             INFO_PRINTF1(HTML_RED);
   341             ERR_PRINTF4(_L("%S: Failed to open RFile64 for file %S, err %d"),
   342                                &KTestFunction, &fname, err );
   343             INFO_PRINTF1(HTML_COLOUR_OFF);
   344             return;
   345             }
   346         
   347         if( (err = fillDiskFile.SetSize(KMaxTUint32)) != KErrNone )
   348             {
   349             SetTestStepResult(EFail);
   350             INFO_PRINTF1(HTML_RED);
   351             ERR_PRINTF4(_L("%S: Failed on RFile64::SetSize for file %S, err %d"),
   352                                &KTestFunction, &fname, err );
   353             INFO_PRINTF1(HTML_COLOUR_OFF);
   354             fillDiskFile.Close();
   355             return;
   356             }
   357         
   358         fillDiskFile.Close();
   359         atowrite-=KMaxTUint32;
   360         count++;
   361         }
   362     }
   363 
   364 // Create a file specified by 'FillFile' in the config and write to
   365 // it until 'DiskFree' bytes remain. Note that because files use whole
   366 // sectors (512/1024/2048/4096 or whatever bytes), that attempting to leave
   367 // (e.g) 1023 bytes could result in 512 bytes remaining on a file system
   368 // with 512 byte sectors, or zero bytes remaining if the sectors are bigger.
   369 void CSQLCDT::NearFillDisk(const TDesC &acfgblk)
   370     {
   371     _LIT(KTestFunction, "NearFillDisk");
   372 
   373     // What file should we use? Requires a full path.
   374     TPtrC fillfile;
   375     (void)FromConfig(KTestFunction, acfgblk, _L("FillFile"), fillfile);
   376     irfs.Delete(fillfile);
   377 
   378     // Get the drive number. This method ignores trailing text.
   379     // Probably wants upper case.
   380     TDriveUnit tdu(fillfile);
   381 
   382     // Find out how much disk we want left.. 
   383     TInt free, err;
   384     (void)FromConfig(KTestFunction, acfgblk, _L("DiskFree"), free);
   385 
   386     // Find out how much disk space currently remains..
   387     TVolumeInfo vol;
   388     if((err = irfs.Volume(vol, tdu )) != KErrNone)
   389         {
   390         SetTestStepResult(EFail);
   391         INFO_PRINTF1(HTML_RED);
   392         ERR_PRINTF4(_L("%S: Failed to get volume info for %S, err %d"),
   393                            &KTestFunction, &fillfile, err );
   394         INFO_PRINTF1(HTML_COLOUR_OFF);
   395         return;
   396         }
   397 
   398     // So how many bytes do we need to write?
   399     TInt64 towrite = vol.iFree - free;
   400     INFO_PRINTF4(_L("%S: Disk writing %Ld, free %Ld"), &KTestFunction, 
   401                     towrite, vol.iFree );
   402     INFO_PRINTF3(_L("%S: free %Ld"), &KTestFunction, vol.iFree );
   403     INFO_PRINTF3(_L("%S: writing %Ld"), &KTestFunction, towrite );
   404 
   405     if( towrite < 0 )
   406         {
   407         SetTestStepResult(EFail);
   408         INFO_PRINTF1(HTML_RED);
   409         ERR_PRINTF3(_L("%S: Disk wanted remaining less than current(%Ld)"),
   410                            &KTestFunction, vol.iFree );
   411         INFO_PRINTF1(HTML_COLOUR_OFF);
   412         return;
   413         }
   414     
   415     //In case the disk is large (i.e >4G -1 bytes) we need another function to 
   416     //create more files to fill it
   417     PrepareLargeDisk(acfgblk, tdu, towrite);
   418     
   419     // Get a file.
   420     RFile64 myfile;
   421     if( (err = myfile.Create(irfs, fillfile, EFileWrite)) != KErrNone )
   422         {
   423         SetTestStepResult(EFail);
   424         INFO_PRINTF1(HTML_RED);
   425         ERR_PRINTF4(_L("%S: Failed to open RFile64 for file %S, err %d"),
   426                            &KTestFunction, &fillfile, err );
   427         INFO_PRINTF1(HTML_COLOUR_OFF);
   428         return;
   429         }
   430     // Write it.
   431 
   432     // We seem to hit trouble if we just try to write 'towrite' bytes, so
   433     // here we write 50% of them and check the remainder repeatedly until
   434     // the right amount remains. Actually it is unlikely to be exactly the
   435     // right amount - depending on sector sizes and other factors the
   436     // remaining space tends to be a kilobyte or two less than requested.
   437     // Obviously this is likely to be different between file system types,
   438     // between hardware and emulator and so on.
   439     
   440     
   441     TInt64 size = 0;
   442     while(towrite > 0)
   443         {
   444         if(towrite < 1024) break;
   445         TInt64 tow = towrite/2;
   446         if(towrite < 4096) tow = towrite;
   447 		size += tow;
   448         if( (err = myfile.SetSize(size)) != KErrNone )
   449             {
   450             SetTestStepResult(EFail);
   451             INFO_PRINTF1(HTML_RED);
   452             ERR_PRINTF4(_L("%S: Failed on RFile64::SetSize for file %S, err %d"),
   453                                &KTestFunction, &fillfile, err );
   454             INFO_PRINTF1(HTML_COLOUR_OFF);
   455 			break;
   456             }
   457         err = irfs.Volume(vol, tdu );
   458         if(err != KErrNone)
   459         	{
   460             SetTestStepResult(EFail);
   461             INFO_PRINTF1(HTML_RED);
   462             ERR_PRINTF3(_L("%S: 2-RFs::Volume() has failed, err=%d"),
   463                                &KTestFunction, err);
   464             INFO_PRINTF1(HTML_COLOUR_OFF);
   465             break;
   466         	}
   467         towrite = vol.iFree - free;
   468         }
   469 
   470     err = irfs.Volume(vol, tdu );
   471     if(err != KErrNone)
   472     	{
   473         SetTestStepResult(EFail);
   474         INFO_PRINTF1(HTML_RED);
   475         ERR_PRINTF3(_L("%S: 3-RFs::Volume() has failed, err=%d"),
   476                            &KTestFunction, err);
   477         INFO_PRINTF1(HTML_COLOUR_OFF);
   478     	}
   479     INFO_PRINTF3(_L("%S: Disk remaining is %Ld"), &KTestFunction, vol.iFree );
   480 	myfile.Close();
   481     return;
   482     }
   483 
   484 // This method exercises the TSqlScalarFullSelectQuery class, which is
   485 // just a wrapper. Its methods expect a select statement whose result will
   486 // be a single cell. Perhaps this should be in sqlfn.cpp.
   487 void CSQLCDT::ScalarFullSelectL(const TDesC &acfgblk, const TInt acnnum)
   488                                    
   489     {
   490     _LIT(KTestFunction, "ScalarFullSelect");
   491 
   492     // Look for an integer called 'Use_SetNN'.
   493     TInt useset;
   494     TBuf<KConfigItemMaxNameLength> conS(_L("Use_Set"));
   495     conS.AppendNum(acnnum);
   496     FromConfig(KTestFunction, acfgblk, conS, useset);
   497     // Look for a string called 'MethodNN'.
   498     TPtrC meth;
   499     TBuf<KConfigItemMaxNameLength> methS(_L("Method"));
   500     methS.AppendNum(acnnum);
   501     FromConfig(KTestFunction, acfgblk, methS, meth);
   502     // Look for a string called 'StatementNN'.
   503     TPtrC stmt;
   504     TBuf<KConfigItemMaxNameLength> stmtS(_L("Statement"));
   505     stmtS.AppendNum(acnnum);
   506     FromConfig(KTestFunction, acfgblk, stmtS, stmt);
   507     // Convert the SQL statement to an UTF-8 version.
   508     RBuf8 stmt8;
   509     stmt8.Create(stmt.Length());
   510     stmt8.Copy(stmt);
   511     CleanupClosePushL(stmt8);
   512 
   513     // Look for a string called 'ResultNN'.
   514     TPtrC res;
   515     TBuf<KConfigItemMaxNameLength> resS(_L("Result"));
   516     resS.AppendNum(acnnum);
   517     FromConfig(KTestFunction, acfgblk, resS, res);
   518     // We may want to convert the expected result to a real or int or something
   519     TLex conv = res;
   520 
   521     // Ok, now create a TSqlScalarFullSelectQuery object.
   522     TSqlScalarFullSelectQuery *asfs;
   523     TSqlScalarFullSelectQuery one(isqldb);
   524     TSqlScalarFullSelectQuery two;
   525     two.SetDatabase(isqldb);
   526     // Use one of the above objects.
   527     asfs = useset ? &two : &one;
   528 
   529     // Get the action hash for this..
   530     CSQLSFSTEFAction *cs = new CSQLSFSTEFAction();
   531     TInt action = cs->GetNumFromString(meth);
   532     switch(action)
   533         {
   534         case CSQLSFSTEFAction::ESFS_SelectIntL:
   535             {
   536             TInt actual;
   537             if(i8bit)
   538                 actual = asfs->SelectIntL(stmt8);
   539             else
   540                 actual = asfs->SelectIntL(stmt);
   541 				
   542             TInt expected;
   543 			if (res.CompareF(_L("DEFAULT_SOFT_HEAP_LIMIT")) == 0)
   544 				{
   545 				expected = KDefaultSoftHeapLimitKb;
   546 				}
   547 			else
   548 				{
   549 				conv.Val(expected);
   550 				}
   551 				
   552             if( actual != expected )
   553                 {
   554                 SetTestStepResult(EFail);
   555                 INFO_PRINTF1(HTML_RED);
   556                 ERR_PRINTF4(_L("%S: SelectIntL gave %d, wanted %d"),
   557                        &KTestFunction, actual,  expected);
   558                 INFO_PRINTF1(HTML_COLOUR_OFF);
   559                 }
   560             else
   561                 {
   562                 INFO_PRINTF1(HTML_GREEN);
   563                 INFO_PRINTF3(_L("%S: SelectIntL gave %d, as expected"),
   564                        &KTestFunction, actual);
   565                 INFO_PRINTF1(HTML_COLOUR_OFF);
   566                 }
   567             }
   568             break;
   569 
   570         case CSQLSFSTEFAction::ESFS_SelectInt64L:
   571             {
   572             TInt64 actual;
   573             if(i8bit)
   574                 actual = asfs->SelectInt64L(stmt8);
   575             else
   576                 actual = asfs->SelectInt64L(stmt);
   577             TInt64 expected;
   578             conv.Val(expected);
   579             if( actual != expected )
   580                 {
   581                 SetTestStepResult(EFail);
   582                 INFO_PRINTF1(HTML_RED);
   583                 ERR_PRINTF4(_L("%S: SelectInt64L gave %d, wanted %d"),
   584                        &KTestFunction, actual,  expected);
   585                 INFO_PRINTF1(HTML_COLOUR_OFF);
   586                 }
   587             else
   588                 {
   589                 INFO_PRINTF1(HTML_GREEN);
   590                 INFO_PRINTF3(_L("%S: SelectInt64L gave %d, as expected"),
   591                        &KTestFunction, actual);
   592                 INFO_PRINTF1(HTML_COLOUR_OFF);
   593                 }
   594             }
   595             break;
   596 
   597         case CSQLSFSTEFAction::ESFS_SelectRealL:
   598             {
   599             TReal actual;
   600             if(i8bit)
   601                 actual = asfs->SelectRealL(stmt8);
   602             else
   603                 actual = asfs->SelectRealL(stmt);
   604             TReal expected;
   605             conv.Val(expected);
   606             if( actual != expected )
   607                 {
   608                 SetTestStepResult(EFail);
   609                 INFO_PRINTF1(HTML_RED);
   610                 ERR_PRINTF4(_L("%S: SelectRealL gave %f, wanted %f"),
   611                        &KTestFunction, actual,  expected);
   612                 INFO_PRINTF1(HTML_COLOUR_OFF);
   613                 }
   614             else
   615                 {
   616                 INFO_PRINTF1(HTML_GREEN);
   617                 INFO_PRINTF3(_L("%S: SelectRealL gave %f, as expected"),
   618                        &KTestFunction, actual);
   619                 INFO_PRINTF1(HTML_COLOUR_OFF);
   620                 }
   621             }
   622             break;
   623 
   624         case CSQLSFSTEFAction::ESFS_SelectTextL:
   625             {
   626             RBuf actual;
   627             actual.Create(32768);
   628             CleanupClosePushL(actual);
   629             TInt rc = KErrNone;
   630             if(i8bit)
   631                 rc = asfs->SelectTextL(stmt8, actual);
   632             else
   633                 rc = asfs->SelectTextL(stmt, actual);
   634             if( actual != res )
   635                 {
   636                 SetTestStepResult(EFail);
   637                 INFO_PRINTF1(HTML_RED);
   638                 ERR_PRINTF4(_L("%S: SelectTextL gave %S, wanted %S"),
   639                        &KTestFunction, &actual,  &res);
   640                 INFO_PRINTF1(HTML_COLOUR_OFF);
   641                 }
   642             else
   643                 {
   644                 INFO_PRINTF1(HTML_GREEN);
   645                 INFO_PRINTF3(_L("%S: SelectTextL gave %S, as expected"),
   646                        &KTestFunction, &actual);
   647                 INFO_PRINTF1(HTML_COLOUR_OFF);
   648                 }
   649             ReportOnError( KTestFunction, _L("SelectTextL"), acfgblk, acnnum,
   650                                                                           rc );
   651             CleanupStack::PopAndDestroy(1, &actual);
   652         }
   653         break;
   654 
   655         case CSQLSFSTEFAction::ESFS_SelectBinaryL:
   656             {
   657             RBuf8 actual;
   658             actual.Create(32768);
   659             CleanupClosePushL(actual);
   660             TInt rc = KErrNone;
   661             if(i8bit)
   662                 rc = asfs->SelectBinaryL(stmt8, actual);
   663             else
   664                 rc = asfs->SelectBinaryL(stmt, actual);
   665             ReportOnError( KTestFunction, _L("SelectBinaryL"), acfgblk, acnnum, rc );
   666             if(!rc)
   667                 {
   668                 TInt rc2 = CompareBinaryAgainstFileL(actual, res);
   669                 if(rc2)
   670                     {
   671                     SetTestStepResult(EFail);
   672                     INFO_PRINTF1(HTML_RED);
   673                     ERR_PRINTF3(_L("%S: File compare gave error %d"),
   674                                      &KTestFunction, rc2 );
   675                     INFO_PRINTF1(HTML_COLOUR_OFF);
   676                     }
   677                 else
   678                     {
   679                     INFO_PRINTF1(HTML_GREEN);
   680                     _LIT(KSelectBinaryStr, "SelectBinaryL");
   681                     ERR_PRINTF3(_L("%S: File compare successful, %S"), &KTestFunction, &KSelectBinaryStr);
   682                     INFO_PRINTF1(HTML_COLOUR_OFF);
   683                     }
   684 
   685                 }
   686             CleanupStack::PopAndDestroy(1, &actual);
   687             }
   688             break;
   689 
   690         default: User::Panic(_L("Unknown Function"), 49);
   691 
   692         }
   693     CleanupStack::PopAndDestroy(1, &stmt8);
   694     }
   695 
   696 // Verifies that two files differ by size.
   697 void CSQLCDT::FilesDifferBySize(const TDesC &acfgblk, const TInt acnnum)
   698                                    
   699     {
   700     _LIT(KTestFunction, "FilesDifferBySize");
   701 
   702     // Look for a string called 'FileANN'.
   703     TPtrC filea;
   704     TBuf<KConfigItemMaxNameLength> fileaS(_L("FileA"));
   705     fileaS.AppendNum(acnnum);
   706     FromConfig(KTestFunction, acfgblk, fileaS, filea);
   707     // Look for a string called 'FileBNN'.
   708     TPtrC fileb;
   709     TBuf<KConfigItemMaxNameLength> filebS(_L("FileB"));
   710     filebS.AppendNum(acnnum);
   711     FromConfig(KTestFunction, acfgblk, filebS, fileb);
   712 
   713     TInt fza = FileSize(filea);
   714     TInt fzb = FileSize(fileb);
   715     if(fza == fzb)
   716         {
   717         SetTestStepResult(EFail);
   718         INFO_PRINTF1(HTML_RED);
   719         ERR_PRINTF4(_L("%S: File A %d, File B %d"), &KTestFunction, fza,  fzb);
   720         INFO_PRINTF1(HTML_COLOUR_OFF);
   721         }
   722     else
   723         {
   724         INFO_PRINTF1(HTML_GREEN);
   725         INFO_PRINTF6(_L("%S: Files %S and %S differ in size as expected, %d, %d"), &KTestFunction, &fileaS, &filebS, fza, fzb);
   726         INFO_PRINTF1(HTML_COLOUR_OFF);
   727         }
   728     }
   729 
   730 // Tests the method that retrive security policies.
   731 void CSQLCDT::SecurityPolicyCheck(const TDesC &/*acfgblk*/, const TInt /*acnnum*/)
   732     {
   733 //    _LIT(KTestFunction, "SecurityPolicyCheck");
   734     
   735     // The methods to be tested here have been tested in the developer test:
   736     // t_sqlsecurityXX.cpp. The work here has been deferred because it has been 
   737     // duplicated in the unit tests.
   738     }
   739 
   740 // Tests for Locale change
   741 // This test has been deferred pending a defect fix, defect is:
   742 // DEF091753 "Initialize locale" should be part of the system startup
   743 void CSQLCDT::CollationTest(const TDesC &/*acfgblk*/, const TInt /*acnnum*/)
   744     {
   745     TExtendedLocale myExtendedLocale;
   746     myExtendedLocale.LoadSystemSettings();
   747 
   748 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL
   749     
   750     TBuf<100> DllLanguage; 
   751     DllLanguage.Copy(_L("elocl_lan.003"));
   752     
   753     TBuf<100> DllRegion; 
   754     DllRegion.Copy(_L("elocl_reg.056"));
   755     
   756     TBuf<100> DllCollation; 
   757     DllCollation.Copy(_L("elocl_col.003"));
   758     
   759     // Change the locale 
   760     TInt err = myExtendedLocale.LoadLocale(DllLanguage, DllRegion, DllCollation);
   761     
   762 #else
   763     
   764     TBuf<100> DllName; 
   765     DllName.Copy(_L("elocl.sc"));
   766     
   767     // Change the locale to Scandinavian Locale 
   768     TInt err = myExtendedLocale.LoadLocale(DllName);    
   769     
   770 #endif
   771     if( err != KErrNone )
   772         {
   773         _LIT(KTestFunction, "CollationTest");
   774         SetTestStepResult(EFail);
   775         INFO_PRINTF1(HTML_RED);
   776         ERR_PRINTF4(_L("%S: TExtendedLocale::LoadLocale gave %d, wanted %d"),
   777                           &KTestFunction, err,  KErrNone);
   778         INFO_PRINTF1(HTML_COLOUR_OFF);
   779         }
   780     
   781     // Save the changes to system settings
   782     myExtendedLocale.SaveSystemSettings();
   783 
   784     // Wait
   785     User::After(1000000);
   786     }
   787 
   788