mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-22 07:41:20 -04:00
Updated GXS tests, lots of mem leak fixes from valgrind run.
- mem leak caused by not deleting stored msgs and groups, rsdatastore now a group/msg sink - mem leak caused in rsgxsnetservice by not deleting meta information after retrieval - fixed mem leak in rstlvkeyset::getTlv due to tlvbindata making own data copy git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5616 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0fc3a2704b
commit
bdd6c6041b
9 changed files with 101 additions and 47 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "genexchangetester.h"
|
||||
#include "support.h"
|
||||
#include "gxs/rsdataservice.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
|
||||
|
||||
GenExchangeTester::GenExchangeTester()
|
||||
|
@ -1404,7 +1405,7 @@ void GenExchangeTester::init(RsGroupMetaData &grpMeta) const
|
|||
grpMeta.mPop = randNum();
|
||||
grpMeta.mSignFlags = randNum();
|
||||
grpMeta.mPublishTs = randNum();
|
||||
grpMeta.mSubscribeFlags = randNum();
|
||||
grpMeta.mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_ADMIN;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1510,7 +1511,7 @@ void GenExchangeTester::pollForToken(uint32_t token, const RsTokReqOptionsV2 &op
|
|||
Sleep((int) (timeDelta * 1000));
|
||||
#endif
|
||||
|
||||
if(RsTokenServiceV2::GXS_REQUEST_STATUS_COMPLETE ==
|
||||
if(RsTokenServiceV2::GXS_REQUEST_V2_STATUS_COMPLETE ==
|
||||
mTokenService->requestStatus(token))
|
||||
{
|
||||
switch(opts.mReqType)
|
||||
|
|
|
@ -10,7 +10,7 @@ QT += core network
|
|||
|
||||
QT -= gui
|
||||
|
||||
CONFIG += gen_exchange_target #dstore_target
|
||||
CONFIG += dstore_target #gen_exchange_target # #nxs_net_test
|
||||
|
||||
dstore_target {
|
||||
|
||||
|
@ -24,6 +24,12 @@ TARGET = gen_exchange_test
|
|||
|
||||
}
|
||||
|
||||
nxs_net_test {
|
||||
|
||||
TARGET = nxs_net_test
|
||||
|
||||
}
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
|
@ -187,4 +193,21 @@ gen_exchange_target {
|
|||
|
||||
}
|
||||
|
||||
nxs_net_test {
|
||||
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
nxstesthub.cc \
|
||||
rsgxsnetservice_test.cc \
|
||||
nxstestscenario.cc \
|
||||
data_support.cc
|
||||
|
||||
|
||||
HEADERS += support.h \
|
||||
nxstesthub.h \
|
||||
rsgxsnetservice_test.h \
|
||||
nxstestscenario.h \
|
||||
data_support.h
|
||||
}
|
||||
|
||||
INCLUDEPATH += ../../
|
||||
|
|
|
@ -82,16 +82,6 @@ void NxsMessageTest::populateStore(RsGeneralDataService* dStore)
|
|||
|
||||
dStore->storeGroup(grps);
|
||||
|
||||
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*>::iterator grp_it
|
||||
= grps.begin();
|
||||
for(; grp_it != grps.end(); grp_it++)
|
||||
{
|
||||
delete grp_it->first;
|
||||
delete grp_it->second;
|
||||
}
|
||||
|
||||
|
||||
int nMsgs = rand()%23;
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
|
||||
RsNxsMsg* msg = NULL;
|
||||
|
@ -119,16 +109,6 @@ void NxsMessageTest::populateStore(RsGeneralDataService* dStore)
|
|||
|
||||
dStore->storeMessage(msgs);
|
||||
|
||||
// clean up
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*>::iterator msg_it
|
||||
= msgs.begin();
|
||||
|
||||
for(; msg_it != msgs.end(); msg_it++)
|
||||
{
|
||||
delete msg_it->first;
|
||||
delete msg_it->second;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void test_groupStoreAndRetrieve(){
|
|||
setUp();
|
||||
|
||||
int nGrp = rand()%32;
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps;
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps, grps_copy;
|
||||
RsNxsGrp* grp;
|
||||
RsGxsGrpMetaData* grpMeta;
|
||||
for(int i = 0; i < nGrp; i++){
|
||||
|
@ -51,13 +51,21 @@ void test_groupStoreAndRetrieve(){
|
|||
init_item(grpMeta);
|
||||
grpMeta->mGroupId = grp->grpId;
|
||||
grps.insert(p);
|
||||
|
||||
RsNxsGrp* grp_copy = new RsNxsGrp(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
*grp_copy = *grp;
|
||||
RsGxsGrpMetaData* grpMeta_copy = new RsGxsGrpMetaData();
|
||||
*grpMeta_copy = *grpMeta;
|
||||
grps_copy.insert(std::make_pair(grp_copy, grpMeta_copy ));
|
||||
grpMeta = NULL;
|
||||
grp = NULL;
|
||||
}
|
||||
|
||||
dStore->storeGroup(grps);
|
||||
|
||||
//use copy, a grps are deleted in store
|
||||
grps.clear();
|
||||
grps = grps_copy;
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> gR;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMetaR;
|
||||
dStore->retrieveNxsGrps(gR, false, false);
|
||||
|
@ -141,6 +149,7 @@ void test_messageStoresAndRetrieve()
|
|||
grpV.push_back(grpId1);
|
||||
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs_copy;
|
||||
RsNxsMsg* msg = NULL;
|
||||
RsGxsMsgMetaData* msgMeta = NULL;
|
||||
int nMsgs = rand()%120;
|
||||
|
@ -170,9 +179,15 @@ void test_messageStoresAndRetrieve()
|
|||
msgMeta->mMsgId = msg->msgId;
|
||||
msgMeta->mGroupId = msg->grpId = grpId;
|
||||
|
||||
RsNxsMsg* msg_copy = new RsNxsMsg(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
RsGxsMsgMetaData* msgMeta_copy = new RsGxsMsgMetaData();
|
||||
|
||||
*msg_copy = *msg;
|
||||
*msgMeta_copy = *msgMeta;
|
||||
|
||||
// store msgs in map to use for verification
|
||||
std::pair<std::string, RsNxsMsg*> vP(msg->msgId, msg);
|
||||
std::pair<std::string, RsGxsMsgMetaData*> vPmeta(msg->msgId, msgMeta);
|
||||
std::pair<std::string, RsNxsMsg*> vP(msg->msgId, msg_copy);
|
||||
std::pair<std::string, RsGxsMsgMetaData*> vPmeta(msg->msgId, msgMeta_copy);
|
||||
|
||||
if(!chosen)
|
||||
{
|
||||
|
@ -184,15 +199,21 @@ void test_messageStoresAndRetrieve()
|
|||
VergrpId1.insert(vP);
|
||||
VerMetagrpId0.insert(vPmeta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
msg = NULL;
|
||||
msgMeta = NULL;
|
||||
|
||||
msgs.insert(p);
|
||||
msgs_copy.insert(std::make_pair(msg_copy, msgMeta_copy));
|
||||
}
|
||||
|
||||
req[grpV[0]] = std::vector<RsGxsMessageId>(); // assign empty list for other
|
||||
|
||||
dStore->storeMessage(msgs);
|
||||
msgs.clear();
|
||||
msgs = msgs_copy;
|
||||
|
||||
// now retrieve msgs for comparison
|
||||
// first selective retrieval
|
||||
|
|
|
@ -17,16 +17,16 @@ int main()
|
|||
// CHECK(tester.testMsgSubmissionRetrieval()); REPORT("testMsgSubmissionRetrieval()");
|
||||
// CHECK(tester.testSpecificMsgMetaRetrieval()); REPORT("testSpecificMsgMetaRetrieval()");
|
||||
// CHECK(tester.testMsgIdRetrieval()); REPORT("tester.testMsgIdRetrieval()");
|
||||
//CHECK(tester.testMsgIdRetrieval_OptParents()); REPORT("tester.testRelatedMsgIdRetrieval_Parents()");
|
||||
// CHECK(tester.testMsgIdRetrieval_OptParents()); REPORT("tester.testRelatedMsgIdRetrieval_Parents()");
|
||||
// CHECK(tester.testMsgIdRetrieval_OptOrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()");
|
||||
// CHECK(tester.testMsgIdRetrieval_OptLatest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()");
|
||||
//CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
|
||||
CHECK(tester.testMsgChildRetrieval()); REPORT("tester.testMsgMetaModRequest()");
|
||||
// CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
|
||||
// CHECK(tester.testMsgChildRetrieval()); REPORT("tester.testMsgMetaModRequest()");
|
||||
|
||||
// CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()");
|
||||
// CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");
|
||||
// CHECK(tester.testGrpIdRetrieval()); REPORT("tester.testGrpIdRetrieval()");
|
||||
// CHECK(tester.testGrpMetaModRequest()); REPORT("tester.testGrpMetaModRequest()");
|
||||
CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()");
|
||||
CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");
|
||||
CHECK(tester.testGrpIdRetrieval()); REPORT("tester.testGrpIdRetrieval()");
|
||||
CHECK(tester.testGrpMetaModRequest()); REPORT("tester.testGrpMetaModRequest()");
|
||||
|
||||
FINALREPORT("RsGenExchangeTest");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue