Skip to content

Commit

Permalink
Merge pull request #6 from martyone/fix-tests
Browse files Browse the repository at this point in the history
Fix tests, fix a memory leak, improve packaging a bit
  • Loading branch information
bwachter committed May 23, 2013
2 parents b4c3d50 + 379f52b commit 1603b51
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 74 deletions.
2 changes: 1 addition & 1 deletion rpm/buteo-syncml.spec
Expand Up @@ -59,7 +59,7 @@ Requires: %{name} = %{version}-%{release}


%build
qmake libbuteosyncml.pro
%qmake libbuteosyncml.pro
make %{?_smp_mflags}


Expand Down
3 changes: 1 addition & 2 deletions src/DatabaseHandler.cpp
Expand Up @@ -49,11 +49,10 @@ DatabaseHandler::DatabaseHandler( const QString& aDbFile )
iConnectionName = CONNECTIONNAME + QString::number( connectionNumber++ );
iDb = QSqlDatabase::addDatabase( "QSQLITE", iConnectionName );

QDir cacheDir;
cacheDir.mkdir( Sync::syncCacheDir() );
QString path( Sync::syncCacheDir() );
path.append( QDir::separator() ).append( aDbFile );
path = QDir::toNativeSeparators( path );
QDir().mkpath( QFileInfo(path).path() );

iDb.setDatabaseName( path );
if(!iDb.open())
Expand Down
9 changes: 9 additions & 0 deletions src/SyncAgent.cpp
Expand Up @@ -488,6 +488,7 @@ void SyncAgent::listenEvent()
RequestListener::RequestData data = iListener->takeRequestData();

iListener->stop();
cleanListenLater();

if( data.iType == RequestListener::REQUEST_CLIENT )
{
Expand Down Expand Up @@ -621,3 +622,11 @@ void SyncAgent::cleanListen()
delete iListener;
iListener = NULL;
}

void SyncAgent::cleanListenLater()
{
FUNCTION_CALL_TRACE

iListener->deleteLater();
iListener = NULL;
}
1 change: 1 addition & 0 deletions src/SyncAgent.h
Expand Up @@ -745,6 +745,7 @@ private slots:

void abortListen();
void cleanListen();
void cleanListenLater();

