libpEpAdapter/test/test_adapter.cc

54 lines
1.3 KiB
C++
Raw Normal View History

2018-10-04 18:12:53 +02:00
// This file is under GNU General Public License 3.0
// see LICENSE.txt
2020-08-12 18:20:25 +02:00
#include "framework.hh"
2018-10-04 18:05:51 +02:00
#include <iostream>
#include <assert.h>
#include <unistd.h>
2020-08-05 17:57:10 +02:00
#include <sys/param.h>
2018-10-04 18:34:00 +02:00
#include <pEp/keymanagement.h>
#include "pEpLog.hh"
2018-10-04 18:05:51 +02:00
using namespace std;
2018-10-05 08:46:40 +02:00
using namespace pEp::Adapter;
2018-10-04 18:05:51 +02:00
PEP_STATUS messageToSend(struct _message *msg)
{
pEpLog("called()");
2018-10-04 18:05:51 +02:00
return PEP_STATUS_OK;
}
PEP_STATUS notifyHandshake(pEp_identity *me, pEp_identity *partner, sync_handshake_signal signal)
2018-10-04 18:05:51 +02:00
{
pEpLog("called()");
2018-10-04 18:05:51 +02:00
return PEP_STATUS_OK;
}
2020-08-12 19:52:57 +02:00
int main(int argc, char **argv)
2018-10-04 18:05:51 +02:00
{
2020-08-12 19:52:57 +02:00
pEp::Test::setup(argc, argv);
2020-08-05 17:57:10 +02:00
// Create new identity
pEpLog("updating or creating identity for me");
2018-10-04 18:34:00 +02:00
pEp_identity *me = new_identity("alice@peptest.ch", NULL, "23", "Who the F* is Alice");
assert(me);
2018-10-05 08:46:40 +02:00
PEP_STATUS status = myself(session(), me);
free_identity(me);
2018-10-05 08:49:22 +02:00
pEp::throw_status(status);
2018-10-04 18:34:00 +02:00
// start and stop sync repeatedly
useconds_t sleepuSec = 1000 * 100;
unsigned long long int nrIters = 1000 * 1000 * 1000;
for (int i = 0; i < nrIters; i++) {
pEpLog("RUN NR: ");
pEpLog(i);
pEpLog("SYNC START");
pEpLog("starting the adapter including sync");
startup(messageToSend, notifyHandshake);
pEpLog("SYNC STOP");
usleep(sleepuSec);
shutdown();
}
2018-10-04 18:05:51 +02:00
return 0;
}