mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-21 04:44:25 -04:00
working on ft tests. Not finished yet
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6034 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2865ba30ce
commit
69859f2a43
13 changed files with 142 additions and 73 deletions
|
@ -10,7 +10,7 @@ OPS_TOP_DIR = ../../../../openpgpsdk/src
|
||||||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
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 ftdata_test.o ftsearch_test.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_dummy.o ftsearch_dummy.o
|
||||||
|
|
||||||
TESTS = 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
|
#ftfilemappertest
|
||||||
|
@ -33,13 +33,13 @@ ftfileprovidertest : ftfileprovidertest.o
|
||||||
$(CC) $(CFLAGS) -o ftfileprovidertest ftfileprovidertest.o $(LIBS)
|
$(CC) $(CFLAGS) -o ftfileprovidertest ftfileprovidertest.o $(LIBS)
|
||||||
|
|
||||||
fttransfermoduletest : fttransfermoduletest.o
|
fttransfermoduletest : fttransfermoduletest.o
|
||||||
$(CC) $(CFLAGS) -o fttransfermoduletest fttransfermoduletest.o $(LIBS)
|
$(CC) $(CFLAGS) -o fttransfermoduletest ftdata_dummy.o ftsearch_dummy.o fttransfermoduletest.o $(LIBS)
|
||||||
|
|
||||||
ftextralisttest : ftextralisttest.o
|
ftextralisttest : ftextralisttest.o
|
||||||
$(CC) $(CFLAGS) -o ftextralisttest ftextralisttest.o $(LIBS)
|
$(CC) $(CFLAGS) -o ftextralisttest ftextralisttest.o $(LIBS)
|
||||||
|
|
||||||
ftdataplextest : ftdataplextest.o ftsearch_test.o ftdata_test.o
|
ftdataplextest : ftdataplextest.o ftsearch_dummy.o ftdata_dummy.o
|
||||||
$(CC) $(CFLAGS) -o ftdataplextest ftdata_test.o ftdataplextest.o ftsearch_test.o $(LIBS)
|
$(CC) $(CFLAGS) -o ftdataplextest ftdata_dummy.o ftdataplextest.o ftsearch_dummy.o $(LIBS)
|
||||||
|
|
||||||
ftserver1test : ftserver1test.o
|
ftserver1test : ftserver1test.o
|
||||||
$(CC) $(CFLAGS) -o ftserver1test ftserver1test.o $(LIBS)
|
$(CC) $(CFLAGS) -o ftserver1test ftserver1test.o $(LIBS)
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
|
|
||||||
//#include "pqi/p3authmgr.h"
|
//#include "pqi/p3authmgr.h"
|
||||||
//#include "pqi/p3connmgr.h"
|
//#include "pqi/p3connmgr.h"
|
||||||
|
#include "pqi/p3peermgr.h"
|
||||||
|
#include "pqi/p3linkmgr.h"
|
||||||
|
#include "pqi/p3netmgr.h"
|
||||||
|
|
||||||
#include "util/rsdebug.h"
|
#include "util/rsdebug.h"
|
||||||
|
|
||||||
|
@ -79,7 +82,7 @@ int main(int argc, char **argv)
|
||||||
std::list<std::string> extraList;
|
std::list<std::string> extraList;
|
||||||
std::list<std::string> peerIds;
|
std::list<std::string> peerIds;
|
||||||
std::map<std::string, ftServer *> mFtServers;
|
std::map<std::string, ftServer *> mFtServers;
|
||||||
std::map<std::string, p3ConnectMgr *> mConnMgrs;
|
std::map<std::string, p3LinkMgrIMPL *> mLinkMgrs;
|
||||||
|
|
||||||
ftServer *mLoadServer = NULL;
|
ftServer *mLoadServer = NULL;
|
||||||
std::list<ftServer *> mOtherServers;
|
std::list<ftServer *> mOtherServers;
|
||||||
|
@ -184,22 +187,24 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p3AuthMgr *authMgr = new p3DummyAuthMgr(*it, friendList);
|
//p3AuthMgr *authMgr = new p3DummyAuthMgr(*it, friendList);
|
||||||
p3ConnectMgr *connMgr = new p3ConnectMgr(authMgr);
|
p3PeerMgrIMPL *peerMgr = new p3PeerMgrIMPL;
|
||||||
mConnMgrs[*it] = connMgr;
|
p3NetMgrIMPL *netMgr = new p3NetMgrIMPL ;
|
||||||
|
p3LinkMgrIMPL *linkMgr = new p3LinkMgrIMPL(peerMgr,netMgr);
|
||||||
|
mLinkMgrs[*it] = linkMgr;
|
||||||
|
|
||||||
|
|
||||||
for(fit = friendList.begin(); fit != friendList.end(); fit++)
|
for(fit = friendList.begin(); fit != friendList.end(); fit++)
|
||||||
{
|
{
|
||||||
/* add as peer to authMgr */
|
/* add as peer to authMgr */
|
||||||
connMgr->addFriend(fit->id);
|
peerMgr->addFriend(fit->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
P3Pipe *pipe = new P3Pipe(); //(*it);
|
P3Pipe *pipe = new P3Pipe(); //(*it);
|
||||||
|
|
||||||
/* add server */
|
/* add server */
|
||||||
ftServer *server;
|
ftServer *server;
|
||||||
server = new ftServer(connMgr);
|
server = new ftServer(peerMgr,linkMgr);
|
||||||
mFtServers[*it] = server;
|
mFtServers[*it] = server;
|
||||||
if (!mLoadServer)
|
if (!mLoadServer)
|
||||||
{
|
{
|
||||||
|
@ -230,7 +235,7 @@ int main(int argc, char **argv)
|
||||||
NotifyBase *base = NULL;
|
NotifyBase *base = NULL;
|
||||||
server->SetupFtServer(base);
|
server->SetupFtServer(base);
|
||||||
|
|
||||||
testHub->addP3Pipe(*it, pipe, connMgr);
|
testHub->addP3Pipe(*it, pipe, linkMgr);
|
||||||
server->StartupThreads();
|
server->StartupThreads();
|
||||||
|
|
||||||
/* setup any extra bits */
|
/* setup any extra bits */
|
||||||
|
@ -239,7 +244,7 @@ int main(int argc, char **argv)
|
||||||
server->setSharedDirectories(fileList);
|
server->setSharedDirectories(fileList);
|
||||||
for(eit = extraList.begin(); eit != extraList.end(); eit++)
|
for(eit = extraList.begin(); eit != extraList.end(); eit++)
|
||||||
{
|
{
|
||||||
server->ExtraFileHash(*eit, 3600, 0);
|
server->ExtraFileHash(*eit, 3600, TransferRequestFlags(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,14 +255,14 @@ int main(int argc, char **argv)
|
||||||
mLoadServer->setSharedDirectories(fileList);
|
mLoadServer->setSharedDirectories(fileList);
|
||||||
for(eit = extraList.begin(); eit != extraList.end(); eit++)
|
for(eit = extraList.begin(); eit != extraList.end(); eit++)
|
||||||
{
|
{
|
||||||
mLoadServer->ExtraFileHash(*eit, 3600, 0);
|
mLoadServer->ExtraFileHash(*eit, 3600, TransferRequestFlags(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* stick your real test here */
|
/* stick your real test here */
|
||||||
std::map<std::string, ftServer *>::iterator sit;
|
std::map<std::string, ftServer *>::iterator sit;
|
||||||
std::map<std::string, p3ConnectMgr *>::iterator cit;
|
std::map<std::string, p3LinkMgrIMPL *>::iterator cit;
|
||||||
|
|
||||||
/* Start up test thread */
|
/* Start up test thread */
|
||||||
pthread_t tid;
|
pthread_t tid;
|
||||||
|
@ -285,7 +290,7 @@ int main(int argc, char **argv)
|
||||||
(sit->second)->tick();
|
(sit->second)->tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(cit = mConnMgrs.begin(); cit != mConnMgrs.end(); cit++)
|
for(cit = mLinkMgrs.begin(); cit != mLinkMgrs.end(); cit++)
|
||||||
{
|
{
|
||||||
/* update */
|
/* update */
|
||||||
(cit->second)->tick();
|
(cit->second)->tick();
|
||||||
|
@ -334,7 +339,8 @@ void *do_server_test_thread(void *data)
|
||||||
REPORT("Successfully Found ExtraFile");
|
REPORT("Successfully Found ExtraFile");
|
||||||
|
|
||||||
/* now we can try a search (should succeed) */
|
/* now we can try a search (should succeed) */
|
||||||
uint32_t hintflags = 0;
|
FileSearchFlags hintflags;
|
||||||
|
|
||||||
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
|
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
|
||||||
{
|
{
|
||||||
CHECK(info2.hash == info.hash);
|
CHECK(info2.hash == info.hash);
|
||||||
|
@ -361,6 +367,7 @@ void *do_server_test_thread(void *data)
|
||||||
|
|
||||||
/* search with other flags (should fail) */
|
/* search with other flags (should fail) */
|
||||||
hintflags = RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY;
|
hintflags = RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY;
|
||||||
|
|
||||||
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
|
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
|
||||||
{
|
{
|
||||||
REPORT2( false, "Search for Extra File (Fail Flags)");
|
REPORT2( false, "Search for Extra File (Fail Flags)");
|
||||||
|
@ -383,18 +390,19 @@ void *do_server_test_thread(void *data)
|
||||||
ftServer *server=mFt->loadServer;
|
ftServer *server=mFt->loadServer;
|
||||||
|
|
||||||
std::string fname,filehash,destination;
|
std::string fname,filehash,destination;
|
||||||
uint32_t size,flags;
|
uint32_t size;
|
||||||
|
FileSearchFlags flags;
|
||||||
std::list<std::string> srcIds;
|
std::list<std::string> srcIds;
|
||||||
|
|
||||||
/* select a file from otherServers */
|
/* select a file from otherServers */
|
||||||
if (mFt->otherServers == NULL)
|
if (mFt->otherServers.empty() )
|
||||||
{
|
{
|
||||||
REPORT2(false,"No otherServers available");
|
REPORT2(false,"No otherServers available");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DirDetails details;
|
DirDetails details;
|
||||||
flags = DIR_FLAGS_DETAILS | DIR_FLAGS_REMOTE;
|
flags = RS_FILE_HINTS_REMOTE;
|
||||||
void *ref = NULL;
|
void *ref = NULL;
|
||||||
|
|
||||||
if(!server->RequestDirDetails(ref,details,flags))
|
if(!server->RequestDirDetails(ref,details,flags))
|
||||||
|
@ -407,8 +415,7 @@ void *do_server_test_thread(void *data)
|
||||||
REPORT("RemoteDirModel::downloadSelected() Calling File Request");
|
REPORT("RemoteDirModel::downloadSelected() Calling File Request");
|
||||||
std::list<std::string> srcIds;
|
std::list<std::string> srcIds;
|
||||||
srcIds.push_back(details.id);
|
srcIds.push_back(details.id);
|
||||||
server->FileRequest(details.name, details.hash,
|
server->FileRequest(details.name, details.hash, details.count, "", TransferRequestFlags(0), srcIds);
|
||||||
details.count, "", 0, srcIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -34,34 +34,37 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "util/rsdir.h"
|
#include "util/rsdir.h"
|
||||||
|
#include <common/fileutils.h>
|
||||||
|
#include <common/argstream.h>
|
||||||
|
|
||||||
void usage(char *name)
|
|
||||||
{
|
|
||||||
std::cerr << "Computes a CRC32 map of a file." << std::endl;
|
|
||||||
std::cerr << "Usage: " << name << " -h <path>" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
uint32_t period = 1;
|
uint32_t period = 1;
|
||||||
uint32_t dPeriod = 600; /* default 10 minutes */
|
uint32_t dPeriod = 600; /* default 10 minutes */
|
||||||
|
|
||||||
std::list<std::string> hashList;
|
std::string inputfile ;
|
||||||
|
|
||||||
|
argstream as(argc,argv) ;
|
||||||
|
|
||||||
|
as >> parameter('i',"input",inputfile,"Input file to hash. If none, a random file will be created in /tmp",false)
|
||||||
|
>> help() ;
|
||||||
|
|
||||||
|
as.defaultErrorHandling() ;
|
||||||
|
|
||||||
|
if(inputfile == "")
|
||||||
|
{
|
||||||
|
uint64_t S = 3983782 ;
|
||||||
|
std::cerr << "Creating a dummy input file in /tmp, of size " << S << std::endl;
|
||||||
|
inputfile = "crc_test_data.bin" ;
|
||||||
|
|
||||||
|
if(!FileUtils::createRandomFile(inputfile,S))
|
||||||
|
return 1 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<std::string> hashList ;
|
||||||
|
hashList.push_back(inputfile) ;
|
||||||
|
|
||||||
while(-1 != (c = getopt(argc, argv, "f:h:")))
|
|
||||||
{
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'f':
|
|
||||||
hashList.push_back(std::string(optarg));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage(argv[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
for(std::list<std::string>::const_iterator it(hashList.begin()); it != hashList.end(); it++)
|
for(std::list<std::string>::const_iterator it(hashList.begin()); it != hashList.end(); it++)
|
||||||
{
|
{
|
||||||
|
@ -79,7 +82,7 @@ int main(int argc, char **argv)
|
||||||
if(f == NULL)
|
if(f == NULL)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not open this file! Sorry." << std::endl ;
|
std::cerr << "Could not open this file! Sorry." << std::endl ;
|
||||||
return 0 ;
|
return 1 ;
|
||||||
}
|
}
|
||||||
CRC32Map crc_map ;
|
CRC32Map crc_map ;
|
||||||
|
|
||||||
|
@ -87,7 +90,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not fseek to end of this file! Sorry." << std::endl ;
|
std::cerr << "Could not fseek to end of this file! Sorry." << std::endl ;
|
||||||
fclose(f) ;
|
fclose(f) ;
|
||||||
return 0 ;
|
return 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = ftell(f) ;
|
size = ftell(f) ;
|
||||||
|
@ -96,7 +99,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
std::cerr << "Could not fseek to beginning of this file! Sorry." << std::endl ;
|
std::cerr << "Could not fseek to beginning of this file! Sorry." << std::endl ;
|
||||||
fclose(f) ;
|
fclose(f) ;
|
||||||
return 0 ;
|
return 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "File size:" << size << std::endl ;
|
std::cerr << "File size:" << size << std::endl ;
|
||||||
|
@ -109,9 +112,9 @@ int main(int argc, char **argv)
|
||||||
for(uint32_t i=0;i<crc_map.size();++i)
|
for(uint32_t i=0;i<crc_map.size();++i)
|
||||||
std::cerr << (void*)crc_map[i] ;
|
std::cerr << (void*)crc_map[i] ;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
return 1 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ftdata_test.h"
|
#include "ftdata_dummy.h"
|
||||||
|
|
||||||
/******* Pair of Send/Recv (Only need to handle Send side) ******/
|
/******* Pair of Send/Recv (Only need to handle Send side) ******/
|
||||||
ftDataSendPair::ftDataSendPair(ftDataRecv *recv)
|
ftDataSendPair::ftDataSendPair(ftDataRecv *recv)
|
||||||
|
@ -142,14 +142,22 @@ bool ftDataRecvDummy::recvChunkMap(const std::string& /*peer_id*/,const std::st
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool ftDataRecvDummy::recvSingleChunkCrcRequest(const std::string& peer_id,const std::string& hash,uint32_t chunk_id)
|
||||||
|
{
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
bool ftDataRecvDummy::recvSingleChunkCrc(const std::string& peer_id,const std::string& hash,uint32_t chunk_id,const Sha1CheckSum& sum)
|
||||||
|
{
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
bool ftDataRecvDummy::sendCRC32MapRequest(const std::string& /*peer_id*/,const std::string& /*hash*/)
|
bool ftDataRecvDummy::recvCRC32MapRequest(const std::string& /*peer_id*/,const std::string& /*hash*/)
|
||||||
{
|
{
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send a chunk map */
|
/* Send a chunk map */
|
||||||
bool ftDataRecvDummy::sendCRC32Map(const std::string& /*peer_id*/,const std::string& /*hash*/, const CompressedChunkMap& /*cmap*/)
|
bool ftDataRecvDummy::recvCRC32Map(const std::string& /*peer_id*/,const std::string& /*hash*/, const CompressedChunkMap& /*cmap*/)
|
||||||
{
|
{
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
|
@ -135,10 +135,13 @@ virtual bool recvChunkMap(const std::string& peer_id,const std::string& hash,
|
||||||
const CompressedChunkMap& cmap,bool is_client);
|
const CompressedChunkMap& cmap,bool is_client);
|
||||||
|
|
||||||
/* Send a request for a chunk map */
|
/* Send a request for a chunk map */
|
||||||
virtual bool sendCRC32MapRequest(const std::string& peer_id,const std::string& hash);
|
virtual bool recvCRC32MapRequest(const std::string& peer_id,const std::string& hash);
|
||||||
|
|
||||||
/* Send a chunk map */
|
/* Send a chunk map */
|
||||||
virtual bool sendCRC32Map(const std::string& peer_id,const std::string& hash, const CompressedChunkMap& cmap);
|
virtual bool recvCRC32Map(const std::string& peer_id,const std::string& hash, const CompressedChunkMap& cmap);
|
||||||
|
|
||||||
|
virtual bool recvSingleChunkCrcRequest(const std::string& peer_id,const std::string& hash,uint32_t chunk_id) ;
|
||||||
|
virtual bool recvSingleChunkCrc(const std::string& peer_id,const std::string& hash,uint32_t chunk_id,const Sha1CheckSum& sum);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -36,15 +36,19 @@
|
||||||
#include "util/rswin.h"
|
#include "util/rswin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <util/utest.h>
|
||||||
|
#include <common/fileutils.h>
|
||||||
#include "ft/ftextralist.h"
|
#include "ft/ftextralist.h"
|
||||||
#include "ft/ftdatamultiplex.h"
|
#include "ft/ftdatamultiplex.h"
|
||||||
#include "ft/ftfilesearch.h"
|
#include "ft/ftfilesearch.h"
|
||||||
|
|
||||||
#include "ftdata_test.h"
|
#include "ftdata_dummy.h"
|
||||||
#include "ftsearch_test.h"
|
#include "ftsearch_dummy.h"
|
||||||
|
|
||||||
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files);
|
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files);
|
||||||
|
|
||||||
|
INITTEST() ;
|
||||||
|
|
||||||
void usage(char *name)
|
void usage(char *name)
|
||||||
{
|
{
|
||||||
|
@ -78,15 +82,26 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if (optind >= argc)
|
if (optind >= argc)
|
||||||
{
|
{
|
||||||
std::cerr << "Missing Files" << std::endl;
|
uint32_t N = 4 ;
|
||||||
usage(argv[0]);
|
std::cerr << "Missing Files. Generating " << N << " random files." << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
for(; optind < argc; optind++)
|
for(uint32_t i=0;i<N;++i)
|
||||||
{
|
{
|
||||||
std::cerr << "Adding: " << argv[optind] << std::endl;
|
std::ostringstream ss ;
|
||||||
fileList.push_back(std::string(argv[optind]));
|
ss << "file_" << i << ".bin" ;
|
||||||
|
uint64_t size = lrand48()%1000 + 200000 ;
|
||||||
|
std::string filename = ss.str() ;
|
||||||
|
if(!FileUtils::createRandomFile(filename,size))
|
||||||
|
return 1 ;
|
||||||
|
std::cerr << " file: " << filename << ", size=" << size << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
for(; optind < argc; optind++)
|
||||||
|
{
|
||||||
|
std::cerr << "Adding: " << argv[optind] << std::endl;
|
||||||
|
fileList.push_back(std::string(argv[optind]));
|
||||||
|
}
|
||||||
|
|
||||||
ftExtraList *eList = new ftExtraList();
|
ftExtraList *eList = new ftExtraList();
|
||||||
eList->start();
|
eList->start();
|
||||||
|
@ -121,6 +136,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* just request random data packets first */
|
/* just request random data packets first */
|
||||||
do_random_server_test(ftmplex, eList, fileList);
|
do_random_server_test(ftmplex, eList, fileList);
|
||||||
|
|
||||||
|
FINALREPORT("FtDataPlex test") ;
|
||||||
|
|
||||||
|
return TESTRESULT() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,8 @@ int test_fill(ftFileCreator *creator)
|
||||||
|
|
||||||
REPORT("Test Fill");
|
REPORT("Test Fill");
|
||||||
|
|
||||||
return 1;
|
int res = TESTRESULT();
|
||||||
|
std::cerr << "Test result: " << res << std::endl;
|
||||||
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "ftsearch_test.h"
|
#include "ftsearch_dummy.h"
|
||||||
|
|
||||||
bool ftSearchDummy::search(const std::string& /*hash*/, FileSearchFlags hintflags, FileInfo &/*info*/) const
|
bool ftSearchDummy::search(const std::string& /*hash*/, FileSearchFlags hintflags, FileInfo &/*info*/) const
|
||||||
{
|
{
|
|
@ -46,7 +46,8 @@
|
||||||
#include "ft/fttransfermodule.h"
|
#include "ft/fttransfermodule.h"
|
||||||
|
|
||||||
#include "util/utest.h"
|
#include "util/utest.h"
|
||||||
#include "ftdata_test.h"
|
#include "ftdata_dummy.h"
|
||||||
|
#include "ftsearch_dummy.h"
|
||||||
|
|
||||||
INITTEST()
|
INITTEST()
|
||||||
|
|
||||||
|
|
21
libretroshare/src/tests/ft/perform_auto_tests.sh
Executable file
21
libretroshare/src/tests/ft/perform_auto_tests.sh
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
printresult() {
|
||||||
|
if test "$?" = "0"; then
|
||||||
|
echo ' 'PASSED
|
||||||
|
else
|
||||||
|
echo *FAILED*
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Warning: printresult needs to be called before anything else because it contains the
|
||||||
|
# result of the call to the test program, until the next command.
|
||||||
|
|
||||||
|
exes="ftcrc32test ftdataplextest ftfilecreatortest ftfileprovidertest ftextralisttest fttransfermoduletest ftcrossprovidercreatortest"
|
||||||
|
|
||||||
|
for exe in $exes; do
|
||||||
|
./$exe > /dev/null 2>&1 ; result=`printresult`; echo "-- $exe \t test :" $result ;
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,14 @@ P3Hub::P3Hub(uint32_t flags, RsSerialiser *rss)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void P3Hub::addP3Pipe(std::string id, P3Pipe *pqi, p3ConnectMgr *mgr)
|
void P3Hub::addP3Pipe(std::string id, P3Pipe *pqi, p3LinkMgr *mgr)
|
||||||
{
|
{
|
||||||
hubItem item(id, pqi, mgr);
|
hubItem item(id, pqi, mgr);
|
||||||
|
|
||||||
std::map<std::string, hubItem>::iterator it;
|
std::map<std::string, hubItem>::iterator it;
|
||||||
for(it = mPeers.begin(); it != mPeers.end(); it++)
|
for(it = mPeers.begin(); it != mPeers.end(); it++)
|
||||||
{
|
{
|
||||||
(it->second).mConnMgr->connectResult(id, true, 0);
|
(it->second).mLinkMgr->connectResult(id, true, 0);
|
||||||
mgr->connectResult(it->first, true, 0);
|
mgr->connectResult(it->first, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,14 @@ class hubItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
hubItem()
|
hubItem()
|
||||||
:mPQI(NULL), mConnMgr(NULL) { return; }
|
:mPQI(NULL), mLinkMgr(NULL) { return; }
|
||||||
|
|
||||||
hubItem(std::string id, P3Pipe *pqi, p3ConnectMgr *mgr)
|
hubItem(std::string id, P3Pipe *pqi, p3LinkMgr *mgr)
|
||||||
:mPeerId(id), mPQI(pqi), mConnMgr(mgr) { return; }
|
:mPeerId(id), mPQI(pqi), mLinkMgr(mgr) { return; }
|
||||||
|
|
||||||
std::string mPeerId;
|
std::string mPeerId;
|
||||||
P3Pipe *mPQI;
|
P3Pipe *mPQI;
|
||||||
p3ConnectMgr *mConnMgr;
|
p3LinkMgr *mLinkMgr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class P3Hub: public RsThread
|
||||||
public:
|
public:
|
||||||
|
|
||||||
P3Hub(uint32_t flags, RsSerialiser *rss);
|
P3Hub(uint32_t flags, RsSerialiser *rss);
|
||||||
void addP3Pipe(std::string id, P3Pipe *, p3ConnectMgr *mgr);
|
void addP3Pipe(std::string id, P3Pipe *, p3LinkMgr *mgr);
|
||||||
|
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
|
@ -137,6 +137,11 @@ class P3Pipe: public P3Interface
|
||||||
virtual RsFileCRC32Map* GetFileCRC32Map() ;
|
virtual RsFileCRC32Map* GetFileCRC32Map() ;
|
||||||
virtual int SendFileCRC32Map(RsFileCRC32Map*) ;
|
virtual int SendFileCRC32Map(RsFileCRC32Map*) ;
|
||||||
|
|
||||||
|
virtual RsFileSingleChunkCrcRequest* GetFileSingleChunkCrcRequest() ;
|
||||||
|
virtual int SendFileSingleChunkCrcRequest(RsFileSingleChunkCrcRequest*) ;
|
||||||
|
virtual RsFileSingleChunkCrc* GetFileSingleChunkCrc() ;
|
||||||
|
virtual int SendFileSingleChunkCrc(RsFileSingleChunkCrc*) ;
|
||||||
|
|
||||||
/* Lower Interface for PQIHub */
|
/* Lower Interface for PQIHub */
|
||||||
|
|
||||||
RsItem *PopSentItem();
|
RsItem *PopSentItem();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue