* Moved final serialiser test over, and test notes from ft.

* removed tests from lib directories for serialiser / dbase / ft



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3177 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2010-06-20 12:37:04 +00:00
parent 05bc4ba76e
commit 3855be974b
29 changed files with 1 additions and 4669 deletions

View File

@ -1,51 +0,0 @@
RS_TOP_DIR = ..
##### Define any flags that are needed for this section #######
###############################################################
###############################################################
include $(RS_TOP_DIR)/scripts/config.mk
###############################################################
RSOBJ = findex.o fimonitor.o cachestrapper.o fistore.o \
rsexpr.o
TESTOBJ = fitest2.o fisavetest.o searchtest.o
#ficachetest.o
TESTS = fitest2 fisavetest searchtest
#ficachetest
ifeq ($(OS),Linux)
TESTOBJ += fimontest.o
TESTS += fimontest
endif
ifeq ($(OS),MacOSX)
TESTOBJ += fimontest.o
TESTS += fimontest
endif
all: librs tests
fitest2 : fitest2.o $(OBJ)
$(CC) $(CFLAGS) -o fitest2 fitest2.o $(OBJ) $(LIBS)
fisavetest : fisavetest.o $(OBJ)
$(CC) $(CFLAGS) -o fisavetest fisavetest.o $(OBJ) $(LIBS)
fimontest : fimontest.o $(OBJ)
$(CC) $(CFLAGS) -o fimontest fimontest.o $(OBJ) $(LIBS)
ficachetest : ficachetest.o $(OBJ)
$(CC) $(CFLAGS) -o ficachetest ficachetest.o $(OBJ) $(LIBS)
searchtest : searchtest.o $(OBJ)
$(CC) $(CFLAGS) -o searchtest searchtest.o $(OBJ) $(LIBS)
###############################################################
include $(RS_TOP_DIR)/scripts/rules.mk
###############################################################

View File

@ -1,207 +0,0 @@
/*
* RetroShare FileCache Module: ficachetest.cc
*
* Copyright 2004-2007 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 "cachestrapper.h"
#include "cachetest.h"
#include <iostream>
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
#else
#include <windows.h>
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
void handleQuery(CacheStrapper *csp, RsPeerId pid,
std::map<RsPeerId, CacheStrapper *> &strappers);
/* A simple test of the CacheStrapper Code.
*
* create 3 different CacheStrappers, each with a Source/Store Pair and Transfer Class.
* pass queries and responses between the CacheStrappers,
* and ensure that the hashes in the Caches are updated.
*
*/
int main(int argc, char **argv)
{
time_t period = 11;
RsPeerId pid1("0x0101");
RsPeerId pid2("0x0102");
RsPeerId pid3("0x0103");
p3ConnectMgr *connMgr1 = NULL;
p3ConnectMgr *connMgr2 = NULL;
p3ConnectMgr *connMgr3 = NULL;
CacheStrapper sc1(connMgr1);
CacheStrapper sc2(connMgr2);
CacheStrapper sc3(connMgr3);
CacheTransfer ctt1(&sc1);
CacheTransfer ctt2(&sc2);
CacheTransfer ctt3(&sc3);
std::map<RsPeerId, CacheStrapper *> strappers;
strappers[pid1] = &sc1;
strappers[pid2] = &sc2;
strappers[pid3] = &sc3;
std::string nulldir = "";
CacheSource *csrc1 = new CacheTestSource(&sc1, nulldir);
CacheStore *cstore1 = new CacheTestStore(&ctt1, nulldir);
CacheId cid1(TESTID, 0);
CacheSource *csrc2 = new CacheTestSource(&sc2, nulldir);
CacheStore *cstore2 = new CacheTestStore(&ctt2, nulldir);
CacheId cid2(TESTID, 0);
CacheSource *csrc3 = new CacheTestSource(&sc3, nulldir);
CacheStore *cstore3 = new CacheTestStore(&ctt3, nulldir);
CacheId cid3(TESTID, 0);
CachePair cp1(csrc1, cstore1, cid1);
CachePair cp2(csrc2, cstore2, cid2);
CachePair cp3(csrc3, cstore3, cid3);
sc1.addCachePair(cp1);
sc2.addCachePair(cp2);
sc3.addCachePair(cp3);
/* add in a cache to sc2 */
CacheData cdata;
cdata.pid = pid1;
cdata.cid = cid1;
cdata.name = "Perm Cache";
cdata.path = "./";
cdata.hash = "GHJKI";
csrc1->refreshCache(cdata);
cdata.pid = pid2;
cdata.cid = cid2;
cdata.name = "Funny Cache";
cdata.path = "./";
cdata.hash = "ABCDEF";
csrc2->refreshCache(cdata);
/* now exercise it */
for(int i = 0; 1 ; i++)
{
RsPeerId src("");
CacheStrapper *csp = NULL;
if (i % 5 == 1)
{
src = pid1;
csp = &sc1;
}
else if (i % 5 == 2)
{
src = pid2;
csp = &sc2;
}
else if (i % 5 == 3)
{
src = pid3;
csp = &sc3;
}
std::cerr << std::endl;
std::cerr << "Cache Iteraton: " << time(NULL) << std::endl;
std::cerr << std::endl;
if (src != "")
{
handleQuery(csp, src, strappers);
}
if (i % 21 == 0)
{
/* print out the resources */
sc1.listCaches(std::cerr);
sc2.listCaches(std::cerr);
sc3.listCaches(std::cerr);
}
/* every once in a while change the cache on 2 */
if (i % 31 == 25)
{
cdata.hash += "X";
csrc2->refreshCache(cdata);
}
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
/* tick the systems */
}
/* Cleanup - TODO */
return 1;
}
void handleQuery(CacheStrapper *csp, RsPeerId pid,
std::map<RsPeerId, CacheStrapper *> &strappers)
{
/* query */
std::list<RsPeerId> ids;
std::list<RsPeerId>::iterator pit;
std::cerr << "Cache Query from: " << pid << std::endl;
csp -> sendCacheQuery(ids, time(NULL));
for(pit = ids.begin(); pit != ids.end(); pit++)
{
std::cerr << "Cache Query for: " << (*pit) << std::endl;
std::map<RsPeerId, CacheStrapper *>::iterator sit;
if (strappers.end() != (sit = strappers.find(*pit)))
{
std::map<CacheId, CacheData> hashs;
std::map<CacheId, CacheData>::iterator hit;
(sit -> second) -> handleCacheQuery(pid, hashs);
for(hit = hashs.begin(); hit != hashs.end(); hit++)
{
csp -> recvCacheResponse(hit->second, time(NULL));
}
}
else
{
std::cerr << "Unknown Query Destination!" << std::endl;
}
}
}

View File

@ -1,87 +0,0 @@
/*
* RetroShare FileCache Module: fimontest.cc
*
* Copyright 2004-2007 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 "findex.h"
#include "fimonitor.h"
#include <iostream>
void usage(char *name)
{
std::cerr << "Usage: " << name << " [-p <period> ] shareDir1 [shareDir2 [shareDir3 [...]]]";
std::cerr << std::endl;
exit(1);
}
int main(int argc, char **argv)
{
/* handle commandline arguments */
int c;
int period = 60; /* recheck period in seconds */
while((c = getopt(argc, argv,"p:")) != -1)
{
switch(c)
{
case 'p':
period = atoi(optarg);
break;
default:
std::cerr << "Bad Option.";
std::cerr << std::endl;
usage(argv[0]);
break;
}
}
std::list<std::string> rootdirs;
/* add all the rest of the commandline arguments to rootdirs list */
for(; optind < argc; optind++)
{
rootdirs.push_back(argv[optind]);
std::cerr << "Adding shared directory: " << argv[optind] << std::endl;
}
if (rootdirs.size() < 1)
{
usage(argv[0]);
}
sleep(1);
FileIndexMonitor mon(NULL,NULL, "", "OWN ID");
/* setup monitor */
mon.setPeriod(period);
mon.setSharedDirectories(rootdirs);
/* simulate running the thread */
mon.run();
return 1;
}

View File

@ -1,118 +0,0 @@
/*
* RetroShare FileCache Module: fisavetest.cc
*
* Copyright 2004-2007 by Kefei Zhou.
*
* 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 "dbase/findex.h"
#include <iostream>
FileIndex *createBasicFileIndex(time_t age);
int main()
{
FileIndex *fi1 = createBasicFileIndex(100);
FileIndex *fi2 = new FileIndex("A SILLY ID");
fi1->printFileIndex(std::cout);
std::string fhash;
uint64_t size;
fi1->saveIndex("test.index", fhash, size);
std::cout << " Saved Index: Size: " << size << " Hash: " << fhash << std::endl;
std::cout << " -- new file index -- " << std::endl;
fi2->loadIndex("test.index", fhash, size);
fi2->printFileIndex(std::cout);
delete fi1;
delete fi2;
return 1;
}
FileIndex *createBasicFileIndex(time_t age)
{
FileIndex *fi = new FileIndex("A SILLY ID");
FileEntry fe;
std::list<std::string> rootdirs;
rootdirs.push_back("base1");
rootdirs.push_back("base2");
rootdirs.push_back("base3");
fi -> setRootDirectories(rootdirs, age);
/* add some entries */
fe.name = "dir1";
fi -> updateDirEntry("base1",fe, age);
fe.name = "dir2";
fi -> updateDirEntry("base1",fe, age);
fe.name = "dir01";
fi -> updateDirEntry("/base1/dir1/",fe, age);
fe.name = "dir001";
fi -> updateDirEntry("/base1/dir1/dir01/",fe, age);
fe.name = "file1";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "file2";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "file3";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "file4";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "dir2";
fi -> updateDirEntry("/base1",fe, age);
fe.name = "file5";
fi -> updateFileEntry("/base1/dir2/",fe, age);
fe.name = "file6";
fi -> updateFileEntry("/base1/dir2/",fe, age);
fe.name = "file7";
fi -> updateFileEntry("/base1/dir2/",fe, age);
fe.name = "file8";
fi -> updateFileEntry("/base1/",fe, age);
fe.name = "dir3";
fi -> updateDirEntry("/base1/dir2/",fe, age);
fe.name = "file10";
fi -> updateFileEntry("/base1/dir2/dir3",fe, age);
fe.name = "file11";
fi -> updateFileEntry("/base1/dir2/dir3",fe, age);
fe.name = "file12";
fi -> updateFileEntry("/base1/dir2/dir3",fe, age);
fe.name = "dir4";
fi -> updateDirEntry("/base3/",fe, age);
fe.name = "file20";
fi -> updateFileEntry("/base3/dir4/",fe, age);
fe.name = "file21";
fi -> updateFileEntry("/base3/dir4",fe, age);
return fi;
}

View File

@ -1,213 +0,0 @@
/*
* RetroShare FileCache Module: fitest2.cc
*
* Copyright 2004-2007 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 "dbase/findex.h"
#include <iostream>
FileIndex *createBasicFileIndex(time_t age);
int test1(FileIndex *fi);
int test2(FileIndex *fi);
int main()
{
FileIndex *fi = createBasicFileIndex(100);
test1(fi);
delete fi;
return 1;
}
int test1(FileIndex *fi)
{
/* in this test we are going to get the old directories - and update them */
time_t stamp = 200;
DirEntry *olddir = NULL;
FileEntry fe;
while((olddir = fi -> findOldDirectory(stamp)))
{
/* update the directories and files here */
std::map<std::string, DirEntry *>::iterator dit;
std::map<std::string, FileEntry *>::iterator fit;
/* update this dir */
fe.name = olddir->name;
fi -> updateDirEntry(olddir->parent->path, fe, stamp);
/* update subdirs */
for(dit = olddir->subdirs.begin(); dit != olddir->subdirs.end(); dit++)
{
fe.name = (dit->second)->name;
/* set the age as out-of-date so that it gets checked */
fi -> updateDirEntry(olddir->path, fe, 0);
}
/* update files */
for(fit = olddir->files.begin(); fit != olddir->files.end(); fit++)
{
fe.name = (fit->second)->name;
fi -> updateFileEntry(olddir->path, fe, stamp);
}
/* clean up the dir (should have no effect) */
fi -> removeOldDirectory(olddir->parent->path, olddir->name, stamp);
fi -> printFileIndex(std::cout);
}
fi -> printFileIndex(std::cout);
return 1;
}
int test2(FileIndex *fi)
{
/* in this test we are going to simulate that 2 directories have disappeared */
time_t stamp = 200;
DirEntry *olddir = NULL;
FileEntry fe;
bool missingdir = false;
int i = 0;
while((olddir = fi -> findOldDirectory(stamp)))
{
missingdir = false;
if (i % 2 == 0)
{
std::cerr << " Simulating that dir doesnt exist :" << olddir->path;
std::cerr << std::endl;
missingdir = true;
}
i++;
if (!missingdir)
{
/* update the directories and files here */
std::map<std::string, DirEntry *>::iterator dit;
std::map<std::string, FileEntry *>::iterator fit;
/* update this dir */
fe.name = olddir->name;
fi -> updateDirEntry(olddir->parent->path, fe, stamp);
/* update subdirs */
for(dit = olddir->subdirs.begin(); dit != olddir->subdirs.end(); dit++)
{
fe.name = (dit->second)->name;
/* set the age as out-of-date so that it gets checked */
fi -> updateDirEntry(olddir->path, fe, 0);
}
/* update files */
for(fit = olddir->files.begin(); fit != olddir->files.end(); fit++)
{
fe.name = (fit->second)->name;
fi -> updateFileEntry(olddir->path, fe, stamp);
}
}
/* clean up the dir */
fi -> removeOldDirectory(olddir->parent->path, olddir->name, stamp);
fi -> printFileIndex(std::cout);
}
fi -> printFileIndex(std::cout);
return 1;
}
FileIndex *createBasicFileIndex(time_t age)
{
FileIndex *fi = new FileIndex("A SILLY ID");
FileEntry fe;
/* print empty FileIndex */
fi -> printFileIndex(std::cout);
std::list<std::string> rootdirs;
rootdirs.push_back("base1");
rootdirs.push_back("base2");
rootdirs.push_back("base3");
fi -> setRootDirectories(rootdirs, age);
/* add some entries */
fe.name = "dir1";
fi -> updateDirEntry("base1",fe, age);
fe.name = "file1";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "file2";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "file3";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "file4";
fi -> updateFileEntry("/base1/dir1/",fe, age);
fe.name = "dir2";
fi -> updateDirEntry("/base1",fe, age);
fe.name = "file5";
fi -> updateFileEntry("/base1/dir2/",fe, age);
fe.name = "file6";
fi -> updateFileEntry("/base1/dir2/",fe, age);
fe.name = "file7";
fi -> updateFileEntry("/base1/dir2/",fe, age);
fe.name = "file8";
fi -> updateFileEntry("/base1/",fe, age);
fe.name = "dir3";
fi -> updateDirEntry("/base1/dir2/",fe, age);
fe.name = "file10";
fi -> updateFileEntry("/base1/dir2/dir3",fe, age);
fe.name = "file11";
fi -> updateFileEntry("/base1/dir2/dir3",fe, age);
fe.name = "file12";
fi -> updateFileEntry("/base1/dir2/dir3",fe, age);
fe.name = "dir4";
fi -> updateDirEntry("/base3/",fe, age);
fe.name = "file20";
fi -> updateFileEntry("/base3/dir4/",fe, age);
fe.name = "file21";
fi -> updateFileEntry("/base3/dir4",fe, age);
// one that will fail.
fe.name = "file20";
fi -> updateFileEntry("/base3/",fe, age);
fi -> printFileIndex(std::cout);
return fi;
}

View File

@ -1,74 +0,0 @@
/*
* RetroShare FileCache Module: searchtest.cc
*
* Copyright 2004-2007 by Kefei Zhou.
*
* 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 "dbase/findex.h"
#include <iostream>
#include <fstream>
int main()
{
std::cout << std::string::npos << std::endl;
std::string testfile = "searchtest.index";
std::string fhash = "6851c28d99a6616a86942c3914476bf11997242a";
FileIndex *fi = new FileIndex("DUMB ID");
// loading fileindex
std::cout << std::endl << "Test load" << std::endl;
fi->loadIndex(testfile, fhash, 1532);
fi->printFileIndex(std::cout);
std::cout << "FileIndex Loaded" << std::endl << std::endl;
std::list<FileEntry *> hashresult;
std::list<FileEntry *> termresult;
// searchhash
std::string findhash = "82bffa6e1cdf8419397311789391238174817481";
std::cout << "Search hash : " << findhash << std::endl;
fi->searchHash(findhash, hashresult);
while(!hashresult.empty())
{
hashresult.back()->print(std::cout);
hashresult.pop_back();
}
// searchterm
std::list<std::string> terms;
terms.push_back("paper");
terms.push_back("doc");
std::cout << "Search terms" << std::endl;
fi->searchTerms(terms, termresult);
while(!termresult.empty())
{
termresult.back()->print(std::cout);
termresult.pop_back();
}
delete fi;
return 1;
}

View File

@ -1,50 +0,0 @@
RS_TOP_DIR = ..
##### Define any flags that are needed for this section #######
###############################################################
###############################################################
include $(RS_TOP_DIR)/scripts/config.mk
###############################################################
RSOBJ = ftdata.o ftfileprovider.o ftfilecreator.o ftextralist.o \
ftdatamultiplex.o ftfilesearch.o fttransfermodule.o ftdbase.o ftserver.o \
ftcontroller.o pqitestor.o ftdwlqueue.o
TESTOBJ = ftfileprovidertest.o ftfilecreatortest.o ftextralisttest.o ftdataplextest.o ftserver1test.o ftserver2test.o fttransfermoduletest.o ftserver3test.o
TESTS = ftfileprovidertest ftfilecreatortest ftextralisttest ftdataplextest ftserver1test ftserver2test fttransfermoduletest ftserver3test
all: librs tests
ftfilecreatortest : ftfilecreatortest.o
$(CC) $(CFLAGS) -o ftfilecreatortest ftfilecreatortest.o $(LIBS)
ftfileprovidertest : ftfileprovidertest.o
$(CC) $(CFLAGS) -o ftfileprovidertest ftfileprovidertest.o $(LIBS)
fttransfermoduletest : fttransfermoduletest.o
$(CC) $(CFLAGS) -o fttransfermoduletest fttransfermoduletest.o $(LIBS)
ftextralisttest : ftextralisttest.o
$(CC) $(CFLAGS) -o ftextralisttest ftextralisttest.o $(LIBS)
ftdataplextest : ftdataplextest.o
$(CC) $(CFLAGS) -o ftdataplextest ftdataplextest.o $(LIBS)
ftserver1test : ftserver1test.o
$(CC) $(CFLAGS) -o ftserver1test ftserver1test.o $(LIBS)
ftserver2test : ftserver2test.o
$(CC) $(CFLAGS) -o ftserver2test ftserver2test.o $(LIBS)
ftserver3test : ftserver3test.o
$(CC) $(CFLAGS) -o ftserver3test ftserver3test.o $(LIBS)
###############################################################
include $(RS_TOP_DIR)/scripts/rules.mk
###############################################################

View File

@ -1,411 +0,0 @@
/*
* libretroshare/src/ft: ftserver1test.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".
*
*/
/*
* ftServer2Test - Demonstrates how to check for test stuff.
*/
#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 "util/rsdebug.h"
#include "ft/pqitestor.h"
#include "util/rsdir.h"
#include "util/utest.h"
#include <sstream>
class TestData
{
public:
ftServer *loadServer;
std::list<ftServer *> otherServers;
std::list<std::string> extraList;
};
extern "C" void *do_server_test_thread(void *p);
void usage(char *name)
{
std::cerr << "Usage: " << name << " [-sa] [-p <peerId>] [-d <debugLvl>] [-e <extrafile>] [<path> [<path2> ... ]] ";
std::cerr << std::endl;
}
int main(int argc, char **argv)
{
int c;
uint32_t period = 1;
uint32_t debugLevel = 5;
bool debugStderr = true;
bool loadAll = false;
std::list<std::string> fileList;
std::list<std::string> extraList;
std::list<std::string> peerIds;
std::map<std::string, ftServer *> mFtServers;
std::map<std::string, p3ConnectMgr *> mConnMgrs;
ftServer *mLoadServer = NULL;
std::list<ftServer *> mOtherServers;
std::list<std::string>::iterator eit;
while(-1 != (c = getopt(argc, argv, "asd:p:e:")))
{
switch (c)
{
case 'p':
peerIds.push_back(optarg);
break;
case 'd':
debugLevel = atoi(optarg);
break;
case 's':
debugStderr = true;
break;
case 'e':
extraList.push_back(optarg);
break;
case 'a':
loadAll = true;
break;
default:
usage(argv[0]);
break;
}
}
/* do logging */
setOutputLevel(debugLevel);
if (optind >= argc)
{
std::cerr << "Missing Shared Directories" << std::endl;
usage(argv[0]);
}
for(; optind < argc; optind++)
{
std::cerr << "Adding: " << argv[optind] << std::endl;
fileList.push_back(std::string(argv[optind]));
}
/* We need to setup a series 2 - 4 different ftServers....
*
* Each one needs:
*
*
* A List of peerIds...
*/
std::list<std::string>::const_iterator it, jit;
std::list<pqiAuthDetails> baseFriendList, friendList;
std::list<pqiAuthDetails>::iterator fit;
P3Hub *testHub = new P3Hub();
testHub->start();
/* Setup Base Friend Info */
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
pqiAuthDetails pad;
pad.id = *it;
pad.name = *it;
pad.trustLvl = 5;
pad.ownsign = true;
pad.trusted = false;
baseFriendList.push_back(pad);
std::cerr << "ftserver1test::setup peer: " << *it;
std::cerr << std::endl;
}
std::ostringstream pname;
pname << "/tmp/rstst-" << time(NULL);
std::string basepath = pname.str();
RsDirUtil::checkCreateDirectory(basepath);
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
friendList = baseFriendList;
/* remove current one */
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
if (fit->id == *it)
{
friendList.erase(fit);
break;
}
}
p3AuthMgr *authMgr = new p3DummyAuthMgr(*it, friendList);
p3ConnectMgr *connMgr = new p3ConnectMgr(authMgr);
mConnMgrs[*it] = connMgr;
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
/* add as peer to authMgr */
connMgr->addFriend(fit->id);
}
P3Pipe *pipe = new P3Pipe(); //(*it);
/* add server */
ftServer *server;
server = new ftServer(authMgr, connMgr);
mFtServers[*it] = server;
if (!mLoadServer)
{
mLoadServer = server;
}
else
{
mOtherServers.push_back(server);
}
server->setP3Interface(pipe);
std::string configpath = basepath + "/" + *it;
RsDirUtil::checkCreateDirectory(configpath);
std::string cachepath = configpath + "/cache";
RsDirUtil::checkCreateDirectory(cachepath);
std::string localpath = cachepath + "/local";
RsDirUtil::checkCreateDirectory(localpath);
std::string remotepath = cachepath + "/remote";
RsDirUtil::checkCreateDirectory(remotepath);
server->setConfigDirectory(configpath);
NotifyBase *base = NULL;
server->SetupFtServer(base);
testHub->addP3Pipe(*it, pipe, connMgr);
server->StartupThreads();
/* setup any extra bits */
if (loadAll)
{
server->setSharedDirectories(fileList);
for(eit = extraList.begin(); eit != extraList.end(); eit++)
{
server->ExtraFileHash(*eit, 3600, 0);
}
}
}
if (mLoadServer)
{
mLoadServer->setSharedDirectories(fileList);
for(eit = extraList.begin(); eit != extraList.end(); eit++)
{
mLoadServer->ExtraFileHash(*eit, 3600, 0);
}
}
/* stick your real test here */
std::map<std::string, ftServer *>::iterator sit;
std::map<std::string, p3ConnectMgr *>::iterator cit;
/* Start up test thread */
pthread_t tid;
TestData *mFt = new TestData;
/* set data */
mFt->loadServer = mLoadServer;
mFt->otherServers = mOtherServers;
mFt->extraList = extraList;
void *data = (void *) mFt;
pthread_create(&tid, 0, &do_server_test_thread, data);
pthread_detach(tid); /* so memory is reclaimed in linux */
while(1)
{
std::cerr << "ftserver2test::sleep()";
std::cerr << std::endl;
sleep(1);
/* tick the connmgrs */
for(sit = mFtServers.begin(); sit != mFtServers.end(); sit++)
{
/* update */
(sit->second)->tick();
}
for(cit = mConnMgrs.begin(); cit != mConnMgrs.end(); cit++)
{
/* update */
(cit->second)->tick();
}
}
}
/* So our actual test can run here.....
*
*/
INITTEST();
void *do_server_test_thread(void *data)
{
TestData *mFt = (TestData *) data;
std::cerr << "do_server_test_thread() running";
std::cerr << std::endl;
/************************* TEST 1 **********************
* Check that the extra List has been processed.
*/
time_t start = time(NULL);
FileInfo info, info2;
time_t now = time(NULL);
std::list<std::string>::iterator eit;
for(eit = mFt->extraList.begin(); eit != mFt->extraList.end(); eit++)
{
while(!mFt->loadServer->ExtraFileStatus(*eit, info))
{
/* max of 30 seconds */
now = time(NULL);
if (now - start > 30)
{
/* FAIL */
REPORT2( false, "Extra File Hashing");
}
sleep(1);
}
/* Got ExtraFileStatus */
REPORT("Successfully Found ExtraFile");
/* now we can try a search (should succeed) */
uint32_t hintflags = 0;
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
{
CHECK(info2.hash == info.hash);
CHECK(info2.size == info.size);
CHECK(info2.fname == info.fname);
}
else
{
REPORT2( false, "Search for Extra File (Basic)");
}
/* search with flags (should succeed) */
hintflags = RS_FILE_HINTS_EXTRA;
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
{
CHECK(info2.hash == info.hash);
CHECK(info2.size == info.size);
CHECK(info2.fname == info.fname);
}
else
{
REPORT2( false, "Search for Extra File (Extra Flag)");
}
/* search with other flags (should fail) */
hintflags = RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY;
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
{
REPORT2( false, "Search for Extra File (Fail Flags)");
}
else
{
REPORT("Search for Extra File (Fail Flags)");
}
/* if we try to download it ... should just find existing one*/
REPORT("Testing with Extra File");
}
FINALREPORT("ExtraList Hashing, Searching and Downloading");
/************************* TEST 2 **********************
* test ftController and ftTransferModule
*/
ftServer *server=mFt->loadServer;
std::string fname,filehash,destination;
uint32_t size,flags;
std::list<std::string> srcIds;
/* select a file from otherServers */
if (mFt->otherServers == NULL)
{
REPORT2(false,"No otherServers available");
exit(1);
}
DirDetails details;
uint32_t flags = DIR_FLAGS_DETAILS | DIR_FLAGS_REMOTE;
void *ref = NULL;
if(!server->RequestDirDetails(ref,details,flags))
{
REPORT2(false,"fail to call RequestDirDetails");
}
if (details.type == DIR_TYPE_FILE)
{
REPORT("RemoteDirModel::downloadSelected() Calling File Request");
std::list<std::string> srcIds;
srcIds.push_back(details.id);
server->FileRequest(details.name, details.hash,
details.count, "", 0, srcIds);
}
exit(1);
}

View File

@ -1,178 +0,0 @@
/*
* libretroshare/src/ft: ftextralisttest.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".
*
*/
/*
* Test for Multiplexor.....
* As this is a key middle component, it is hard to test without other bits.
* It relies on ftFileProvider/ftFileCreator/ftTransferModule...
*
* And has dummy ftDataSend and ftSearch.
*
*/
#ifdef WIN32
#include "util/rswin.h"
#endif
#include "ft/ftextralist.h"
#include "ft/ftdatamultiplex.h"
#include "ft/ftfilesearch.h"
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files);
void usage(char *name)
{
std::cerr << "Usage: " << name << " [-p <period>] [-d <dperiod>] <path> [<path2> ... ] ";
std::cerr << std::endl;
}
int main(int argc, char **argv)
{
int c;
uint32_t period = 1;
uint32_t dPeriod = 600; /* default 10 minutes */
std::list<std::string> fileList;
while(-1 != (c = getopt(argc, argv, "d:p:")))
{
switch (c)
{
case 'p':
period = atoi(optarg);
break;
case 'd':
dPeriod = atoi(optarg);
break;
default:
usage(argv[0]);
break;
}
}
if (optind >= argc)
{
std::cerr << "Missing Files" << std::endl;
usage(argv[0]);
}
for(; optind < argc; optind++)
{
std::cerr << "Adding: " << argv[optind] << std::endl;
fileList.push_back(std::string(argv[optind]));
}
ftExtraList *eList = new ftExtraList();
eList->start();
ftSearch *ftsd = new ftSearchDummy();
ftFileSearch *ftfs = new ftFileSearch();
ftfs-> addSearchMode(ftsd, RS_FILE_HINTS_LOCAL);
ftfs-> addSearchMode(eList, RS_FILE_HINTS_EXTRA);
ftDataSend *ftds = new ftDataSendDummy();
/* setup Actual Test bit */
ftDataMultiplex *ftmplex = new ftDataMultiplex("ownId", ftds, ftfs);
ftmplex->start();
/* Setup Search with some valid results */
/* Request Data */
/* now work the thread */
std::list<std::string>::iterator it;
uint32_t flags = 0;
for(it = fileList.begin(); it != fileList.end(); it++)
{
eList->hashExtraFile(*it, dPeriod, flags);
}
/* now request files from ftDataMultiplex */
/* just request random data packets first */
do_random_server_test(ftmplex, eList, fileList);
}
uint32_t do_random_server_iteration(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files)
{
std::cerr << "do_random_server_iteration()";
std::cerr << std::endl;
std::list<std::string>::iterator it;
uint32_t i = 0;
for(it = files.begin(); it != files.end(); it++)
{
FileInfo info;
if (eList->hashExtraFileDone(*it, info))
{
std::cerr << "Hash Done for: " << *it;
std::cerr << std::endl;
std::cerr << info << std::endl;
std::cerr << "Requesting Data Packet";
std::cerr << std::endl;
/* Server Recv */
uint64_t offset = 10000;
uint32_t chunk = 20000;
mplex->recvDataRequest("Peer", info.hash, info.size, offset, chunk);
i++;
}
else
{
std::cerr << "do_random_server_iteration() Hash Not Done for: " << *it;
std::cerr << std::endl;
}
}
return i;
}
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files)
{
std::cerr << "do_random_server_test()";
std::cerr << std::endl;
uint32_t size = files.size();
while(size > do_random_server_iteration(mplex, eList, files))
{
std::cerr << "do_random_server_test() sleep";
std::cerr << std::endl;
sleep(10);
}
}

View File

@ -1,166 +0,0 @@
/*
* libretroshare/src/ft: ftextralisttest.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".
*
*/
#ifdef WIN32
#include "util/rswin.h"
#endif
#include "ft/ftextralist.h"
extern "C" void* runExtraList(void* p)
{
ftExtraList *eList = (ftExtraList *) p;
if (!eList)
{
pthread_exit(NULL);
}
while (1)
{
//eList->tick();
sleep(1);
}
delete eList;
pthread_exit(NULL);
return NULL;
}
void displayExtraListDetails(ftExtraList *eList, std::list<std::string> toHash, std::list<std::string> hashed);
void usage(char *name)
{
std::cerr << "Usage: " << name << " -h <path> -p <period> -d <dperiod>";
std::cerr << std::endl;
}
int main(int argc, char **argv)
{
int c;
uint32_t period = 1;
uint32_t dPeriod = 600; /* default 10 minutes */
std::list<std::string> hashList;
while(-1 != (c = getopt(argc, argv, "h:p:d:")))
{
switch (c)
{
case 'h':
hashList.push_back(std::string(optarg));
break;
case 'p':
period = atoi(optarg);
break;
case 'd':
dPeriod = atoi(optarg);
break;
default:
usage(argv[0]);
break;
}
}
ftExtraList *eList = new ftExtraList();
/* now startup background thread to keep it reunning */
eList->start();
/* now work the thread */
std::list<std::string> toHash;
std::list<std::string> hashed;
std::list<std::string>::iterator it;
uint32_t flags = 0;
for(it = hashList.begin(); it != hashList.end(); it++)
{
sleep(period);
/* load up file */
//eList->addExtraFile(*it);
eList->hashExtraFile(*it, dPeriod, flags);
toHash.push_back(*it);
displayExtraListDetails(eList, toHash, hashed);
}
while(1)
{
sleep(period);
displayExtraListDetails(eList, toHash, hashed);
}
}
void displayExtraListDetails(ftExtraList *eList, std::list<std::string> toHash, std::list<std::string> hashed)
{
std::cerr << "displayExtraListDetails()";
std::cerr << std::endl;
std::list<std::string>::iterator it;
for(it = toHash.begin(); it != toHash.end(); it++)
{
FileInfo info;
if (eList->hashExtraFileDone(*it, info))
{
std::cerr << "displayExtraListDetails() Hash Completed for: " << *it;
std::cerr << std::endl;
std::cerr << info << std::endl;
}
else
{
std::cerr << "displayExtraListDetails() Hash Not Done for: " << *it;
std::cerr << std::endl;
}
}
for(it = hashed.begin(); it != hashed.end(); it++)
{
FileInfo info;
if (eList->search(*it, 0, 0, info))
{
std::cerr << "displayExtraListDetails() Found Hash: " << *it;
std::cerr << std::endl;
std::cerr << info << std::endl;
}
else
{
std::cerr << "displayExtraListDetails() Hash Not Found: " << *it;
std::cerr << std::endl;
}
}
}

View File

@ -1,122 +0,0 @@
#include "ftfilecreator.h"
#include "util/utest.h"
#include <stdlib.h>
#include "util/rswin.h"
INITTEST();
static int test_timeout(ftFileCreator *creator);
static int test_fill(ftFileCreator *creator);
int main()
{
/* use ftcreator to create a file on tmp drive */
ftFileCreator fcreator("/tmp/rs-ftfc-test.dta",100000,"hash",0);
test_timeout(&fcreator);
test_fill(&fcreator);
FINALREPORT("RsTlvItem Stack Tests");
return TESTRESULT();
}
int test_timeout(ftFileCreator *creator)
{
uint32_t chunk = 1000;
uint64_t offset = 0;
int max_timeout = 30;
int max_offset = chunk * max_timeout;
int i;
std::cerr << "60 second test of chunk queue.";
std::cerr << std::endl;
for(i = 0; i < max_timeout; i++)
{
creator->getMissingChunk(offset, chunk);
std::cerr << "Allocated Offset: " << offset << " chunk: " << chunk << std::endl;
CHECK(offset <= max_offset);
sleep(1);
}
std::cerr << "Expect Repeats now";
std::cerr << std::endl;
for(i = 0; i < max_timeout; i++)
{
sleep(1);
creator->getMissingChunk(offset, chunk);
std::cerr << "Allocated Offset: " << offset << " chunk: " << chunk << std::endl;
CHECK(offset <= max_offset);
}
REPORT("Chunk Queue");
return 1;
}
int test_fill(ftFileCreator *creator)
{
uint32_t chunk = 1000;
uint64_t offset = 0;
uint64_t init_size = creator->getFileSize();
uint64_t init_trans = creator->getRecvd();
std::cerr << "Initial FileSize: " << init_size << std::endl;
std::cerr << "Initial Transferred:" << init_trans << std::endl;
while(creator->getMissingChunk(offset, chunk))
{
if (chunk == 0)
{
std::cerr << "Missing Data already Alloced... wait";
std::cerr << std::endl;
sleep(1);
chunk = 1000;
continue;
}
/* give it to them */
void *data = malloc(chunk);
/* fill with ascending numbers */
for(int i = 0; i < chunk; i++)
{
((uint8_t *) data)[i] = 'a' + i % 27;
if (i % 27 == 26)
{
((uint8_t *) data)[i] = '\n';
}
}
creator->addFileData(offset, chunk, data);
free(data);
#ifndef WINDOWS_SYS
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
usleep(250000); /* 1/4 of sec */
#else
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
Sleep(250); /* 1/4 of sec */
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
chunk = 1000; /* reset chunk size */
}
uint64_t end_size = creator->getFileSize();
uint64_t end_trans = creator->getRecvd();
std::cerr << "End FileSize: " << end_size << std::endl;
std::cerr << "End Transferred:" << end_trans << std::endl;
CHECK(init_size == end_size);
CHECK(end_trans == end_size);
REPORT("Test Fill");
return 1;
}

View File

@ -1,93 +0,0 @@
#include "ftfileprovider.h"
#include "ftfilecreator.h"
#include "util/utest.h"
#include <stdlib.h>
#include "util/rswin.h"
INITTEST()
int main()
{
/* create a random file */
uint64_t size = 100000;
uint32_t max_chunk = 10000;
uint32_t chunk = 1000;
uint64_t offset = 0;
std::string filename = "/tmp/ft_test.dta";
std::string filename2 = "/tmp/ft_test.dta.dup";
/* use creator to make it */
void *data = malloc(max_chunk);
for(int i = 0; i < max_chunk; i++)
{
((uint8_t *) data)[i] = 'a' + i % 27;
if (i % 27 == 26)
{
((uint8_t *) data)[i] = '\n';
}
}
ftFileCreator *creator = new ftFileCreator(filename, size, "hash", 0);
for(offset = 0; offset != size; offset += chunk)
{
if (!creator->addFileData(offset, chunk, data))
{
FAILED("Create Test Data File");
std::cerr << "Failed to add data (CREATE)";
std::cerr << std::endl;
}
}
delete creator;
std::cerr << "Created file: " << filename << " of size: " << size;
std::cerr << std::endl;
/* load it with file provider */
creator = new ftFileCreator(filename2, size, "hash", 0);
ftFileProvider *provider = new ftFileProvider(filename, size, "hash");
/* create duplicate with file creator */
while(creator->getMissingChunk(offset, chunk))
{
if (chunk == 0)
{
std::cerr << "All currently allocated .... waiting";
std::cerr << std::endl;
sleep(1);
/* reset chunk size */
chunk = (uint64_t) max_chunk * (rand() / (1.0 + RAND_MAX));
std::cerr << "ChunkSize = " << chunk << std::endl;
continue;
}
if (!provider->getFileData(offset, chunk, data))
{
FAILED("Read from Test Data File");
std::cerr << "Failed to get data";
std::cerr << std::endl;
}
if (!creator->addFileData(offset, chunk, data))
{
FAILED("Write to Duplicate");
std::cerr << "Failed to add data";
std::cerr << std::endl;
}
std::cerr << "Transferred: " << chunk << " @ " << offset;
std::cerr << std::endl;
/* reset chunk size */
chunk = (uint64_t) max_chunk * (rand() / (1.0 + RAND_MAX));
std::cerr << "ChunkSize = " << chunk << std::endl;
}
return 1;
}

View File

@ -1,329 +0,0 @@
/*
* libretroshare/src/ft: ftserver1test.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".
*
*/
/*
* Test for Whole Basic system.....
*
* Put it all together, and make it compile.
*/
#ifdef WIN32
#include "util/rswin.h"
#endif
#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 "util/rsdebug.h"
#include "ft/pqitestor.h"
#include "util/rsdir.h"
#include <sstream>
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files);
void usage(char *name)
{
std::cerr << "Usage: " << name << " [-p <period>] [-d <dperiod>] <path> [<path2> ... ] ";
std::cerr << std::endl;
}
int main(int argc, char **argv)
{
int c;
uint32_t period = 1;
uint32_t debugLevel = 5;
bool debugStderr = true;
std::list<std::string> fileList;
std::list<std::string> peerIds;
std::map<std::string, ftServer *> mFtServers;
std::map<std::string, p3ConnectMgr *> mConnMgrs;
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
#ifdef WIN32
// Windows Networking Init.
WORD wVerReq = MAKEWORD(2,2);
WSADATA wsaData;
if (0 != WSAStartup(wVerReq, &wsaData))
{
std::cerr << "Failed to Startup Windows Networking";
std::cerr << std::endl;
}
else
{
std::cerr << "Started Windows Networking";
std::cerr << std::endl;
}
#endif
while(-1 != (c = getopt(argc, argv, "d:p:s")))
{
switch (c)
{
case 'p':
peerIds.push_back(optarg);
break;
case 'd':
debugLevel = atoi(optarg);
break;
case 's':
debugStderr = true;
break;
default:
usage(argv[0]);
break;
}
}
/* do logging */
setOutputLevel(debugLevel);
if (optind >= argc)
{
std::cerr << "Missing Files" << std::endl;
usage(argv[0]);
}
std::cerr << "Point 1" << std::endl;
for(; optind < argc; optind++)
{
std::cerr << "Adding: " << argv[optind] << std::endl;
fileList.push_back(std::string(argv[optind]));
}
std::cerr << "Point 2" << std::endl;
/* We need to setup a series 2 - 4 different ftServers....
*
* Each one needs:
*
*
* A List of peerIds...
*/
std::list<std::string>::const_iterator it, jit;
std::list<pqiAuthDetails> baseFriendList, friendList;
std::list<pqiAuthDetails>::iterator fit;
std::cerr << "Point 3" << std::endl;
P3Hub *testHub = new P3Hub(0, NULL);
testHub->start();
std::cerr << "Point 4" << std::endl;
/* Setup Base Friend Info */
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
pqiAuthDetails pad;
pad.id = *it;
pad.name = *it;
pad.trustLvl = 5;
pad.ownsign = true;
pad.trusted = false;
baseFriendList.push_back(pad);
std::cerr << "ftserver1test::setup peer: " << *it;
std::cerr << std::endl;
}
std::cerr << "Point 5" << std::endl;
std::ostringstream pname;
pname << "/tmp/rstst-" << time(NULL);
std::string basepath = pname.str();
RsDirUtil::checkCreateDirectory(basepath);
std::cerr << "Point 6" << std::endl;
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
friendList = baseFriendList;
/* remove current one */
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
if (fit->id == *it)
{
friendList.erase(fit);
break;
}
}
p3AuthMgr *authMgr = new p3DummyAuthMgr(*it, friendList);
p3ConnectMgr *connMgr = new p3ConnectMgr(authMgr);
mConnMgrs[*it] = connMgr;
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
/* add as peer to authMgr */
connMgr->addFriend(fit->id);
}
P3Pipe *pipe = new P3Pipe(); //(*it);
/* add server */
ftServer *server;
server = new ftServer(authMgr, connMgr);
mFtServers[*it] = server;
server->setP3Interface(pipe);
std::string configpath = basepath + "/" + *it;
RsDirUtil::checkCreateDirectory(configpath);
std::string cachepath = configpath + "/cache";
RsDirUtil::checkCreateDirectory(cachepath);
std::string partialspath = configpath + "/partials";
RsDirUtil::checkCreateDirectory(partialspath);
std::string downloadpath = configpath + "/downloads";
RsDirUtil::checkCreateDirectory(downloadpath);
std::string localpath = cachepath + "/local";
RsDirUtil::checkCreateDirectory(localpath);
std::string remotepath = cachepath + "/remote";
RsDirUtil::checkCreateDirectory(remotepath);
server->setConfigDirectory(configpath);
//sleep(60);
NotifyBase *base = NULL;
server->SetupFtServer(base);
testHub->addP3Pipe(*it, pipe, connMgr);
server->StartupThreads();
/* setup any extra bits */
server->setPartialsDirectory(partialspath);
server->setDownloadDirectory(downloadpath);
server->setSharedDirectories(fileList);
}
/* stick your real test here */
std::map<std::string, ftServer *>::iterator sit;
std::map<std::string, p3ConnectMgr *>::iterator cit;
while(1)
{
std::cerr << "ftserver1test::sleep()";
std::cerr << std::endl;
sleep(1);
/* tick the connmgrs */
for(sit = mFtServers.begin(); sit != mFtServers.end(); sit++)
{
/* update */
(sit->second)->tick();
}
for(cit = mConnMgrs.begin(); cit != mConnMgrs.end(); cit++)
{
/* update */
(cit->second)->tick();
}
}
}
#if 0
uint32_t do_random_server_iteration(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files)
{
std::cerr << "do_random_server_iteration()";
std::cerr << std::endl;
std::list<std::string>::iterator it;
uint32_t i = 0;
for(it = files.begin(); it != files.end(); it++)
{
FileInfo info;
if (eList->hashExtraFileDone(*it, info))
{
std::cerr << "Hash Done for: " << *it;
std::cerr << std::endl;
std::cerr << info << std::endl;
std::cerr << "Requesting Data Packet";
std::cerr << std::endl;
/* Server Recv */
uint64_t offset = 10000;
uint32_t chunk = 20000;
mplex->recvDataRequest("Peer", info.hash, info.size, offset, chunk);
i++;
}
else
{
std::cerr << "do_random_server_iteration() Hash Not Done for: " << *it;
std::cerr << std::endl;
}
}
return i;
}
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files)
{
std::cerr << "do_random_server_test()";
std::cerr << std::endl;
uint32_t size = files.size();
while(size > do_random_server_iteration(mplex, eList, files))
{
std::cerr << "do_random_server_test() sleep";
std::cerr << std::endl;
sleep(10);
}
}
#endif

View File

@ -1,424 +0,0 @@
/*
* libretroshare/src/ft: ftserver1test.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".
*
*/
/*
* ftServer2Test - Demonstrates how to check for test stuff.
* This tests hashing of files using extraList.
*/
#ifdef WIN32
#include "util/rswin.h"
#endif
#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 "util/rsdebug.h"
#include "ft/pqitestor.h"
#include "util/rsdir.h"
#include "util/utest.h"
#include <sstream>
class TestData
{
public:
ftServer *loadServer;
std::list<ftServer *> otherServers;
std::list<std::string> extraList;
};
extern "C" void *do_server_test_thread(void *p);
void usage(char *name)
{
std::cerr << "Usage: " << name << " [-sa] [-p <peerId>] [-d <debugLvl>] [-e <extrafile>] [<path> [<path2> ... ]] ";
std::cerr << std::endl;
}
int main(int argc, char **argv)
{
int c;
uint32_t period = 1;
uint32_t debugLevel = 5;
bool debugStderr = true;
bool loadAll = false;
std::list<std::string> fileList;
std::list<std::string> extraList;
std::list<std::string> peerIds;
std::map<std::string, ftServer *> mFtServers;
std::map<std::string, p3ConnectMgr *> mConnMgrs;
ftServer *mLoadServer = NULL;
std::list<ftServer *> mOtherServers;
std::list<std::string>::iterator eit;
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
#ifdef WIN32
// Windows Networking Init.
WORD wVerReq = MAKEWORD(2,2);
WSADATA wsaData;
if (0 != WSAStartup(wVerReq, &wsaData))
{
std::cerr << "Failed to Startup Windows Networking";
std::cerr << std::endl;
}
else
{
std::cerr << "Started Windows Networking";
std::cerr << std::endl;
}
#endif
while(-1 != (c = getopt(argc, argv, "asd:p:e:")))
{
switch (c)
{
case 'p':
peerIds.push_back(optarg);
break;
case 'd':
debugLevel = atoi(optarg);
break;
case 's':
debugStderr = true;
break;
case 'e':
extraList.push_back(optarg);
break;
case 'a':
loadAll = true;
break;
default:
usage(argv[0]);
break;
}
}
/* do logging */
setOutputLevel(debugLevel);
if (optind >= argc)
{
std::cerr << "Missing Shared Directories" << std::endl;
usage(argv[0]);
}
for(; optind < argc; optind++)
{
std::cerr << "Adding: " << argv[optind] << std::endl;
fileList.push_back(std::string(argv[optind]));
}
/* We need to setup a series 2 - 4 different ftServers....
*
* Each one needs:
*
*
* A List of peerIds...
*/
std::list<std::string>::const_iterator it, jit;
std::list<pqiAuthDetails> baseFriendList, friendList;
std::list<pqiAuthDetails>::iterator fit;
/* Add in serialiser */
RsSerialiser *rss = new RsSerialiser();
rss->addSerialType(new RsFileItemSerialiser());
rss->addSerialType(new RsCacheItemSerialiser());
rss->addSerialType(new RsServiceSerialiser());
P3Hub *testHub = new P3Hub(0, rss);
testHub->start();
/* Setup Base Friend Info */
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
pqiAuthDetails pad;
pad.id = *it;
pad.name = *it;
pad.trustLvl = 5;
pad.ownsign = true;
pad.trusted = false;
baseFriendList.push_back(pad);
std::cerr << "ftserver1test::setup peer: " << *it;
std::cerr << std::endl;
}
std::ostringstream pname;
pname << "/tmp/rstst-" << time(NULL);
std::string basepath = pname.str();
RsDirUtil::checkCreateDirectory(basepath);
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
friendList = baseFriendList;
/* remove current one */
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
if (fit->id == *it)
{
friendList.erase(fit);
break;
}
}
p3AuthMgr *authMgr = new p3DummyAuthMgr(*it, friendList);
p3ConnectMgr *connMgr = new p3ConnectMgr(authMgr);
mConnMgrs[*it] = connMgr;
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
/* add as peer to authMgr */
connMgr->addFriend(fit->id);
}
P3Pipe *pipe = new P3Pipe(); //(*it);
/* add server */
ftServer *server;
server = new ftServer(authMgr, connMgr);
mFtServers[*it] = server;
if (!mLoadServer)
{
mLoadServer = server;
}
else
{
mOtherServers.push_back(server);
}
server->setP3Interface(pipe);
std::string configpath = basepath + "/" + *it;
RsDirUtil::checkCreateDirectory(configpath);
std::string cachepath = configpath + "/cache";
RsDirUtil::checkCreateDirectory(cachepath);
std::string partialspath = configpath + "/partials";
RsDirUtil::checkCreateDirectory(partialspath);
std::string downloadpath = configpath + "/downloads";
RsDirUtil::checkCreateDirectory(downloadpath);
std::string localpath = cachepath + "/local";
RsDirUtil::checkCreateDirectory(localpath);
std::string remotepath = cachepath + "/remote";
RsDirUtil::checkCreateDirectory(remotepath);
server->setConfigDirectory(configpath);
NotifyBase *base = NULL;
server->SetupFtServer(base);
testHub->addP3Pipe(*it, pipe, connMgr);
server->StartupThreads();
/* setup any extra bits */
/* everyone gets download directories */
server->setPartialsDirectory(partialspath);
server->setDownloadDirectory(downloadpath);
if (loadAll)
{
server->setSharedDirectories(fileList);
for(eit = extraList.begin(); eit != extraList.end(); eit++)
{
server->ExtraFileHash(*eit, 3600, 0);
}
}
}
if (mLoadServer)
{
mLoadServer->setSharedDirectories(fileList);
for(eit = extraList.begin(); eit != extraList.end(); eit++)
{
mLoadServer->ExtraFileHash(*eit, 3600, 0);
}
}
/* stick your real test here */
std::map<std::string, ftServer *>::iterator sit;
std::map<std::string, p3ConnectMgr *>::iterator cit;
/* Start up test thread */
pthread_t tid;
TestData *mFt = new TestData;
/* set data */
mFt->loadServer = mLoadServer;
mFt->otherServers = mOtherServers;
mFt->extraList = extraList;
void *data = (void *) mFt;
pthread_create(&tid, 0, &do_server_test_thread, data);
pthread_detach(tid); /* so memory is reclaimed in linux */
while(1)
{
std::cerr << "ftserver2test::sleep()";
std::cerr << std::endl;
sleep(1);
/* tick the connmgrs */
for(sit = mFtServers.begin(); sit != mFtServers.end(); sit++)
{
/* update */
(sit->second)->tick();
}
for(cit = mConnMgrs.begin(); cit != mConnMgrs.end(); cit++)
{
/* update */
(cit->second)->tick();
}
}
}
/* So our actual test can run here.....
*
*/
INITTEST();
void *do_server_test_thread(void *data)
{
TestData *mFt = (TestData *) data;
std::cerr << "do_server_test_thread() running";
std::cerr << std::endl;
/************************* TEST 1 **********************
* Check that the extra List has been processed.
*/
time_t start = time(NULL);
FileInfo info, info2;
time_t now = time(NULL);
std::list<std::string>::iterator eit;
for(eit = mFt->extraList.begin(); eit != mFt->extraList.end(); eit++)
{
while(!mFt->loadServer->ExtraFileStatus(*eit, info))
{
/* max of 30 seconds */
now = time(NULL);
if (now - start > 30)
{
/* FAIL */
REPORT2( false, "Extra File Hashing");
}
sleep(1);
}
/* Got ExtraFileStatus */
REPORT("Successfully Found ExtraFile");
/* now we can try a search (should succeed) */
uint32_t hintflags = 0;
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
{
CHECK(info2.hash == info.hash);
CHECK(info2.size == info.size);
CHECK(info2.fname == info.fname);
}
else
{
REPORT2( false, "Search for Extra File (Basic)");
}
/* search with flags (should succeed) */
hintflags = RS_FILE_HINTS_EXTRA;
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
{
CHECK(info2.hash == info.hash);
CHECK(info2.size == info.size);
CHECK(info2.fname == info.fname);
}
else
{
REPORT2( false, "Search for Extra File (Extra Flag)");
}
/* search with other flags (should fail) */
hintflags = RS_FILE_HINTS_REMOTE | RS_FILE_HINTS_SPEC_ONLY;
if (mFt->loadServer->FileDetails(info.hash, hintflags, info2))
{
REPORT2( false, "Search for Extra File (Fail Flags)");
}
else
{
REPORT("Search for Extra File (Fail Flags)");
}
/* if we try to download it ... should just find existing one*/
REPORT("Testing with Extra File");
}
FINALREPORT("ExtraList Hashing, Searching and Downloading");
exit(1);
}

View File

@ -1,464 +0,0 @@
/*
* libretroshare/src/ft: ftserver3test.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".
*
*/
/*
* ftServer3Test - Test of the file transfer from a server level.
* Steps:
* 1) load shared directories into others, and let them be
transferred between clients.
* 2) search for local item on others.
* 3) request item on load server.
should transfer from all others simultaneously.
*/
#ifdef WIN32
#include "util/rswin.h"
#endif
#include "rsiface/rsexpr.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 "util/rsdebug.h"
#include "ft/pqitestor.h"
#include "util/rsdir.h"
#include "util/utest.h"
#include <sstream>
class TestData
{
public:
ftServer *loadServer;
std::list<ftServer *> otherServers;
std::list<std::string> extraList;
};
extern "C" void *do_server_test_thread(void *p);
void usage(char *name)
{
std::cerr << "Usage: " << name << " [-soa] [-p <peerId>] [-d <debugLvl>] [-e <extrafile>] [<path> [<path2> ... ]] ";
std::cerr << std::endl;
}
int main(int argc, char **argv)
{
int c;
uint32_t period = 1;
uint32_t debugLevel = 5;
bool debugStderr = true;
bool loadAll = false;
bool loadOthers = false;
std::list<std::string> fileList;
std::list<std::string> extraList;
std::list<std::string> peerIds;
std::map<std::string, ftServer *> mFtServers;
std::map<std::string, p3ConnectMgr *> mConnMgrs;
ftServer *mLoadServer = NULL;
std::list<ftServer *> mOtherServers;
std::list<std::string>::iterator eit;
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
#ifdef WIN32
// Windows Networking Init.
WORD wVerReq = MAKEWORD(2,2);
WSADATA wsaData;
if (0 != WSAStartup(wVerReq, &wsaData))
{
std::cerr << "Failed to Startup Windows Networking";
std::cerr << std::endl;
}
else
{
std::cerr << "Started Windows Networking";
std::cerr << std::endl;
}
#endif
while(-1 != (c = getopt(argc, argv, "aosd:p:e:")))
{
switch (c)
{
case 'p':
peerIds.push_back(optarg);
break;
case 'd':
debugLevel = atoi(optarg);
break;
case 's':
debugStderr = true;
break;
case 'e':
extraList.push_back(optarg);
break;
case 'a':
loadAll = true;
break;
case 'o':
loadOthers = true;
break;
default:
usage(argv[0]);
break;
}
}
/* do logging */
setOutputLevel(debugLevel);
if (optind >= argc)
{
std::cerr << "Missing Shared Directories" << std::endl;
usage(argv[0]);
}
for(; optind < argc; optind++)
{
std::cerr << "Adding: " << argv[optind] << std::endl;
fileList.push_back(std::string(argv[optind]));
}
/* We need to setup a series 2 - 4 different ftServers....
*
* Each one needs:
*
*
* A List of peerIds...
*/
std::list<std::string>::const_iterator it, jit;
std::list<pqiAuthDetails> baseFriendList, friendList;
std::list<pqiAuthDetails>::iterator fit;
/* Add in Serialiser Test
*/
RsSerialiser *rss = new RsSerialiser();
rss->addSerialType(new RsFileItemSerialiser());
rss->addSerialType(new RsCacheItemSerialiser());
rss->addSerialType(new RsServiceSerialiser());
P3Hub *testHub = new P3Hub(0, rss);
testHub->start();
/* Setup Base Friend Info */
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
pqiAuthDetails pad;
pad.id = *it;
pad.name = *it;
pad.trustLvl = 5;
pad.ownsign = true;
pad.trusted = false;
baseFriendList.push_back(pad);
std::cerr << "ftserver1test::setup peer: " << *it;
std::cerr << std::endl;
}
std::ostringstream pname;
pname << "/tmp/rstst-" << time(NULL);
std::string basepath = pname.str();
RsDirUtil::checkCreateDirectory(basepath);
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
friendList = baseFriendList;
/* remove current one */
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
if (fit->id == *it)
{
friendList.erase(fit);
break;
}
}
p3AuthMgr *authMgr = new p3DummyAuthMgr(*it, friendList);
p3ConnectMgr *connMgr = new p3ConnectMgr(authMgr);
mConnMgrs[*it] = connMgr;
for(fit = friendList.begin(); fit != friendList.end(); fit++)
{
/* add as peer to authMgr */
connMgr->addFriend(fit->id);
}
P3Pipe *pipe = new P3Pipe(); //(*it);
/* add server */
ftServer *server;
server = new ftServer(authMgr, connMgr);
mFtServers[*it] = server;
bool isOther;
if (!mLoadServer)
{
mLoadServer = server;
isOther = false;
}
else
{
mOtherServers.push_back(server);
isOther = true;
}
server->setP3Interface(pipe);
std::string configpath = basepath + "/" + *it;
RsDirUtil::checkCreateDirectory(configpath);
std::string cachepath = configpath + "/cache";
RsDirUtil::checkCreateDirectory(cachepath);
std::string partialspath = configpath + "/partials";
RsDirUtil::checkCreateDirectory(partialspath);
std::string downloadpath = configpath + "/downloads";
RsDirUtil::checkCreateDirectory(downloadpath);
std::string localpath = cachepath + "/local";
RsDirUtil::checkCreateDirectory(localpath);
std::string remotepath = cachepath + "/remote";
RsDirUtil::checkCreateDirectory(remotepath);
server->setConfigDirectory(configpath);
NotifyBase *base = NULL;
server->SetupFtServer(base);
testHub->addP3Pipe(*it, pipe, connMgr);
server->StartupThreads();
/* setup any extra bits */
server->setPartialsDirectory(partialspath);
server->setDownloadDirectory(downloadpath);
if ((loadAll) || (isOther && loadOthers))
{
server->setSharedDirectories(fileList);
for(eit = extraList.begin(); eit != extraList.end(); eit++)
{
server->ExtraFileHash(*eit, 3600, 0);
}
}
}
if ((mLoadServer) && (!loadOthers))
{
mLoadServer->setSharedDirectories(fileList);
for(eit = extraList.begin(); eit != extraList.end(); eit++)
{
mLoadServer->ExtraFileHash(*eit, 3600, 0);
}
}
/* stick your real test here */
std::map<std::string, ftServer *>::iterator sit;
std::map<std::string, p3ConnectMgr *>::iterator cit;
/* Start up test thread */
pthread_t tid;
TestData *mFt = new TestData;
/* set data */
mFt->loadServer = mLoadServer;
mFt->otherServers = mOtherServers;
mFt->extraList = extraList;
void *data = (void *) mFt;
pthread_create(&tid, 0, &do_server_test_thread, data);
pthread_detach(tid); /* so memory is reclaimed in linux */
while(1)
{
//std::cerr << "ftserver3test::sleep()";
//std::cerr << std::endl;
sleep(1);
/* tick the connmgrs */
for(sit = mFtServers.begin(); sit != mFtServers.end(); sit++)
{
/* update */
(sit->second)->tick();
}
for(cit = mConnMgrs.begin(); cit != mConnMgrs.end(); cit++)
{
/* update */
(cit->second)->tick();
}
}
}
/* So our actual test can run here.....
*
*/
INITTEST();
void *do_server_test_thread(void *data)
{
TestData *mFt = (TestData *) data;
time_t startTS = time(NULL);
std::cerr << "do_server_test_thread() running";
std::cerr << std::endl;
/* search Others for a suitable file
* (Tests GUI search functionality)
*/
if (mFt->otherServers.size() < 1)
{
std::cerr << "no Other Servers to search on";
std::cerr << std::endl;
exit(1);
return NULL;
}
for(int i = 0; i < 90; i++)
{
int age = time(NULL) - startTS;
std::cerr << "Waited " << age << " seconds to share caches";
std::cerr << std::endl;
sleep(1);
}
ftServer *oServer = *(mFt->otherServers.begin());
std::string oId = oServer->OwnId();
/* create Expression */
uint64_t minFileSize = 100000;
//SizeExpression se(Greater, minFileSize);
SizeExpression se(Smaller, minFileSize);
Expression *expr = &se;
std::list<FileDetail> results;
std::list<FileDetail>::iterator it;
oServer->SearchBoolExp(expr, results);
if (results.size() < 1)
{
std::cerr << "no Shared Files > " << minFileSize;
std::cerr << std::endl;
exit(1);
return NULL;
}
/* find the first remote entry */
FileDetail sFile;
bool foundFile = false;
for(it = results.begin();
(it != results.end()); it++)
{
std::cerr << "Shared File: " << it->name;
std::cerr << std::endl;
if (!foundFile)
{
if (it->id != mFt->loadServer->OwnId())
{
std::cerr << "Selected: " << it->name;
std::cerr << std::endl;
foundFile = true;
sFile = *it;
}
else
{
std::cerr << "LoadId: ";
std::cerr << mFt->loadServer->OwnId();
std::cerr << "FileId: ";
std::cerr << it->id;
std::cerr << std::endl;
}
}
}
if (!foundFile)
{
std::cerr << "Not Found Suitable File";
std::cerr << std::endl;
}
/*** Now Download it! ***/
std::list<std::string> srcIds;
//srcIds.push_back(sFile.id);
// Don't add srcId - to test whether the search works - or not
//srcIds.push_back(oId);
if (foundFile)
{
mFt->loadServer->FileRequest(sFile.name, sFile.hash,
sFile.size, "", 0, srcIds);
}
/* Give it a while to transfer */
for(int i = 0; i < 100; i++)
{
int age = time(NULL) - startTS;
std::cerr << "Waited " << age << " seconds for tranfer";
std::cerr << std::endl;
sleep(1);
}
FINALREPORT("Shared Directories, Bool Search, multi-source transfers");
exit(1);
}

View File

@ -1,180 +0,0 @@
/*
* libretroshare/src/ft: fttransfermoduletest.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".
*
*/
/*
* Test for Multiplexor.....
* As this is a key middle component, it is hard to test without other bits.
* It relies on ftFileProvider/ftFileCreator/ftTransferModule...
*
* And has dummy ftDataSend and ftSearch.
*
*/
#ifdef WIN32
#include "util/rswin.h"
#endif
#include "ft/ftextralist.h"
#include "ft/ftdatamultiplex.h"
#include "ft/ftfilesearch.h"
#include "ftfileprovider.h"
#include "ftfilecreator.h"
#include "ftcontroller.h"
#include "fttransfermodule.h"
#include "util/utest.h"
INITTEST()
void do_random_server_test(ftDataMultiplex *mplex, ftExtraList *eList, std::list<std::string> &files);
void usage(char *name)
{
std::cerr << "Usage: " << name << " [-p <period>] [-d <dperiod>] <path> [<path2> ... ] ";
std::cerr << std::endl;
}
int main(int argc, char **argv)
{
int c;
uint32_t period = 1;
uint32_t dPeriod = 600; /* default 10 minutes */
std::list<std::string> fileList;
while(-1 != (c = getopt(argc, argv, "d:p:")))
{
switch (c)
{
case 'p':
period = atoi(optarg);
break;
case 'd':
dPeriod = atoi(optarg);
break;
default:
usage(argv[0]);
break;
}
}
if (optind >= argc)
{
std::cerr << "Missing Files" << std::endl;
usage(argv[0]);
}
for(; optind < argc; optind++)
{
std::cerr << "Adding: " << argv[optind] << std::endl;
fileList.push_back(std::string(argv[optind]));
}
ftExtraList *eList = new ftExtraList();
eList->start();
ftSearch *ftsd = new ftSearchDummy();
ftFileSearch *ftfs = new ftFileSearch();
ftfs-> addSearchMode(ftsd, RS_FILE_HINTS_LOCAL);
ftfs-> addSearchMode(eList, RS_FILE_HINTS_EXTRA);
ftDataSendPair *ftds1 = new ftDataSendPair(NULL);
ftDataSendPair *ftds2 = new ftDataSendPair(NULL);
/* setup Actual Test bit */
ftDataMultiplex *ftmplex1 = new ftDataMultiplex("ownId", ftds2, ftfs);
ftDataMultiplex *ftmplex2 = new ftDataMultiplex("ownId", ftds1, ftfs);
ftds1->mDataRecv = ftmplex1;
ftds2->mDataRecv = ftmplex2;
ftmplex1->start();
ftmplex2->start();
/* Setup Search with some valid results */
/* Request Data */
/* now work the thread */
std::list<std::string>::iterator it;
uint32_t flags = 0;
for(it = fileList.begin(); it != fileList.end(); it++)
{
eList->hashExtraFile(*it, dPeriod, flags);
}
if (fileList.size() < 1)
{
std::cerr << "come on, give us some files...";
std::cerr << std::endl;
return 0;
}
/* now request files from ftDataMultiplex
* by adding in a ftTransferModule!
*/
std::string filename = *(fileList.begin());
/* wait for file to hash */
FileInfo info;
while(!eList->hashExtraFileDone(filename, info))
{
std::cerr << "Waiting for file to hash";
std::cerr << std::endl;
sleep(1);
}
std::string savename = "/tmp/" + info.fname;
ftFileCreator *creator = new ftFileCreator(savename, info.size, info.hash, 0);
ftController *controller = NULL;
ftTransferModule *transfer = new ftTransferModule(creator, ftmplex1, controller);
ftmplex1->addTransferModule(transfer, creator);
std::list<std::string> peerIds;
peerIds.push_back("ownId2");
transfer->setFileSources(peerIds);
transfer->setPeerState("ownId2", PQIPEER_IDLE, 1000);
//transfer->resumeTransfer();
/* check file progress */
while(1)
{
std::cerr << "File Transfer Status";
std::cerr << std::endl;
std::cerr << "Transfered: " << creator->getRecvd();
std::cerr << std::endl;
transfer->tick();
sleep(1);
}
}

View File

@ -1,75 +0,0 @@
RS_TOP_DIR = ..
##### Define any flags that are needed for this section #######
###############################################################
###############################################################
include $(RS_TOP_DIR)/scripts/config.mk
###############################################################
RSOBJ = rsserial.o rsbaseserial.o rstlvbase.o rstlvtypes.o
RSOBJ += rstlvfileitem.o # TLV Objs
RSOBJ += rstlvkeys.o # TLV Objs
RSOBJ += rstlvimage.o # TLV Objs
RSOBJ += rstlvutil.o # TLV Objs
RSOBJ += rstlvkvwide.o # TLV Objs
RSOBJ += rsbaseitems.o rsconfigitems.o rsdiscitems.o # RsItems
RSOBJ += rsmsgitems.o rsrankitems.o # RsItems
RSOBJ += rsphotoitems.o # RsItems
RSOBJ += rsgameitems.o # RsItems
RSOBJ += rsdistribitems.o # RsItems
RSOBJ += rsforumitems.o # RsItems
RSOBJ += rschannelitems.o # RsItems
RSOBJ += rsqblogitems.o # RsItems
RSOBJ += rsstatusitems.o # RsItems
TESTOBJ = tlvbase_test.o tlvbase_test2.o tlvfileitem_test.o
TESTOBJ += tlvitems_test.o tlvstack_test.o tlvconfig_test.o
TESTOBJ += rsserial_test.o rstlvwidetest.o tlvrandom_test.o
#rsbaseitem_test.o
TESTS = tlvbase_test tlvbase_test2 tlvfileitem_test
TESTS += tlvitems_test tlvstack_test tlvconfig_test
TESTS += rstlvwidetest tlvrandom_test
#rsserial_test
#rsbaseitem_test
all: librs tests
tlvbase_test : tlvbase_test.o
$(CC) $(CFLAGS) -o tlvbase_test tlvbase_test.o $(OBJ) $(LIBS)
tlvbase_test2 : tlvbase_test2.o
$(CC) $(CFLAGS) -o tlvbase_test2 tlvbase_test2.o $(OBJ) $(LIBS)
tlvfileitem_test : tlvfileitem_test.o
$(CC) $(CFLAGS) -o tlvfileitem_test tlvfileitem_test.o $(OBJ) $(LIBS)
tlvitems_test : tlvitems_test.o
$(CC) $(CFLAGS) -o tlvitems_test tlvitems_test.o $(OBJ) $(LIBS)
tlvstack_test : tlvstack_test.o
$(CC) $(CFLAGS) -o tlvstack_test tlvstack_test.o $(OBJ) $(LIBS)
tlvconfig_test : tlvconfig_test.o
$(CC) $(CFLAGS) -o tlvconfig_test tlvconfig_test.o $(OBJ) $(LIBS)
rsserial_test : rsserial_test.o
$(CC) $(CFLAGS) -o rsserial_test rsserial_test.o $(OBJ) $(LIBS)
rsbaseitem_test : rsbaseitem_test.o
$(CC) $(CFLAGS) -o rsbaseitem_test rsbaseitem_test.o $(OBJ) $(LIBS)
rstlvwidetest : rstlvwidetest.o
$(CC) $(CFLAGS) -o rstlvwidetest rstlvwidetest.o $(OBJ) $(LIBS)
tlvrandom_test : tlvrandom_test.o
$(CC) $(CFLAGS) -o tlvrandom_test tlvrandom_test.o $(OBJ) $(LIBS)
###############################################################
include $(RS_TOP_DIR)/scripts/rules.mk
###############################################################

View File

@ -1,191 +0,0 @@
/*
* libretroshare/src/serialiser: rsbaseitem_test.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-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".
*
*/
/******************************************************************
* tlvfileitem test.
*
*
*/
#include <iostream>
#include <sstream>
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
INITTEST();
static int test_RsFileItem();
static int test_RsFileData();
int main()
{
std::cerr << "RsFile[Item/Data/...] Tests" << std::endl;
test_RsFileItem();
test_RsFileData();
FINALREPORT("RsTlvFile[Item/Data/...] Tests");
return TESTRESULT();
}
int test_RsTlvFileItem()
{
RsTlvFileItem i1;
RsTlvFileItem i2;
/* initialise */
i1.filesize = 101010;
i1.hash = "ABCDEFEGHE";
i1.name = "TestFile.txt";
i1.pop = 12;
i1.age = 456;
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/* check the data is the same */
CHECK(i1.filesize == i2.filesize);
CHECK(i1.hash == i2.hash);
CHECK(i1.name == i2.name);
CHECK(i1.path == i2.path);
CHECK(i1.pop == i2.pop);
CHECK(i1.age == i2.age);
/* do it again without optional data */
i1.filesize = 123;
i1.name = "";
i1.pop = 0;
i1.age = 0;
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/* check the data is the same */
CHECK(i1.filesize == i2.filesize);
CHECK(i1.hash == i2.hash);
CHECK(i1.name == i2.name);
CHECK(i1.path == i2.path);
CHECK(i1.pop == i2.pop);
CHECK(i1.age == i2.age);
/* one more time - long file name, some optional data */
i1.filesize = 123;
i1.name = "A Very Long File name that should fit in easily ??? with som $&%&^%* strange char (**$^%#&^$#*^%(&^ in there too!!!! ~~~!!$#(^$)$)(&%^)&\" oiyu thend";
i1.pop = 666;
i1.age = 0;
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/* check the data is the same */
CHECK(i1.filesize == i2.filesize);
CHECK(i1.hash == i2.hash);
CHECK(i1.name == i2.name);
CHECK(i1.path == i2.path);
CHECK(i1.pop == i2.pop);
CHECK(i1.age == i2.age);
REPORT("Serialise/Deserialise RsTlvFileItem");
return 1;
}
int test_RsTlvFileSet()
{
RsTlvFileSet s1;
RsTlvFileSet s2;
int i = 0;
for(i = 0; i < 15; i++)
{
RsTlvFileItem fi;
fi.filesize = 16 + i * i;
fi.hash = "ABCDEF";
std::ostringstream out;
out << "File" << i << "_inSet.txt";
fi.name = out.str();
if (i % 2 == 0)
{
fi.age = 10 * i;
}
else
{
fi.age = 0;
}
fi.pop = 0;
s1.items.push_back(fi);
}
CHECK(test_SerialiseTlvItem(std::cerr, &s1, &s2));
/* check the data is the same - TODO */
REPORT("Serialise/Deserialise RsTlvFileSet");
return 1;
}
int test_RsTlvFileData()
{
RsTlvFileData d1;
RsTlvFileData d2;
/* initialise */
d1.file.filesize = 101010;
d1.file.hash = "ABCDEFEGHE";
d1.file.name = "";
d1.file.age = 0;
d1.file.pop = 0;
char data[15];
d1.binData.setBinData(data, 15);
d1.file_offset = 222;
CHECK(test_SerialiseTlvItem(std::cerr, &d1, &d2));
/* check the data is the same */
CHECK(d1.file.filesize == d2.file.filesize);
CHECK(d1.file.hash == d2.file.hash);
CHECK(d1.file.name == d2.file.name);
CHECK(d1.file.path == d2.file.path);
CHECK(d1.file.pop == d2.file.pop);
CHECK(d1.file.age == d2.file.age);
CHECK(d1.file_offset == d2.file_offset);
CHECK(d1.binData.bin_len == d2.binData.bin_len);
REPORT("Serialise/Deserialise RsTlvFileData");
return 1;
}

View File

@ -1,88 +0,0 @@
/*
* libretroshare/src/serialiser: rstlvkvwidetest.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Chris Parker
*
* 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 <stdlib.h>
#include <iostream>
#include <sstream>
#include "serialiser/rstlvkvwide.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
INITTEST();
/* define utility functions to test out with */
//static int testRstlvWide();
static int testRsTlvWideSet();
int main()
{
std::cerr << "RsTlvWideTest[Item/Data/...] Tests" << std::endl;
testRsTlvWideSet();
FINALREPORT("RsTlvWideTest[Item/Data/...] Tests");
return TESTRESULT();
}
int testRsTlvWideSet()
{
RsTlvKeyValueWideSet i1, i2; // one to set and other to get
RsTlvKeyValueWide i_pair; // input pair
RsTlvFileItem hello;
std::string randString("it should work now.");
int j, k;
std::cerr << "entering loop now" << std::endl;
/* store a 15 random pairs */
for(int i = 0; i < 15 ; i++)
{
j = rand() % 4;
k = rand() % 4;
std::cerr << "j: " << j << " k: " << k << std::endl;
i_pair.wKey.assign(randString.begin(), randString.end());
std::cerr << "loop count:" << i << std::endl;
i_pair.wValue.assign(randString.begin(), randString.end());
std::cerr << "loop count:" << i << std::endl;
i1.wPairs.push_back(i_pair);
i_pair.TlvClear();
}
std::cerr << "out of loop now" << std::endl;
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/*check that the data is the same*/
REPORT("Serialize/Deserialize RsTlvKeyValueWideSet");
return 1;
}

View File

@ -1,185 +0,0 @@
/*
* libretroshare/src/serialiser: tlvbase_test.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Horatio.
*
* 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 <string.h>
#include <string>
#include <iostream>
#include "serialiser/rstlvbase.h"
#include "util/utest.h"
#include "util/rsnet.h"
INITTEST();
static int test_RsTlvBase();
int main()
{
std::cerr << " RsTlvBase Tests" <<std::endl;
test_RsTlvBase();
FINALREPORT("RsTlvBase Tests");
return TESTRESULT();
}
int test_RsTlvBase()
{
//uint32_t array[] = {0x122, 0x234};
char data[20];
memset((void*)data, 65, sizeof(data)); // In ASCII 'A' =65
std::string out;
data[0]=0;
data[1]=0;
data[2]=0;
data[3]=8;
uint32_t off =0;
GetTlvString((void*)data, 20, &off, 0, out);
CHECK(out == "AAAA");
std::cout << "Output is : " << out << std::endl;
uint16_t data2[] = {0, 0x0300};
uint16_t t = GetTlvSize((void*) data2);
CHECK( t == ntohs(0x0300));
//std::cout << "GetTlvSize = " <<t <<std::endl;
std::string line;
//*************Test SetTlvBase***********
{
uint16_t data3 [2];
off =0;
uint32_t *offset = &off;
uint32_t const SIZE_SetTlvBase=4;
uint32_t val_before = *offset;
SetTlvBase((void *)data3, SIZE_SetTlvBase, offset, 0x0011, 0x0001);
CHECK(*offset - val_before == SIZE_SetTlvBase);
CHECK(0x0011 == ntohs(data3[0]));
CHECK(0x0001 == ntohs(data3[1]));
}
REPORT("Test SetTlvBase");
/**
* test GetTlvUInt32 & SetTlvGetUInt32
*/
{
uint16_t data4[4];
bool ok = true;
uint32_t off =0;
uint32_t pre_set_off = off;
uint32_t* offset = &off;
uint32_t out = 3324;
*offset =0;
ok = SetTlvUInt32((void*)data4, 8, offset, 0x0011, out);
CHECK(*offset - pre_set_off == 8);
uint32_t readPos = 0;
offset = &readPos;
uint32_t in =0;
ok &= GetTlvUInt32((void*)data4, 8, offset, 0x0011, &in);
CHECK(*offset - pre_set_off == 8);
CHECK(in == out);
std::cerr<<"in = " <<in <<std::endl;
std::cout << "*offset = " <<*offset <<std::endl;
std::cout <<std::hex << data4[2]<< " " <<data4[3] <<std::endl;
}
{
uint16_t data4[4];
data4[0] = 0x0500; /* type (little-endian?) */
data4[1] = 0x0800; /* size (little-endian?) */
data4[3]=0x0000;
data4[2] = 0xFFFF;
uint32_t got;
uint32_t off =0;
uint32_t*offset = &off;
GetTlvUInt32((void*)data4, 8, offset, 5, &got);
CHECK(got ==0xFFFF0000);
std::cout << " got = " << std::hex << got <<std::endl;
}
REPORT("Test TlvUInt32");
/**
* Test GetTlvString()
*/
{
std::string teststring = "Hello RS!";
uint16_t data5[4 + 20];
uint32_t pos =0;
uint32_t* offset = &pos;
uint32_t pre_pos = pos;
SetTlvString((void*)data5, sizeof(data5), offset, TLV_TYPE_STR_NAME, teststring);
uint16_t tlvsize = GetTlvStringSize(teststring);
CHECK(tlvsize == *offset);
CHECK(data5[0] == htons(TLV_TYPE_STR_NAME));
CHECK(data5[1] == htons(tlvsize));
std::string str((char*) ((char*)data5 +4) ,strlen("Hello RS!"));
CHECK(str == "Hello RS!");
// std::cout <<str <<std::endl;
std::string out_str;
pos =0;
GetTlvString((void*)data5, sizeof(data5), offset, TLV_TYPE_STR_NAME, out_str);
CHECK(out_str == "Hello RS!");
CHECK(*offset == sizeof(uint16_t)*2 + out_str.size());
uint16_t data6[2];
*offset =0;
SetTlvSize((void*)data6, sizeof(data6), 0x00000022);
std::cout << std::hex << data6[1] <<std::endl;
}
REPORT("Test TlvString");
return 0;
}

View File

@ -1,191 +0,0 @@
/*
* libretroshare/src/serialiser: tlvbase_test2.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-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".
*
*/
/******************************************************************
* tlvfileitem test.
*
*
*/
#include <iostream>
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvbase.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
#include "util/rsnet.h"
INITTEST();
static int test_RsTlvString();
static int test_RsTlvUInt32();
static int test_RsTlvIPAddr();
int main()
{
std::cerr << "RsTlvBase Tests" << std::endl;
test_RsTlvString();
test_RsTlvUInt32();
test_RsTlvIPAddr();
FINALREPORT("RsTlvBase Tests");
return TESTRESULT();
}
int test_RsTlvUInt32()
{
return 1;
}
int test_OneString(std::string input, uint16_t type);
int test_RsTlvString()
{
std::string nullString;
std::string oneString = "1";
std::string shortString = "ab cd";
std::string longString = "abcd efgh ijkl mnop qrst uvw";
std::cerr << "test_RsTlvString() Testing" << std::endl;
test_OneString(nullString, 1234);
test_OneString(oneString, 12);
test_OneString(shortString, 79);
test_OneString(longString, 7654);
REPORT("Serialise RsTlvFileItem");
return 1;
}
int test_OneString(std::string input, uint16_t type)
{
/* an array to work from */
char tlvdata[2048];
std::string OutString;
std::cerr << "test_OneString() Testing ... Print/Serialise/Deserialise";
std::cerr << std::endl;
/* start with SetTlvString() */
uint16_t initsize = GetTlvStringSize(input);
uint32_t outOffset = 0;
uint32_t inOffset = 0;
std::cerr << "Serialising: " << input << std::endl;
CHECK(SetTlvString((void*)tlvdata, 2048, &outOffset, type, input));
std::cerr << "Init Size: " << initsize << std::endl;
std::cerr << "Serialised Size: " << outOffset << std::endl;
displayRawPacket(std::cerr, tlvdata, outOffset);
CHECK(outOffset == initsize); /* check that the offset matches the size */
std::cerr << "DeSerialising" << std::endl;
/* fails if type is wrong! */
CHECK(0 == GetTlvString((void*)tlvdata, outOffset, &inOffset, type-1, OutString));
CHECK(GetTlvString((void*)tlvdata, outOffset, &inOffset, type, OutString));
CHECK(initsize == inOffset); /* check that the offset matches the size */
CHECK(input == OutString); /* check that strings match */
std::cerr << "Deserialised: Size: " << inOffset << std::endl;
std::cerr << "Deserialised: String: " << OutString << std::endl;
REPORT("Serialise OneString");
return 1;
}
int test_IpAddr(struct sockaddr_in *addr, uint16_t type);
static int test_RsTlvIPAddr()
{
struct sockaddr_in addr;
inet_aton("10.0.0.111", &(addr.sin_addr));
addr.sin_port = htons(1111);
test_IpAddr(&addr, 1234);
inet_aton("255.255.255.1", &(addr.sin_addr));
addr.sin_port = htons(9999);
test_IpAddr(&addr, 1234);
inet_aton("128.255.255.1", &(addr.sin_addr));
addr.sin_port = htons(0);
test_IpAddr(&addr, 1234);
return 1;
}
int test_IpAddr(struct sockaddr_in *addr, uint16_t type)
{
/* an array to work from */
char tlvdata[2048];
struct sockaddr_in outaddr;
std::cerr << "test_IpAddr() Testing ... Print/Serialise/Deserialise";
std::cerr << std::endl;
/* start with SetTlvString() */
uint16_t initsize = GetTlvIpAddrPortV4Size();
uint32_t outOffset = 0;
uint32_t inOffset = 0;
std::cerr << "Serialising IPAddr: " << inet_ntoa(addr->sin_addr) << std::endl;
std::cerr << " Port : " << ntohs(addr->sin_port) << std::endl;
CHECK(SetTlvIpAddrPortV4((void*)tlvdata, 2048, &outOffset, type, addr));
std::cerr << "Init Size: " << initsize << std::endl;
std::cerr << "Serialised Size: " << outOffset << std::endl;
displayRawPacket(std::cerr, tlvdata, outOffset);
CHECK(outOffset == initsize); /* check that the offset matches the size */
std::cerr << "DeSerialising" << std::endl;
/* fails if type is wrong! */
CHECK(0 == GetTlvIpAddrPortV4((void*)tlvdata, outOffset, &inOffset, type-1, &outaddr));
CHECK(GetTlvIpAddrPortV4((void*)tlvdata, outOffset, &inOffset, type, &outaddr));
CHECK(initsize == inOffset); /* check that the offset matches the size */
CHECK(addr->sin_addr.s_addr == outaddr.sin_addr.s_addr); /* check that IP match */
CHECK(addr->sin_port == outaddr.sin_port); /* check that Port match */
std::cerr << "Deserialised: Size: " << inOffset << std::endl;
std::cerr << "Deserialised IPAddr: " << inet_ntoa(outaddr.sin_addr) << std::endl;
std::cerr << " Port : " << ntohs(outaddr.sin_port) << std::endl;
REPORT("Serialise OneIP/Port");
return 1;
}

View File

@ -1,192 +0,0 @@
/*
* libretroshare/src/serialiser: tlvconfig_test.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Chris Parker.
*
* 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".
*
*/
/******************************************************************
* tlvfileitem test.
*
*
*/
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvkvwide.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
INITTEST();
static int testRsTlvPeerIdSet();
static int testRsTlvServiceIdSet();
static int testRsTlvKeyValue();
static int testRsTlvKeyValueSet();
static int testRsTlvWideSet();
int main()
{
std::cerr << "RsTlvConfig[Item/Data/...] Tests" << std::endl;
testRsTlvPeerIdSet();
testRsTlvServiceIdSet();//tbd
testRsTlvKeyValue();//tbd
testRsTlvKeyValueSet();//tbd
testRsTlvWideSet();
FINALREPORT("RsTlvConfig[Item/Data/...] Tests");
return TESTRESULT();
}
int testRsTlvPeerIdSet()
{
RsTlvPeerIdSet i1, i2; // one to set and other to get
std::string testString;
std::string randString[5];
randString[0] = "e$424!<21>!<21>";
randString[1] = "e~:@L{L{KHKG";
randString[2] = "e{@O**/*/*";
randString[3] = "e?<<BNMB>HG<48>!<21>%$";
randString[4] = "e><?<NVBCEE<45>$$%*^";
/* store a number of random ids */
for(int i = 0; i < 15 ; i++)
{
testString = randString[(rand() % 4)] + randString[(rand() % 4)];
i1.ids.push_back(testString);
}
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/*check that the data is the same*/
REPORT("Serialize/Deserialize RsTlvPeerIdSet");
return 1;
}
int testRsTlvServiceIdSet()
{
RsTlvServiceIdSet i1, i2; // one to set and other to get
/* store random numbers */
for(int i = 0; i < 15 ; i++)
{
i1.ids.push_back(1 + rand() % 12564);
}
std::cout << "error here!!!?";
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/*check that the data is the same*/
REPORT("Serialize/Deserialize RsTlvServiceIdSet");
return 1;
}
int testRsTlvKeyValue()
{
RsTlvKeyValue i1, i2; // one to set and other to get
i1.key = "whatever";
i1.value = "better work";
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/*check that the data is the same*/
REPORT("Serialize/Deserialize RsTlvKeyValue");
return 1;
}
int testRsTlvKeyValueSet()
{
RsTlvKeyValueSet i1, i2; // one to set and other to get
/* instantiate the objects values */
std::string randString[5];
randString[0] = "e$424!<21>!<21>";
randString[1] = "e~:@L{L{KHKG";
randString[2] = "e{@O**/*/*";
randString[3] = "e?<<BNMB>HG<48>!<21>%$";
randString[4] = "e><?<NVBCEE<45>$$%*^";
for(int i = 0; i < 15; i++)
{
RsTlvKeyValue kv;
kv.key = randString[(rand() % 4)] + randString[(rand() % 4)];
kv.value = randString[(rand() % 4)] + randString[(rand() % 4)];
i1.pairs.push_back(kv);
}
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/*check that the data is the same*/
REPORT("Serialize/Deserialize RsTlvKeyValueSet");
}
int testRsTlvWideSet()
{
RsTlvKeyValueWideSet i1, i2; // one to set and other to get
RsTlvKeyValueWide i_pair; // input pair
RsTlvFileItem hello;
std::string randString[5];
randString[0] = "e$424!<21>!<21>";
randString[1] = "e~:@L{L{KHKG";
randString[2] = "e{@O**/*/*";
randString[3] = "e?<<BNMB>HG<48>!<21>%$";
randString[4] = "e><?<NVBCEE<45>$$%*^";
/* store a 15 random pairs */
for(int i = 0; i < 15 ; i++)
{
i_pair.wKey.assign(randString[(rand() % 4)].begin(), randString[(rand() % 4)].end());
i_pair.wValue.assign(randString[(rand() % 4)].begin(), randString[(rand() % 4)].end());
i1.wPairs.push_back(i_pair);
}
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/*check that the data is the same*/
REPORT("Serialize/Deserialize RsTlvKeyValueWideSet");
return 1;
}

View File