RequestListener* iListener;
SessionHandler* iHandler;
Expand Down
4 changes: 2 additions & 2 deletions src/meegosyncml.pro
Expand Up @@ -115,9 +115,9 @@ QMAKE_CLEAN += $(OBJECTS_DIR)/*.gcda \
$(OBJECTS_DIR)/*.gcov \
lib*.so*

QMAKE_STRIP = strip
#QMAKE_STRIP = strip

QMAKE_STRIPFLAGS_LIB += --strip-unneeded
#QMAKE_STRIPFLAGS_LIB += --strip-unneeded

headers.path = /usr/include/libbuteosyncml
headers.files = $$HEADERS
Expand Down
4 changes: 2 additions & 2 deletions src/src.pro
Expand Up @@ -133,9 +133,9 @@ QMAKE_CXXFLAGS = -Wall \
QMAKE_CLEAN += lib*.so* \
lib$${TARGET}.prl pkgconfig/*

QMAKE_STRIP = strip
#QMAKE_STRIP = strip

QMAKE_STRIPFLAGS_LIB += --strip-unneeded
#QMAKE_STRIPFLAGS_LIB += --strip-unneeded

headers.path = /usr/include/buteosyncml
headers.files = $$HEADERS
Expand Down
7 changes: 5 additions & 2 deletions tests_meego/Mock.h
Expand Up @@ -111,6 +111,8 @@ class MockStorage: public StoragePlugin {
iFormats.setPreferredTx(format);
iFormats.rx().append(format);
iFormats.tx().append(format);

iIdCounter = 0;
}

virtual ~MockStorage() {}
Expand Down Expand Up @@ -198,7 +200,7 @@ class MockStorage: public StoragePlugin {

virtual SyncItem* newItem()
{
return new MockSyncItem( "1" );
return new MockSyncItem( "" );
}

virtual SyncItem* getSyncItem( const SyncItemKey& aKey )
Expand Down Expand Up @@ -228,6 +230,7 @@ class MockStorage: public StoragePlugin {
QList<StoragePluginStatus> results;

for( int i = 0; i < aItems.count(); ++i ) {
aItems[i]->setKey( QString("MockStorage-item-%1").arg( ++iIdCounter ) );
results.append( STATUS_OK );
}

Expand Down Expand Up @@ -267,7 +270,7 @@ class MockStorage: public StoragePlugin {
QString iSourceURI;
qint64 iMaxObjSize;
StorageContentFormatInfo iFormats;

int iIdCounter;
};

class MockTransport : public DataSync::Transport {
Expand Down
13 changes: 9 additions & 4 deletions tests_meego/SessionHandlerTest.cpp
Expand Up @@ -43,6 +43,7 @@
#include "TestUtils.h"
#include "ServerAlertedNotification.h"
#include "SyncAgentConfigProperties.h"
#include "SyncCommonDefs.h"

#include "TestLoader.h"

Expand Down Expand Up @@ -83,12 +84,16 @@ void SessionHandlerTest::releaseStorage( StoragePlugin* aStorage )

void SessionHandlerTest::init()
{
QFile::remove( DBFILE );
// See DataSync::DatabaseHandler::DatabaseHandler()
QString effectivePath = Sync::syncCacheDir() + QDir::separator() + DBFILE;
QFile::remove( effectivePath );
}

void SessionHandlerTest::cleanup()
{
QFile::remove( DBFILE );
// See DataSync::DatabaseHandler::DatabaseHandler()
QString effectivePath = Sync::syncCacheDir() + QDir::separator() + DBFILE;
QFile::remove( effectivePath );
}

void SessionHandlerTest::testClientWithClientInitiated()
Expand Down Expand Up @@ -877,7 +882,7 @@ void SessionHandlerTest::testClientAuthBasicContinuous()
// Test that basic authentication information is continued to be sent
// if server responds with 200.

QVERIFY( false );
QSKIP( "Unimplemented!", SkipAll );
}

void SessionHandlerTest::testClientAuthMD5NoCreds()
Expand Down Expand Up @@ -1218,7 +1223,7 @@ void SessionHandlerTest::testClientAuthMD5ChalToBasic()

void SessionHandlerTest::testClientAuthMD5Continuous()
{
QVERIFY( false );
QSKIP( "Unimplemented!", SkipAll );
}

void SessionHandlerTest::regression_NB153701_01()
Expand Down
4 changes: 2 additions & 2 deletions tests_meego/SyncAgentTest.cpp
Expand Up @@ -68,7 +68,7 @@ void SyncAgentTest::releaseStorage( StoragePlugin* aStorage )
void SyncAgentTest::testSync()
{
createSyncAgent_t createSyncAgent = (createSyncAgent_t) QLibrary::resolve(
"libmeegosyncml.so", "createSyncAgent");
"libbuteosyncml.so", "createSyncAgent");
QVERIFY(NULL != createSyncAgent);
SyncAgent* agent = createSyncAgent(NULL);
QVERIFY(NULL != agent);
Expand Down Expand Up @@ -159,7 +159,7 @@ void SyncAgentTest::testSync()
QCOMPARE(agent->cleanUp(&config), false);

destroySyncAgent_t* destroySyncAgent =
(destroySyncAgent_t*) QLibrary::resolve("libmeegosyncml.so",
(destroySyncAgent_t*) QLibrary::resolve("libbuteosyncml.so",
"destroySyncAgent");
QVERIFY(NULL != destroySyncAgent);
destroySyncAgent(agent);
Expand Down
2 changes: 1 addition & 1 deletion tests_meego/clienttests/ClientSessionHandlerTest.cpp
Expand Up @@ -51,7 +51,7 @@ void ClientSessionHandlerTest::initTestCase()
iDbHandler = new DatabaseHandler( "/tmp/clientsessionhandler.db");
iClientId = QString("clientId");
iConfig = new SyncAgentConfig();
iTransport = new MockTransport(QString("testfiles/transport_initrequest_nohdr.txt"));
iTransport = new MockTransport(QString("data/transport_initrequest_nohdr.txt"));
iConfig->setTransport(iTransport);
const SyncAgentConfig *tempConstConfig = iConfig;
iHandler = new ClientSessionHandler(tempConstConfig);
Expand Down
14 changes: 1 addition & 13 deletions tests_meego/runstarget.sh
Expand Up @@ -11,16 +11,4 @@ FILE=${1##*/}

cd /opt/tests/buteo-syncml

${1} -maxwarnings 0 1>/tmp/$FILE.out 2>&1
RESULT=$?

echo "$RESULT is return value of executing ${1}" >> /tmp/$FILE.out

grep "Totals:" /tmp/$FILE.out >/tmp/$FILE.cmp
grep -E "PASS|FAIL|Totals:|Start testing|Finished testing" /tmp/$FILE.out >/tmp/$FILE.detailed
echo "Test finished with return value $RESULT. Summary can be found in /tmp/$FILE.cmp"

