- Restored compilation of most tests (The part using previously named p3ConnectMgr is still to be done).

- moved ftSearchDummy and ftDataSendPair in tests/ft since it is only used there.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6009 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-12-17 23:05:25 +00:00
parent 6571279b70
commit bc65dd40c2
48 changed files with 314 additions and 1797 deletions

View file

@ -1,6 +1,8 @@
RS_TOP_DIR = ../..
DHT_TOP_DIR = ../../../../libbitdht/src
OPS_TOP_DIR = ../../../../openpgpsdk/src
##### Define any flags that are needed for this section #######
###############################################################
@ -8,9 +10,10 @@ DHT_TOP_DIR = ../../../../libbitdht/src
include $(RS_TOP_DIR)/tests/scripts/config.mk
###############################################################
TESTOBJ = ftfilemappertest.o ftfileprovidertest.o ftfilecreatortest.o ftextralisttest.o ftdataplextest.o fttransfermoduletest.o ftcrc32test.o ftcrossprovidercreatortest.o ftcontrollertest.o ftserver1test.o ftserver2test.o ftserver3test.o
TESTOBJ = ftfilemappertest.o ftfileprovidertest.o ftfilecreatortest.o ftextralisttest.o ftdataplextest.o fttransfermoduletest.o ftcrc32test.o ftcrossprovidercreatortest.o ftcontrollertest.o ftserver1test.o ftserver2test.o ftserver3test.o ftdata_test.o
TESTS = ftfilemappertest ftfileprovidertest ftfilecreatortest ftextralisttest ftdataplextest fttransfermoduletest ftcrc32test ftcrossprovidercreatortest ftcontrollertest ftserver1test ftserver2test fttransfermoduletest ftserver3test
TESTS = ftfileprovidertest ftfilecreatortest ftextralisttest ftdataplextest fttransfermoduletest ftcrc32test ftcrossprovidercreatortest ftcontrollertest ftserver1test ftserver2test fttransfermoduletest ftserver3test
#ftfilemappertest
all: tests

View file

@ -28,14 +28,15 @@
*/
#include "retroshare/rsfiles.h"
#include "retroshare/rspeers.h"
#include "ft/ftserver.h"
#include "ft/ftextralist.h"
#include "ft/ftdatamultiplex.h"
#include "ft/ftfilesearch.h"
#include "pqi/p3authmgr.h"
#include "pqi/p3connmgr.h"
//#include "pqi/p3authmgr.h"
//#include "pqi/p3connmgr.h"
#include "util/rsdebug.h"
@ -123,7 +124,7 @@ int main(int argc, char **argv)
std::cerr << "Adding: " << argv[optind] << std::endl;
SharedDirInfo info ;
info.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
info.shareflags = DIR_FLAGS_PERMISSIONS_MASK;
info.filename = std::string(argv[optind]);
info.virtualname = info.filename ;
@ -140,8 +141,8 @@ int main(int argc, char **argv)
std::list<std::string>::const_iterator it, jit;
std::list<pqiAuthDetails> baseFriendList, friendList;
std::list<pqiAuthDetails>::iterator fit;
std::list<RsPeerDetails> baseFriendList, friendList;
std::list<RsPeerDetails>::iterator fit;
P3Hub *testHub = new P3Hub(0,NULL);
testHub->start();
@ -149,12 +150,12 @@ int main(int argc, char **argv)
/* Setup Base Friend Info */
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
pqiAuthDetails pad;
RsPeerDetails pad;
pad.id = *it;
pad.name = *it;
pad.trustLvl = 5;
pad.ownsign = true;
pad.trusted = false;
//pad.trusted = false;
baseFriendList.push_back(pad);

View file

