added memory testing

This commit is contained in:
Fournier Nicolas 2015-08-06 15:13:37 +02:00
parent c1ff80a106
commit 7288765704

View File

@ -20,6 +20,7 @@
*/ */
#include "platform.h" #include "platform.h"
#include "perf_taler_mintdb_interpreter.h" #include "perf_taler_mintdb_interpreter.h"
#include "perf_taler_mintdb_init.h"
#define NB_DENOMINATION_INIT 2 #define NB_DENOMINATION_INIT 2
@ -34,6 +35,39 @@
#define NB_WITHDRAW_INIT 1 #define NB_WITHDRAW_INIT 1
#define NB_WITHDRAW_SAVE 1 #define NB_WITHDRAW_SAVE 1
/**
* Allocate, copies and free all the data used in the interpreter
* Used to check for memory leaks
*/
void
test_alocate ()
{
struct TALER_MINTDB_DenominationKeyIssueInformation *dki, *dki_copy;
struct PERF_TALER_MINTDB_Reserve *reserve, *reserve_copy;
struct PERF_TALER_MINTDB_Coin *coin, *coin_copy;
struct TALER_MINTDB_Deposit *deposit, *deposit_copy;
dki = PERF_TALER_MINTDB_denomination_init ();
reserve = PERF_TALER_MINTDB_reserve_init ();
coin = PERF_TALER_MINTDB_coin_init (dki,
reserve);
deposit = PERF_TALER_MINTDB_deposit_init (coin);
dki_copy = PERF_TALER_MINTDB_denomination_copy (dki);
reserve_copy = PERF_TALER_MINTDB_reserve_copy (reserve);
coin_copy = PERF_TALER_MINTDB_coin_copy (coin);
deposit_copy = PERF_TALER_MINTDB_deposit_copy (deposit);
PERF_TALER_MINTDB_denomination_free (dki);
PERF_TALER_MINTDB_denomination_free (dki_copy);
PERF_TALER_MINTDB_reserve_free (reserve);
PERF_TALER_MINTDB_reserve_free (reserve_copy);
PERF_TALER_MINTDB_coin_free (coin);
PERF_TALER_MINTDB_coin_free (coin_copy);
PERF_TALER_MINTDB_deposit_free (deposit);
PERF_TALER_MINTDB_deposit_free (deposit_copy);
}
/** /**
* Runs the performances tests for the mint database * Runs the performances tests for the mint database
* and logs the results using Gauger * and logs the results using Gauger
@ -41,7 +75,7 @@
int int
main (int argc, char ** argv) main (int argc, char ** argv)
{ {
int ret; int ret = 0;
struct PERF_TALER_MINTDB_Cmd init[] = struct PERF_TALER_MINTDB_Cmd init[] =
{ {
PERF_TALER_MINTDB_INIT_CMD_END ("init") PERF_TALER_MINTDB_INIT_CMD_END ("init")
@ -128,11 +162,11 @@ main (int argc, char ** argv)
PERF_TALER_MINTDB_INIT_CMD_END ("end"), PERF_TALER_MINTDB_INIT_CMD_END ("end"),
}; };
test_alocate ();
ret = PERF_TALER_MINTDB_run_benchmark ("perf-taler-mintdb", ret = PERF_TALER_MINTDB_run_benchmark ("perf-taler-mintdb",
"./test-mint-db-postgres.conf", "./test-mint-db-postgres.conf",
init, init,
benchmark); benchmark);
if (GNUNET_SYSERR == ret) if (GNUNET_SYSERR == ret)
return 1; return 1;
return 0; return 0;