Changeset 922
- Timestamp:
- 01/09/2006 09:45:50 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
box/chris/merge/test/backupstore/testbackupstore.cpp
r921 r922 949 949 protocol.QuerySetClientStoreMarker(0x8732523ab23aLL); 950 950 951 #ifndef WIN32 951 #ifndef WIN32 // can't open more than one connection on Win32 952 952 // Open a new connection which is read only 953 953 SocketStreamTLS connReadOnly; … … 969 969 } 970 970 #else // WIN32 971 // we can't open a new connection, so fake it 971 972 BackupProtocolClient& protocolReadOnly(protocol); 972 973 #endif … … 1531 1532 // The test block to a file 1532 1533 { 1533 FileStream f("testfiles/testenc1", O_WRONLY | O_CREAT | O_EXCL); 1534 FileStream f("testfiles" DIRECTORY_SEPARATOR 1535 "testenc1", O_WRONLY | O_CREAT | O_EXCL); 1534 1536 f.Write(encfile, sizeof(encfile)); 1535 1537 } … … 1537 1539 // Encode it 1538 1540 { 1539 FileStream out("testfiles/testenc1_enc", O_WRONLY | O_CREAT | O_EXCL); 1540 BackupStoreFilenameClear name("testfiles/testenc1"); 1541 1542 std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/testenc1", 32, name)); 1541 FileStream out("testfiles" DIRECTORY_SEPARATOR 1542 "testenc1_enc", O_WRONLY | O_CREAT | O_EXCL); 1543 BackupStoreFilenameClear name("testfiles" 1544 DIRECTORY_SEPARATOR "testenc1"); 1545 1546 std::auto_ptr<IOStream> encoded( 1547 BackupStoreFile::EncodeFile( 1548 "testfiles" DIRECTORY_SEPARATOR 1549 "testenc1", 32, name)); 1543 1550 encoded->CopyStreamTo(out); 1544 1551 } … … 1546 1553 // Verify it 1547 1554 { 1548 FileStream enc("testfiles/testenc1_enc"); 1555 FileStream enc("testfiles" DIRECTORY_SEPARATOR 1556 "testenc1_enc"); 1549 1557 TEST_THAT(BackupStoreFile::VerifyEncodedFileFormat(enc) == true); 1550 1558 } … … 1552 1560 // Decode it 1553 1561 { 1554 FileStream enc("testfiles/testenc1_enc"); 1555 BackupStoreFile::DecodeFile(enc, "testfiles/testenc1_orig", IOStream::TimeOutInfinite); 1562 FileStream enc("testfiles" DIRECTORY_SEPARATOR 1563 "testenc1_enc"); 1564 BackupStoreFile::DecodeFile(enc, "testfiles" 1565 DIRECTORY_SEPARATOR "testenc1_orig", 1566 IOStream::TimeOutInfinite); 1556 1567 } 1557 1568 1558 1569 // Read in rebuilt original, and compare contents 1559 1570 { 1560 TEST_THAT(TestGetFileSize("testfiles/testenc1_orig") == sizeof(encfile)); 1561 FileStream in("testfiles/testenc1_orig"); 1571 TEST_THAT(TestGetFileSize("testfiles" 1572 DIRECTORY_SEPARATOR "testenc1_orig") 1573 == sizeof(encfile)); 1574 FileStream in("testfiles" DIRECTORY_SEPARATOR 1575 "testenc1_orig"); 1562 1576 int encfile_i[ENCFILE_SIZE]; 1563 1577 in.Read(encfile_i, sizeof(encfile_i)); … … 1567 1581 // Check how many blocks it had, and test the stream based interface 1568 1582 { 1569 FileStream enc("testfiles/testenc1_enc"); 1583 FileStream enc("testfiles" DIRECTORY_SEPARATOR 1584 "testenc1_enc"); 1570 1585 std::auto_ptr<BackupStoreFile::DecodedStream> decoded(BackupStoreFile::DecodeFileStream(enc, IOStream::TimeOutInfinite)); 1571 1586 CollectInBufferStream d; … … 1581 1596 { 1582 1597 #define FILE_SIZE_JUST_OVER ((4096*2)+58) 1583 FileStream f("testfiles/testenc2", O_WRONLY | O_CREAT | O_EXCL); 1598 FileStream f("testfiles" DIRECTORY_SEPARATOR 1599 "testenc2", O_WRONLY | O_CREAT | O_EXCL); 1584 1600 f.Write(encfile + 2, FILE_SIZE_JUST_OVER); 1601 f.Close(); 1585 1602 BackupStoreFilenameClear name("testenc2"); 1586 std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/testenc2", 32, name)); 1603 std::auto_ptr<IOStream> encoded( 1604 BackupStoreFile::EncodeFile( 1605 "testfiles" DIRECTORY_SEPARATOR 1606 "testenc2", 32, name)); 1587 1607 CollectInBufferStream e; 1588 1608 encoded->CopyStreamTo(e); … … 1600 1620 // Test that reordered streams work too 1601 1621 { 1602 FileStream enc("testfiles/testenc1_enc"); 1622 FileStream enc("testfiles" DIRECTORY_SEPARATOR 1623 "testenc1_enc"); 1603 1624 std::auto_ptr<IOStream> reordered(BackupStoreFile::ReorderFileToStreamOrder(&enc, false)); 1604 1625 std::auto_ptr<BackupStoreFile::DecodedStream> decoded(BackupStoreFile::DecodeFileStream(*reordered, IOStream::TimeOutInfinite)); … … 1630 1651 { 1631 1652 RaidFileWrite::CreateDirectory(0, "test-info"); 1632 BackupStoreInfo::CreateNew(76, "test-info/", 0, 3461231233455433LL, 2934852487LL); 1633 TEST_CHECK_THROWS(BackupStoreInfo::CreateNew(76, "test-info/", 0, 0, 0), RaidFileException, CannotOverwriteExistingFile); 1634 std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, "test-info/", 0, true)); 1653 BackupStoreInfo::CreateNew(76, "test-info" DIRECTORY_SEPARATOR, 1654 0, 3461231233455433LL, 2934852487LL); 1655 TEST_CHECK_THROWS(BackupStoreInfo::CreateNew(76, 1656 "test-info" DIRECTORY_SEPARATOR, 0, 0, 0), 1657 RaidFileException, CannotOverwriteExistingFile); 1658 std::auto_ptr<BackupStoreInfo> info( 1659 BackupStoreInfo::Load(76, 1660 "test-info" DIRECTORY_SEPARATOR, 0, true)); 1635 1661 TEST_CHECK_THROWS(info->Save(), BackupStoreException, StoreInfoIsReadOnly); 1636 1662 TEST_CHECK_THROWS(info->ChangeBlocksUsed(1), BackupStoreException, StoreInfoIsReadOnly); … … 1641 1667 } 1642 1668 { 1643 std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, "test-info/", 0, false)); 1669 std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, 1670 "test-info" DIRECTORY_SEPARATOR, 0, false)); 1644 1671 info->ChangeBlocksUsed(8); 1645 1672 info->ChangeBlocksInOldFiles(9); … … 1659 1686 } 1660 1687 { 1661 std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, "test-info/", 0, true)); 1688 std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, 1689 "test-info" DIRECTORY_SEPARATOR, 0, true)); 1662 1690 TEST_THAT(info->GetBlocksUsed() == 7); 1663 1691 TEST_THAT(info->GetBlocksInOldFiles() == 5); … … 1677 1705 TLSContext context; 1678 1706 context.Initialise(false /* client */, 1679 "testfiles /clientCerts.pem",1680 "testfiles /clientPrivKey.pem",1681 "testfiles /clientTrustedCAs.pem");1707 "testfiles" DIRECTORY_SEPARATOR "clientCerts.pem", 1708 "testfiles" DIRECTORY_SEPARATOR "clientPrivKey.pem", 1709 "testfiles" DIRECTORY_SEPARATOR "clientTrustedCAs.pem"); 1682 1710 1683 1711 // First, try logging in without an account having been created... just make sure login fails.
Note: See TracChangeset
for help on using the changeset viewer.