@ -1,190 +0,0 @@
/*
* libretroshare/src/serialiser: tlvfileitem_test.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-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".
*
*/
/******************************************************************
* tlvfileitem test.
*
*
*/
#include <iostream>
#include <sstream>
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
INITTEST();
static int test_RsTlvFileItem();
static int test_RsTlvFileSet();
static int test_RsTlvFileData();
static int test_RsTlvFileStack();
int main()
{
std::cerr << "RsTlvFile[Item/Data/...] Tests" << std::endl;
test_RsTlvFileItem();
test_RsTlvFileData();
test_RsTlvFileSet();
FINALREPORT("RsTlvFile[Item/Data/...] Tests");
return TESTRESULT();
}
int test_RsTlvFileItem()
{
RsTlvFileItem i1;
RsTlvFileItem i2;
/* initialise */
i1.filesize = 101010;
i1.hash = "ABCDEFEGHE";
i1.name = "TestFile.txt";
i1.pop = 12;
i1.age = 456;
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/* check the data is the same */
CHECK(i1.filesize == i2.filesize);
CHECK(i1.hash == i2.hash);
CHECK(i1.name == i2.name);
CHECK(i1.path == i2.path);
CHECK(i1.pop == i2.pop);
CHECK(i1.age == i2.age);
/* do it again without optional data */
i1.filesize = 123;
i1.name = "";
i1.pop = 0;
i1.age = 0;
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/* check the data is the same */
CHECK(i1.filesize == i2.filesize);
CHECK(i1.hash == i2.hash);
CHECK(i1.name == i2.name);
CHECK(i1.path == i2.path);
CHECK(i1.pop == i2.pop);
CHECK(i1.age == i2.age);
/* one more time - long file name, some optional data */
i1.filesize = 123;
i1.name = "A Very Long File name that should fit in easily ??? with som $&%&^%* strange char (**$^%#&^$#*^%(&^ in there too!!!! ~~~!!$#(^$)$)(&%^)&\" oiyu thend";
i1.pop = 666;
i1.age = 0;
CHECK(test_SerialiseTlvItem(std::cerr, &i1, &i2));
/* check the data is the same */
CHECK(i1.filesize == i2.filesize);
CHECK(i1.hash == i2.hash);
CHECK(i1.name == i2.name);
CHECK(i1.path == i2.path);
CHECK(i1.pop == i2.pop);
CHECK(i1.age == i2.age);
REPORT("Serialise/Deserialise RsTlvFileItem");
return 1;
}
int test_RsTlvFileSet()
{
RsTlvFileSet s1;
RsTlvFileSet s2;
int i = 0;
for(i = 0; i < 15; i++)
{
RsTlvFileItem fi;
fi.filesize = 16 + i * i;
fi.hash = "ABCDEF";
std::ostringstream out;
out << "File" << i << "_inSet.txt";
fi.name = out.str();
if (i % 2 == 0)
{
fi.age = 10 * i;
}
else
{
fi.age = 0;
}
fi.pop = 0;
s1.items.push_back(fi);
}
CHECK(test_SerialiseTlvItem(std::cerr, &s1, &s2));
/* check the data is the same - TODO */
REPORT("Serialise/Deserialise RsTlvFileSet");
return 1;
}
int test_RsTlvFileData()
{
RsTlvFileData d1;
RsTlvFileData d2;
/* initialise */
d1.file.filesize = 101010;
d1.file.hash = "ABCDEFEGHE";
d1.file.name = "";
d1.file.age = 0;
d1.file.pop = 0;
char data[15];
d1.binData.setBinData(data, 15);
d1.file_offset = 222;
CHECK(test_SerialiseTlvItem(std::cerr, &d1, &d2));
/* check the data is the same */
CHECK(d1.file.filesize == d2.file.filesize);
CHECK(d1.file.hash == d2.file.hash);
CHECK(d1.file.name == d2.file.name);
CHECK(d1.file.path == d2.file.path);
CHECK(d1.file.pop == d2.file.pop);
CHECK(d1.file.age == d2.file.age);
CHECK(d1.file_offset == d2.file_offset);
CHECK(d1.binData.bin_len == d2.binData.bin_len);
REPORT("Serialise/Deserialise RsTlvFileData");
return 1;
}

View File

@ -1,89 +0,0 @@
/*
* libretroshare/src/serialiser: tlvitems_test.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-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".
*
*/
/******************************************************************
* tlvfileitem test.
*
*
*/
#include <string.h>
#include <iostream>
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
INITTEST();
static int test_RsTlvBinData();
static int test_RsTlvStepping();
int main()
{
std::cerr << "RsTlvItems Tests" << std::endl;
test_RsTlvBinData();
FINALREPORT("RsTlvItems Tests");
return TESTRESULT();
}
#define BIN_LEN 523456 /* bigger than 64k */
int test_RsTlvBinData()
{
RsTlvBinaryData d1(1023);
RsTlvBinaryData d2(1023);
char data[BIN_LEN] = {0};
int i, j;
for(i = 0; i < BIN_LEN; i++)
{
data[i] = i%13;
}
for(j = 1; j < BIN_LEN; j *= 2)
{
d1.setBinData(data, j);
CHECK(test_SerialiseTlvItem(std::cerr, &d1, &d2));
CHECK(d1.bin_len == d2.bin_len);
CHECK(0 == memcmp(d1.bin_data, d2.bin_data, d1.bin_len));
}
REPORT("Serialise/Deserialise RsTlvBinData");
return 1;
}
int test_RsTlvStepping()
{
return 1;
}

View File

@ -1,194 +0,0 @@
/*
* libretroshare/src/serialiser: tlvrandom_test.cc
*
* RetroShare Serialiser.
*
* Copyright 2009 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".
*
*/
/******************************************************************
* tlvrandom_test.
*
* This test is designed to attempt to break the TLV serialiser.
*
* To do this we throw random data at the serialisers and try to decode it.
* As the serialiser will only attempt to deserialise if the tlvtype matches
* we cheat a little, and make this match - to increase to actual deserialise
* attempts.
*
* This test runs for 30 seconds and attempts to do as
* many deserialisation as possible.
*/
#include <string.h>
#include <iostream>
#include "serialiser/rstlvbase.h"
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvkeys.h"
#include "serialiser/rstlvkvwide.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
INITTEST();
#define TEST_LENGTH 30
static int test_TlvRandom(void *data, uint32_t len, uint32_t offset);
int main()
{
std::cerr << "TlvRandom Tests" << std::endl;
/* random data array to work through */
uint32_t dsize = 10000000;
uint32_t i;
uint8_t *data = (uint8_t *) malloc(dsize);
if (!data)
{
std::cerr << "Failed to allocate array";
std::cerr << std::endl;
exit(1);
}
time_t startTs = time(NULL);
time_t endTs = startTs + TEST_LENGTH;
srandom(startTs);
for(i = 0; i < dsize; i++)
{
data[i] = random() % 256;
}
std::cerr << "TlvRandom Tests: setup data." << std::endl;
int count = 0;
for(i = 0; endTs > time(NULL); i += 2)
{
uint32_t len = dsize - i;
count += test_TlvRandom(&(data[i]), len, i);
std::cerr << "Run: " << count << " tests";
std::cerr << std::endl;
}
FINALREPORT("RsTlvItems Tests");
return TESTRESULT();
}
#define BIN_LEN 523456 /* bigger than 64k */
int test_TlvItem(RsTlvItem *item, void *data, uint32_t size, uint32_t offset);
int test_SetTlvItem(RsTlvItem *item, uint16_t type, void *data, uint32_t size, uint32_t offset);
int test_TlvRandom(void *data, uint32_t len, uint32_t offset)
{
uint32_t tmpoffset = 0;
/* List of all the TLV types it could be! */
RsTlvSecurityKey skey;
RsTlvSecurityKeySet skeyset;
RsTlvKeySignature keysign;
RsTlvBinaryData bindata(TLV_TYPE_IMAGE);
RsTlvFileItem fileitem;
RsTlvFileSet fileset;
RsTlvFileData filedata;
RsTlvPeerIdSet peerset;
RsTlvServiceIdSet servset;
RsTlvKeyValue kv;
RsTlvKeyValueSet kvset;
RsTlvKeyValueWide kvwide;
RsTlvKeyValueWideSet kvwideset;
RsTlvImage image;
/* try to decode - with all types first */
std::cerr << "test_TlvRandom:: Testing Files " << std::endl;
test_TlvItem(&bindata, data, len, offset);
test_TlvItem(&fileitem, data, len, offset);
test_TlvItem(&fileset, data, len, offset);
test_TlvItem(&filedata, data, len, offset);
std::cerr << "test_TlvRandom:: Testing Sets " << std::endl;
test_TlvItem(&peerset, data, len, offset);
test_TlvItem(&servset, data, len, offset);
test_TlvItem(&kv, data, len, offset);
test_TlvItem(&kvset, data, len, offset);
test_TlvItem(&kvwide, data, len, offset);
test_TlvItem(&kvwideset, data, len, offset);
std::cerr << "test_TlvRandom:: Testing Keys " << std::endl;
test_TlvItem(&skey, data, len, offset);
test_TlvItem(&skeyset, data, len, offset);
test_TlvItem(&keysign, data, len, offset);
/* now set the type correctly before decoding */
std::cerr << "test_TlvRandom:: Testing Files (TYPESET)" << std::endl;
test_SetTlvItem(&bindata, TLV_TYPE_IMAGE, data, len, offset);
test_SetTlvItem(&fileitem,TLV_TYPE_FILEITEM, data, len, offset);
test_SetTlvItem(&fileset, TLV_TYPE_FILESET, data, len, offset);
test_SetTlvItem(&filedata, TLV_TYPE_FILEDATA, data, len, offset);
std::cerr << "test_TlvRandom:: Testing Sets (TYPESET)" << std::endl;
test_SetTlvItem(&peerset, TLV_TYPE_PEERSET, data, len, offset);
test_SetTlvItem(&servset, TLV_TYPE_SERVICESET, data, len, offset);
test_SetTlvItem(&kv, TLV_TYPE_KEYVALUE, data, len, offset);
test_SetTlvItem(&kvset, TLV_TYPE_KEYVALUESET, data, len, offset);
test_SetTlvItem(&kvwide, TLV_TYPE_WKEYVALUE, data, len, offset);
test_SetTlvItem(&kvwideset, TLV_TYPE_WKEYVALUESET, data, len, offset);
std::cerr << "test_TlvRandom:: Testing Keys (TYPESET)" << std::endl;
test_SetTlvItem(&skey, TLV_TYPE_SECURITYKEY, data, len, offset);
test_SetTlvItem(&skeyset, TLV_TYPE_SECURITYKEYSET, data, len, offset);
test_SetTlvItem(&keysign, TLV_TYPE_KEYSIGNATURE, data, len, offset);
return 26; /* number of tests */
}
int test_TlvItem(RsTlvItem *item, void *data, uint32_t size, uint32_t offset)
{
uint32_t tmp_offset = offset;
if (item->GetTlv(data, size, &tmp_offset))
{
std::cerr << "TLV decoded Random!";
std::cerr << std::endl;
item->print(std::cerr, 20);
}
else
{
std::cerr << "TLV failed to decode";
std::cerr << std::endl;
}
}
int test_SetTlvItem(RsTlvItem *item, uint16_t type, void *data, uint32_t size, uint32_t offset)
{
/* set TLV type first! */
void *typedata = (((uint8_t *) data) + offset);
SetTlvType(typedata, size - offset, type);
return test_TlvItem(item, data, size, offset);
}

View File

@ -1,104 +0,0 @@
/*
* libretroshare/src/serialiser: tlvstack_test.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-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".
*
*/
/******************************************************************
* tlvfileitem test.
*
*
*/
#include <iostream>
#include "serialiser/rstlvtypes.h"
#include "serialiser/rstlvutil.h"
#include "util/utest.h"
INITTEST();
static int test_RsTlvStack();
int main()
{
std::cerr << "RsTlvItem Stack Tests" << std::endl;
test_RsTlvStack();
FINALREPORT("RsTlvItem Stack Tests");
return TESTRESULT();
}
#define BIN_LEN 53
int test_RsTlvStack()
{
/* now create a set of TLV items for the random generator */
RsTlvBinaryData *bd1 = new RsTlvBinaryData(123);
RsTlvBinaryData *bd2 = new RsTlvBinaryData(125);
char data[BIN_LEN] = {0};
int i;
for(i = 0; i < BIN_LEN; i++)
{
data[i] = i%13;
}
bd1->setBinData(data, 5);
bd2->setBinData(data, 21);
RsTlvFileItem *fi1 = new RsTlvFileItem();
RsTlvFileItem *fi2 = new RsTlvFileItem();
/* initialise */
fi1->filesize = 101010;
fi1->hash = "ABCDEFEGHE";
fi1->name = "TestFile.txt";
fi1->pop = 12;
fi1->age = 456;
fi2->filesize = 101010;
fi2->hash = "ABCDEFEGHE";
fi2->name = "TestFile.txt";
fi2->pop = 0;
fi2->age = 0;;
std::vector<RsTlvItem *> items;
items.resize(4);
items[0] = bd1;
items[1] = bd2;
items[2] = fi1;
items[3] = fi2;
test_TlvSet(items, 1024);
REPORT("Serialise/Deserialise RsTlvBinData");
return 1;
}

View File

@ -13,9 +13,7 @@ TESTOBJ += rsserial_test.o rstlvwidetest.o tlvrandom_test.o
TESTS = tlvbase_test tlvbase_test2 tlvfileitem_test
TESTS += tlvitems_test tlvstack_test tlvconfig_test
TESTS += rstlvwidetest tlvrandom_test
#rsserial_test
TESTS += rstlvwidetest tlvrandom_test rsserial_test
#rsbaseitem_test
all: tests