Rewrite maxscale_process_user
Changed output format to be more robust and used stack allocated objects instead of heap allocated ones.
This commit is contained in:
@ -1,37 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* @file maxscale_process_user.cpp bug143 maxscale_process_user check if Maxscale priocess is running as
|
* Check if Maxscale priocess is running as 'maxscale'
|
||||||
*'maxscale'
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include "testconnections.h"
|
#include "testconnections.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
TestConnections* Test = new TestConnections(argc, argv);
|
TestConnections test(argc, argv);
|
||||||
int exit_code;
|
|
||||||
|
|
||||||
Test->set_timeout(50);
|
test.set_timeout(50);
|
||||||
char* user = Test->maxscales->ssh_node_output(0,
|
auto res = test.maxscales->ssh_output("ps -U maxscale -C maxscale -o user --no-headers").second;
|
||||||
"ps -FC maxscale|tail -n 1|cut -f 1 -d \" \"",
|
res = res.substr(0, strlen("maxscale"));
|
||||||
false,
|
test.expect(res == "maxscale", "MaxScale running as '%s' instead of 'maxscale'", res.c_str());
|
||||||
&exit_code);
|
|
||||||
char* nl = user ? strchr(user, '\n') : NULL;
|
|
||||||
|
|
||||||
if (nl)
|
return test.global_result;
|
||||||
{
|
|
||||||
*nl = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
Test->tprintf("MaxScale is running as '%s'", user);
|
|
||||||
Test->add_result(strcmp(user, "maxscale"),
|
|
||||||
"MaxScale process running as '%s' instead of 'maxscale'\n",
|
|
||||||
user);
|
|
||||||
|
|
||||||
int rval = Test->global_result;
|
|
||||||
delete Test;
|
|
||||||
return rval;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user