summaryrefslogtreecommitdiff
path: root/test/backupstore/testbackupstore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/backupstore/testbackupstore.cpp')
-rw-r--r--test/backupstore/testbackupstore.cpp717
1 files changed, 0 insertions, 717 deletions
diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp
index cc708da0..661973e0 100644
--- a/test/backupstore/testbackupstore.cpp
+++ b/test/backupstore/testbackupstore.cpp
@@ -12,34 +12,6 @@
#include <stdlib.h>
#include <string.h>
-<<<<<<< HEAD
-#include "Test.h"
-#include "autogen_BackupProtocolClient.h"
-#include "SSLLib.h"
-#include "TLSContext.h"
-#include "SocketStreamTLS.h"
-#include "BoxPortsAndFiles.h"
-#include "BackupStoreConstants.h"
-#include "Socket.h"
-#include "BackupStoreFilenameClear.h"
-#include "CollectInBufferStream.h"
-#include "BackupStoreDirectory.h"
-#include "BackupStoreFile.h"
-#include "FileStream.h"
-#include "RaidFileController.h"
-#include "RaidFileWrite.h"
-#include "BackupStoreInfo.h"
-#include "BackupStoreException.h"
-#include "RaidFileException.h"
-#include "MemBlockStream.h"
-#include "BackupClientFileAttributes.h"
-#include "BackupClientCryptoKeys.h"
-#include "ServerControl.h"
-#include "BackupStoreAccountDatabase.h"
-#include "BackupStoreRefCountDatabase.h"
-#include "BackupStoreAccounts.h"
-#include "HousekeepStoreAccount.h"
-=======
#include "Archive.h"
#include "BackupClientCryptoKeys.h"
#include "BackupClientFileAttributes.h"
@@ -68,7 +40,6 @@
#include "TLSContext.h"
#include "Test.h"
#include "autogen_BackupProtocol.h"
->>>>>>> 0.12
#include "MemLeakFindOn.h"
@@ -252,13 +223,6 @@ void CheckEntries(BackupStoreDirectory &rDir, int16_t FlagsMustBeSet, int16_t Fl
int test1(int argc, const char *argv[])
{
-<<<<<<< HEAD
- // Initialise the raid file controller
- RaidFileController &rcontroller = RaidFileController::GetController();
- rcontroller.Initialise("testfiles/raidfile.conf");
-
-=======
->>>>>>> 0.12
// test some basics -- encoding and decoding filenames
{
// Make some filenames in various ways
@@ -471,15 +435,6 @@ void test_test_file(int t, IOStream &rStream)
void test_everything_deleted(BackupProtocolClient &protocol, int64_t DirID)
{
-<<<<<<< HEAD
- printf("Test for del: %llx\n", DirID);
-
- // Command
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
- DirID,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
printf("Test for del: %llx\n", (unsigned long long)DirID);
// Command
@@ -487,7 +442,6 @@ void test_everything_deleted(BackupProtocolClient &protocol, int64_t DirID)
DirID,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -499,11 +453,7 @@ void test_everything_deleted(BackupProtocolClient &protocol, int64_t DirID)
int dirs = 0;
while((en = i.Next()) != 0)
{
-<<<<<<< HEAD
- if(en->GetFlags() & BackupProtocolClientListDirectory::Flags_Dir)
-=======
if(en->GetFlags() & BackupProtocolListDirectory::Flags_Dir)
->>>>>>> 0.12
{
dirs++;
// Recurse
@@ -514,11 +464,7 @@ void test_everything_deleted(BackupProtocolClient &protocol, int64_t DirID)
files++;
}
// Check it's deleted
-<<<<<<< HEAD
- TEST_THAT(en->GetFlags() & BackupProtocolClientListDirectory::Flags_Deleted);
-=======
TEST_THAT(en->GetFlags() & BackupProtocolListDirectory::Flags_Deleted);
->>>>>>> 0.12
}
// Check there were the right number of files and directories
@@ -530,11 +476,7 @@ std::vector<uint32_t> ExpectedRefCounts;
void set_refcount(int64_t ObjectID, uint32_t RefCount = 1)
{
-<<<<<<< HEAD
- if (ExpectedRefCounts.size() <= ObjectID);
-=======
if ((int64_t)ExpectedRefCounts.size() <= ObjectID);
->>>>>>> 0.12
{
ExpectedRefCounts.resize(ObjectID + 1, 0);
}
@@ -547,11 +489,7 @@ void create_file_in_dir(std::string name, std::string source, int64_t parentId,
BackupStoreFilenameClear name_encoded("file_One");
std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(
source.c_str(), parentId, name_encoded));
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> stored(
-=======
std::auto_ptr<BackupProtocolSuccess> stored(
->>>>>>> 0.12
protocol.QueryStoreFile(
parentId,
0x123456789abcdefLL, /* modification time */
@@ -575,22 +513,14 @@ int64_t create_test_data_subdirs(BackupProtocolClient &protocol, int64_t indir,
// Create with dummy attributes
int attrS = 0;
MemBlockStream attr(&attrS, sizeof(attrS));
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory(
-=======
std::auto_ptr<BackupProtocolSuccess> dirCreate(protocol.QueryCreateDirectory(
->>>>>>> 0.12
indir,
9837429842987984LL, dirname, attr));
subdirid = dirCreate->GetObjectID();
}
-<<<<<<< HEAD
- printf("Create subdirs, depth = %d, dirid = %llx\n", depth, subdirid);
-=======
printf("Create subdirs, depth = %d, dirid = %llx\n", depth,
(unsigned long long)subdirid);
->>>>>>> 0.12
TEST_EQUAL(subdirid, rRefCount.GetLastObjectIDUsed());
TEST_EQUAL(1, rRefCount.GetRefCount(subdirid))
@@ -619,19 +549,11 @@ int64_t create_test_data_subdirs(BackupProtocolClient &protocol, int64_t indir,
void check_dir_after_uploads(BackupProtocolClient &protocol, const StreamableMemBlock &Attributes)
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
- TEST_THAT(dirreply->GetObjectID() == BackupProtocolClientListDirectory::RootDirectory);
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
BackupProtocolListDirectory::RootDirectory,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
TEST_THAT(dirreply->GetObjectID() == BackupProtocolListDirectory::RootDirectory);
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -652,15 +574,9 @@ void check_dir_after_uploads(BackupProtocolClient &protocol, const StreamableMem
TEST_THAT(en->GetName() == uploads[t].name);
TEST_THAT(en->GetObjectID() == uploads[t].allocated_objid);
TEST_THAT(en->GetModificationTime() == uploads[t].mod_time);
-<<<<<<< HEAD
- int correct_flags = BackupProtocolClientListDirectory::Flags_File;
- if(uploads[t].should_be_old_version) correct_flags |= BackupProtocolClientListDirectory::Flags_OldVersion;
- if(uploads[t].delete_file) correct_flags |= BackupProtocolClientListDirectory::Flags_Deleted;
-=======
int correct_flags = BackupProtocolListDirectory::Flags_File;
if(uploads[t].should_be_old_version) correct_flags |= BackupProtocolListDirectory::Flags_OldVersion;
if(uploads[t].delete_file) correct_flags |= BackupProtocolListDirectory::Flags_Deleted;
->>>>>>> 0.12
TEST_THAT(en->GetFlags() == correct_flags);
if(t == UPLOAD_ATTRS_EN)
{
@@ -689,17 +605,10 @@ typedef struct
void recursive_count_objects_r(BackupProtocolClient &protocol, int64_t id, recursive_count_objects_results &results)
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
- id,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
id,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -739,15 +648,9 @@ void recursive_count_objects(const char *hostname, int64_t id, recursive_count_o
BackupProtocolClient protocolReadOnly(connReadOnly);
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
- TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
- std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly));
-=======
std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly));
->>>>>>> 0.12
}
// Count objects
@@ -854,17 +757,10 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
for(int l = 0; l < 3; ++l)
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
BackupProtocolListDirectory::RootDirectory,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -875,17 +771,10 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
// Read the dir from the readonly connection (make sure it gets in the cache)
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
BackupProtocolListDirectory::RootDirectory,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -897,11 +786,7 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
BackupStoreFilenameClear store1name("testfiles/file1");
{
FileStream out("testfiles/file1_upload1", O_WRONLY | O_CREAT | O_EXCL);
-<<<<<<< HEAD
- std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocolClientListDirectory::RootDirectory, store1name));
-=======
std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocolListDirectory::RootDirectory, store1name));
->>>>>>> 0.12
encoded->CopyStreamTo(out);
}
@@ -911,13 +796,8 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
int64_t store1objid = 0;
{
FileStream upload("testfiles/file1_upload1");
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
- BackupProtocolClientListDirectory::RootDirectory,
-=======
std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile(
BackupProtocolListDirectory::RootDirectory,
->>>>>>> 0.12
0x123456789abcdefLL, /* modification time */
0x7362383249872dfLL, /* attr hash */
0, /* diff from ID */
@@ -930,11 +810,7 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
// And retrieve it
{
// Retrieve as object
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> getfile(protocol.QueryGetObject(store1objid));
-=======
std::auto_ptr<BackupProtocolSuccess> getfile(protocol.QueryGetObject(store1objid));
->>>>>>> 0.12
TEST_THAT(getfile->GetObjectID() == store1objid);
// BLOCK
{
@@ -949,11 +825,7 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
}
// Retrieve as file
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> getobj(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, store1objid));
-=======
std::auto_ptr<BackupProtocolSuccess> getobj(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, store1objid));
->>>>>>> 0.12
TEST_THAT(getobj->GetObjectID() == store1objid);
// BLOCK
{
@@ -979,11 +851,7 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
// Retrieve the block index, by ID
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid));
-=======
std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid));
->>>>>>> 0.12
TEST_THAT(getblockindex->GetObjectID() == store1objid);
std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream());
// Check against uploaded file
@@ -991,11 +859,7 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
}
// and again, by name
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolClientListDirectory::RootDirectory, store1name));
-=======
std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolListDirectory::RootDirectory, store1name));
->>>>>>> 0.12
TEST_THAT(getblockindex->GetObjectID() == store1objid);
std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream());
// Check against uploaded file
@@ -1005,17 +869,10 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
// Get the directory again, and see if the entry is in it
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
BackupProtocolListDirectory::RootDirectory,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -1038,11 +895,7 @@ void test_server_1(BackupProtocolClient &protocol, BackupProtocolClient &protoco
// Try using GetFile on a directory
{
-<<<<<<< HEAD
- TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> getFile(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, BackupProtocolClientListDirectory::RootDirectory)),
-=======
TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> getFile(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, BackupProtocolListDirectory::RootDirectory)),
->>>>>>> 0.12
ConnectionException, Conn_Protocol_UnexpectedReply);
}
}
@@ -1065,16 +918,6 @@ std::auto_ptr<SocketStreamTLS> open_conn(const char *hostname,
return conn;
}
-<<<<<<< HEAD
-std::auto_ptr<BackupProtocolClient> test_server_login(SocketStreamTLS& rConn)
-{
- // Make a protocol
- std::auto_ptr<BackupProtocolClient> protocol(new
- BackupProtocolClient(rConn));
-
- // Check the version
- std::auto_ptr<BackupProtocolClientVersion> serverVersion(
-=======
std::auto_ptr<BackupProtocolClient> test_server_login(const char *hostname,
TLSContext& rContext, std::auto_ptr<SocketStreamTLS>& rapConn)
{
@@ -1086,16 +929,11 @@ std::auto_ptr<BackupProtocolClient> test_server_login(const char *hostname,
// Check the version
std::auto_ptr<BackupProtocolVersion> serverVersion(
->>>>>>> 0.12
protocol->QueryVersion(BACKUP_STORE_SERVER_VERSION));
TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
// Login
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(
-=======
std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(
->>>>>>> 0.12
protocol->QueryLogin(0x01234567, 0));
return protocol;
@@ -1112,15 +950,6 @@ void run_housekeeping(BackupStoreAccountDatabase::Entry& rAccount)
housekeeping.DoHousekeeping(true /* keep trying forever */);
}
-<<<<<<< HEAD
-int test_server(const char *hostname)
-{
- TLSContext context;
- std::auto_ptr<SocketStreamTLS> conn = open_conn(hostname, context);
- std::auto_ptr<BackupProtocolClient> apProtocol(
- test_server_login(*conn));
- BackupProtocolClient& protocol(*apProtocol);
-=======
// Run housekeeping (for which we need to disconnect ourselves) and check
// that it doesn't change the numbers of files.
//
@@ -1150,7 +979,6 @@ int test_server(const char *hostname)
std::auto_ptr<SocketStreamTLS> conn;
std::auto_ptr<BackupProtocolClient> apProtocol =
test_server_login(hostname, context, conn);
->>>>>>> 0.12
// Make some test attributes
#define ATTR1_SIZE 245
@@ -1171,11 +999,7 @@ int test_server(const char *hostname)
// Get it logging
FILE *protocolLog = ::fopen("testfiles/protocol.log", "w");
TEST_THAT(protocolLog != 0);
-<<<<<<< HEAD
- protocol.SetLogToFile(protocolLog);
-=======
apProtocol->SetLogToFile(protocolLog);
->>>>>>> 0.12
#ifndef WIN32
// Check that we can't open a new connection which requests write permissions
@@ -1184,26 +1008,16 @@ int test_server(const char *hostname)
conn.Open(context, Socket::TypeINET, hostname,
BOX_PORT_BBSTORED_TEST);
BackupProtocolClient protocol(conn);
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
- TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
- TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),
-=======
std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),
->>>>>>> 0.12
ConnectionException, Conn_Protocol_UnexpectedReply);
protocol.QueryFinished();
}
#endif
// Set the client store marker
-<<<<<<< HEAD
- protocol.QuerySetClientStoreMarker(0x8732523ab23aLL);
-=======
apProtocol->QuerySetClientStoreMarker(0x8732523ab23aLL);
->>>>>>> 0.12
#ifndef WIN32
// Open a new connection which is read only
@@ -1218,26 +1032,14 @@ int test_server(const char *hostname)
protocolReadOnly.SetLogToFile(protocolReadOnlyLog);
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
- TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
- std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly));
-=======
std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly));
->>>>>>> 0.12
// Check client store marker
TEST_THAT(loginConf->GetClientStoreMarker() == 0x8732523ab23aLL);
}
#else // WIN32
-<<<<<<< HEAD
- BackupProtocolClient& protocolReadOnly(protocol);
-#endif
-
- test_server_1(protocol, protocolReadOnly);
-=======
#define protocolReadOnly (*apProtocol)
#endif
@@ -1262,7 +1064,6 @@ int test_server(const char *hostname)
run_housekeeping_and_check_account(hostname, context,
conn, apProtocol);
TEST_NUM_FILES(1, 0, 0, 1);
->>>>>>> 0.12
// sleep to ensure that the timestamp on the file will change
::safe_sleep(1);
@@ -1276,17 +1077,6 @@ int test_server(const char *hostname)
std::string filename("testfiles/test");
filename += uploads[t].fnextra;
int64_t modtime = 0;
-<<<<<<< HEAD
-
- std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocolClientListDirectory::RootDirectory, uploads[t].name, &modtime));
- TEST_THAT(modtime != 0);
-
- std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
- BackupProtocolClientListDirectory::RootDirectory,
- modtime,
- modtime, /* use it for attr hash too */
- 0, /* diff from ID */
-=======
std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocolListDirectory::RootDirectory, uploads[t].name, &modtime));
TEST_THAT(modtime != 0);
@@ -1296,7 +1086,6 @@ int test_server(const char *hostname)
modtime,
modtime, /* use it for attr hash too */
0, /* diff from ID */
->>>>>>> 0.12
uploads[t].name,
*upload));
uploads[t].allocated_objid = stored->GetObjectID();
@@ -1306,47 +1095,28 @@ int test_server(const char *hostname)
BOX_TRACE("wrote file " << filename << " to server "
"as object " <<
BOX_FORMAT_OBJECTID(stored->GetObjectID()));
-<<<<<<< HEAD
-=======
TEST_NUM_FILES(t + 2, 0, 0, 1);
run_housekeeping_and_check_account(hostname, context,
conn, apProtocol);
TEST_NUM_FILES(t + 2, 0, 0, 1);
->>>>>>> 0.12
}
// Add some attributes onto one of them
{
-<<<<<<< HEAD
- MemBlockStream attrnew(attr3, sizeof(attr3));
- std::auto_ptr<BackupProtocolClientSuccess> set(protocol.QuerySetReplacementFileAttributes(
- BackupProtocolClientListDirectory::RootDirectory,
-=======
TEST_NUM_FILES(UPLOAD_NUM + 1, 0, 0, 1);
MemBlockStream attrnew(attr3, sizeof(attr3));
std::auto_ptr<BackupProtocolSuccess> set(apProtocol->QuerySetReplacementFileAttributes(
BackupProtocolListDirectory::RootDirectory,
->>>>>>> 0.12
32498749832475LL,
uploads[UPLOAD_ATTRS_EN].name,
attrnew));
TEST_THAT(set->GetObjectID() == uploads[UPLOAD_ATTRS_EN].allocated_objid);
-<<<<<<< HEAD
-=======
TEST_NUM_FILES(UPLOAD_NUM + 1, 0, 0, 1);
->>>>>>> 0.12
}
// Delete one of them (will implicitly delete an old version)
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> del(protocol.QueryDeleteFile(
- BackupProtocolClientListDirectory::RootDirectory,
- uploads[UPLOAD_DELETE_EN].name));
- TEST_THAT(del->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid);
- }
-=======
std::auto_ptr<BackupProtocolSuccess> del(apProtocol->QueryDeleteFile(
BackupProtocolListDirectory::RootDirectory,
uploads[UPLOAD_DELETE_EN].name));
@@ -1354,23 +1124,11 @@ int test_server(const char *hostname)
TEST_NUM_FILES(UPLOAD_NUM, 0, 1, 1);
}
->>>>>>> 0.12
// Check that the block index can be obtained by name even though it's been deleted
{
// Fetch the raw object
{
FileStream out("testfiles/downloaddelobj", O_WRONLY | O_CREAT);
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> getobj(protocol.QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid));
- std::auto_ptr<IOStream> objstream(protocol.ReceiveStream());
- objstream->CopyStreamTo(out);
- }
- // query index and test
- std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByName(
- BackupProtocolClientListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name));
- TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid);
- std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream());
-=======
std::auto_ptr<BackupProtocolSuccess> getobj(apProtocol->QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid));
std::auto_ptr<IOStream> objstream(apProtocol->ReceiveStream());
objstream->CopyStreamTo(out);
@@ -1380,7 +1138,6 @@ int test_server(const char *hostname)
BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name));
TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid);
std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream());
->>>>>>> 0.12
TEST_THAT(check_block_index("testfiles/downloaddelobj", *blockIndexStream));
}
@@ -1388,15 +1145,9 @@ int test_server(const char *hostname)
for(int t = 0; t < UPLOAD_NUM; ++t)
{
printf("%d\n", t);
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> getFile(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, uploads[t].allocated_objid));
- TEST_THAT(getFile->GetObjectID() == uploads[t].allocated_objid);
- std::auto_ptr<IOStream> filestream(protocol.ReceiveStream());
-=======
std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, uploads[t].allocated_objid));
TEST_THAT(getFile->GetObjectID() == uploads[t].allocated_objid);
std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream());
->>>>>>> 0.12
test_test_file(t, *filestream);
}
@@ -1408,11 +1159,7 @@ int test_server(const char *hostname)
check_dir_after_uploads(protocolReadOnly, attrtest);
printf("done.\n\n");
// And on the read/write one
-<<<<<<< HEAD
- check_dir_after_uploads(protocol, attrtest);
-=======
check_dir_after_uploads(*apProtocol, attrtest);
->>>>>>> 0.12
}
// sleep to ensure that the timestamp on the file will change
@@ -1434,14 +1181,6 @@ int test_server(const char *hostname)
out.Write(buf, TEST_FILE_FOR_PATCHING_SIZE - TEST_FILE_FOR_PATCHING_PATCH_AT);
::free(buf);
}
-<<<<<<< HEAD
- {
- // Fetch the block index for this one
- std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByName(
- BackupProtocolClientListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name));
- TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_PATCH_EN].allocated_objid);
- std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream());
-=======
TEST_NUM_FILES(UPLOAD_NUM, 0, 1, 1);
@@ -1470,7 +1209,6 @@ int test_server(const char *hostname)
BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name));
TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_PATCH_EN].allocated_objid);
std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream());
->>>>>>> 0.12
// Do the patching
bool isCompletelyDifferent = false;
@@ -1478,11 +1216,7 @@ int test_server(const char *hostname)
std::auto_ptr<IOStream> patchstream(
BackupStoreFile::EncodeFileDiff(
TEST_FILE_FOR_PATCHING ".mod",
-<<<<<<< HEAD
- BackupProtocolClientListDirectory::RootDirectory,
-=======
BackupProtocolListDirectory::RootDirectory,
->>>>>>> 0.12
uploads[UPLOAD_PATCH_EN].name,
uploads[UPLOAD_PATCH_EN].allocated_objid,
*blockIndexStream,
@@ -1501,13 +1235,8 @@ int test_server(const char *hostname)
int64_t patchedID = 0;
{
FileStream uploadpatch(TEST_FILE_FOR_PATCHING ".patch");
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
- BackupProtocolClientListDirectory::RootDirectory,
-=======
std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile(
BackupProtocolListDirectory::RootDirectory,
->>>>>>> 0.12
modtime,
modtime, /* use it for attr hash too */
uploads[UPLOAD_PATCH_EN].allocated_objid, /* diff from ID */
@@ -1521,14 +1250,6 @@ int test_server(const char *hostname)
set_refcount(patchedID, 1);
// Then download it to check it's OK
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> getFile(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, patchedID));
- TEST_THAT(getFile->GetObjectID() == patchedID);
- std::auto_ptr<IOStream> filestream(protocol.ReceiveStream());
- BackupStoreFile::DecodeFile(*filestream, TEST_FILE_FOR_PATCHING ".downloaded", IOStream::TimeOutInfinite);
- // Check it's the same
- TEST_THAT(check_files_same(TEST_FILE_FOR_PATCHING ".downloaded", TEST_FILE_FOR_PATCHING ".mod"));
-=======
std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, patchedID));
TEST_THAT(getFile->GetObjectID() == patchedID);
std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream());
@@ -1537,7 +1258,6 @@ int test_server(const char *hostname)
TEST_THAT(check_files_same(TEST_FILE_FOR_PATCHING ".downloaded", TEST_FILE_FOR_PATCHING ".mod"));
TEST_NUM_FILES(UPLOAD_NUM, 1, 1, 1);
->>>>>>> 0.12
}
// Create a directory
@@ -1546,13 +1266,6 @@ int test_server(const char *hostname)
{
// Attributes
MemBlockStream attr(attr1, sizeof(attr1));
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- 9837429842987984LL, dirname, attr));
- subdirid = dirCreate->GetObjectID();
- TEST_THAT(subdirid == maxID + 1);
-=======
std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory(
BackupProtocolListDirectory::RootDirectory,
9837429842987984LL, dirname, attr));
@@ -1560,7 +1273,6 @@ int test_server(const char *hostname)
TEST_THAT(subdirid == maxID + 1);
TEST_NUM_FILES(UPLOAD_NUM, 1, 1, 2);
->>>>>>> 0.12
}
set_refcount(subdirid, 1);
@@ -1572,11 +1284,7 @@ int test_server(const char *hostname)
int64_t modtime;
std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), subdirid, uploads[0].name, &modtime));
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
-=======
std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile(
->>>>>>> 0.12
subdirid,
modtime,
modtime, /* use for attr hash too */
@@ -1584,11 +1292,8 @@ int test_server(const char *hostname)
uploads[0].name,
*upload));
subdirfileid = stored->GetObjectID();
-<<<<<<< HEAD
-=======
TEST_NUM_FILES(UPLOAD_NUM + 1, 1, 1, 2);
->>>>>>> 0.12
}
set_refcount(subdirfileid, 1);
@@ -1597,17 +1302,10 @@ int test_server(const char *hostname)
// Check the directories on the read only connection
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
BackupProtocolListDirectory::RootDirectory,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream
->>>>>>> 0.12
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
dir.ReadFromStream(*dirstream, IOStream::TimeOutInfinite);
@@ -1629,28 +1327,17 @@ int test_server(const char *hostname)
}
// Does it look right?
TEST_THAT(en->GetName() == dirname);
-<<<<<<< HEAD
- TEST_THAT(en->GetFlags() == BackupProtocolClientListDirectory::Flags_Dir);
-=======
TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_Dir);
->>>>>>> 0.12
TEST_THAT(en->GetObjectID() == subdirid);
TEST_THAT(en->GetModificationTime() == 0); // dirs don't have modification times.
}
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- subdirid,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
subdirid,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */));
->>>>>>> 0.12
TEST_THAT(dirreply->GetObjectID() == subdirid);
// Stream
BackupStoreDirectory dir;
@@ -1665,11 +1352,7 @@ int test_server(const char *hostname)
TEST_THAT(en != 0);
// Does it look right?
TEST_THAT(en->GetName() == uploads[0].name);
-<<<<<<< HEAD
- TEST_THAT(en->GetFlags() == BackupProtocolClientListDirectory::Flags_File);
-=======
TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_File);
->>>>>>> 0.12
TEST_THAT(en->GetObjectID() == subdirfileid);
TEST_THAT(en->GetModificationTime() != 0);
@@ -1684,17 +1367,10 @@ int test_server(const char *hostname)
// Check that we don't get attributes if we don't ask for them
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- subdirid,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
subdirid,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1708,11 +1384,7 @@ int test_server(const char *hostname)
// Change attributes on the directory
{
MemBlockStream attrnew(attr2, sizeof(attr2));
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> changereply(protocol.QueryChangeDirAttributes(
-=======
std::auto_ptr<BackupProtocolSuccess> changereply(apProtocol->QueryChangeDirAttributes(
->>>>>>> 0.12
subdirid,
329483209443598LL,
attrnew));
@@ -1721,17 +1393,10 @@ int test_server(const char *hostname)
// Check the new attributes
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- subdirid,
- 0, // no flags
- BackupProtocolClientListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
subdirid,
0, // no flags
BackupProtocolListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1752,30 +1417,15 @@ int test_server(const char *hostname)
{
BackupStoreFilenameClear newName("moved-files");
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> rep(protocol.QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
- BackupProtocolClientListDirectory::RootDirectory,
- subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName));
-=======
std::auto_ptr<BackupProtocolSuccess> rep(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
BackupProtocolListDirectory::RootDirectory,
subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName));
->>>>>>> 0.12
TEST_THAT(rep->GetObjectID() == uploads[UPLOAD_FILE_TO_MOVE].allocated_objid);
}
// Try some dodgy renames
{
BackupStoreFilenameClear newName("moved-files");
-<<<<<<< HEAD
- TEST_CHECK_THROWS(protocol.QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
- BackupProtocolClientListDirectory::RootDirectory,
- subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName),
- ConnectionException, Conn_Protocol_UnexpectedReply);
- TEST_CHECK_THROWS(protocol.QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
- subdirid,
- subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName),
-=======
TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
BackupProtocolListDirectory::RootDirectory,
subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName),
@@ -1783,38 +1433,24 @@ int test_server(const char *hostname)
TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
subdirid,
subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName),
->>>>>>> 0.12
ConnectionException, Conn_Protocol_UnexpectedReply);
}
// Rename within a directory
{
BackupStoreFilenameClear newName("moved-files-x");
-<<<<<<< HEAD
- protocol.QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
- subdirid,
- subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName);
-=======
apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
subdirid,
subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName);
->>>>>>> 0.12
}
// Check it's all gone from the root directory...
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
BackupProtocolListDirectory::RootDirectory,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1833,17 +1469,10 @@ int test_server(const char *hostname)
BackupStoreFilenameClear lookFor("moved-files-x");
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- subdirid,
- BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
subdirid,
BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1875,22 +1504,14 @@ int test_server(const char *hostname)
BackupStoreFilenameClear nd("sub2");
// Attributes
MemBlockStream attr(attr1, sizeof(attr1));
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory(
-=======
std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory(
->>>>>>> 0.12
subdirid,
9837429842987984LL, nd, attr));
subsubdirid = dirCreate->GetObjectID();
FileStream upload("testfiles/file1_upload1");
BackupStoreFilenameClear nf("file2");
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
-=======
std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile(
->>>>>>> 0.12
subsubdirid,
0x123456789abcdefLL, /* modification time */
0x7362383249872dfLL, /* attr hash */
@@ -1905,21 +1526,6 @@ int test_server(const char *hostname)
// Query names -- test that invalid stuff returns not found OK
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientObjectName> nameRep(protocol.QueryGetObjectName(3248972347823478927LL, subsubdirid));
- TEST_THAT(nameRep->GetNumNameElements() == 0);
- }
- {
- std::auto_ptr<BackupProtocolClientObjectName> nameRep(protocol.QueryGetObjectName(subsubfileid, 2342378424LL));
- TEST_THAT(nameRep->GetNumNameElements() == 0);
- }
- {
- std::auto_ptr<BackupProtocolClientObjectName> nameRep(protocol.QueryGetObjectName(38947234789LL, 2342378424LL));
- TEST_THAT(nameRep->GetNumNameElements() == 0);
- }
- {
- std::auto_ptr<BackupProtocolClientObjectName> nameRep(protocol.QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL));
-=======
std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid));
TEST_THAT(nameRep->GetNumNameElements() == 0);
}
@@ -1933,25 +1539,16 @@ int test_server(const char *hostname)
}
{
std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL));
->>>>>>> 0.12
TEST_THAT(nameRep->GetNumNameElements() == 0);
}
// Query names... first, get info for the file
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientObjectName> nameRep(protocol.QueryGetObjectName(subsubfileid, subsubdirid));
- std::auto_ptr<IOStream> namestream(protocol.ReceiveStream());
-
- TEST_THAT(nameRep->GetNumNameElements() == 3);
- TEST_THAT(nameRep->GetFlags() == BackupProtocolClientListDirectory::Flags_File);
-=======
std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid));
std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream());
TEST_THAT(nameRep->GetNumNameElements() == 3);
TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_File);
->>>>>>> 0.12
TEST_THAT(nameRep->GetModificationTime() == 0x123456789abcdefLL);
TEST_THAT(nameRep->GetAttributesHash() == 0x7362383249872dfLL);
static const char *testnames[] = {"file2","sub2","lovely_directory"};
@@ -1965,19 +1562,11 @@ int test_server(const char *hostname)
// Query names... secondly, for the directory
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientObjectName> nameRep(protocol.QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, subsubdirid));
- std::auto_ptr<IOStream> namestream(protocol.ReceiveStream());
-
- TEST_THAT(nameRep->GetNumNameElements() == 2);
- TEST_THAT(nameRep->GetFlags() == BackupProtocolClientListDirectory::Flags_Dir);
-=======
std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, subsubdirid));
std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream());
TEST_THAT(nameRep->GetNumNameElements() == 2);
TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_Dir);
->>>>>>> 0.12
static const char *testnames[] = {"sub2","lovely_directory"};
for(int l = 0; l < nameRep->GetNumNameElements(); ++l)
{
@@ -1989,33 +1578,18 @@ int test_server(const char *hostname)
//} skip:
-<<<<<<< HEAD
- std::auto_ptr<BackupStoreAccountDatabase> apAccounts(
- BackupStoreAccountDatabase::Read(
- "testfiles/accounts.txt"));
-=======
->>>>>>> 0.12
std::auto_ptr<BackupStoreRefCountDatabase> apRefCount(
BackupStoreRefCountDatabase::Load(
apAccounts->GetEntry(0x1234567), true));
// Create some nice recursive directories
-<<<<<<< HEAD
- int64_t dirtodelete = create_test_data_subdirs(protocol,
- BackupProtocolClientListDirectory::RootDirectory,
-=======
int64_t dirtodelete = create_test_data_subdirs(*apProtocol,
BackupProtocolListDirectory::RootDirectory,
->>>>>>> 0.12
"test_delete", 6 /* depth */, *apRefCount);
// And delete them
{
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirdel(protocol.QueryDeleteDirectory(
-=======
std::auto_ptr<BackupProtocolSuccess> dirdel(apProtocol->QueryDeleteDirectory(
->>>>>>> 0.12
dirtodelete));
TEST_THAT(dirdel->GetObjectID() == dirtodelete);
}
@@ -2023,17 +1597,10 @@ int test_server(const char *hostname)
// Get the root dir, checking for deleted items
{
// Command
-<<<<<<< HEAD
- std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- BackupProtocolClientListDirectory::Flags_Dir | BackupProtocolClientListDirectory::Flags_Deleted,
- BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-=======
std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
BackupProtocolListDirectory::RootDirectory,
BackupProtocolListDirectory::Flags_Dir | BackupProtocolListDirectory::Flags_Deleted,
BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
->>>>>>> 0.12
// Stream
BackupStoreDirectory dir;
std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -2060,11 +1627,7 @@ int test_server(const char *hostname)
#ifndef WIN32
protocolReadOnly.QueryFinished();
#endif
-<<<<<<< HEAD
- protocol.QueryFinished();
-=======
apProtocol->QueryFinished();
->>>>>>> 0.12
// Close logs
#ifndef WIN32
@@ -2257,10 +1820,7 @@ int test3(int argc, const char *argv[])
TEST_CHECK_THROWS(info->ChangeBlocksInDeletedFiles(1), BackupStoreException, StoreInfoIsReadOnly);
TEST_CHECK_THROWS(info->RemovedDeletedDirectory(2), BackupStoreException, StoreInfoIsReadOnly);
TEST_CHECK_THROWS(info->AddDeletedDirectory(2), BackupStoreException, StoreInfoIsReadOnly);
-<<<<<<< HEAD
-=======
TEST_CHECK_THROWS(info->SetAccountName("hello"), BackupStoreException, StoreInfoIsReadOnly);
->>>>>>> 0.12
}
{
std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(76, "test-info/", 0, false));
@@ -2277,10 +1837,7 @@ int test3(int argc, const char *argv[])
info->AddDeletedDirectory(3);
info->AddDeletedDirectory(4);
info->RemovedDeletedDirectory(3);
-<<<<<<< HEAD
-=======
info->SetAccountName("whee");
->>>>>>> 0.12
TEST_CHECK_THROWS(info->RemovedDeletedDirectory(9), BackupStoreException, StoreInfoDirNotInList);
info->Save();
}
@@ -2291,10 +1848,7 @@ int test3(int argc, const char *argv[])
TEST_THAT(info->GetBlocksInDeletedFiles() == 1);
TEST_THAT(info->GetBlocksSoftLimit() == 3461231233455433LL);
TEST_THAT(info->GetBlocksHardLimit() == 2934852487LL);
-<<<<<<< HEAD
-=======
TEST_THAT(info->GetAccountName() == "whee");
->>>>>>> 0.12
const std::vector<int64_t> &delfiles(info->GetDeletedDirectories());
TEST_THAT(delfiles.size() == 2);
TEST_THAT(delfiles[0] == 2);
@@ -2318,238 +1872,6 @@ int test3(int argc, const char *argv[])
int pid = LaunchServer(cmd.c_str(), "testfiles/bbstored.pid");
TEST_THAT(pid != -1 && pid != 0);
-<<<<<<< HEAD
- if(pid > 0)
- {
- ::sleep(1);
- TEST_THAT(ServerIsAlive(pid));
-
- // BLOCK
- {
- // Open a connection to the server
- SocketStreamTLS conn;
- conn.Open(context, Socket::TypeINET, "localhost",
- BOX_PORT_BBSTORED_TEST);
-
- // Make a protocol
- BackupProtocolClient protocol(conn);
-
- // Check the version
- std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
- TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
-
- // Login
- TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),
- ConnectionException, Conn_Protocol_UnexpectedReply);
-
- // Finish the connection
- protocol.QueryFinished();
- }
-
- // Create an account for the test client
- TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS
- " -c testfiles/bbstored.conf create 01234567 0 "
- "10000B 20000B") == 0);
-
- TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
-
- TEST_THAT(TestDirExists("testfiles/0_0/backup/01234567"));
- TEST_THAT(TestDirExists("testfiles/0_1/backup/01234567"));
- TEST_THAT(TestDirExists("testfiles/0_2/backup/01234567"));
- TEST_THAT(TestGetFileSize("testfiles/accounts.txt") > 8);
- // make sure something is written to it
-
- std::auto_ptr<BackupStoreAccountDatabase> apAccounts(
- BackupStoreAccountDatabase::Read("testfiles/accounts.txt"));
-
- std::auto_ptr<BackupStoreRefCountDatabase> apReferences(
- BackupStoreRefCountDatabase::Load(
- apAccounts->GetEntry(0x1234567), true));
- TEST_EQUAL(BACKUPSTORE_ROOT_DIRECTORY_ID,
- apReferences->GetLastObjectIDUsed());
- TEST_EQUAL(1, apReferences->GetRefCount(BACKUPSTORE_ROOT_DIRECTORY_ID))
- apReferences.reset();
-
- // Delete the refcount database and log in again,
- // check that it is recreated automatically but with
- // no objects in it, to ensure seamless upgrade.
- TEST_EQUAL(0, ::unlink("testfiles/0_0/backup/01234567/refcount.db.rfw"));
-
- TLSContext context;
- std::auto_ptr<SocketStreamTLS> conn = open_conn("localhost",
- context);
- test_server_login(*conn)->QueryFinished();
-
- BackupStoreAccountDatabase::Entry account =
- apAccounts->GetEntry(0x1234567);
- apReferences = BackupStoreRefCountDatabase::Load(account, true);
- TEST_EQUAL(0, apReferences->GetLastObjectIDUsed());
-
- TEST_THAT(ServerIsAlive(pid));
-
- run_housekeeping(account);
-
- // Check that housekeeping fixed the ref counts
- TEST_EQUAL(BACKUPSTORE_ROOT_DIRECTORY_ID,
- apReferences->GetLastObjectIDUsed());
- TEST_EQUAL(1, apReferences->GetRefCount(BACKUPSTORE_ROOT_DIRECTORY_ID))
-
- TEST_THAT(ServerIsAlive(pid));
-
- set_refcount(BACKUPSTORE_ROOT_DIRECTORY_ID, 1);
-
- TEST_THAT(test_server("localhost") == 0);
-
- // test that all object reference counts have the
- // expected values
- TEST_EQUAL(ExpectedRefCounts.size() - 1,
- apReferences->GetLastObjectIDUsed());
- for (unsigned int i = BACKUPSTORE_ROOT_DIRECTORY_ID;
- i < ExpectedRefCounts.size(); i++)
- {
- TEST_EQUAL_LINE(ExpectedRefCounts[i],
- apReferences->GetRefCount(i),
- "object " << BOX_FORMAT_OBJECTID(i));
- }
-
- // Delete the refcount database again, and let
- // housekeeping recreate it and fix the ref counts.
- // This could also happen after upgrade, if a housekeeping
- // runs before the user logs in.
- apReferences.reset();
- TEST_EQUAL(0, ::unlink("testfiles/0_0/backup/01234567/refcount.db.rfw"));
- run_housekeeping(account);
- apReferences = BackupStoreRefCountDatabase::Load(account, true);
-
- TEST_EQUAL(ExpectedRefCounts.size() - 1,
- apReferences->GetLastObjectIDUsed());
- for (unsigned int i = BACKUPSTORE_ROOT_DIRECTORY_ID;
- i < ExpectedRefCounts.size(); i++)
- {
- TEST_EQUAL_LINE(ExpectedRefCounts[i],
- apReferences->GetRefCount(i),
- "object " << BOX_FORMAT_OBJECTID(i));
- }
-
- // Test the deletion of objects by the housekeeping system
- // First, things as they are now.
- recursive_count_objects_results before = {0,0,0};
-
- recursive_count_objects("localhost", BackupProtocolClientListDirectory::RootDirectory, before);
-
- TEST_THAT(before.objectsNotDel != 0);
- TEST_THAT(before.deleted != 0);
- TEST_THAT(before.old != 0);
-
- // Kill it
- TEST_THAT(KillServer(pid));
- ::sleep(1);
- TEST_THAT(!ServerIsAlive(pid));
-
- #ifdef WIN32
- TEST_THAT(unlink("testfiles/bbstored.pid") == 0);
- #else
- TestRemoteProcessMemLeaks("bbstored.memleaks");
- #endif
-
- // Set a new limit on the account -- leave the hard limit
- // high to make sure the target for freeing space is the
- // soft limit.
- TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS
- " -c testfiles/bbstored.conf setlimit 01234567 "
- "10B 20000B") == 0);
- TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
-
- // Start things up
- pid = LaunchServer(BBSTORED " testfiles/bbstored.conf",
- "testfiles/bbstored.pid");
-
- ::sleep(1);
- TEST_THAT(ServerIsAlive(pid));
-
- // wait for housekeeping to happen
- printf("waiting for housekeeping:\n");
- for(int l = 0; l < 30; ++l)
- {
- ::sleep(1);
- printf(".");
- fflush(stdout);
- }
- printf("\n");
-
- // Count the objects again
- recursive_count_objects_results after = {0,0,0};
- recursive_count_objects("localhost",
- BackupProtocolClientListDirectory::RootDirectory,
- after);
-
- // If these tests fail then try increasing the timeout above
- TEST_THAT(after.objectsNotDel == before.objectsNotDel);
- TEST_THAT(after.deleted == 0);
- TEST_THAT(after.old == 0);
-
- // Set a really small hard limit
- TEST_THAT_ABORTONFAIL(::system(BBSTOREACCOUNTS
- " -c testfiles/bbstored.conf setlimit 01234567 "
- "10B 20B") == 0);
- TestRemoteProcessMemLeaks("bbstoreaccounts.memleaks");
-
- // Try to upload a file and create a directory, and check an error is generated
- {
- // Open a connection to the server
- SocketStreamTLS conn;
- conn.Open(context, Socket::TypeINET, "localhost",
- BOX_PORT_BBSTORED_TEST);
-
- // Make a protocol
- BackupProtocolClient protocol(conn);
-
- // Check the version
- std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
- TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
-
- // Login
- std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0));
-
- int64_t modtime = 0;
-
- BackupStoreFilenameClear fnx("exceed-limit");
- std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/test3", BackupProtocolClientListDirectory::RootDirectory, fnx, &modtime));
- TEST_THAT(modtime != 0);
-
- TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
- BackupProtocolClientListDirectory::RootDirectory,
- modtime,
- modtime, /* use it for attr hash too */
- 0, /* diff from ID */
- fnx,
- *upload)),
- ConnectionException, Conn_Protocol_UnexpectedReply);
-
- MemBlockStream attr(&modtime, sizeof(modtime));
- BackupStoreFilenameClear fnxd("exceed-limit-dir");
- TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory(
- BackupProtocolClientListDirectory::RootDirectory,
- 9837429842987984LL, fnxd, attr)),
- ConnectionException, Conn_Protocol_UnexpectedReply);
-
-
- // Finish the connection
- protocol.QueryFinished();
- }
-
- // Kill it again
- TEST_THAT(KillServer(pid));
- ::sleep(1);
- TEST_THAT(!ServerIsAlive(pid));
-
- #ifdef WIN32
- TEST_THAT(unlink("testfiles/bbstored.pid") == 0);
- #else
- TestRemoteProcessMemLeaks("bbstored.memleaks");
- #endif
- }
-=======
if(pid <= 0)
{
return 1;
@@ -2818,7 +2140,6 @@ int test3(int argc, const char *argv[])
#else
TestRemoteProcessMemLeaks("bbstored.memleaks");
#endif
->>>>>>> 0.12
return 0;
}
@@ -2866,36 +2187,18 @@ int multi_server()
return 0;
}
-<<<<<<< HEAD
-#ifdef WIN32
-WCHAR* ConvertUtf8ToWideString(const char* pString);
-std::string ConvertPathToAbsoluteUnicode(const char *pFileName);
-#endif
-
-int test(int argc, const char *argv[])
-=======
void test_open_files_with_limited_win32_permissions()
->>>>>>> 0.12
{
#ifdef WIN32
// this had better work, or bbstored will die when combining diffs
char* file = "foo";
-<<<<<<< HEAD
- std::string abs = ConvertPathToAbsoluteUnicode(file);
- WCHAR* wfile = ConvertUtf8ToWideString(abs.c_str());
-=======
->>>>>>> 0.12
DWORD accessRights = FILE_READ_ATTRIBUTES |
FILE_LIST_DIRECTORY | FILE_READ_EA | FILE_WRITE_ATTRIBUTES |
FILE_WRITE_DATA | FILE_WRITE_EA /*| FILE_ALL_ACCESS*/;
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
-<<<<<<< HEAD
- HANDLE h1 = CreateFileW(wfile, accessRights, shareMode,
-=======
HANDLE h1 = CreateFileA(file, accessRights, shareMode,
->>>>>>> 0.12
NULL, OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
assert(h1 != INVALID_HANDLE_VALUE);
TEST_THAT(h1 != INVALID_HANDLE_VALUE);
@@ -2903,36 +2206,21 @@ void test_open_files_with_limited_win32_permissions()
accessRights = FILE_READ_ATTRIBUTES |
FILE_LIST_DIRECTORY | FILE_READ_EA;
-<<<<<<< HEAD
- HANDLE h2 = CreateFileW(wfile, accessRights, shareMode,
-=======
HANDLE h2 = CreateFileA(file, accessRights, shareMode,
->>>>>>> 0.12
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
assert(h2 != INVALID_HANDLE_VALUE);
TEST_THAT(h2 != INVALID_HANDLE_VALUE);
CloseHandle(h2);
CloseHandle(h1);
-<<<<<<< HEAD
- delete [] wfile;
-
- h1 = openfile("foo", O_CREAT | O_RDWR, 0);
- TEST_THAT(h1 != INVALID_HANDLE_VALUE);
- h2 = openfile("foo", O_RDWR, 0);
-=======
h1 = openfile(file, O_CREAT | O_RDWR, 0);
TEST_THAT(h1 != INVALID_HANDLE_VALUE);
h2 = openfile(file, O_RDWR, 0);
->>>>>>> 0.12
TEST_THAT(h2 != INVALID_HANDLE_VALUE);
CloseHandle(h2);
CloseHandle(h1);
#endif
-<<<<<<< HEAD
-
-=======
}
void compare_backupstoreinfo_values_to_expected
@@ -3224,7 +2512,6 @@ int test(int argc, const char *argv[])
return ret;
}
->>>>>>> 0.12
// SSL library
SSLLib::Initialise();
@@ -3273,11 +2560,7 @@ int test(int argc, const char *argv[])
/* {
int64_t modtime = 0;
std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("/Users/ben/temp/large.tar",
-<<<<<<< HEAD
- BackupProtocolClientListDirectory::RootDirectory, uploads[0].name, &modtime));
-=======
BackupProtocolListDirectory::RootDirectory, uploads[0].name, &modtime));
->>>>>>> 0.12
TEST_THAT(modtime != 0);
FileStream write("testfiles/large.enc", O_WRONLY | O_CREAT);
upload->CopyStreamTo(write);