From d9dac474dcd98cba0d0cb523e7240896255572b8 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 1 Sep 2006 08:45:50 +0000 Subject: (refs #3) Use correct directory separator everywhere --- test/backupstore/testbackupstore.cpp | 72 +++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 76cca520..b98058cf 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -948,7 +948,7 @@ int test_server(const char *hostname) // Set the client store marker protocol.QuerySetClientStoreMarker(0x8732523ab23aLL); -#ifndef WIN32 +#ifndef WIN32 // can't open more than one connection on Win32 // Open a new connection which is read only SocketStreamTLS connReadOnly; connReadOnly.Open(context, Socket::TypeINET, hostname, BOX_PORT_BBSTORED); @@ -968,6 +968,7 @@ int test_server(const char *hostname) TEST_THAT(loginConf->GetClientStoreMarker() == 0x8732523ab23aLL); } #else // WIN32 + // we can't open a new connection, so fake it BackupProtocolClient& protocolReadOnly(protocol); #endif @@ -1530,35 +1531,48 @@ int test3(int argc, const char *argv[]) // The test block to a file { - FileStream f("testfiles/testenc1", O_WRONLY | O_CREAT | O_EXCL); + FileStream f("testfiles" DIRECTORY_SEPARATOR + "testenc1", O_WRONLY | O_CREAT | O_EXCL); f.Write(encfile, sizeof(encfile)); } // Encode it { - FileStream out("testfiles/testenc1_enc", O_WRONLY | O_CREAT | O_EXCL); - BackupStoreFilenameClear name("testfiles/testenc1"); + FileStream out("testfiles" DIRECTORY_SEPARATOR + "testenc1_enc", O_WRONLY | O_CREAT | O_EXCL); + BackupStoreFilenameClear name("testfiles" + DIRECTORY_SEPARATOR "testenc1"); - std::auto_ptr encoded(BackupStoreFile::EncodeFile("testfiles/testenc1", 32, name)); + std::auto_ptr encoded( + BackupStoreFile::EncodeFile( + "testfiles" DIRECTORY_SEPARATOR + "testenc1", 32, name)); encoded->CopyStreamTo(out); } // Verify it { - FileStream enc("testfiles/testenc1_enc"); + FileStream enc("testfiles" DIRECTORY_SEPARATOR + "testenc1_enc"); TEST_THAT(BackupStoreFile::VerifyEncodedFileFormat(enc) == true); } // Decode it { - FileStream enc("testfiles/testenc1_enc"); - BackupStoreFile::DecodeFile(enc, "testfiles/testenc1_orig", IOStream::TimeOutInfinite); + FileStream enc("testfiles" DIRECTORY_SEPARATOR + "testenc1_enc"); + BackupStoreFile::DecodeFile(enc, "testfiles" + DIRECTORY_SEPARATOR "testenc1_orig", + IOStream::TimeOutInfinite); } // Read in rebuilt original, and compare contents { - TEST_THAT(TestGetFileSize("testfiles/testenc1_orig") == sizeof(encfile)); - FileStream in("testfiles/testenc1_orig"); + TEST_THAT(TestGetFileSize("testfiles" + DIRECTORY_SEPARATOR "testenc1_orig") + == sizeof(encfile)); + FileStream in("testfiles" DIRECTORY_SEPARATOR + "testenc1_orig"); int encfile_i[ENCFILE_SIZE]; in.Read(encfile_i, sizeof(encfile_i)); TEST_THAT(memcmp(encfile, encfile_i, sizeof(encfile)) == 0); @@ -1566,7 +1580,8 @@ int test3(int argc, const char *argv[]) // Check how many blocks it had, and test the stream based interface { - FileStream enc("testfiles/testenc1_enc"); + FileStream enc("testfiles" DIRECTORY_SEPARATOR + "testenc1_enc"); std::auto_ptr decoded(BackupStoreFile::DecodeFileStream(enc, IOStream::TimeOutInfinite)); CollectInBufferStream d; decoded->CopyStreamTo(d, IOStream::TimeOutInfinite, 971 /* buffer block size */); @@ -1580,10 +1595,15 @@ int test3(int argc, const char *argv[]) // Test that the last block in a file, if less than 256 bytes, gets put into the last block { #define FILE_SIZE_JUST_OVER ((4096*2)+58) - FileStream f("testfiles/testenc2", O_WRONLY | O_CREAT | O_EXCL); + FileStream f("testfiles" DIRECTORY_SEPARATOR + "testenc2", O_WRONLY | O_CREAT | O_EXCL); f.Write(encfile + 2, FILE_SIZE_JUST_OVER); + f.Close(); BackupStoreFilenameClear name("testenc2"); - std::auto_ptr encoded(BackupStoreFile::EncodeFile("testfiles/testenc2", 32, name)); + std::auto_ptr encoded( + BackupStoreFile::EncodeFile( + "testfiles" DIRECTORY_SEPARATOR + "testenc2", 32, name)); CollectInBufferStream e; encoded->CopyStreamTo(e); e.SetForReading(); @@ -1599,7 +1619,8 @@ int test3(int argc, const char *argv[]) // Test that reordered streams work too { - FileStream enc("testfiles/testenc1_enc"); + FileStream enc("testfiles" DIRECTORY_SEPARATOR + "testenc1_enc"); std::auto_ptr reordered(BackupStoreFile::ReorderFileToStreamOrder(&enc, false)); std::auto_ptr decoded(BackupStoreFile::DecodeFileStream(*reordered, IOStream::TimeOutInfinite)); CollectInBufferStream d; @@ -1629,9 +1650,14 @@ int test3(int argc, const char *argv[]) // Store info { RaidFileWrite::CreateDirectory(0, "test-info"); - BackupStoreInfo::CreateNew(76, "test-info/", 0, 3461231233455433LL, 2934852487LL); - TEST_CHECK_THROWS(BackupStoreInfo::CreateNew(76, "test-info/", 0, 0, 0), RaidFileException, CannotOverwriteExistingFile); - std::auto_ptr info(BackupStoreInfo::Load(76, "test-info/", 0, true)); + BackupStoreInfo::CreateNew(76, "test-info" DIRECTORY_SEPARATOR, + 0, 3461231233455433LL, 2934852487LL); + TEST_CHECK_THROWS(BackupStoreInfo::CreateNew(76, + "test-info" DIRECTORY_SEPARATOR, 0, 0, 0), + RaidFileException, CannotOverwriteExistingFile); + std::auto_ptr info( + BackupStoreInfo::Load(76, + "test-info" DIRECTORY_SEPARATOR, 0, true)); TEST_CHECK_THROWS(info->Save(), BackupStoreException, StoreInfoIsReadOnly); TEST_CHECK_THROWS(info->ChangeBlocksUsed(1), BackupStoreException, StoreInfoIsReadOnly); TEST_CHECK_THROWS(info->ChangeBlocksInOldFiles(1), BackupStoreException, StoreInfoIsReadOnly); @@ -1640,7 +1666,8 @@ int test3(int argc, const char *argv[]) TEST_CHECK_THROWS(info->AddDeletedDirectory(2), BackupStoreException, StoreInfoIsReadOnly); } { - std::auto_ptr info(BackupStoreInfo::Load(76, "test-info/", 0, false)); + std::auto_ptr info(BackupStoreInfo::Load(76, + "test-info" DIRECTORY_SEPARATOR, 0, false)); info->ChangeBlocksUsed(8); info->ChangeBlocksInOldFiles(9); info->ChangeBlocksInDeletedFiles(10); @@ -1658,7 +1685,8 @@ int test3(int argc, const char *argv[]) info->Save(); } { - std::auto_ptr info(BackupStoreInfo::Load(76, "test-info/", 0, true)); + std::auto_ptr info(BackupStoreInfo::Load(76, + "test-info" DIRECTORY_SEPARATOR, 0, true)); TEST_THAT(info->GetBlocksUsed() == 7); TEST_THAT(info->GetBlocksInOldFiles() == 5); TEST_THAT(info->GetBlocksInDeletedFiles() == 1); @@ -1676,9 +1704,9 @@ int test3(int argc, const char *argv[]) // Context TLSContext context; context.Initialise(false /* client */, - "testfiles/clientCerts.pem", - "testfiles/clientPrivKey.pem", - "testfiles/clientTrustedCAs.pem"); + "testfiles" DIRECTORY_SEPARATOR "clientCerts.pem", + "testfiles" DIRECTORY_SEPARATOR "clientPrivKey.pem", + "testfiles" DIRECTORY_SEPARATOR "clientTrustedCAs.pem"); // First, try logging in without an account having been created... just make sure login fails. int pid = LaunchServer("../../bin/bbstored/bbstored testfiles/bbstored.conf", "testfiles/bbstored.pid"); -- cgit v1.2.3