1220 |
1230 |
1221 |
1231 |
1222 test.Next(_L("open connection")); |
1232 test.Next(_L("open connection")); |
1223 RFs theFs; |
1233 RFs theFs; |
1224 test(theFs.Connect() == KErrNone); |
1234 test(theFs.Connect() == KErrNone); |
1225 |
1235 |
1226 |
1236 // So that we are in a consistant state lets |
|
1237 // Remove the password file first. i.e. could be passwords left over from previous test failures |
|
1238 test.Next(_L("tidy up")); |
|
1239 TEntry theEntry; |
|
1240 TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile); |
|
1241 mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar(); |
|
1242 test.Printf(_L("password file : %S\n"),&mediaPWrdFile); |
|
1243 error = theFs.Delete(mediaPWrdFile); |
|
1244 // Should be either KErrNone, KErrPathNotFound or KErrNotFound |
|
1245 test.Printf(_L("password file deleted: %d\n"),error); |
1227 |
1246 |
1228 // Now set the first password that we will use |
1247 // Now set the first password that we will use |
1229 test.Next(_L("lock the media card")); |
1248 test.Next(_L("lock the media card")); |
1230 TMediaPassword& nulPWrd = *PWDs[0]; |
1249 TMediaPassword& nulPWrd = *PWDs[0]; |
1231 TMediaPassword& oldPWrd = *PWDs[1]; |
1250 TMediaPassword& oldPWrd = *PWDs[1]; |
1232 error = theFs.LockDrive(KDriveNum, nulPWrd, oldPWrd, ETrue); |
1251 error = theFs.LockDrive(KDriveNum, nulPWrd, oldPWrd, ETrue); |
1233 test(KErrNone == error); |
1252 |
1234 |
1253 if (KErrNotSupported == error) |
|
1254 { |
|
1255 // Appears that passwords aren't supported on this drive config (i.e. NFE) |
|
1256 theFs.Close(); |
|
1257 test.End(); |
|
1258 return; |
|
1259 } |
|
1260 test_KErrNone(error); |
1235 |
1261 |
1236 // Verify that the password file does exist and is in the correct place |
1262 // Verify that the password file does exist and is in the correct place |
1237 test.Next(_L("check password file exists")); |
1263 test.Next(_L("check password file exists")); |
1238 TEntry theEntry; |
|
1239 TBuf<sizeof(KMediaPWrdFile)> mediaPWrdFile(KMediaPWrdFile); |
|
1240 mediaPWrdFile[0] = (TUint8) RFs::GetSystemDriveChar(); |
|
1241 error = theFs.Entry(mediaPWrdFile, theEntry); |
1264 error = theFs.Entry(mediaPWrdFile, theEntry); |
1242 test (KErrNone == error); |
1265 test.Printf(_L("password file exists: %d\n"),error); |
1243 |
1266 if (error != KErrNone && error != KErrNotFound) |
|
1267 { |
|
1268 test(0); |
|
1269 } |
1244 |
1270 |
1245 // Attempt to set a new password without specifying the current one |
1271 // Attempt to set a new password without specifying the current one |
1246 test.Next(_L("change password failure")); |
1272 test.Next(_L("change password failure")); |
1247 TMediaPassword& newPWrd = *PWDs[2]; |
1273 TMediaPassword& newPWrd = *PWDs[2]; |
1248 error = theFs.LockDrive(KDriveNum, nulPWrd, newPWrd, ETrue); |
1274 error = theFs.LockDrive(KDriveNum, nulPWrd, newPWrd, ETrue); |
1250 |
1276 |
1251 |
1277 |
1252 // Change the password for a new one... |
1278 // Change the password for a new one... |
1253 test.Next(_L("change password success")); |
1279 test.Next(_L("change password success")); |
1254 error = theFs.LockDrive(KDriveNum, oldPWrd, newPWrd, ETrue); |
1280 error = theFs.LockDrive(KDriveNum, oldPWrd, newPWrd, ETrue); |
1255 test(KErrNone == error); |
1281 test_KErrNone(error); |
1256 |
1282 |
1257 |
1283 |
1258 // Clear the password |
1284 // Clear the password |
|
1285 // NB The file server uses a separate thread to write to the password file, |
|
1286 // so we may need to wait a short while to see any change... |
1259 test.Next(_L("clear the password")); |
1287 test.Next(_L("clear the password")); |
1260 error = theFs.ClearPassword(KDriveNum, newPWrd); |
1288 error = theFs.ClearPassword(KDriveNum, newPWrd); |
1261 test(KErrNone == error); |
1289 test_KErrNone(error); |
1262 |
1290 |
1263 |
1291 |
1264 // Check that the password has been removed from the file |
1292 // Check that the password has been removed from the file |
1265 // (KMediaPWrdFile should now be zero bytes in size) |
1293 // (KMediaPWrdFile should now be zero bytes in size) |
1266 test.Next(_L("check password removal")); |
1294 test.Next(_L("check password removal")); |
1267 error = theFs.Entry(mediaPWrdFile, theEntry); |
1295 theEntry.iSize = KMaxTInt; |
1268 test (KErrNone == error); |
1296 TInt n; |
1269 test (0 == theEntry.iSize); |
1297 for (n=0; theEntry.iSize > 0 && n<10; n++) |
|
1298 { |
|
1299 error = theFs.Entry(mediaPWrdFile, theEntry); |
|
1300 test_KErrNone(error); |
|
1301 test.Printf(_L("Password file size is %d\n"), theEntry.iSize); |
|
1302 if (theEntry.iSize > 0) |
|
1303 User::After(1000000); |
|
1304 } |
|
1305 test (theEntry.iSize == 0); |
1270 |
1306 |
1271 |
1307 |
1272 // Remove the password file |
1308 // Remove the password file |
1273 test.Next(_L("tidy up")); |
1309 test.Next(_L("tidy up")); |
1274 error = theFs.Delete(mediaPWrdFile); |
1310 error = KErrInUse; |
1275 test (KErrNone == error); |
1311 for (n=0; error == KErrInUse && n<10; n++) |
|
1312 { |
|
1313 error = theFs.Delete(mediaPWrdFile); |
|
1314 test.Printf(_L("Deleting %S, Iter %d, r %d\n"), &mediaPWrdFile, n, error); |
|
1315 if (error == KErrInUse) |
|
1316 User::After(1000000); |
|
1317 } |
|
1318 test_KErrNone(error); |
1276 |
1319 |
1277 |
1320 |
1278 theFs.Close(); |
1321 theFs.Close(); |
1279 |
1322 |
1280 test.End(); |
1323 test.End(); |
1327 |
1370 |
1328 test.Next(_L("format locked card")); |
1371 test.Next(_L("format locked card")); |
1329 r = fmt.Open(fs, driveName, EHighDensity, stepPkg()); |
1372 r = fmt.Open(fs, driveName, EHighDensity, stepPkg()); |
1330 if (r != KErrLocked) |
1373 if (r != KErrLocked) |
1331 test.Printf(_L("RFormat::Next() returned %d\n"), r); |
1374 test.Printf(_L("RFormat::Next() returned %d\n"), r); |
1332 test(r == KErrLocked); |
1375 test_Value(r, r == KErrLocked); |
1333 |
1376 |
1334 test.Printf(_L("\n")); |
1377 test.Printf(_L("\n")); |
1335 fmt.Close(); |
1378 fmt.Close(); |
1336 |
1379 |
1337 _LIT(KLitStars,"********************"); |
1380 _LIT(KLitStars,"********************"); |
1338 test.Next(_L("force erase locked card")); |
1381 test.Next(_L("force erase locked card")); |
1339 r = fmt.Open(fs, driveName, EHighDensity | EForceErase, stepPkg()); |
1382 r = fmt.Open(fs, driveName, EHighDensity | EForceErase, stepPkg()); |
1340 if (r != KErrNone) |
1383 if (r != KErrNone) |
1341 test.Printf(_L("RFormat::Open() returned %d\n"), r); |
1384 test.Printf(_L("RFormat::Open() returned %d\n"), r); |
1342 test (r == KErrNone); |
1385 test_KErrNone(r); |
1343 |
1386 |
1344 while (stepPkg() > 0) |
1387 while (stepPkg() > 0) |
1345 { |
1388 { |
1346 TRequestStatus status; |
1389 TRequestStatus status; |
1347 fmt.Next(stepPkg, status); |
1390 fmt.Next(stepPkg, status); |
1386 test(TBLD.PasswordStoreLengthInBytes() == 0); |
1429 test(TBLD.PasswordStoreLengthInBytes() == 0); |
1387 |
1430 |
1388 test.Next(_L("lock card")); |
1431 test.Next(_L("lock card")); |
1389 test.Next(_L("assign test password")); |
1432 test.Next(_L("assign test password")); |
1390 r = TBLD.SetPassword(nulPWrd, testPassword, EFalse); |
1433 r = TBLD.SetPassword(nulPWrd, testPassword, EFalse); |
1391 test(r == KErrNone); |
1434 test_KErrNone(r); |
1392 |
1435 |
1393 RemountMedia(); // card is now locked |
1436 RemountMedia(); // card is now locked |
1394 |
1437 |
1395 // test Caps() reports that card is locked |
1438 // test Caps() reports that card is locked |
1396 test.Next(_L("test card is locked")); |
1439 test.Next(_L("test card is locked")); |
1397 TLocalDriveCapsV5 driveCaps; |
1440 TLocalDriveCapsV5 driveCaps; |
1398 TPckg<TLocalDriveCapsV5> driveCapsPkg(driveCaps); |
1441 TPckg<TLocalDriveCapsV5> driveCapsPkg(driveCaps); |
1399 r = TBLD.Caps(driveCapsPkg); |
1442 r = TBLD.Caps(driveCapsPkg); |
1400 test.Printf(_L("Caps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1443 test.Printf(_L("Caps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1401 |
1444 |
1402 test (r == KErrNone); |
1445 test_KErrNone(r); |
1403 test ((driveCaps.iMediaAtt & KMediaAttLocked) != 0); |
1446 test ((driveCaps.iMediaAtt & KMediaAttLocked) != 0); |
1404 |
1447 |
1405 // Write correct password to store |
1448 // Write correct password to store |
1406 test.Next(_L("write correct password to store")); |
1449 test.Next(_L("write correct password to store")); |
1407 |
1450 |
1455 |
1498 |
1456 TDriveInfoV1Buf diBuf; |
1499 TDriveInfoV1Buf diBuf; |
1457 UserHal::DriveInfo(diBuf); |
1500 UserHal::DriveInfo(diBuf); |
1458 TDriveInfoV1 &di=diBuf(); |
1501 TDriveInfoV1 &di=diBuf(); |
1459 |
1502 |
1460 test.Printf(_L(" iRegisteredDriveBitmask 0x%08X"), di.iRegisteredDriveBitmask); |
1503 test.Printf(_L(" iRegisteredDriveBitmask 0x%08X\n"), di.iRegisteredDriveBitmask); |
1461 |
1504 |
1462 aDrive = -1; |
1505 aDrive = -1; |
1463 |
1506 |
1464 TLocalDriveCapsV5Buf capsBuf; |
1507 TLocalDriveCapsV5Buf capsBuf; |
1465 TBusLocalDrive TBLD; |
1508 TBusLocalDrive TBLD; |
1466 TLocalDriveCapsV5& caps = capsBuf(); |
1509 TLocalDriveCapsV5& caps = capsBuf(); |
|
1510 |
1467 TPtrC8 localSerialNum; |
1511 TPtrC8 localSerialNum; |
1468 TInt registeredDriveNum = 0; |
1512 TInt registeredDriveNum = 0; |
|
1513 |
|
1514 // Find a Drive that has Password support. |
1469 for(aDrive=0; aDrive < KMaxLocalDrives; aDrive++) |
1515 for(aDrive=0; aDrive < KMaxLocalDrives; aDrive++) |
1470 { |
1516 { |
1471 TInt driveNumberMask = 1 << aDrive; |
1517 TInt driveNumberMask = 1 << aDrive; |
1472 if ((di.iRegisteredDriveBitmask & driveNumberMask) == 0) |
1518 if ((di.iRegisteredDriveBitmask & driveNumberMask) == 0) |
1473 continue; |
1519 continue; |
1474 |
1520 |
1475 test.Printf(_L(" Drive %d - %S\r\n"), aDrive, &di.iDriveName[registeredDriveNum]); |
1521 test.Printf(_L(" Drive %d - %S\r\n"), aDrive, &di.iDriveName[registeredDriveNum]); |
1476 |
1522 |
1477 // check that the card is readable (so we can ignore for empty card slots) |
1523 TBool TBLDChangedFlag; |
1478 if ((di.iDriveName[registeredDriveNum].MatchF(_L("MultiMediaCard0")) == KErrNone) || |
1524 TInt r = TBLD.Connect(aDrive, TBLDChangedFlag); |
1479 (di.iDriveName[registeredDriveNum].MatchF(_L("SDIOCard0")) == KErrNone)) |
|
1480 { |
|
1481 |
|
1482 TBool TBLDChangedFlag; |
|
1483 TInt r = TBLD.Connect(aDrive, TBLDChangedFlag); |
|
1484 //test.Printf(_L(" Connect returned %d\n"), r); |
1525 //test.Printf(_L(" Connect returned %d\n"), r); |
1485 if (r == KErrNone) |
1526 if (r == KErrNone) |
1486 { |
1527 { |
1487 r = TBLD.Caps(capsBuf); |
1528 r = TBLD.Caps(capsBuf); |
1488 localSerialNum.Set(caps.iSerialNum, caps.iSerialNumLength); |
1529 |
1489 const TInt KSectSize = 512; |
1530 //Check media is lockable if not carry on |
1490 TBuf8<KSectSize> sect; |
1531 if (caps.iMediaAtt & KMediaAttLockable) |
1491 r = TBLD.Read(0, KSectSize, sect); |
1532 { |
|
1533 test.Printf(_L("Drive %d is Lockable\n"),aDrive); |
|
1534 localSerialNum.Set(caps.iSerialNum, caps.iSerialNumLength); |
|
1535 const TInt KSectSize = 512; |
|
1536 TBuf8<KSectSize> sect; |
|
1537 r = TBLD.Read(0, KSectSize, sect); |
1492 //test.Printf(_L(" Read returned %d\n"), r); |
1538 //test.Printf(_L(" Read returned %d\n"), r); |
1493 |
1539 |
1494 TBLD.Disconnect(); |
1540 TBLD.Disconnect(); |
1495 if (r == KErrNone) |
1541 if (r == KErrNone) |
1496 break; |
1542 break; |
1497 } |
1543 } |
|
1544 |
|
1545 TBLD.Disconnect(); |
1498 } |
1546 } |
1499 registeredDriveNum++; |
1547 registeredDriveNum++; |
1500 } |
1548 } |
1501 |
1549 |
1502 if(aDrive == KMaxLocalDrives) |
1550 if(aDrive == KMaxLocalDrives) |
1655 // Lock card (with password stored) |
1705 // Lock card (with password stored) |
1656 test.Next(_L("Locking Card - Password Stored")); |
1706 test.Next(_L("Locking Card - Password Stored")); |
1657 |
1707 |
1658 test.Next(_L("Locking card (Successful)")) ; |
1708 test.Next(_L("Locking card (Successful)")) ; |
1659 r = TestLockCard(fs, RFsDNum, oldpassword, password, ETrue); |
1709 r = TestLockCard(fs, RFsDNum, oldpassword, password, ETrue); |
1660 test(r == KErrNone); |
1710 test_KErrNone(r); |
1661 |
1711 |
1662 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1712 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1663 |
1713 |
1664 test.Next(_L("Card reports unlocked - before PowerDown")); |
1714 test.Next(_L("Card reports unlocked - before PowerDown")); |
1665 r = TBLD.Caps(driveCapsPkg); |
1715 r = TBLD.Caps(driveCapsPkg); |
1666 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1716 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1667 |
1717 |
1668 test (r == KErrNone); |
1718 test_KErrNone(r); |
1669 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1719 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1670 |
1720 |
1671 WaitForPowerDownUnlock(fs, RFsDNum); |
1721 WaitForPowerDownUnlock(fs, RFsDNum); |
1672 |
1722 |
1673 test.Next(_L("Check card reports unlocked - after PowerDown")); |
1723 test.Next(_L("Check card reports unlocked - after PowerDown")); |
1674 r = TBLD.Caps(driveCapsPkg); |
1724 r = TBLD.Caps(driveCapsPkg); |
1675 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1725 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1676 |
1726 |
1677 test (r == KErrNone); |
1727 test_KErrNone(r); |
1678 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1728 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1679 |
1729 |
1680 test.Next(_L("Clear password (Successful)")); |
1730 test.Next(_L("Clear password (Successful)")); |
1681 r = TestClearPassword(fs, RFsDNum, password); |
1731 r = TestClearPassword(fs, RFsDNum, password); |
1682 test(r == KErrNone); |
1732 test_KErrNone(r); |
1683 |
1733 |
1684 // Lock card (without password in store) |
1734 // Lock card (without password in store) |
1685 test.Next(_L("Locking card - Password NOT Stored")); |
1735 test.Next(_L("Locking card - Password NOT Stored")); |
1686 |
1736 |
1687 test.Next(_L("Locking card (Successful)")); |
1737 test.Next(_L("Locking card (Successful)")); |
1688 r = TestLockCard(fs, RFsDNum, oldpassword, password, EFalse); |
1738 r = TestLockCard(fs, RFsDNum, oldpassword, password, EFalse); |
1689 test(r == KErrNone); |
1739 test_KErrNone(r); |
1690 |
1740 |
1691 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1741 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1692 |
1742 |
1693 test.Next(_L("Card is reports Unlocked - before PowerDown")); |
1743 test.Next(_L("Card is reports Unlocked - before PowerDown")); |
1694 r = TBLD.Caps(driveCapsPkg); |
1744 r = TBLD.Caps(driveCapsPkg); |
1695 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1745 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1696 |
1746 |
1697 test (r == KErrNone); |
1747 test_KErrNone(r); |
1698 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1748 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1699 |
1749 |
1700 WaitForPowerDownLock(fs, RFsDNum); |
1750 WaitForPowerDownLock(fs, RFsDNum); |
1701 |
1751 |
1702 test.Next(_L("Card reports Locked - after PowerDown")); |
1752 test.Next(_L("Card reports Locked - after PowerDown")); |
1703 r = TBLD.Caps(driveCapsPkg); |
1753 r = TBLD.Caps(driveCapsPkg); |
1704 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1754 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1705 |
1755 |
1706 test (r == KErrNone); |
1756 test_KErrNone(r); |
1707 test ((driveCaps.iMediaAtt & KMediaAttLocked) != 0); |
1757 test ((driveCaps.iMediaAtt & KMediaAttLocked) != 0); |
1708 |
1758 |
1709 // Unlock card |
1759 // Unlock card |
1710 test.Next(_L("Unlock 'locked' Card - Password Stored")); |
1760 test.Next(_L("Unlock 'locked' Card - Password Stored")); |
1711 |
1761 |
1712 test.Next(_L("Unlocking card (Successful)")) ; |
1762 test.Next(_L("Unlocking card (Successful)")) ; |
1713 r = TestUnlockCard(fs, RFsDNum, password, ETrue); |
1763 r = TestUnlockCard(fs, RFsDNum, password, ETrue); |
1714 test(r == KErrNone); |
1764 test_KErrNone(r); |
1715 test (!TestLocked(fs, RFsDNum)); // not locked as stack hasn't powered down |
1765 test (!TestLocked(fs, RFsDNum)); // not locked as stack hasn't powered down |
1716 |
1766 |
1717 test.Next(_L("Card reports unlocked - before PowerDown")); |
1767 test.Next(_L("Card reports unlocked - before PowerDown")); |
1718 r = TBLD.Caps(driveCapsPkg); |
1768 r = TBLD.Caps(driveCapsPkg); |
1719 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1769 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1720 |
1770 |
1721 test (r == KErrNone); |
1771 test_KErrNone(r); |
1722 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1772 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1723 |
1773 |
1724 WaitForPowerDownUnlock(fs, RFsDNum); |
1774 WaitForPowerDownUnlock(fs, RFsDNum); |
1725 |
1775 |
1726 test.Next(_L("Card reports unlocked - after PowerDown")); |
1776 test.Next(_L("Card reports unlocked - after PowerDown")); |
1727 r = TBLD.Caps(driveCapsPkg); |
1777 r = TBLD.Caps(driveCapsPkg); |
1728 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1778 test.Printf(_L("\tCaps() returned %d , iMediaAtt %08x\n"), r, driveCaps.iMediaAtt); |
1729 |
1779 |
1730 test (r == KErrNone); |
1780 test_KErrNone(r); |
1731 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1781 test ((driveCaps.iMediaAtt & KMediaAttLocked) == 0); |
1732 |
1782 |
1733 test.Next(_L("Clearing Password (Successful)")); |
1783 test.Next(_L("Clearing Password (Successful)")); |
1734 r = TestClearPassword(fs, RFsDNum, password); |
1784 r = TestClearPassword(fs, RFsDNum, password); |
1735 test(r == KErrNone); |
1785 test_KErrNone(r); |
1736 |
1786 |
1737 fs.Close(); |
1787 fs.Close(); |
1738 |
1788 |
1739 test.End(); |
1789 test.End(); |
1740 } |
1790 } |
1755 TMediaPassword oldpassword; |
1805 TMediaPassword oldpassword; |
1756 TMediaPassword newpassword = (TUint8*) "salasana"; |
1806 TMediaPassword newpassword = (TUint8*) "salasana"; |
1757 TMediaPassword wrongpwd = (TUint8*) "failtest"; |
1807 TMediaPassword wrongpwd = (TUint8*) "failtest"; |
1758 |
1808 |
1759 r = TestLockCard(fs, RFsDNum, oldpassword, newpassword, EFalse); |
1809 r = TestLockCard(fs, RFsDNum, oldpassword, newpassword, EFalse); |
1760 test(r == KErrNone); |
1810 test_KErrNone(r); |
1761 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1811 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1762 |
1812 |
1763 test.Next(_L("test unlocking fails if still powered up")); |
1813 test.Next(_L("test unlocking fails if still powered up")); |
1764 r = TestUnlockCard(fs, RFsDNum, newpassword, EFalse); |
1814 r = TestUnlockCard(fs, RFsDNum, newpassword, EFalse); |
1765 test(r == KErrAlreadyExists); // already unlocked (as stack won't have powered down yet) |
1815 test_Value(r, r == KErrAlreadyExists); // already unlocked (as stack won't have powered down yet) |
1766 test (!TestLocked(fs, RFsDNum)); |
1816 test (!TestLocked(fs, RFsDNum)); |
1767 |
1817 |
1768 test.Next(_L("test clearing succeeds if still powered up")); |
1818 test.Next(_L("test clearing succeeds if still powered up")); |
1769 r = TestClearPassword(fs, RFsDNum, newpassword); |
1819 r = TestClearPassword(fs, RFsDNum, newpassword); |
1770 test(r == KErrNone); |
1820 test_KErrNone(r); |
1771 test(!TestLocked(fs, RFsDNum)); |
1821 test(!TestLocked(fs, RFsDNum)); |
1772 |
1822 |
1773 test.Next(_L("test locking card again")); |
1823 test.Next(_L("test locking card again")); |
1774 r = TestLockCard(fs, RFsDNum, oldpassword, newpassword, EFalse); |
1824 r = TestLockCard(fs, RFsDNum, oldpassword, newpassword, EFalse); |
1775 test(r == KErrNone); |
1825 test_KErrNone(r); |
1776 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1826 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1777 |
1827 |
1778 WaitForPowerDownLock(fs, RFsDNum); |
1828 WaitForPowerDownLock(fs, RFsDNum); |
1779 |
1829 |
1780 // DEF111681: CheckDisk is returning bad error code when run on locked SD card |
1830 // DEF111681: CheckDisk is returning bad error code when run on locked SD card |
1786 WaitForPowerDownLock(fs, RFsDNum); |
1836 WaitForPowerDownLock(fs, RFsDNum); |
1787 TFileName sessionPath; |
1837 TFileName sessionPath; |
1788 sessionPath=_L("?:\\"); |
1838 sessionPath=_L("?:\\"); |
1789 TChar driveLetter; |
1839 TChar driveLetter; |
1790 r = fs.DriveToChar(RFsDNum,driveLetter); |
1840 r = fs.DriveToChar(RFsDNum,driveLetter); |
1791 test(r==KErrNone); |
1841 test_KErrNone(r); |
1792 sessionPath[0]=(TText)driveLetter; |
1842 sessionPath[0]=(TText)driveLetter; |
1793 r = fs.CheckDisk(sessionPath); |
1843 r = fs.CheckDisk(sessionPath); |
1794 test(r == KErrNone || r == KErrLocked); |
1844 test_Value(r, r == KErrNone || r == KErrLocked); |
1795 WaitForPowerDownLock(fs, RFsDNum); |
1845 WaitForPowerDownLock(fs, RFsDNum); |
1796 |
1846 |
1797 |
1847 |
1798 // DEF111700: Formatting a locked SD/MMC leaves it in a bad state (causes panics later) |
1848 // DEF111700: Formatting a locked SD/MMC leaves it in a bad state (causes panics later) |
1799 // This was caused by format calling TDrive::MountMedia(ETrue) and then not dismounting |
1849 // This was caused by format calling TDrive::MountMedia(ETrue) and then not dismounting |
1800 r = fs.RemountDrive(RFsDNum); |
1850 r = fs.RemountDrive(RFsDNum); |
1801 test (r == KErrNone); |
1851 test_KErrNone(r); |
1802 RFormat fmt; |
1852 RFormat fmt; |
1803 TPckgBuf<TInt> stepPkg; |
1853 TPckgBuf<TInt> stepPkg; |
1804 TDriveUnit driveUnit(RFsDNum); |
1854 TDriveUnit driveUnit(RFsDNum); |
1805 TDriveName driveName = driveUnit.Name(); |
1855 TDriveName driveName = driveUnit.Name(); |
1806 test.Next(_L("format locked card")); |
1856 test.Next(_L("format locked card")); |
1807 r = fmt.Open(fs, driveName, EHighDensity, stepPkg()); |
1857 r = fmt.Open(fs, driveName, EHighDensity, stepPkg()); |
1808 if (r != KErrLocked) |
1858 if (r != KErrLocked) |
1809 test.Printf(_L("RFormat::Next() returned %d\n"), r); |
1859 test.Printf(_L("RFormat::Next() returned %d\n"), r); |
1810 test(r == KErrLocked); |
1860 test_Value(r, r == KErrLocked); |
1811 test.Printf(_L("\n")); |
1861 test.Printf(_L("\n")); |
1812 fmt.Close(); |
1862 fmt.Close(); |
1813 r = fs.CheckDisk(sessionPath); |
1863 r = fs.CheckDisk(sessionPath); |
1814 test(r == KErrLocked); |
1864 test_Value(r, r == KErrLocked); |
1815 |
1865 |
1816 |
1866 |
1817 test.Next(_L("test unlocking fails after powered down & unlocked with wrong password")); |
1867 test.Next(_L("test unlocking fails after powered down & unlocked with wrong password")); |
1818 r = TestUnlockCard(fs, RFsDNum, wrongpwd, EFalse); |
1868 r = TestUnlockCard(fs, RFsDNum, wrongpwd, EFalse); |
1819 test(r == KErrAccessDenied); // unlocked should now fail |
1869 test_Value(r, r == KErrAccessDenied); // unlocked should now fail |
1820 |
1870 |
1821 test.Next(_L("test unlocking succeeds for correct password after powered down & locked")); |
1871 test.Next(_L("test unlocking succeeds for correct password after powered down & locked")); |
1822 r = TestUnlockCard(fs, RFsDNum, newpassword, EFalse); |
1872 r = TestUnlockCard(fs, RFsDNum, newpassword, EFalse); |
1823 test(r == KErrNone); // unlocked should now succeed |
1873 test_KErrNone(r); // unlocked should now succeed |
1824 |
1874 |
1825 test.Next(_L("test unlocking fails after successful unlock")); |
1875 test.Next(_L("test unlocking fails after successful unlock")); |
1826 r = TestUnlockCard(fs, RFsDNum, wrongpwd, EFalse); |
1876 r = TestUnlockCard(fs, RFsDNum, wrongpwd, EFalse); |
1827 test(r == KErrAlreadyExists); // unlocked should now succeed |
1877 test_Value(r, r == KErrAlreadyExists); // unlocked should now succeed |
1828 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1878 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1829 |
1879 |
1830 test.Next(_L("test locking card with new password (with wrong password as old password)")); |
1880 test.Next(_L("test locking card with new password (with wrong password as old password)")); |
1831 r = TestLockCard(fs, RFsDNum, wrongpwd, newpassword, EFalse); |
1881 r = TestLockCard(fs, RFsDNum, wrongpwd, newpassword, EFalse); |
1832 test(r == KErrAccessDenied); |
1882 test_Value(r, r == KErrAccessDenied); |
1833 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1883 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1834 |
1884 |
1835 test.Next(_L("test locking card with new password (with right password as old password)")); |
1885 test.Next(_L("test locking card with new password (with right password as old password)")); |
1836 r = TestLockCard(fs, RFsDNum, newpassword, wrongpwd, EFalse); |
1886 r = TestLockCard(fs, RFsDNum, newpassword, wrongpwd, EFalse); |
1837 test(r == KErrNone); |
1887 test_KErrNone(r); |
1838 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1888 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1839 |
1889 |
1840 WaitForPowerDownLock(fs, RFsDNum); |
1890 WaitForPowerDownLock(fs, RFsDNum); |
1841 |
1891 |
1842 test.Next(_L("test clearing fails with wrong password if powered down & locked")); |
1892 test.Next(_L("test clearing fails with wrong password if powered down & locked")); |
1843 r = TestClearPassword(fs, RFsDNum, newpassword); // Note: we have set the wrong password as the new password |
1893 r = TestClearPassword(fs, RFsDNum, newpassword); // Note: we have set the wrong password as the new password |
1844 test(r == KErrAccessDenied); |
1894 test_Value(r, r == KErrAccessDenied); |
1845 test(TestLocked(fs, RFsDNum)); |
1895 test(TestLocked(fs, RFsDNum)); |
1846 |
1896 |
1847 test.Next(_L("test clearing succeeds with right password if powered down & locked")); |
1897 test.Next(_L("test clearing succeeds with right password if powered down & locked")); |
1848 r = TestClearPassword(fs, RFsDNum, wrongpwd); |
1898 r = TestClearPassword(fs, RFsDNum, wrongpwd); |
1849 test(r == KErrNone); |
1899 test_KErrNone(r); |
1850 test(!TestLocked(fs, RFsDNum)); |
1900 test(!TestLocked(fs, RFsDNum)); |
1851 |
1901 |
1852 test.Next(_L("test locking card again")); |
1902 test.Next(_L("test locking card again")); |
1853 r = TestLockCard(fs, RFsDNum, oldpassword, newpassword, EFalse); |
1903 r = TestLockCard(fs, RFsDNum, oldpassword, newpassword, EFalse); |
1854 test(r == KErrNone); |
1904 test_KErrNone(r); |
1855 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1905 test(!TestLocked(fs, RFsDNum)); // not locked yet as stack hasn't powered down |
1856 |
1906 |
1857 test.Next(_L("test forced erase fails if still powered up")); |
1907 test.Next(_L("test forced erase fails if still powered up")); |
1858 r = ExecuteForcedEraseTestL(fs, RFsDNum); |
1908 r = ExecuteForcedEraseTestL(fs, RFsDNum); |
1859 test(r == KErrAccessDenied); // fails because card is not yet locked |
1909 test_Value(r, r == KErrAccessDenied); // fails because card is not yet locked |
1860 |
1910 |
1861 WaitForPowerDownLock(fs, RFsDNum); |
1911 WaitForPowerDownLock(fs, RFsDNum); |
1862 |
1912 |
1863 |
1913 |
1864 test.Next(_L("test forced erase succeeds if powered down & locked")); |
1914 test.Next(_L("test forced erase succeeds if powered down & locked")); |
1865 r = ExecuteForcedEraseTestL(fs, RFsDNum); |
1915 r = ExecuteForcedEraseTestL(fs, RFsDNum); |
1866 test(r == KErrNone); |
1916 test_KErrNone(r); |
1867 |
1917 |
1868 fs.Close(); |
1918 fs.Close(); |
1869 test.End(); |
1919 test.End(); |
1870 } |
1920 } |
1871 |
1921 |
1953 test(TBLD.Connect(TBLDNum, TBLDChangedFlag) == KErrNone); |
2002 test(TBLD.Connect(TBLDNum, TBLDChangedFlag) == KErrNone); |
1954 |
2003 |
1955 test.Next(_L("Allocating test data")); |
2004 test.Next(_L("Allocating test data")); |
1956 AllocateTestData(); |
2005 AllocateTestData(); |
1957 |
2006 |
1958 test.Next(_L("Testing locking / unlocking using file server APIs")); |
2007 if (gManual) |
1959 TestFsLockUnlock(); |
2008 { |
1960 |
2009 test.Next(_L("Testing locking / unlocking using file server APIs")); |
1961 test.Next(_L("Testing Power Down Status Reporting using file server APIs")); |
2010 TestFsLockUnlock(); |
1962 TestPowerDownStatus(); |
2011 |
1963 |
2012 test.Next(_L("Testing Power Down Status Reporting using file server APIs")); |
1964 test.Next(_L("Testing RFs::NotifyChange() with RFs::UnlockDrive()")); |
2013 TestPowerDownStatus(); |
1965 TestUnlockDriveNotifyChange(); |
2014 |
1966 |
2015 test.Next(_L("Testing RFs::NotifyChange() with RFs::UnlockDrive()")); |
1967 test.Next(_L("Forced Erase")); |
2016 TestUnlockDriveNotifyChange(); |
1968 TestFormatErase(); |
2017 |
|
2018 test.Next(_L("Forced Erase")); |
|
2019 TestFormatErase(); |
|
2020 } |
|
2021 |
1969 test.Next(_L("Testing store management")); |
2022 test.Next(_L("Testing store management")); |
1970 TestStaticStore(); |
2023 TestStaticStore(); |
1971 test.Next(_L("Testing locking functions")); |
2024 |
1972 TestLockUnlock(); |
2025 if (gManual) |
1973 test.Next(_L("Testing Elide Passwords")); |
2026 { |
1974 TestElidePasswords(); |
2027 test.Next(_L("Testing locking functions")); |
1975 test.Next(_L("Testing Null Passwords")); |
2028 TestLockUnlock(); |
1976 TestNullPasswords(); |
2029 test.Next(_L("Testing Elide Passwords")); |
1977 test.Next(_L("Testing controller store")); |
2030 TestElidePasswords(); |
1978 TestControllerStore(); |
2031 test.Next(_L("Testing Null Passwords")); |
1979 test.Next(_L("Testing auto unlock")); |
2032 TestNullPasswords(); |
1980 TestAutoUnlock(); |
2033 test.Next(_L("Testing controller store")); |
|
2034 TestControllerStore(); |
|
2035 test.Next(_L("Testing auto unlock")); |
|
2036 TestAutoUnlock(); |
|
2037 } |
|
2038 |
1981 test.Next(_L("Testing password file")); |
2039 test.Next(_L("Testing password file")); |
1982 TestPasswordFile(); |
2040 TestPasswordFile(); |
1983 test.Next(_L("Testing writing a valid password to store unlocks card")); |
2041 |
1984 TestWriteToPasswordStoreUnlocksCard(); |
2042 if (gManual) |
1985 |
2043 { |
|
2044 test.Next(_L("Testing writing a valid password to store unlocks card")); |
|
2045 TestWriteToPasswordStoreUnlocksCard(); |
|
2046 } |
|
2047 |
1986 test.Next(_L("Disconnecting TBLD")); |
2048 test.Next(_L("Disconnecting TBLD")); |
1987 TBLD.Disconnect(); |
2049 TBLD.Disconnect(); |
1988 |
2050 |
1989 test.Next(_L("Deleting test data")); |
2051 test.Next(_L("Deleting test data")); |
1990 DeleteTestData(); |
2052 DeleteTestData(); |
1991 |
2053 |
1992 __UHEAP_MARKEND; |
2054 __UHEAP_MARKEND; |
1993 } |
2055 } |
1994 |
2056 |
|
2057 LOCAL_D void ParseCommandLineArgs() |
|
2058 { |
|
2059 |
|
2060 TBuf<0x100> cmd; |
|
2061 User::CommandLine(cmd); |
|
2062 TLex lex(cmd); |
|
2063 |
|
2064 for (TPtrC token=lex.NextToken(); token.Length() != 0;token.Set(lex.NextToken())) |
|
2065 { |
|
2066 if (token.CompareF(_L("-m"))== 0) |
|
2067 { |
|
2068 gManual = ETrue; |
|
2069 continue; |
|
2070 } |
|
2071 } |
|
2072 } |
1995 |
2073 |
1996 TInt E32Main() |
2074 TInt E32Main() |
1997 { |
2075 { |
1998 |
2076 |
1999 test.Title(); |
2077 test.Title(); |
2000 test.Start(_L("E32Main")); |
2078 test.Start(_L("T_PWSTR")); |
2001 |
2079 |
2002 RunTests(); |
2080 #if defined(__WINS__) |
2003 |
2081 if (!gManual) |
|
2082 { |
|
2083 test.Printf(_L("Automated T_PWSTR not supported on emulated devices\n")); |
|
2084 } |
|
2085 else |
|
2086 #endif |
|
2087 { |
|
2088 ParseCommandLineArgs(); |
|
2089 |
|
2090 RunTests(); |
|
2091 } |
|
2092 |
|
2093 |
2004 test.End(); |
2094 test.End(); |
2005 test.Close(); |
2095 test.Close(); |
2006 |
2096 |
2007 return KErrNone; |
2097 return KErrNone; |
2008 } |
2098 } |