Update contrib.
1 // Copyright (c) 2008-2009 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 the License "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\demandpaging\t_tbus_datapaging.cpp
15 // Functional tests for data paging.
20 //! @SYMTestCaseID KBASE-T_TBUS_DATAPAGING
23 //! @SYMTestCaseDesc Data Paging functional tests with TBusLocalDrive.
24 //! @SYMTestActions 001 ???
25 //! @SYMTestExpectedResults All tests should pass.
26 //! @SYMTestPriority High
27 //! @SYMTestStatus Implementation on-going
29 #define __E32TEST_EXTENSION__
43 #include "../secure/d_sldd.h"
44 #include "../mmu/mmudetect.h"
46 const TInt KMaxLengthOfStoreMapping = 16 + sizeof(TInt32) + KMaxMediaPassword;
47 const TInt KMaxPersistentStore(TPasswordStore::EMaxPasswordLength+KMaxLengthOfStoreMapping);
48 typedef TBuf8<KMaxPersistentStore> TPersistentStore;
53 const TUint8 KClearValue = 0xed;
54 const TUint KChunkSizeInPages = 64; // 64 * 4096 = 256K
55 const TInt KTestBufLen=256;
58 #define __DECLARE_VAR_IN_CHUNK(type, varRef) \
59 type varRef = *(type*) (gData+gOffset); \
60 gOffset += Max(gPageSize, sizeof(type)); \
61 test(gOffset <= gPageSize * KChunkSizeInPages);
63 #define __DECLARE_AND_INIT_VAR_IN_CHUNK(type, var) \
64 type &var = *(type*) (gData+gOffset); \
66 gOffset += Max(gPageSize, sizeof(type)); \
67 test(gOffset <= gPageSize * KChunkSizeInPages);
70 #define __DECLARE_ARRAY_IN_CHUNK(type, var, size) \
71 type *var = (type*) (gData+gOffset); \
72 gOffset += Max(gPageSize, (sizeof(type) * size)); \
73 test(gOffset <= gPageSize * KChunkSizeInPages);
75 #define __FLUSH_AND_CALL_API_METHOD(return, function) \
76 DPTest::FlushCache(); \
81 TInt gFsDriveNumber = -1;
83 RTest test(_L("T_TBUS_DATAPAGING"));
84 _LIT(KChunkName, "t_datapaging chunk");
86 const TUint KDriveAttMask = KDriveAttLocal | KDriveAttRom | KDriveAttRemote;
87 const TUint KMediaAttMask = KMediaAttVariableSize | KMediaAttDualDensity | KMediaAttLockable | KMediaAttLocked | KMediaAttHasPassword | KMediaAttReadWhileWrite;
89 void CreatePagedChunk(TInt aSizeInPages, TInt aWipeByte = -1)
91 test_Equal(0,gMyChunk.Handle());
93 TChunkCreateInfo createInfo;
94 TInt size = aSizeInPages * gPageSize;
95 createInfo.SetNormal(size, size);
96 createInfo.SetPaging(TChunkCreateInfo::EPaged);
97 createInfo.SetOwner(EOwnerProcess);
98 createInfo.SetGlobal(KChunkName);
100 createInfo.SetClearByte(aWipeByte);
101 test_KErrNone(gMyChunk.Create(createInfo));
102 test(gMyChunk.IsPaged()); // this is only ever called if data paging is supported
104 gData = gMyChunk.Base();
107 TInt TestDriveConnectAndCaps(TBusLocalDrive &aDrive, TInt &aLocalDriveNumber)
110 test.Next(_L("Test Drive Connect And Caps"));
112 __DECLARE_VAR_IN_CHUNK(TInt, &r);
114 test.Printf(_L("changeFlag...\n"));
115 __DECLARE_VAR_IN_CHUNK(TBool, &changeFlag);
118 test.Printf(_L("call aDrive.Connect()...\n"));
119 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Connect(aLocalDriveNumber,changeFlag));
121 test.Printf(_L("r:%d\n"),r);
122 test_Equal(KErrNone, r);
124 test.Printf(_L("call aDrive.Caps()...\n"));
125 __DECLARE_VAR_IN_CHUNK(TLocalDriveCapsV5, &driveCaps);
127 TPckg<TLocalDriveCapsV5> capsPckg(driveCaps);
128 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Caps(capsPckg));
130 test_Equal(KErrNone, r);
131 test.Printf(_L("r:%d\n"),r);
132 test.Printf(_L("driveCaps.iDriveAtt :0x%08x\n"), driveCaps.iDriveAtt);
133 test.Printf(_L("driveCaps.iSize :%ld\n"), driveCaps.iSize);
134 test.Printf(_L("driveCaps.iSerialNumLength :%d\n"), driveCaps.iSerialNumLength);
136 return I64LOW(driveCaps.iSize);
139 void TestDriveSizeRelatedMethods(TBusLocalDrive &aDrive, TInt aNewSize, TInt aOldSize)
143 test.Next(_L("Test Drive Size Related Methods"));
144 test.Printf(_L("newDriveSize...\n"));
145 __DECLARE_VAR_IN_CHUNK(TInt, &newDriveSize);
146 newDriveSize = aNewSize;
148 test.Printf(_L("call aDrive.Enlarge()...\n"));
149 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Enlarge(newDriveSize));
150 test.Printf(_L("r:%d\n"),r);
151 test((KErrNone == r) || (KErrNotSupported == r) || (KErrNotReady == r));
154 test.Printf(_L("errInfo...\n"));
155 __DECLARE_ARRAY_IN_CHUNK(TUint8, errInfo, KTestBufLen);
157 TPtr8 pErrInfoBuff(errInfo, KTestBufLen);
159 __FLUSH_AND_CALL_API_METHOD(r, aDrive.GetLastErrorInfo(pErrInfoBuff));
160 test.Printf(_L("r:%d\n"),r);
161 test((KErrNone == r) || (KErrNotSupported == r));
165 test.Printf(_L("call aDrive.ReduceSize()...\n"));
166 __FLUSH_AND_CALL_API_METHOD(r, aDrive.ReduceSize(0, aOldSize));
167 test((KErrNone == r) || (KErrNotSupported == r) || (KErrNotReady == r));
171 void TestWriteReadRelatedMethods(TBusLocalDrive &aDrive)
174 test.Next(_L("Test Write & Read Related Methods"));
176 __DECLARE_VAR_IN_CHUNK(TInt, &r);
178 test.Printf(_L("msgHandle...\n"));
179 __DECLARE_VAR_IN_CHUNK(TInt, &msgHandle);
180 msgHandle = KLocalMessageHandle;
183 __DECLARE_VAR_IN_CHUNK(TUint, &i);
184 test.Printf(_L("wrBuf...\n"));
185 TBuf8<KTestBufLen> wrBuf(KTestBufLen);
186 for (i=0 ; i<(TUint)KTestBufLen ; i++)
190 test.Printf(_L("wrBuf2...\n"));
191 __DECLARE_ARRAY_IN_CHUNK(TUint8, wrBuf2, KTestBufLen);
193 test.Printf(_L("fill wrBuf2...\n"));
194 for (i=0 ; i<(TUint)KTestBufLen ; i++)
197 TPtr8 pWrBuf2(wrBuf2, KTestBufLen, KTestBufLen);
199 test.Printf(_L("rdBuf...\n"));
200 TBuf8<KTestBufLen> rdBuf(KTestBufLen);
203 test.Printf(_L("rdBuf2...\n"));
204 __DECLARE_ARRAY_IN_CHUNK(TUint8, rdBuf2, KTestBufLen);
206 TPtr8 pRdBuf2(rdBuf2, KTestBufLen);
208 test.Printf(_L("call aDrive.Write()...\n"));
209 rdBuf.Fill(0,KTestBufLen);
210 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Write(0,KTestBufLen,&wrBuf,msgHandle,0));
211 test_Equal(KErrNone, r);
214 test.Printf(_L("call aDrive.Read()...\n"));
215 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Read(0,KTestBufLen,&rdBuf,msgHandle,0));
216 test_Equal(KErrNone, r);
218 for (i=0 ; i<(TUint)KTestBufLen ; i++)
219 test_Equal(wrBuf[i], rdBuf[i]);
221 test.Printf(_L("call aDrive.Write()...\n"));
222 pRdBuf2.Fill(0,KTestBufLen);
223 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Write(0,pWrBuf2));
224 test_Equal(KErrNone, r);
227 test.Printf(_L("call aDrive.Read()...\n"));
228 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Read(0,KTestBufLen, pRdBuf2));
229 test_Equal(KErrNone, r);
231 for (i=0 ; i<(TUint)KTestBufLen ; i++)
232 test_Equal(wrBuf2[i], rdBuf2[i]);
236 void TestPasswordRelatedMethods(TBusLocalDrive &aDrive)
240 test.Next(_L("Test Password Related Methods"));
241 //__DECLARE_VAR_IN_CHUNK(TPersistentStore, &wStore);
243 TPersistentStore* pstoreAB;
244 test((pstoreAB = new TPersistentStore) != 0);
245 TPersistentStore& wStore = *pstoreAB;
247 //__DECLARE_AND_INIT_VAR_IN_CHUNK(TPersistentStore, wStore);
249 // Password related API methods call
250 test.Printf(_L("call aDrive.WritePasswordData() to clear passwords...\n"));
251 __DECLARE_VAR_IN_CHUNK(TInt, &passwordStoreLength);
254 __FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(nulSt));
255 test( r == KErrNone);// empty
257 test.Printf(_L("call aDrive.PasswordStoreLengthInBytes()...\n"));
258 __FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
260 test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
261 test_Equal(0, passwordStoreLength);
264 test.Printf(_L("call aDrive.ErasePassword()...\n"));
265 __FLUSH_AND_CALL_API_METHOD(r, aDrive.ErasePassword());
266 test.Printf(_L("r:%d\n"),r);
269 test.Printf(_L("wStore.Size():%d\n"),wStore.Size());
270 __FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore));
272 test.Printf(_L("r:%d\n"),r);
273 test((KErrNone == r)); // || (KErrCorrupt == r)); // TO-DO Why Corrupt???
275 __FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
277 test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
278 test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
282 test.Printf(_L("Set and store a password...\n"));
284 TMediaPassword a((const TUint8*) "CID0ccccccccccc#");
285 TUint8 passLen[sizeof(TInt32)];
291 //test.Printf(_L("Password3:'%S'\n"), &a);
294 st.Append(passLen, sizeof(TInt32));
297 test.Printf(_L("wStore.Size():%d\n"),wStore.Size());
298 __FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore));
300 test.Printf(_L("r:%d\n"),r);
301 test((KErrNone == r));
303 __FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
305 test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
306 test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
308 test.Printf(_L("call aDrive.ErasePassword()...\n"));
309 __FLUSH_AND_CALL_API_METHOD(r, aDrive.ErasePassword());
310 test.Printf(_L("r:%d\n"),r);
312 test.Printf(_L("call aDrive.WritePasswordData() to set password again...\n"));
313 test.Printf(_L("wStore.Size():%d\n"),wStore.Size());
314 __FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore));
316 test.Printf(_L("r:%d\n"),r);
317 test((KErrNone == r));
319 __FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
321 test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
322 test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
325 // Finally erase password
326 test.Printf(_L("call aDrive.WritePasswordData() to erase password...\n"));
327 wStore.Zero(); // empty password store
328 __FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore))
329 test( r == KErrNone);// Clear
331 __FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
333 test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
334 test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
339 TMediaPassword nul(nulSt);
341 test.Printf(_L("call aDrive.SetPassword()...\n"));
342 __FLUSH_AND_CALL_API_METHOD(r, aDrive.SetPassword(nul, a, EFalse));
343 test.Printf(_L("r:%d\n"),r);
344 test_Equal(KErrNone, r);
347 test.Printf(_L("call aDrive.ErasePassword()...\n"));
348 __FLUSH_AND_CALL_API_METHOD(r, aDrive.ErasePassword());
349 test.Printf(_L("r:%d\n"),r);
352 test.Printf(_L("call aDrive.SetPassword()...\n"));
353 __FLUSH_AND_CALL_API_METHOD(r, aDrive.SetPassword(nul, a, EFalse));
354 test.Printf(_L("r:%d\n"),r);
355 test_Equal(KErrNone, r);
358 test.Printf(_L("call aDrive.Clear()...\n"));
359 __FLUSH_AND_CALL_API_METHOD(r, aDrive.Clear(a));
360 test.Printf(_L("r:%d\n"),r);
363 test.Printf(_L("call aDrive.SetPassword() to clear again...\n"));
364 __FLUSH_AND_CALL_API_METHOD(r, aDrive.SetPassword(a, nul, EFalse));
365 test.Printf(_L("r:%d\n"),r);
366 test_Equal(KErrAccessDenied, r);
369 // Finally erase password
370 test.Printf(_L("call aDrive.WritePasswordData() to erase password...\n"));
371 wStore.Zero(); // empty password store
372 __FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore))
373 test( r == KErrNone);// Clear
375 __FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
377 test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
378 test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
382 void TestFormatRelatedMethods(TBusLocalDrive &aDrive, TInt aSize )
384 test.Next(_L("Test Format Related Methods"));
386 test.Printf(_L("call aDrive.Format(TFormatInfo)...\n"));
387 __DECLARE_AND_INIT_VAR_IN_CHUNK(TFormatInfo, fi);
388 __DECLARE_VAR_IN_CHUNK(TInt, &ret);
389 __DECLARE_VAR_IN_CHUNK(TInt, &attempt);
391 __FLUSH_AND_CALL_API_METHOD(ret, aDrive.Format(fi));
392 test.Printf(_L("ret:%d\n"),ret);
395 if( ret == KErrNotReady )
398 while( (ret= aDrive.Format(fi)) == KErrNotReady && --attempt)
400 test.Printf(_L("attempt:%d\n"),attempt);
401 User::After(1000000);
408 ret= aDrive.Format(fi);
413 test.Printf(_L("call aDrive.Format(pos, length)...\n"));
414 User::After(1000000);
416 __DECLARE_VAR_IN_CHUNK(TInt64, &pos);
418 __DECLARE_VAR_IN_CHUNK(TInt, &length);
422 __FLUSH_AND_CALL_API_METHOD(ret, aDrive.Format(pos, length));
423 while( ret == KErrNotReady && --attempt)
425 User::After(1000000);
426 ret= aDrive.Format(pos, length);
429 test_Equal(KErrNone, ret);
431 test.Printf(_L("End of TestFormatRelatedMethods)...\n"));
434 void RestoreDriveState(void)
438 const TText KDrvLtr = 'A' + gFsDriveNumber;
440 bfDrv.Append(KDrvLtr);
449 test(fmt.Open(TheFs, bfDrv, EHighDensity, count) == KErrNone);
452 test.Printf(_L("\rfmt:%d "), count);
453 test(fmt.Next(count) == KErrNone);
455 test.Printf(_L("\n"));
462 TInt FindDataPagingDrive()
464 Find the drive containing a swap partition.
466 @return Local drive identifier.
469 TInt drive = KErrNotFound;
471 test.Printf(_L("Searching for data paging drive:\n"));
473 for(TInt i = 0; i < KMaxLocalDrives && drive < 0; ++i)
476 TBool change = EFalse;
478 if(d.Connect(i, change) == KErrNone)
480 TLocalDriveCapsV4 dc;
481 TPckg<TLocalDriveCapsV4> capsPack(dc);
483 if(d.Caps(capsPack) == KErrNone)
485 if ((dc.iMediaAtt & KMediaAttPageable) &&
486 (dc.iPartitionType == KPartitionTypePagedData))
488 test.Printf(_L("Found swap partition on local drive %d\n"), i);
491 TPageDeviceInfo pageDeviceInfo;
493 TPtr8 pageDeviceInfoBuf((TUint8*) &pageDeviceInfo, sizeof(pageDeviceInfo));
494 pageDeviceInfoBuf.FillZ();
496 TInt r = d.QueryDevice(RLocalDrive::EQueryPageDeviceInfo, pageDeviceInfoBuf);
498 test.Printf(_L("EQueryPageDeviceInfo on local drive %d returned %d\n"), i, r);
507 TDes& GetSerialNumber(TLocalDriveCapsV5& aCaps)
509 static TBuf16<80> serialNumBuf;
511 serialNumBuf.SetLength(0);
513 for (TUint n=0; n<aCaps.iSerialNumLength; n+=16)
515 for (TUint m=n; m<n+16; m++)
518 hexBuf.Format(_L("%02X "), aCaps.iSerialNum[m]);
519 serialNumBuf.Append(hexBuf);
526 TDes& GetSerialNumber(TMediaSerialNumber& aSerialNum)
528 static TBuf16<80> serialNumBuf;
530 serialNumBuf.SetLength(0);
532 TInt len = aSerialNum.Length();
533 for (TInt n=0; n<len; n+=16)
535 for (TInt m=n; m<n+16; m++)
538 hexBuf.Format(_L("%02X "), aSerialNum[m]);
539 serialNumBuf.Append(hexBuf);
546 TPtrC GetMediaType(TMediaType aType)
550 case EMediaNotPresent: return _L("NotPresent");
551 case EMediaUnknown: return _L("Unknown");
552 case EMediaFloppy: return _L("Floppy");
553 case EMediaHardDisk: return _L("HardDisk");
554 case EMediaCdRom: return _L("CdRom");
555 case EMediaRam: return _L("Ram");
556 case EMediaFlash: return _L("Flash");
557 case EMediaRom: return _L("Rom");
558 case EMediaRemote: return _L("Remote");
559 case EMediaNANDFlash: return _L("NANDFlash");
560 case EMediaRotatingMedia : return _L("RotatingMedia ");
561 default:return _L("Unrecognised");
565 TPtrC GetFileSystemId(TUint aFileSystemId)
567 switch(aFileSystemId)
569 case KDriveFileSysFAT: return _L("FAT");
570 case KDriveFileSysROM: return _L("ROM");
571 case KDriveFileSysLFFS: return _L("LFFS");
572 case KDriveFileSysROFS: return _L("ROFS");
573 case KDriveFileNone: return _L("None");
574 default:return _L("Unrecognised");
580 // Find a drive which contains the swap partition; if this succeeds, find and return the FAT drive on the same media.
581 // This isn't fool-proof as it works by comparing media types/drive attributes/media attributes/serial numbers
582 TInt FindFatDriveOnDataPagingMedia()
584 TInt dataPagingDrive = FindDataPagingDrive();
585 if (dataPagingDrive == KErrNotFound)
588 TInt fatDriveNumber = KErrNotFound;
590 test.Printf(_L("Finding Fat drive on datapaging media...\n"));
593 TBool change = EFalse;
595 TInt r = dpDrive.Connect(dataPagingDrive, change);
597 TLocalDriveCapsV5 dpDriveCaps;
598 TPckg<TLocalDriveCapsV5> capsPack(dpDriveCaps);
599 r = dpDrive.Caps(capsPack);
601 TPtrC8 dpDriveSerialNum(dpDriveCaps.iSerialNum, dpDriveCaps.iSerialNumLength);
604 TPtrC mediaType = GetMediaType(dpDriveCaps.iType);
605 TPtrC fileSystemId = GetFileSystemId(dpDriveCaps.iFileSystemId);
606 test.Printf(_L("Swap Drive %2d Type %S DriveAtt 0x%x MediaAtt 0x%x FileSysId %S SerialNum %S\n"),
607 dataPagingDrive, &mediaType, dpDriveCaps.iDriveAtt, dpDriveCaps.iMediaAtt, &fileSystemId, &GetSerialNumber(dpDriveCaps));
609 // swap partition should be hidden
610 test (dpDriveCaps.iDriveAtt & KDriveAttHidden);
612 // search for a FAT drive on the same media by searching for a drive which has
613 // 'similar' drive & media attributes as the the swap drive
615 dpDriveCaps.iDriveAtt&= KDriveAttMask;
616 dpDriveCaps.iMediaAtt&= KMediaAttMask;
618 for (TInt i = 0; i < KMaxLocalDrives /*&& fatDriveNumber == KErrNotFound*/; ++i)
621 TBool change = EFalse;
623 if(d.Connect(i, change) == KErrNone)
625 TLocalDriveCapsV5 caps;
626 TPckg<TLocalDriveCapsV5> capsPack(caps);
628 r = d.Caps(capsPack);
632 TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength);
633 TPtrC mediaType = GetMediaType(caps.iType);
634 TPtrC fileSystemId = GetFileSystemId(caps.iFileSystemId);
635 test.Printf(_L("Drive %2d Type %S DriveAtt 0x%x MediaAtt 0x%x FileSysId %S SerialNum %S\n"),
636 i, &mediaType, caps.iDriveAtt, caps.iMediaAtt, &fileSystemId, &GetSerialNumber(caps));
638 // Turn off bits which may be different
639 caps.iDriveAtt&= KDriveAttMask;
640 caps.iMediaAtt&= KMediaAttMask;
642 if ((caps.iType == dpDriveCaps.iType) &&
643 (caps.iDriveAtt == dpDriveCaps.iDriveAtt) &&
644 (caps.iMediaAtt == dpDriveCaps.iMediaAtt) &&
645 (localSerialNum.Compare(dpDriveSerialNum) == 0) &&
646 (caps.iFileSystemId == KDriveFileSysFAT))
648 if (fatDriveNumber == KErrNotFound)
656 return fatDriveNumber;
660 // Find and return the File Server drive number (0-25) corresponing to the passed local drive number
661 // This isn't fool-proof as it works by comparing media types/drive attributes/media attributes/serial numbers
662 TInt FindFsDriveNumber(TInt aLocalDriveNumber)
664 TInt fsDriveNumber = KErrNotFound;
667 TBool change = EFalse;
669 TInt r = dpDrive.Connect(aLocalDriveNumber, change);
671 TLocalDriveCapsV5 dpDriveCaps;
672 TPckg<TLocalDriveCapsV5> capsPack(dpDriveCaps);
673 r = dpDrive.Caps(capsPack);
675 TPtrC8 dpDriveSerialNum(dpDriveCaps.iSerialNum, dpDriveCaps.iSerialNumLength);
678 dpDriveCaps.iDriveAtt&= KDriveAttMask;
679 dpDriveCaps.iMediaAtt&= KMediaAttMask;
687 for (TInt n=0; n<KMaxDrives /* && fsDriveNumber == KErrNotFound*/; n++)
691 TMediaSerialNumber serialNum;
692 fs.GetMediaSerialNumber(serialNum, n);
695 fs.FileSystemName(fsName, n);
700 TPtrC mediaType = GetMediaType(di.iType);
701 test.Printf(_L("Drive %C Type %S DriveAtt 0x%x MediaAtt 0x%x FileSysId %S SerialNum %S\n"),
702 'A' + n, &mediaType, di.iDriveAtt, di.iMediaAtt, &fsName, &GetSerialNumber(serialNum));
704 di.iDriveAtt&= KDriveAttMask;
705 di.iMediaAtt&= KMediaAttMask;
707 if ((di.iType == dpDriveCaps.iType) &&
708 (di.iDriveAtt == dpDriveCaps.iDriveAtt) &&
709 (di.iMediaAtt == dpDriveCaps.iMediaAtt) &&
710 (serialNum.Compare(dpDriveSerialNum) == 0))
712 if (fsDriveNumber == KErrNotFound)
719 return fsDriveNumber;
725 // To use in command line
726 TBool callPasswordRelated = EFalse;
729 User::CommandLine(cmdline);
734 TPtrC token=lex.NextToken();
735 if(token.Length() != 0)
737 if (token == _L("-p"))
739 callPasswordRelated = ETrue;
742 test.Printf(_L("Unknown argument '%S' was ignored.\n"), &token);
752 test.Start(_L("Verify the global and this process's data paging attributes"));
753 test_KErrNone(GetGlobalPolicies());
755 if (IsDataPagingSupported())
757 test.Printf(_L("Data paging supported\n"));
760 {// The system doesn't support data paging so this process shouldn't be
762 test.Printf(_L("Data paging not supported\n"));
763 test_Equal(EFalse, gProcessPaged);
768 r = UserHal::PageSizeInBytes(gPageSize);
771 TInt fatDriveNumber = FindFatDriveOnDataPagingMedia();
772 if (fatDriveNumber == KErrNotFound)
774 test.Printf(_L("Could not find FAT partition on data paging media\n"));
777 gFsDriveNumber = FindFsDriveNumber(fatDriveNumber);
778 if (gFsDriveNumber == KErrNotFound)
780 test.Printf(_L("Could not File Server drive\n"));
784 test.Printf(_L("Found FAT drive on %C: (local drive #%d) on data paging media\n"), 'A'+gFsDriveNumber, fatDriveNumber);
786 // User::SetDebugMask(0x10000000); //KMMU2
787 // User::SetDebugMask(0x40000000, 1); //KPAGING
789 test.Next(_L("Create a paged chunk"));
790 CreatePagedChunk(KChunkSizeInPages, KClearValue);
792 test.Next(_L("Chunk created, declare variables"));
794 __DECLARE_VAR_IN_CHUNK(TBusLocalDrive, &drive)
795 TInt driveSize = TestDriveConnectAndCaps(drive, fatDriveNumber);
797 TestDriveSizeRelatedMethods(drive, 0x00001000, driveSize);
799 TestWriteReadRelatedMethods(drive);
801 TestFormatRelatedMethods(drive, driveSize);
803 if(callPasswordRelated)
805 TestPasswordRelatedMethods(drive);
809 test.Next(_L("call aDrive.Disconnect()..."));
810 DPTest::FlushCache();
819 User::SetDebugMask(0x00000000); // No debug info
820 User::SetDebugMask(0x00000000, 1); //No KPAGING