1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-2010 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 |
315 // Create a file specified by 'FillFile' in the config and write to |
364 // Create a file specified by 'FillFile' in the config and write to |
316 // it until 'DiskFree' bytes remain. Note that because files use whole |
365 // it until 'DiskFree' bytes remain. Note that because files use whole |
317 // sectors (512/1024/2048/4096 or whatever bytes), that attempting to leave |
366 // sectors (512/1024/2048/4096 or whatever bytes), that attempting to leave |
318 // (e.g) 1023 bytes could result in 512 bytes remaining on a file system |
367 // (e.g) 1023 bytes could result in 512 bytes remaining on a file system |
319 // with 512 byte sectors, or zero bytes remaining if the sectors are bigger. |
368 // with 512 byte sectors, or zero bytes remaining if the sectors are bigger. |
345 INFO_PRINTF1(HTML_COLOUR_OFF); |
394 INFO_PRINTF1(HTML_COLOUR_OFF); |
346 return; |
395 return; |
347 } |
396 } |
348 |
397 |
349 // So how many bytes do we need to write? |
398 // So how many bytes do we need to write? |
350 TInt towrite = vol.iFree - free; |
399 TInt64 towrite = vol.iFree - free; |
351 INFO_PRINTF4(_L("%S: Disk writing %d, free %d"), &KTestFunction, |
400 INFO_PRINTF4(_L("%S: Disk writing %Ld, free %Ld"), &KTestFunction, |
352 towrite, vol.iFree ); |
401 towrite, vol.iFree ); |
353 INFO_PRINTF3(_L("%S: free %d"), &KTestFunction, vol.iFree ); |
402 INFO_PRINTF3(_L("%S: free %Ld"), &KTestFunction, vol.iFree ); |
354 INFO_PRINTF3(_L("%S: writing %d"), &KTestFunction, towrite ); |
403 INFO_PRINTF3(_L("%S: writing %Ld"), &KTestFunction, towrite ); |
355 |
404 |
356 if( towrite < 0 ) |
405 if( towrite < 0 ) |
357 { |
406 { |
358 SetTestStepResult(EFail); |
407 SetTestStepResult(EFail); |
359 INFO_PRINTF1(HTML_RED); |
408 INFO_PRINTF1(HTML_RED); |
360 ERR_PRINTF3(_L("%S: Disk wanted remaining less than current(%d)"), |
409 ERR_PRINTF3(_L("%S: Disk wanted remaining less than current(%Ld)"), |
361 &KTestFunction, vol.iFree ); |
410 &KTestFunction, vol.iFree ); |
362 INFO_PRINTF1(HTML_COLOUR_OFF); |
411 INFO_PRINTF1(HTML_COLOUR_OFF); |
363 return; |
412 return; |
364 } |
413 } |
365 |
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 |
366 // Get a file. |
419 // Get a file. |
367 RFile myfile; |
420 RFile64 myfile; |
368 if( (err = myfile.Create(irfs, fillfile, EFileWrite)) != KErrNone ) |
421 if( (err = myfile.Create(irfs, fillfile, EFileWrite)) != KErrNone ) |
369 { |
422 { |
370 SetTestStepResult(EFail); |
423 SetTestStepResult(EFail); |
371 INFO_PRINTF1(HTML_RED); |
424 INFO_PRINTF1(HTML_RED); |
372 ERR_PRINTF4(_L("%S: Failed to open RFile for file %S, err %d"), |
425 ERR_PRINTF4(_L("%S: Failed to open RFile64 for file %S, err %d"), |
373 &KTestFunction, &fillfile, err ); |
426 &KTestFunction, &fillfile, err ); |
374 INFO_PRINTF1(HTML_COLOUR_OFF); |
427 INFO_PRINTF1(HTML_COLOUR_OFF); |
375 return; |
428 return; |
376 } |
429 } |
377 // Write it. |
430 // Write it. |
381 // the right amount remains. Actually it is unlikely to be exactly the |
434 // the right amount remains. Actually it is unlikely to be exactly the |
382 // right amount - depending on sector sizes and other factors the |
435 // right amount - depending on sector sizes and other factors the |
383 // remaining space tends to be a kilobyte or two less than requested. |
436 // remaining space tends to be a kilobyte or two less than requested. |
384 // Obviously this is likely to be different between file system types, |
437 // Obviously this is likely to be different between file system types, |
385 // between hardware and emulator and so on. |
438 // between hardware and emulator and so on. |
386 TInt size = 0; |
439 |
|
440 |
|
441 TInt64 size = 0; |
387 while(towrite > 0) |
442 while(towrite > 0) |
388 { |
443 { |
389 if(towrite < 1024) break; |
444 if(towrite < 1024) break; |
390 TInt tow = towrite/2; |
445 TInt64 tow = towrite/2; |
391 if(towrite < 4096) tow = towrite; |
446 if(towrite < 4096) tow = towrite; |
392 size += tow; |
447 size += tow; |
393 if( (err = myfile.SetSize(size)) != KErrNone ) |
448 if( (err = myfile.SetSize(size)) != KErrNone ) |
394 { |
449 { |
395 SetTestStepResult(EFail); |
450 SetTestStepResult(EFail); |
396 INFO_PRINTF1(HTML_RED); |
451 INFO_PRINTF1(HTML_RED); |
397 ERR_PRINTF4(_L("%S: Failed on RFile::SetSize for file %S, err %d"), |
452 ERR_PRINTF4(_L("%S: Failed on RFile64::SetSize for file %S, err %d"), |
398 &KTestFunction, &fillfile, err ); |
453 &KTestFunction, &fillfile, err ); |
399 INFO_PRINTF1(HTML_COLOUR_OFF); |
454 INFO_PRINTF1(HTML_COLOUR_OFF); |
400 break; |
455 break; |
401 } |
456 } |
402 err = irfs.Volume(vol, tdu ); |
457 err = irfs.Volume(vol, tdu ); |
419 INFO_PRINTF1(HTML_RED); |
474 INFO_PRINTF1(HTML_RED); |
420 ERR_PRINTF3(_L("%S: 3-RFs::Volume() has failed, err=%d"), |
475 ERR_PRINTF3(_L("%S: 3-RFs::Volume() has failed, err=%d"), |
421 &KTestFunction, err); |
476 &KTestFunction, err); |
422 INFO_PRINTF1(HTML_COLOUR_OFF); |
477 INFO_PRINTF1(HTML_COLOUR_OFF); |
423 } |
478 } |
424 INFO_PRINTF3(_L("%S: Disk remaining is %d"), &KTestFunction, vol.iFree ); |
479 INFO_PRINTF3(_L("%S: Disk remaining is %Ld"), &KTestFunction, vol.iFree ); |
425 myfile.Close(); |
480 myfile.Close(); |
426 return; |
481 return; |
427 } |
482 } |
428 |
483 |
429 // This method exercises the TSqlScalarFullSelectQuery class, which is |
484 // This method exercises the TSqlScalarFullSelectQuery class, which is |