mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-22 07:41:20 -04:00
* 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:
parent
05bc4ba76e
commit
3855be974b
29 changed files with 1 additions and 4669 deletions
54
libretroshare/src/tests/ft/TestNotes.txt
Normal file
54
libretroshare/src/tests/ft/TestNotes.txt
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
Features that need to be tested, and which test checks it.
|
||||
-----------------------------------------------------------
|
||||
|
||||
(*) Transfer Related
|
||||
|
||||
(*) Search Related
|
||||
|
||||
(*) ExtraList Related
|
||||
|
||||
(*) Cache Related
|
||||
|
||||
(*) Config / Storage.
|
||||
Change Config Directory works dynamically. (no restart required).
|
||||
|
||||
|
||||
(*) Miscelleous
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
-----------------------------------------------------------
|
||||
Actual Tests, and what they check.
|
||||
-----------------------------------------------------------
|
||||
|
||||
ftserver1test.cc
|
||||
==================
|
||||
|
||||
Used to develop test framework.
|
||||
Tests.
|
||||
1) Test Framework. OK
|
||||
2) File Indexing. OK
|
||||
3) Cache Packet Exchange. OK
|
||||
4) Cache downloads (including loopback). FAILS
|
||||
5) FileIndex Store loading.
|
||||
6) Basic Search.
|
||||
|
||||
ftserver2test.cc
|
||||
==================
|
||||
|
||||
Test out the ExtraList functions.
|
||||
Demonstrates the use of libretroshare/src/util/utest.h
|
||||
|
||||
Tests.
|
||||
1) Load ExtraList path OK
|
||||
2) Hashing of ExtraList File OK
|
||||
3) ExtraHashDone. OK
|
||||
4) Local Search for ExtraList Data. OK
|
||||
5) Remote Search of ExtraList (should Fail) OK
|
||||
6) Transfer of ExtraList File (Local) TODO
|
||||
7) Transfer of ExtraList File (Remote) TODO
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
|
136
libretroshare/src/tests/serialiser/rsserial_test.cc
Normal file
136
libretroshare/src/tests/serialiser/rsserial_test.cc
Normal file
|
@ -0,0 +1,136 @@
|
|||
|
||||
/*
|
||||
* libretroshare/src/serialiser: rsserial_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/rsserial.h"
|
||||
#include "serialiser/rsbaseitems.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_RsFileItem()
|
||||
{
|
||||
/* make a serialisable FileItem */
|
||||
|
||||
RsSerialiser srl;
|
||||
RsFileRequest rsfi;
|
||||
|
||||
/* initialise */
|
||||
rsfi.file.filesize = 101010;
|
||||
rsfi.file.hash = "ABCDEFEGHE";
|
||||
rsfi.file.name = "TestFile.txt";
|
||||
rsfi.file.pop = 12;
|
||||
rsfi.file.age = 456;
|
||||
|
||||
/* attempt to serialise it before we add it to the serialiser */
|
||||
|
||||
CHECK(0 == srl.size(&rsfi));
|
||||
|
||||
#define MAX_BUFSIZE 16000
|
||||
|
||||
char buffer[MAX_BUFSIZE];
|
||||
uint32_t sersize = MAX_BUFSIZE;
|
||||
|
||||
CHECK(false == srl.serialise(&rsfi, (void *) buffer, &sersize));
|
||||
|
||||
|
||||
/* now add to serialiser */
|
||||
|
||||
RsFileItemSerialiser *rsfis = new RsFileItemSerialiser();
|
||||
srl.addSerialType(rsfis);
|
||||
|
||||
uint32_t size = srl.size(&rsfi);
|
||||
bool done = srl.serialise(&rsfi, (void *) buffer, &sersize);
|
||||
|
||||
std::cerr << "test_RsFileItem() size: " << size << std::endl;
|
||||
std::cerr << "test_RsFileItem() done: " << done << std::endl;
|
||||
std::cerr << "test_RsFileItem() sersize: " << sersize << std::endl;
|
||||
|
||||
std::cerr << "test_RsFileItem() serialised:" << std::endl;
|
||||
displayRawPacket(std::cerr, (void *) buffer, sersize);
|
||||
|
||||
CHECK(done == true);
|
||||
|
||||
uint32_t sersize2 = sersize;
|
||||
RsItem *output = srl.deserialise((void *) buffer, &sersize2);
|
||||
|
||||
CHECK(output != NULL);
|
||||
CHECK(sersize2 == sersize);
|
||||
|
||||
RsFileRequest *outfi = dynamic_cast<RsFileRequest *>(output);
|
||||
|
||||
CHECK(outfi != NULL);
|
||||
|
||||
if (outfi)
|
||||
{
|
||||
/* check the data is the same */
|
||||
CHECK(rsfi.file.filesize == outfi->file.filesize);
|
||||
CHECK(rsfi.file.hash == outfi->file.hash);
|
||||
CHECK(rsfi.file.name == outfi->file.name);
|
||||
CHECK(rsfi.file.path == outfi->file.path);
|
||||
CHECK(rsfi.file.pop == outfi->file.pop);
|
||||
CHECK(rsfi.file.age == outfi->file.age);
|
||||
}
|
||||
|
||||
sersize2 = MAX_BUFSIZE;
|
||||
bool done2 = srl.serialise(outfi, (void *) &(buffer[16*8]), &sersize2);
|
||||
|
||||
CHECK(sersize2 == sersize);
|
||||
|
||||
displayRawPacket(std::cerr, (void *) buffer, 16 * 8 + sersize2);
|
||||
|
||||
|
||||
REPORT("Serialise/Deserialise RsFileRequest");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue