persistentstorage/sql/TEST/testexecute/SQLite/src/cdtest.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   310     INFO_PRINTF3(_L("%S bound %d integers"), &KTestFunction, i );
   310     INFO_PRINTF3(_L("%S bound %d integers"), &KTestFunction, i );
   311 
   311 
   312     return;
   312     return;
   313     }
   313     }
   314 
   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
   315 // Create a file specified by 'FillFile' in the config and write to
   365 // it until 'DiskFree' bytes remain. Note that because files use whole
   316 // it until 'DiskFree' bytes remain. Note that because files use whole
   366 // sectors (512/1024/2048/4096 or whatever bytes), that attempting to leave
   317 // 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
   318 // (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.
   319 // with 512 byte sectors, or zero bytes remaining if the sectors are bigger.
   394         INFO_PRINTF1(HTML_COLOUR_OFF);
   345         INFO_PRINTF1(HTML_COLOUR_OFF);
   395         return;
   346         return;
   396         }
   347         }
   397 
   348 
   398     // So how many bytes do we need to write?
   349     // So how many bytes do we need to write?
   399     TInt64 towrite = vol.iFree - free;
   350     TInt towrite = vol.iFree - free;
   400     INFO_PRINTF4(_L("%S: Disk writing %Ld, free %Ld"), &KTestFunction, 
   351     INFO_PRINTF4(_L("%S: Disk writing %d, free %d"), &KTestFunction, 
   401                     towrite, vol.iFree );
   352                     towrite, vol.iFree );
   402     INFO_PRINTF3(_L("%S: free %Ld"), &KTestFunction, vol.iFree );
   353     INFO_PRINTF3(_L("%S: free %d"), &KTestFunction, vol.iFree );
   403     INFO_PRINTF3(_L("%S: writing %Ld"), &KTestFunction, towrite );
   354     INFO_PRINTF3(_L("%S: writing %d"), &KTestFunction, towrite );
   404 
   355 
   405     if( towrite < 0 )
   356     if( towrite < 0 )
   406         {
   357         {
   407         SetTestStepResult(EFail);
   358         SetTestStepResult(EFail);
   408         INFO_PRINTF1(HTML_RED);
   359         INFO_PRINTF1(HTML_RED);
   409         ERR_PRINTF3(_L("%S: Disk wanted remaining less than current(%Ld)"),
   360         ERR_PRINTF3(_L("%S: Disk wanted remaining less than current(%d)"),
   410                            &KTestFunction, vol.iFree );
   361                            &KTestFunction, vol.iFree );
   411         INFO_PRINTF1(HTML_COLOUR_OFF);
   362         INFO_PRINTF1(HTML_COLOUR_OFF);
   412         return;
   363         return;
   413         }
   364         }
   414     
   365         
   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.
   366     // Get a file.
   420     RFile64 myfile;
   367     RFile myfile;
   421     if( (err = myfile.Create(irfs, fillfile, EFileWrite)) != KErrNone )
   368     if( (err = myfile.Create(irfs, fillfile, EFileWrite)) != KErrNone )
   422         {
   369         {
   423         SetTestStepResult(EFail);
   370         SetTestStepResult(EFail);
   424         INFO_PRINTF1(HTML_RED);
   371         INFO_PRINTF1(HTML_RED);
   425         ERR_PRINTF4(_L("%S: Failed to open RFile64 for file %S, err %d"),
   372         ERR_PRINTF4(_L("%S: Failed to open RFile for file %S, err %d"),
   426                            &KTestFunction, &fillfile, err );
   373                            &KTestFunction, &fillfile, err );
   427         INFO_PRINTF1(HTML_COLOUR_OFF);
   374         INFO_PRINTF1(HTML_COLOUR_OFF);
   428         return;
   375         return;
   429         }
   376         }
   430     // Write it.
   377     // Write it.
   434     // the right amount remains. Actually it is unlikely to be exactly the
   381     // the right amount remains. Actually it is unlikely to be exactly the
   435     // right amount - depending on sector sizes and other factors the
   382     // right amount - depending on sector sizes and other factors the
   436     // remaining space tends to be a kilobyte or two less than requested.
   383     // remaining space tends to be a kilobyte or two less than requested.
   437     // Obviously this is likely to be different between file system types,
   384     // Obviously this is likely to be different between file system types,
   438     // between hardware and emulator and so on.
   385     // between hardware and emulator and so on.
   439     
   386 	TInt size = 0;
   440     
       
   441     TInt64 size = 0;
       
   442     while(towrite > 0)
   387     while(towrite > 0)
   443         {
   388         {
   444         if(towrite < 1024) break;
   389         if(towrite < 1024) break;
   445         TInt64 tow = towrite/2;
   390         TInt tow = towrite/2;
   446         if(towrite < 4096) tow = towrite;
   391         if(towrite < 4096) tow = towrite;
   447 		size += tow;
   392 		size += tow;
   448         if( (err = myfile.SetSize(size)) != KErrNone )
   393         if( (err = myfile.SetSize(size)) != KErrNone )
   449             {
   394             {
   450             SetTestStepResult(EFail);
   395             SetTestStepResult(EFail);
   451             INFO_PRINTF1(HTML_RED);
   396             INFO_PRINTF1(HTML_RED);
   452             ERR_PRINTF4(_L("%S: Failed on RFile64::SetSize for file %S, err %d"),
   397             ERR_PRINTF4(_L("%S: Failed on RFile::SetSize for file %S, err %d"),
   453                                &KTestFunction, &fillfile, err );
   398                                &KTestFunction, &fillfile, err );
   454             INFO_PRINTF1(HTML_COLOUR_OFF);
   399             INFO_PRINTF1(HTML_COLOUR_OFF);
   455 			break;
   400 			break;
   456             }
   401             }
   457         err = irfs.Volume(vol, tdu );
   402         err = irfs.Volume(vol, tdu );
   474         INFO_PRINTF1(HTML_RED);
   419         INFO_PRINTF1(HTML_RED);
   475         ERR_PRINTF3(_L("%S: 3-RFs::Volume() has failed, err=%d"),
   420         ERR_PRINTF3(_L("%S: 3-RFs::Volume() has failed, err=%d"),
   476                            &KTestFunction, err);
   421                            &KTestFunction, err);
   477         INFO_PRINTF1(HTML_COLOUR_OFF);
   422         INFO_PRINTF1(HTML_COLOUR_OFF);
   478     	}
   423     	}
   479     INFO_PRINTF3(_L("%S: Disk remaining is %Ld"), &KTestFunction, vol.iFree );
   424     INFO_PRINTF3(_L("%S: Disk remaining is %d"), &KTestFunction, vol.iFree );
   480 	myfile.Close();
   425 	myfile.Close();
   481     return;
   426     return;
   482     }
   427     }
   483 
   428 
   484 // This method exercises the TSqlScalarFullSelectQuery class, which is
   429 // This method exercises the TSqlScalarFullSelectQuery class, which is
   536             TInt actual;
   481             TInt actual;
   537             if(i8bit)
   482             if(i8bit)
   538                 actual = asfs->SelectIntL(stmt8);
   483                 actual = asfs->SelectIntL(stmt8);
   539             else
   484             else
   540                 actual = asfs->SelectIntL(stmt);
   485                 actual = asfs->SelectIntL(stmt);
   541 				
   486 			
   542             TInt expected;
   487 			TInt expected;	
   543 			if (res.CompareF(_L("DEFAULT_SOFT_HEAP_LIMIT")) == 0)
   488 			if (res.CompareF(_L("DEFAULT_SOFT_HEAP_LIMIT")) == 0)
   544 				{
   489 				{
   545 				expected = KDefaultSoftHeapLimitKb;
   490 				expected = KDefaultSoftHeapLimitKb;
   546 				}
   491 				}
   547 			else
   492 			else