# Exit with the same code as the test binary
#exit $RESULT
# Exit always with zero until problems in CI environment are resolved
exit 0
exec ${1} -maxwarnings 0
2 changes: 1 addition & 1 deletion tests_meego/servertests/ServerSessionHandlerTest.cpp
Expand Up @@ -53,7 +53,7 @@ void ServerSessionHandlerTest::initTestCase()
iConfig = new SyncAgentConfig();
QString localDb = "localcontacts";
iStorage = new MockStorage( localDb );
iTransport = new MockTransport(QString("testfiles/transport_initrequest_nohdr.txt"));
iTransport = new MockTransport(QString("data/transport_initrequest_nohdr.txt"));
iConfig->setTransport(iTransport);
const SyncAgentConfig *tempConstConfig = iConfig;
iHandler = new ServerSessionHandler(tempConstConfig);
Expand Down
4 changes: 2 additions & 2 deletions tests_meego/syncelementstests/SyncMLAddTest.cpp
Expand Up @@ -41,9 +41,9 @@ using namespace DataSync;
//QString add QString(
void SyncMLAddTest::testSyncMLAdd() {
SyncMLAdd add(10);
QFile toXMLfile("testfiles/testAdd.txt");
QFile toXMLfile("data/testAdd.txt");
if(!toXMLfile.open(QIODevice::ReadOnly)) {
QFAIL("Failed to open the file testfiles/testAlert.txt");
QFAIL("Failed to open the file data/testAlert.txt");
} else {

QtEncoder encoder;
Expand Down
2 changes: 1 addition & 1 deletion tests_meego/syncelementstests/SyncMLAlertTest.cpp
Expand Up @@ -61,7 +61,7 @@ void SyncMLAlertTest::testSyncMLAlert()
SyncMLAlert alert(alertParams);

QByteArray expected;
QVERIFY( readFile( "testfiles/testAlert.txt", expected ) );
QVERIFY( readFile( "data/testAlert.txt", expected ) );

QtEncoder encoder;
QByteArray output;
Expand Down
2 changes: 1 addition & 1 deletion tests_meego/syncelementstests/SyncMLDevInfTest.cpp
Expand Up @@ -50,7 +50,7 @@ void SyncMLDevInfTest::testSyncMLDevInf() {
SyncMLDevInf devInf( pluginList, devInfo, SYNCML_1_2, ROLE_CLIENT);

QByteArray expected;
QVERIFY( readFile("testfiles/testDevInf.txt", expected ) );
QVERIFY( readFile("data/testDevInf.txt", expected ) );
QtEncoder encoder;
QByteArray output;
QVERIFY( encoder.encodeToXML( devInf, output, true ) );
Expand Down
4 changes: 2 additions & 2 deletions tests_meego/syncelementstests/SyncMLHdrTest.cpp
Expand Up @@ -57,7 +57,7 @@ void SyncMLHdrTest::testSyncMLHdr_11()
SyncMLHdr hdr(headerParams);

QByteArray expected;
QVERIFY( readFile( "testfiles/SyncMLHdrTest_11.txt", expected ) );
QVERIFY( readFile( "data/SyncMLHdrTest_11.txt", expected ) );
QtEncoder encoder;
QByteArray output;
QVERIFY( encoder.encodeToXML( hdr, output, true ) );
Expand All @@ -79,7 +79,7 @@ void SyncMLHdrTest::testSyncMLHdr_12()
SyncMLHdr hdr(headerParams);

QByteArray expected;
QVERIFY( readFile( "testfiles/SyncMLHdrTest.txt", expected ) );
QVERIFY( readFile( "data/SyncMLHdrTest.txt", expected ) );
QtEncoder encoder;
QByteArray output;
QVERIFY( encoder.encodeToXML( hdr, output, true ) );
Expand Down
2 changes: 1 addition & 1 deletion tests_meego/syncelementstests/SyncMLItemTest.cpp
Expand Up @@ -60,7 +60,7 @@ void SyncMLItemTest::testSyncMLItem()

QByteArray data;

QVERIFY( readFile("testfiles/testItem.txt", data ) );
QVERIFY( readFile("data/testItem.txt", data ) );

QtEncoder encoder;
QByteArray output;
Expand Down
22 changes: 11 additions & 11 deletions tests_meego/syncelementstests/SyncMLMessageParserTest.cpp
Expand Up @@ -51,7 +51,7 @@ void SyncMLMessageParserTest::testResp1()

QByteArray data;

QVERIFY( readFile( "testfiles/resp.txt", data ) );
QVERIFY( readFile( "data/resp.txt", data ) );

QBuffer buffer(&data );
QVERIFY( buffer.open( QIODevice::ReadOnly ) );
Expand Down Expand Up @@ -198,37 +198,37 @@ void SyncMLMessageParserTest::testInvalid1()
QSignalSpy errorSpy( &parser, SIGNAL(parsingError(DataSync::ParserError)) );

QByteArray data;
QVERIFY( readFile( "testfiles/respinvalid1.txt", data ) );
QVERIFY( readFile( "data/respinvalid1.txt", data ) );
QBuffer buffer(&data );
QVERIFY( buffer.open( QIODevice::ReadOnly ) );
parser.parseResponse( &buffer, true );
buffer.close();

QVERIFY( readFile( "testfiles/respinvalid2.txt", data ) );
QVERIFY( readFile( "data/respinvalid2.txt", data ) );
buffer.setBuffer(&data);
QVERIFY( buffer.open( QIODevice::ReadOnly ) );
parser.parseResponse( &buffer, true );
buffer.close();

QVERIFY( readFile( "testfiles/respinvalid3.txt", data ) );
QVERIFY( readFile( "data/respinvalid3.txt", data ) );
buffer.setBuffer(&data);
QVERIFY( buffer.open( QIODevice::ReadOnly ) );
parser.parseResponse( &buffer, true );
buffer.close();

QVERIFY( readFile( "testfiles/respinvalid4.txt", data ) );
QVERIFY( readFile( "data/respinvalid4.txt", data ) );
buffer.setBuffer(&data);
QVERIFY( buffer.open( QIODevice::ReadOnly ) );
parser.parseResponse( &buffer, true );
buffer.close();

QVERIFY( readFile( "testfiles/respinvalid5.txt", data ) );
QVERIFY( readFile( "data/respinvalid5.txt", data ) );
buffer.setBuffer(&data);
QVERIFY( buffer.open( QIODevice::ReadOnly ) );
parser.parseResponse( &buffer, true );
buffer.close();

QVERIFY( readFile( "testfiles/respinvalid6.txt", data ) );
QVERIFY( readFile( "data/respinvalid6.txt", data ) );
buffer.setBuffer(&data);
QVERIFY( buffer.open( QIODevice::ReadOnly ) );
parser.parseResponse( &buffer, true );
Expand Down Expand Up @@ -269,7 +269,7 @@ void SyncMLMessageParserTest::verifyDelete( const DataSync::CommandParams& aData
void SyncMLMessageParserTest::testDevInf11()
{
QByteArray data;
QVERIFY( readFile( "testfiles/devinf01.txt", data ) );
QVERIFY( readFile( "data/devinf01.txt", data ) );
QBuffer buffer( &data );
buffer.open( QIODevice::ReadOnly );
buffer.seek( 0 );
Expand Down Expand Up @@ -367,7 +367,7 @@ void SyncMLMessageParserTest::testDevInf11()
void SyncMLMessageParserTest::testDevInf12()
{
QByteArray data;
QVERIFY( readFile( "testfiles/devinf02.txt", data ) );
QVERIFY( readFile( "data/devinf02.txt", data ) );
QBuffer buffer( &data );
buffer.open( QIODevice::ReadOnly );
buffer.seek( 0 );
Expand Down Expand Up @@ -471,7 +471,7 @@ void SyncMLMessageParserTest::testDevInf12()
void SyncMLMessageParserTest::testSubcommands()
{
QByteArray data;
QVERIFY( readFile( "testfiles/subcommands01.txt", data ) );
QVERIFY( readFile( "data/subcommands01.txt", data ) );
QBuffer buffer( &data );
buffer.open( QIODevice::ReadOnly );
buffer.seek( 0 );
Expand Down Expand Up @@ -530,7 +530,7 @@ void SyncMLMessageParserTest::testSubcommands()
void SyncMLMessageParserTest::testEmbeddedXML()
{
QByteArray data;
QVERIFY( readFile( "testfiles/resp2.txt", data ) );
QVERIFY( readFile( "data/resp2.txt", data ) );
QBuffer buffer( &data );
buffer.open( QIODevice::ReadOnly );
buffer.seek( 0 );
Expand Down
12 changes: 1 addition & 11 deletions tests_meego/tests.xml
Expand Up @@ -5,21 +5,11 @@
<!-- At least one set per suite, name and description mandatory -->
<set name="SyncmlStack " description="tests for syncml-stack" feature="Sync ML 1.1">

<pre_steps>
<step>export LD_LIBRARY_PATH=/opt/tests/buteo-syncml:$LD_LIBRARY_PATH</step>
</pre_steps>

<case name="libmeegosyncml-all" type="Functional" description="Running Tests for Syncml Stack" timeout="1000" subfeature="">
<!-- At least one step per test, expected_result optional - tells which return code is considered passed -->
<step expected_result="0">/opt/tests/buteo-syncml/runstarget.sh /opt/tests/buteo-syncml/libmeegosyncml-tests</step>
<step expected_result="0">/opt/tests/buteo-syncml/runstarget.sh /opt/tests/buteo-syncml/libbuteosyncml-tests</step>
</case>

<!-- Get optional - fetches additional result files -->
<get>
<file>/tmp/libmeegosyncml-tests.out</file>
<file>/tmp/libmeegosyncml-tests.detailed</file>
<file>/tmp/libmeegosyncml-tests.cmp</file>
</get>
</set>
</suite>
</testdefinition>

0 comments on commit 1603b51

Please sign in to comment.