temporary changes (lrand48 - rand(), s/random - s/rand() to turtle tunnel, and tlv random tests to allow windows

compatability.
added some explicit headers to distrib items test 
again for compatability.


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3349 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-08-07 19:05:49 +00:00
parent 7b4364035e
commit cf75bee791
5 changed files with 949 additions and 947 deletions

View File

@ -48,7 +48,7 @@ tlvrandom_test : tlvrandom_test.o
$(CC) $(CFLAGS) -o tlvrandom_test tlvrandom_test.o $(OBJ) $(LIBS) $(CC) $(CFLAGS) -o tlvrandom_test tlvrandom_test.o $(OBJ) $(LIBS)
rsturtleitem_test : rsturtleitem_test.o support.o rsturtleitem_test : rsturtleitem_test.o support.o
$(CC) $(CFLAGS) -o rsturtleitem_test rsturtleitem_test.o $(OBJ) $(LIBS) $(CC) $(CFLAGS) -o rsturtleitem_test rsturtleitem_test.o support.o $(OBJ) $(LIBS)
rstunnelitem_test : rstunnelitem_test.o support.o rstunnelitem_test : rstunnelitem_test.o support.o
$(CC) $(CFLAGS) -o rstunnelitem_test rstunnelitem_test.o support.o $(OBJ) $(LIBS) $(CC) $(CFLAGS) -o rstunnelitem_test rstunnelitem_test.o support.o $(OBJ) $(LIBS)

View File

@ -1,3 +1,4 @@
<<<<<<< .mine
/* /*
* libretroshare/src/serialiser: distribitem_test.cc * libretroshare/src/serialiser: distribitem_test.cc
* *
@ -24,12 +25,12 @@
*/ */
#include <iostream> #include <iostream>
#include <time.h>
#include "serialiser/rsdistribitems.h" #include "serialiser/rsdistribitems.h"
#include "serialiser/rschannelitems.h" #include "serialiser/rschannelitems.h"
#include "serialiser/rsforumitems.h" #include "serialiser/rsforumitems.h"
#include "serialiser/rsblogitems.h" #include "serialiser/rsblogitems.h"
#include "retroshare/rsdistrib.h" #include "rsiface/rsdistrib.h"
#include "serialiser/rstlvutil.h" #include "serialiser/rstlvutil.h"
#include "util/utest.h" #include "util/utest.h"
#include "support.h" #include "support.h"
@ -317,4 +318,3 @@ int main(){
return TESTRESULT(); return TESTRESULT();
} }

View File

@ -27,6 +27,7 @@
/****************************************************************** /******************************************************************
*/ */
#include <stdlib.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <serialiser/rstunnelitems.h> #include <serialiser/rstunnelitems.h>
@ -38,11 +39,11 @@
RsTunnelSerialiser* init_item(RsTunnelDataItem& item) RsTunnelSerialiser* init_item(RsTunnelDataItem& item)
{ {
uint32_t S = lrand48()%20000 ; uint32_t S = rand()%20000 ;
item.encoded_data = malloc(S) ; item.encoded_data = malloc(S) ;
item.encoded_data_len = S ; item.encoded_data_len = S ;
for(uint32_t i=0;i<S;++i) for(uint32_t i=0;i<S;++i)
((unsigned char *)item.encoded_data)[i] = lrand48()%256 ; ((unsigned char *)item.encoded_data)[i] = rand()%256 ;
item.sourcePeerId = "67641e38df0e75432033d222eae93fff" ; item.sourcePeerId = "67641e38df0e75432033d222eae93fff" ;
item.relayPeerId = "6013bfc2cea7ab823af7a79fb3ca0df1" ; item.relayPeerId = "6013bfc2cea7ab823af7a79fb3ca0df1" ;
item.destPeerId = "1d5768db7cd4720d0eb75cc1917da332" ; item.destPeerId = "1d5768db7cd4720d0eb75cc1917da332" ;
@ -69,10 +70,10 @@ RsTunnelSerialiser* init_item(RsTunnelHandshakeItem& item)
item.destPeerId = "1d5768db7cd4720d0eb75cc1917da332" ; item.destPeerId = "1d5768db7cd4720d0eb75cc1917da332" ;
item.sslCertPEM = "" ; item.sslCertPEM = "" ;
uint32_t s=lrand48()%20 ; uint32_t s=rand()%20 ;
for(uint32_t i=0;i<s;++i) for(uint32_t i=0;i<s;++i)
item.sslCertPEM += "6013bfc2cea7ab823af7a79fb3ca0df1" ; item.sslCertPEM += "6013bfc2cea7ab823af7a79fb3ca0df1" ;
item.connection_accepted = lrand48() ; item.connection_accepted = rand() ;
return new RsTunnelSerialiser(); return new RsTunnelSerialiser();
} }