@ -23,6 +23,7 @@
*
*/
#include <stdio.h>
#include <iostream>
#include "retroshare/rstypes.h"
#include <util/rsdir.h>
@ -67,7 +68,9 @@ int main(int argc, char **argv)
std::cerr << "Hashing file :" << *it << std::endl ;
std::string hash ;
RsDirUtil::hashFile( *it,hash) ;
uint64_t size ;
std::string name ;
RsDirUtil::hashFile( *it,name,hash,size) ;
std::cerr << "Hash = " << hash << std::endl;
@ -87,7 +90,7 @@ int main(int argc, char **argv)
return 0 ;
}
uint64_t size = ftell(f) ;
size = ftell(f) ;
if(fseek(f,0,SEEK_SET))
{

View file

@ -0,0 +1,146 @@
/*
* libretroshare/src/ft: ftdata.cc
*
* File Transfer for RetroShare.
*
* Copyright 2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "ft/ftdata.h"
/******* Pair of Send/Recv (Only need to handle Send side) ******/
ftDataSendPair::ftDataSendPair(ftDataRecv *recv)
:mDataRecv(recv)
{
return;
}
/* Client Send */
bool ftDataSendPair::sendDataRequest(const std::string &peerId, const std::string &hash,
uint64_t size, uint64_t offset, uint32_t chunksize)
{
return mDataRecv->recvDataRequest(peerId,hash,size,offset,chunksize);
}
/* Server Send */
bool ftDataSendPair::sendData(const std::string &peerId, const std::string &hash,
uint64_t size, uint64_t offset, uint32_t chunksize, void *data)
{
return mDataRecv->recvData(peerId, hash,size,offset,chunksize,data);
}
/* Send a request for a chunk map */
bool ftDataSendPair::sendChunkMapRequest(const std::string& peer_id,const std::string& hash,bool is_client)
{
return mDataRecv->recvChunkMapRequest(peer_id,hash,is_client);
}
/* Send a chunk map */
bool ftDataSendPair::sendChunkMap(const std::string& peer_id,const std::string& hash, const CompressedChunkMap& cmap,bool is_client)
{
return mDataRecv->recvChunkMap(peer_id,hash,cmap, is_client);
}
/* Send a request for a chunk map */
bool ftDataSendPair::sendCRC32MapRequest(const std::string& peer_id,const std::string& hash)
{
return mDataRecv->recvCRC32MapRequest(peer_id,hash);
}
/* Send a chunk map */
bool ftDataSendPair::sendCRC32Map(const std::string& peer_id,const std::string& hash, const CRC32Map& crcmap)
{
return mDataRecv->recvCRC32Map(peer_id,hash,crcmap) ;
}
/* Client Send */
bool ftDataSendDummy::sendDataRequest(const std::string &/*peerId*/, const std::string &/*hash*/,
uint64_t /*size*/, uint64_t /*offset*/, uint32_t /*chunksize*/)
{
return true;
}
/* Server Send */
bool ftDataSendDummy::sendData(const std::string &/*peerId*/, const std::string &/*hash*/,
uint64_t /*size*/, uint64_t /*offset*/, uint32_t /*chunksize*/, void */*data*/)
{
return true;
}
/* Send a request for a chunk map */
bool ftDataSendDummy::sendChunkMapRequest(const std::string& /*peer_id*/,const std::string& /*hash*/,bool /*is_client*/)
{
return true;
}
/* Send a chunk map */
bool ftDataSendDummy::sendChunkMap(const std::string& /*peer_id*/,const std::string& /*hash*/, const CompressedChunkMap& /*cmap*/,bool /*is_client*/)
{
return true;
}
bool ftDataSendDummy::sendCRC32MapRequest(const std::string& /*peer_id*/,const std::string& /*hash*/)
{
return true;
}
/* Send a chunk map */
bool ftDataSendDummy::sendCRC32Map(const std::string& /*peer_id*/,const std::string& /*hash*/, const CRC32Map& /*cmap*/)
{
return true;
}
/* Client Recv */
bool ftDataRecvDummy::recvData(const std::string &/*peerId*/, const std::string &/*hash*/,
uint64_t /*size*/, uint64_t /*offset*/, uint32_t /*chunksize*/, void */*data*/)
{
return true;
}
/* Server Recv */
bool ftDataRecvDummy::recvDataRequest(const std::string &/*peerId*/, const std::string &/*hash*/,
uint64_t /*size*/, uint64_t /*offset*/, uint32_t /*chunksize*/)
{
return true;
}
/* Send a request for a chunk map */
bool ftDataRecvDummy::recvChunkMapRequest(const std::string& /*peer_id*/,const std::string& /*hash*/,
bool /*is_client*/)
{
return true;
}
/* Send a chunk map */
bool ftDataRecvDummy::recvChunkMap(const std::string& /*peer_id*/,const std::string& /*hash*/,
const CompressedChunkMap& /*cmap*/,bool /*is_client*/)
{
return true;
}
bool ftDataRecvDummy::sendCRC32MapRequest(const std::string& /*peer_id*/,const std::string& /*hash*/)
{
return true ;
}
/* Send a chunk map */
bool ftDataRecvDummy::sendCRC32Map(const std::string& /*peer_id*/,const std::string& /*hash*/, const CompressedChunkMap& /*cmap*/)
{
return true ;
}

View file

@ -0,0 +1,144 @@
/*
* libretroshare/src/ft: ftdata.h
*
* File Transfer for RetroShare.
*
* Copyright 2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef FT_DATA_TEST_INTERFACE_HEADER
#define FT_DATA_TEST_INTERFACE_HEADER
/*
* ftData.
*
* Internal Interfaces for sending and receiving data.
* Most likely to be implemented by ftServer.
* Provided as an independent interface for testing purposes.
*
*/
#include <string>
#include <inttypes.h>
#include <retroshare/rstypes.h>
#include <ft/ftdata.h>
/*************** SEND INTERFACE *******************/
class CompressedChunkMap ;
class Sha1CheckSum ;
/**************** FOR TESTING ***********************/
/******* Pair of Send/Recv (Only need to handle Send side) ******/
class ftDataSendPair: public ftDataSend
{
public:
ftDataSendPair(ftDataRecv *recv);
virtual ~ftDataSendPair() { return; }
/* Client Send */
virtual bool sendDataRequest(const std::string &peerId, const std::string &hash,
uint64_t size, uint64_t offset, uint32_t chunksize);
/* Server Send */
virtual bool sendData(const std::string &peerId, const std::string &hash, uint64_t size,
uint64_t offset, uint32_t chunksize, void *data);
/* Send a request for a chunk map */
virtual bool sendChunkMapRequest(const std::string& peer_id,const std::string& hash,bool is_client);
/* Send a chunk map */
virtual bool sendChunkMap(const std::string& peer_id,const std::string& hash, const CompressedChunkMap& cmap,bool is_client);
/* Send a request for a chunk map */
virtual bool sendCRC32MapRequest(const std::string& peer_id,const std::string& hash);
/* Send a chunk map */
virtual bool sendCRC32Map(const std::string& peer_id,const std::string& hash, const CRC32Map& cmap);
ftDataRecv *mDataRecv;
virtual bool sendSingleChunkCRCRequest(const std::string&, const std::string&, uint32_t);
virtual bool sendSingleChunkCRC(const std::string&, const std::string&, uint32_t, const Sha1CheckSum&);
};
class ftDataSendDummy: public ftDataSend
{
public:
virtual ~ftDataSendDummy() { return; }
/* Client Send */
virtual bool sendDataRequest(const std::string &peerId, const std::string &hash,
uint64_t size, uint64_t offset, uint32_t chunksize);
/* Server Send */
virtual bool sendData(const std::string &peerId, const std::string &hash, uint64_t size,
uint64_t offset, uint32_t chunksize, void *data);
/* Send a request for a chunk map */
virtual bool sendChunkMapRequest(const std::string& peer_id,const std::string& hash,bool is_client);
/* Send a chunk map */
virtual bool sendChunkMap(const std::string& peer_id,const std::string& hash, const CompressedChunkMap& cmap,bool is_client);
/* Send a request for a chunk map */
virtual bool sendCRC32MapRequest(const std::string& peer_id,const std::string& hash);
/* Send a chunk map */
virtual bool sendCRC32Map(const std::string& peer_id,const std::string& hash, const CRC32Map& cmap);
virtual bool sendSingleChunkCRCRequest(const std::string&, const std::string&, uint32_t);
virtual bool sendSingleChunkCRC(const std::string&, const std::string&, uint32_t, const Sha1CheckSum&);
};
class ftDataRecvDummy: public ftDataRecv
{
public:
virtual ~ftDataRecvDummy() { return; }
/* Client Recv */
virtual bool recvData(const std::string& peerId, const std::string& hash,
uint64_t size, uint64_t offset, uint32_t chunksize, void *data);
/* Server Recv */
virtual bool recvDataRequest(const std::string& peerId, const std::string& hash,
uint64_t size, uint64_t offset, uint32_t chunksize);
/* Send a request for a chunk map */
virtual bool recvChunkMapRequest(const std::string& peer_id,const std::string& hash,
bool is_client);
/* Send a chunk map */
virtual bool recvChunkMap(const std::string& peer_id,const std::string& hash,
const CompressedChunkMap& cmap,bool is_client);
/* Send a request for a chunk map */
virtual bool sendCRC32MapRequest(const std::string& peer_id,const std::string& hash);
/* Send a chunk map */
virtual bool sendCRC32Map(const std::string& peer_id,const std::string& hash, const CompressedChunkMap& cmap);
};
#endif

View file

@ -40,6 +40,8 @@
#include "ft/ftdatamultiplex.h"
#include "ft/ftfilesearch.h"
#include "ftdata_test.h"
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files);
@ -107,7 +109,7 @@ int main(int argc, char **argv)
/* now work the thread */
std::list<std::string>::iterator it;
uint32_t flags = 0;
TransferRequestFlags flags(0);
for(it = fileList.begin(); it != fileList.end(); it++)
{
eList->hashExtraFile(*it, dPeriod, flags);

View file

@ -101,7 +101,7 @@ int main(int argc, char **argv)
std::list<std::string> hashed;
std::list<std::string>::iterator it;
uint32_t flags = 0;
TransferRequestFlags flags(0);
for(it = hashList.begin(); it != hashList.end(); it++)
{
sleep(period);
@ -148,7 +148,7 @@ void displayExtraListDetails(ftExtraList *eList, std::list<std::string> toHash,
for(it = hashed.begin(); it != hashed.end(); it++)
{
FileInfo info;
if (eList->search(*it, 0, info))
if (eList->search(*it, FileSearchFlags(0), info))
{
std::cerr << "displayExtraListDetails() Found Hash: " << *it;
std::cerr << std::endl;

View file

@ -0,0 +1,16 @@
#include "ftsearch_test.h"
bool ftSearchDummy::search(std::string /*hash*/, FileSearchFlags hintflags, FileInfo &/*info*/) const
{
/* remove unused parameter warnings */
(void) hintflags;
#ifdef DEBUG_SEARCH
std::cerr << "ftSearchDummy::search(" << hash ;
std::cerr << ", " << hintflags << ");";
std::cerr << std::endl;
#endif
return false;
}

View file

@ -0,0 +1,38 @@
/*
* libretroshare/src/ft: ftsearch.h
*
* File Transfer for RetroShare.
*
* Copyright 2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#pragma once
#include "ft/ftsearch.h"
class ftSearchDummy: public ftSearch
{
public:
ftSearchDummy() { return; }
virtual ~ftSearchDummy() { return; }
virtual bool search(const std::string& hash, FileSearchFlags hintflags, FileInfo &info) const;
};

View file

@ -40,8 +40,8 @@
#include "ft/ftdatamultiplex.h"
#include "ft/ftfilesearch.h"
#include "pqi/p3authmgr.h"
#include "pqi/p3connmgr.h"
//#include "pqi/p3authmgr.h"
//#include "pqi/p3connmgr.h"
#include "util/rsdebug.h"

View file

@ -37,7 +37,10 @@
#include "util/rswin.h"
#endif
#include <vector>
#include "retroshare/rsexpr.h"
#include "retroshare/rstypes.h"
#include "retroshare/rsfiles.h"
#include "ft/ftserver.h"
@ -45,8 +48,8 @@
#include "ft/ftdatamultiplex.h"
#include "ft/ftfilesearch.h"
#include "pqi/p3authmgr.h"
#include "pqi/p3connmgr.h"
//#include "pqi/p3authmgr.h"
//#include "pqi/p3connmgr.h"
#include "util/rsdebug.h"
@ -163,7 +166,7 @@ int main(int argc, char **argv)
SharedDirInfo info ;
info.filename = std::string(argv[optind]);
info.virtualname = info.filename ;
info.shareflags = RS_FILE_HINTS_NETWORK_WIDE | RS_FILE_HINTS_BROWSABLE ;
info.shareflags = DIR_FLAGS_PERMISSIONS_MASK;
fileList.push_back(info) ;
}

View file

@ -46,6 +46,7 @@
#include "ft/fttransfermodule.h"
#include "util/utest.h"
#include "ftdata_test.h"
INITTEST()
@ -122,7 +123,7 @@ int main(int argc, char **argv)
/* now work the thread */
std::list<std::string>::iterator it;
uint32_t flags = 0;
TransferRequestFlags flags(0);
for(it = fileList.begin(); it != fileList.end(); it++)
{
eList->hashExtraFile(*it, dPeriod, flags);
@ -150,7 +151,7 @@ int main(int argc, char **argv)
}
std::string savename = "/tmp/" + info.fname;
ftFileCreator *creator = new ftFileCreator(savename, info.size, info.hash);
ftFileCreator *creator = new ftFileCreator(savename, info.size, info.hash,false);
ftController *controller = NULL;
ftTransferModule *transfer = new ftTransferModule(creator, ftmplex1, controller);

View file

@ -109,7 +109,7 @@ private:
class P3Pipe: public P3Interface
{
public:
P3Pipe() {return; }
P3Pipe() : pipeMtx(std::string("Pipe mutex")) {return; }
virtual ~P3Pipe() {return; }
virtual int tick() { return 1; }