Add a possibility to run tests under callgrind
Flag 'use_callgrind' make all maxscale-system-test run Maxscale under Valgrind with --tool=callgrind option
This commit is contained in:
@ -4,17 +4,16 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "envv.h"
|
#include "envv.h"
|
||||||
|
|
||||||
Maxscales::Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind,
|
Maxscales::Maxscales(const char *pref, const char *test_cwd, bool verbose,
|
||||||
std::string network_config)
|
std::string network_config)
|
||||||
{
|
{
|
||||||
strcpy(prefix, pref);
|
strcpy(prefix, pref);
|
||||||
this->verbose = verbose;
|
this->verbose = verbose;
|
||||||
this->use_valgrind = use_valgrind;
|
|
||||||
valgring_log_num = 0;
|
valgring_log_num = 0;
|
||||||
strcpy(test_dir, test_cwd);
|
strcpy(test_dir, test_cwd);
|
||||||
this->network_config = network_config;
|
this->network_config = network_config;
|
||||||
read_env();
|
read_env();
|
||||||
if (use_valgrind)
|
if (this->use_valgrind)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < N; i++)
|
for (int i = 0; i < N; i++)
|
||||||
{
|
{
|
||||||
@ -61,6 +60,13 @@ int Maxscales::read_env()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use_valgrind = readenv_bool("use_valgrind", false);
|
||||||
|
use_callgrind = readenv_bool("use_callgrind", false);
|
||||||
|
if (use_callgrind)
|
||||||
|
{
|
||||||
|
use_valgrind = true;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,11 +216,24 @@ int Maxscales::start_maxscale(int m)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
if (use_valgrind)
|
if (use_valgrind)
|
||||||
|
{
|
||||||
|
if (use_callgrind)
|
||||||
|
{
|
||||||
|
res = ssh_node_f(m, false,
|
||||||
|
"sudo --user=maxscale valgrind -d "
|
||||||
|
"--log-file=/%s/valgrind%02d.log --trace-children=yes "
|
||||||
|
" --tool=callgrind --callgrind-out-file=/%s/callgrind%02d.log "
|
||||||
|
" /usr/bin/maxscale",
|
||||||
|
maxscale_log_dir[m], valgring_log_num,
|
||||||
|
maxscale_log_dir[m], valgring_log_num);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
res = ssh_node_f(m, false,
|
res = ssh_node_f(m, false,
|
||||||
"sudo --user=maxscale valgrind --leak-check=full --show-leak-kinds=all "
|
"sudo --user=maxscale valgrind --leak-check=full --show-leak-kinds=all "
|
||||||
"--log-file=/%s/valgrind%02d.log --trace-children=yes "
|
"--log-file=/%s/valgrind%02d.log --trace-children=yes "
|
||||||
"--track-origins=yes /usr/bin/maxscale", maxscale_log_dir[m], valgring_log_num);
|
"--track-origins=yes /usr/bin/maxscale", maxscale_log_dir[m], valgring_log_num);
|
||||||
|
}
|
||||||
valgring_log_num++;
|
valgring_log_num++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public:
|
|||||||
READCONN_SLAVE
|
READCONN_SLAVE
|
||||||
};
|
};
|
||||||
|
|
||||||
Maxscales(const char *pref, const char *test_cwd, bool verbose, bool use_valgrind,
|
Maxscales(const char *pref, const char *test_cwd, bool verbose,
|
||||||
std::string network_config);
|
std::string network_config);
|
||||||
|
|
||||||
int read_env();
|
int read_env();
|
||||||
@ -338,6 +338,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool use_valgrind;
|
bool use_valgrind;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief use_callgrind if true Maxscale will be executed under Valgrind with
|
||||||
|
* --callgrind option
|
||||||
|
*/
|
||||||
|
bool use_callgrind;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief valgring_log_num Counter for Maxscale restarts to avoid Valgrind log overwriting
|
* @brief valgring_log_num Counter for Maxscale restarts to avoid Valgrind log overwriting
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -127,7 +127,6 @@ TestConnections::TestConnections(int argc, char* argv[])
|
|||||||
, no_vm_revert(true)
|
, no_vm_revert(true)
|
||||||
, threads(4)
|
, threads(4)
|
||||||
, use_ipv6(false)
|
, use_ipv6(false)
|
||||||
, use_valgrind(false)
|
|
||||||
{
|
{
|
||||||
std::ios::sync_with_stdio(true);
|
std::ios::sync_with_stdio(true);
|
||||||
signal_set(SIGSEGV, sigfatal_handler);
|
signal_set(SIGSEGV, sigfatal_handler);
|
||||||
@ -372,7 +371,7 @@ TestConnections::TestConnections(int argc, char* argv[])
|
|||||||
galera = NULL;
|
galera = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
maxscales = new Maxscales("maxscale", test_dir, verbose, use_valgrind, network_config);
|
maxscales = new Maxscales("maxscale", test_dir, verbose, network_config);
|
||||||
|
|
||||||
bool maxscale_ok = maxscales->check_nodes();
|
bool maxscale_ok = maxscales->check_nodes();
|
||||||
bool repl_ok = no_repl || repl_future.get();
|
bool repl_ok = no_repl || repl_future.get();
|
||||||
@ -502,7 +501,7 @@ TestConnections::~TestConnections()
|
|||||||
// galera->disable_ssl();
|
// galera->disable_ssl();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_valgrind)
|
if (maxscales->use_valgrind)
|
||||||
{
|
{
|
||||||
// stop all Maxscales to get proper Valgrind logs
|
// stop all Maxscales to get proper Valgrind logs
|
||||||
for (int i = 0; i < maxscales->N; i++)
|
for (int i = 0; i < maxscales->N; i++)
|
||||||
@ -665,7 +664,6 @@ void TestConnections::read_env()
|
|||||||
revert_snapshot_command = readenv("revert_snapshot_command",
|
revert_snapshot_command = readenv("revert_snapshot_command",
|
||||||
"mdbci snapshot revert --path-to-nodes %s --snapshot-name ", mdbci_config_name);
|
"mdbci snapshot revert --path-to-nodes %s --snapshot-name ", mdbci_config_name);
|
||||||
no_vm_revert = readenv_bool("no_vm_revert", true);
|
no_vm_revert = readenv_bool("no_vm_revert", true);
|
||||||
use_valgrind = readenv_bool("use_valgrind", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestConnections::print_env()
|
void TestConnections::print_env()
|
||||||
@ -1459,7 +1457,7 @@ int TestConnections::find_connected_slave1(int m)
|
|||||||
|
|
||||||
int TestConnections::check_maxscale_processes(int m, int expected)
|
int TestConnections::check_maxscale_processes(int m, int expected)
|
||||||
{
|
{
|
||||||
const char* ps_cmd = use_valgrind ?
|
const char* ps_cmd = maxscales->use_valgrind ?
|
||||||
"ps ax | grep valgrind | grep maxscale | grep -v grep | wc -l" :
|
"ps ax | grep valgrind | grep maxscale | grep -v grep | wc -l" :
|
||||||
"ps -C maxscale | grep maxscale | wc -l";
|
"ps -C maxscale | grep maxscale | wc -l";
|
||||||
|
|
||||||
|
|||||||
@ -686,11 +686,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
int call_mdbci(const char *options);
|
int call_mdbci(const char *options);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief use_valrind if true Maxscale will be executed under Valgrind
|
|
||||||
*/
|
|
||||||
bool use_valgrind;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief resinstall_maxscales Remove Maxscale form all nodes and installs new ones
|
* @brief resinstall_maxscales Remove Maxscale form all nodes and installs new ones
|
||||||
* (to be used for run_test_snapshot)
|
* (to be used for run_test_snapshot)
|
||||||
|
|||||||
Reference in New Issue
Block a user