20 #include <ndb_global.h>
21 #include "../CpcClient.hpp"
34 #define ABORT() {ndbout_c("ABORT"); while(true); abort();}
44 for(
int i = 0;
i<1000;
i++){
45 int sz = g_procs.size();
46 int test = rand() % 100;
47 if(sz == 0 || test < 10){
54 int proc = rand() % g_procs.size();
56 if(p.m_status ==
"running" && test > 50){
57 ndbout_c(
"undefine %d: %s (running)", p.m_id, p.m_name.
c_str());
62 if(p.m_status ==
"running" && test <= 50){
63 ndbout_c(
"stop %d: %s(running)", p.m_id, p.m_name.
c_str());
67 if(p.m_status ==
"stopped" && test > 50){
68 ndbout_c(
"undefine %d: %s(stopped)", p.m_id, p.m_name.
c_str());
73 if(p.m_status ==
"stopped" && test <= 50){
74 ndbout_c(
"start %d %s(stopped)", p.m_id, p.m_name.
c_str());
78 ndbout_c(
"Unknown: %s", p.m_status.
c_str());
85 m_proc.m_type =
"temporary";
86 m_proc.m_owner =
"atrt";
87 m_proc.m_group =
"group";
93 m_proc.m_ulimit =
"c:unlimited";
94 if((rand() & 15) >= 0){
95 m_proc.m_name.
assfmt(
"%d-%d-%s", getpid(),
name++,
"sleep");
96 m_proc.m_path.
assign(
"/bin/sleep");
97 m_proc.m_args =
"600";
99 m_proc.m_name.
assfmt(
"%d-%d-%s", getpid(),
name++,
"test.sh");
100 m_proc.m_path.
assign(
"/home/jonas/run/cpcd/test.sh");
101 m_proc.m_args =
"600";
103 g_procs.push_back(m_proc);
106 if(g_client.define_process(g_procs.back(), reply) != 0){
107 ndbout_c(
"define %s -> ERR", m_proc.m_name.
c_str());
111 ndbout_c(
"define %s -> %d", m_proc.m_name.
c_str(), m_proc.m_id);
116 if(g_client.start_process(p.m_id, reply) != 0){
124 if(g_client.stop_process(p.m_id, reply) != 0){
132 if(g_client.undefine_process(p.m_id, reply) != 0){
141 if(g_client.list_processes(procs, reply) != 0){
146 for(Uint32
i = 0;
i<procs.size();
i++){
149 p->m_status = procs[
i].m_status;
154 for(Uint32
i = 0;
i<g_procs.size();
i++){
155 if(g_procs[
i].m_id ==
id)