View File

@ -39,8 +39,8 @@ INITTEST();
RsSerialType* init_item(CompressedChunkMap& map) RsSerialType* init_item(CompressedChunkMap& map)
{ {
map._map.clear() ; map._map.clear() ;
for(uint i=0;i<15;++i) for(uint32_t i=0;i<15;++i)
map._map.push_back(lrand48()) ; map._map.push_back(rand()) ;
return new RsTurtleSerialiser(); return new RsTurtleSerialiser();
} }
@ -90,7 +90,7 @@ RsSerialType* init_item(RsTurtleFileDataItem& item)
item.chunk_size = S ; item.chunk_size = S ;
item.chunk_data = new unsigned char[S] ; item.chunk_data = new unsigned char[S] ;
for(uint32_t i=0;i<S;++i) for(uint32_t i=0;i<S;++i)
((unsigned char *)item.chunk_data)[i] = lrand48()%256 ; ((unsigned char *)item.chunk_data)[i] = rand()%256 ;
return new RsTurtleSerialiser(); return new RsTurtleSerialiser();
} }
bool operator==(const RsTurtleFileDataItem& i1,const RsTurtleFileDataItem& i2) bool operator==(const RsTurtleFileDataItem& i1,const RsTurtleFileDataItem& i2)
@ -105,9 +105,9 @@ bool operator==(const RsTurtleFileDataItem& i1,const RsTurtleFileDataItem& i2)
} }
RsSerialType* init_item(RsTurtleFileRequestItem& item) RsSerialType* init_item(RsTurtleFileRequestItem& item)
{ {
item.tunnel_id = lrand48() ; item.tunnel_id = rand() ;
item.chunk_offset = 0x25ea228437894379ull ; item.chunk_offset = 0x25ea228437894379ull ;
item.chunk_size = lrand48() ; item.chunk_size = rand() ;
return new RsTurtleSerialiser(); return new RsTurtleSerialiser();
} }
bool operator==(const RsTurtleFileRequestItem& it1,const RsTurtleFileRequestItem& it2) bool operator==(const RsTurtleFileRequestItem& it1,const RsTurtleFileRequestItem& it2)
@ -120,8 +120,8 @@ bool operator==(const RsTurtleFileRequestItem& it1,const RsTurtleFileRequestItem
} }
RsSerialType* init_item(RsTurtleTunnelOkItem& item) RsSerialType* init_item(RsTurtleTunnelOkItem& item)
{ {
item.tunnel_id = lrand48() ; item.tunnel_id = rand() ;
item.request_id = lrand48() ; item.request_id = rand() ;
return new RsTurtleSerialiser(); return new RsTurtleSerialiser();
} }
bool operator==(const RsTurtleTunnelOkItem& it1,const RsTurtleTunnelOkItem& it2) bool operator==(const RsTurtleTunnelOkItem& it1,const RsTurtleTunnelOkItem& it2)
@ -132,9 +132,9 @@ bool operator==(const RsTurtleTunnelOkItem& it1,const RsTurtleTunnelOkItem& it2)
} }
RsSerialType* init_item(RsTurtleOpenTunnelItem& item) RsSerialType* init_item(RsTurtleOpenTunnelItem& item)
{ {
item.depth = lrand48() ; item.depth = rand() ;
item.request_id = lrand48() ; item.request_id = rand() ;
item.partial_tunnel_id = lrand48() ; item.partial_tunnel_id = rand() ;
item.file_hash = std::string("c0edcfecc0844ef175d61dd589ab288d262b6bc8") ; item.file_hash = std::string("c0edcfecc0844ef175d61dd589ab288d262b6bc8") ;
return new RsTurtleSerialiser(); return new RsTurtleSerialiser();
} }
@ -148,14 +148,14 @@ bool operator==(const RsTurtleOpenTunnelItem& it1,const RsTurtleOpenTunnelItem&
} }
RsSerialType* init_item(RsTurtleRegExpSearchRequestItem& item) RsSerialType* init_item(RsTurtleRegExpSearchRequestItem& item)
{ {
item.request_id = lrand48() ; item.request_id = rand() ;
item.depth = lrand48() ; item.depth = rand() ;
item.expr._tokens.clear() ; item.expr._tokens.clear() ;
item.expr._ints.clear() ; item.expr._ints.clear() ;
item.expr._strings.clear() ; item.expr._strings.clear() ;
for(uint32_t i=0;i<10u;++i) item.expr._tokens.push_back(lrand48()%8) ; for(uint32_t i=0;i<10u;++i) item.expr._tokens.push_back(rand()%8) ;
for(uint32_t i=0;i<6u;++i) item.expr._ints.push_back(lrand48()) ; for(uint32_t i=0;i<6u;++i) item.expr._ints.push_back(rand()) ;
for(uint32_t i=0;i<8u;++i) item.expr._strings.push_back("test string") ; for(uint32_t i=0;i<8u;++i) item.expr._strings.push_back("test string") ;
return new RsTurtleSerialiser(); return new RsTurtleSerialiser();
} }
@ -173,8 +173,8 @@ bool operator==(const RsTurtleRegExpSearchRequestItem& it1,const RsTurtleRegExpS
} }
RsSerialType* init_item(RsTurtleStringSearchRequestItem& item) RsSerialType* init_item(RsTurtleStringSearchRequestItem& item)
{ {
item.request_id = lrand48() ; item.request_id = rand() ;
item.depth = lrand48() ; item.depth = rand() ;
item.match_string = std::string("432hkjfdsjkhjk43r3fw") ; item.match_string = std::string("432hkjfdsjkhjk43r3fw") ;
return new RsTurtleSerialiser(); return new RsTurtleSerialiser();
} }
@ -202,8 +202,8 @@ bool operator==(const TurtleFileInfo& it1,const TurtleFileInfo& it2)
} }
RsSerialType* init_item(RsTurtleSearchResultItem& item) RsSerialType* init_item(RsTurtleSearchResultItem& item)
{ {
item.depth = lrand48() ; item.depth = rand() ;
item.request_id = lrand48() ; item.request_id = rand() ;
item.result.clear() ; item.result.clear() ;
static const uint32_t S = 10 ; static const uint32_t S = 10 ;
for(uint32_t i=0;i<S;++i) for(uint32_t i=0;i<S;++i)

View File

@ -38,6 +38,7 @@
* many deserialisation as possible. * many deserialisation as possible.
*/ */
#include <time.h>
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
#include "serialiser/rstlvbase.h" #include "serialiser/rstlvbase.h"
@ -73,10 +74,10 @@ int main()
time_t startTs = time(NULL); time_t startTs = time(NULL);
time_t endTs = startTs + TEST_LENGTH; time_t endTs = startTs + TEST_LENGTH;
srandom(startTs); srand(startTs);
for(i = 0; i < dsize; i++) for(i = 0; i < dsize; i++)
{ {
data[i] = random() % 256; data[i] = rand() % 256;
} }
std::cerr << "TlvRandom Tests: setup data." << std::endl; std::cerr << "TlvRandom Tests: setup data." << std::endl;