int main(int argc, char *argv[]) { bool client = false; int event_len; int ferr; int inx; int len; int lerr; int linx; int loop = 10; int msgid; int oid; TPT_DECL (phandle); RT results; int send_len; int srv_nid = -1; int srv_pid = -1; MS_SRE sre; TAD zargs[] = { { "-client", TA_Bool, TA_NOMAX, &client }, { "-loop", TA_Int, TA_NOMAX, &loop }, { "-server", TA_Ign, TA_NOMAX, NULL }, { "", TA_End, TA_NOMAX, NULL } }; msfs_util_init(&argc, &argv, msg_debug_hook); arg_proc_args(zargs, false, argc, argv); util_test_start(client); ferr = msg_mon_process_startup(!client); // system messages? TEST_CHK_FEOK(ferr); if (client) { ferr = msg_mon_open_process((char *) "$srv", // name TPT_REF(phandle), &oid); TEST_CHK_FEOK(ferr); ferr = msg_mon_get_process_info((char *) "$srv", &srv_nid, &srv_pid); TEST_CHK_FEOK(ferr); } util_gethostname(my_name, sizeof(my_name)); msg_mon_enable_mon_messages(true); for (inx = 0; inx < MS_MON_MAX_SYNC_DATA; inx++) event_data[inx] = (char) (inx + 1); for (inx = 0; inx < loop; inx++) { if (client) { sprintf(send_buffer, "hello, greetings from %s, inx=%d", my_name, inx); send_len = (int) strlen(send_buffer) + 1; ferr = XMSG_LINK_(TPT_REF(phandle), // phandle &msgid, // msgid send_buffer2, // reqctrl (ushort) (inx & 1), // reqctrlsize recv_buffer3, // replyctrl 1, // replyctrlmax send_buffer, // reqdata (ushort) send_len, // reqdatasize recv_buffer, // replydata BUFSIZ, // replydatamax 0, // linkertag 0, // pri 0, // xmitclass 0); // linkopts util_check("XMSG_LINK_", ferr); lerr = XWAIT(LDONE, 10); TEST_CHK_WAITIGNORE(lerr); assert(!XMSG_ISDONE_(msgid)); ferr = msg_mon_event_send(srv_nid, // nid srv_pid, // pid MS_ProcessType_Undefined, // process-type inx, // event-id inx % MS_MON_MAX_SYNC_DATA, // event-len event_data); // event-data TEST_CHK_FEOK(ferr); ferr = XMSG_BREAK_(msgid, results.u.s, TPT_REF(phandle)); util_check("XMSG_BREAK_", ferr); assert(results.u.t.ctrl_size == (uint) (inx & 1)); assert(results.u.t.data_size > (strlen(send_buffer) + 14)); assert(results.u.t.errm == RT_DATA_RCVD); // data printf("%s\n", recv_buffer); } else { do { lerr = XWAIT(LREQ, -1); lerr = XMSG_LISTEN_((short *) &sre, // sre 0, // listenopts 0); // listenertag } while (lerr == XSRETYPE_NOWORK); ferr = XMSG_READCTRL_(sre.sre_msgId, // msgid recv_buffer2, // reqctrl 1); // bytecount util_check("XMSG_READCTRL_", ferr); ferr = XMSG_READDATA_(sre.sre_msgId, // msgid recv_buffer, // reqdata BUFSIZ); // bytecount util_check("XMSG_READDATA_", ferr); if (sre.sre_flags & XSRE_MON) { printf("server received mon message\n"); inx--; len = 0; } else { memset(event_data, 0, sizeof(event_data)); ferr = msg_mon_event_wait(inx, &event_len, event_data); TEST_CHK_FEOK(ferr); assert(event_len == (inx % MS_MON_MAX_SYNC_DATA)); for (linx = 0; linx < event_len; linx++) assert(event_data[linx] == (linx + 1)); strcat(recv_buffer, "- reply from "); strcat(recv_buffer, my_name); len = (int) strlen(recv_buffer) + 1; } XMSG_REPLY_(sre.sre_msgId, // msgid recv_buffer2, // replyctrl sre.sre_reqCtrlSize, // replyctrlsize recv_buffer, // replydata (ushort) len, // replydatasize 0, // errorclass NULL); // newphandle } } if (client) { ferr = msg_mon_close_process(TPT_REF(phandle)); TEST_CHK_FEOK(ferr); } else { ferr = msg_mon_process_close(); TEST_CHK_FEOK(ferr); } ferr = msg_mon_process_shutdown(); TEST_CHK_FEOK(ferr); util_test_finish(client); return 0; }
int main(int argc, char *argv[]) { bool client = false; unsigned expR3; int ferr; int inx; int lc; int lerr; int msgid; int oid; RT results; TPT_DECL (phandle); MS_SRE sre; TAD zargs[] = { { "-client", TA_Bool, TA_NOMAX, &client }, { "-server", TA_Ign, TA_NOMAX, NULL }, { "", TA_End, TA_NOMAX, NULL } }; msfs_util_init(&argc, &argv, msg_debug_hook); arg_proc_args(zargs, false, argc, argv); util_test_start(client); ferr = msg_mon_process_startup(!client); // system messages TEST_CHK_FEOK(ferr); if (client) { ferr = msg_mon_open_process((char *) "$srv", // name TPT_REF(phandle), &oid); TEST_CHK_FEOK(ferr); } util_gethostname(my_name, sizeof(my_name)); lc = (int) (sizeof(res)/sizeof(Test_Results)); for (inx = 0; inx < lc; inx++) { if (client) { sprintf(send_buffer, "hello, greetings from %s, inx=%d", my_name, inx); ferr = XMSG_LINK_(TPT_REF(phandle), // phandle &msgid, // msgid ctrl_buffer, // reqctrl res[inx].cQc, // reqctrlsize ctrl_buffer, // replyctrl res[inx].cPcM, // replyctrlmax send_buffer, // reqdata res[inx].cQd, // reqdatasize recv_buffer, // replydata res[inx].cPdM, // replydatamax 0, // linkertag 0, // pri 0, // xmitclass 0); // linkopts util_check("XMSG_LINK_", ferr); // ferr = XMSG_ISDONE_(msgid); // checkdone("XMSG_ISDONE_", ferr); results.u.t.ctrl_size = (uint) -1; results.u.t.data_size = (uint) -1; results.u.t.errm = (uint) -1; ferr = XMSG_BREAK_(msgid, results.u.s, TPT_REF(phandle)); util_check("XMSG_BREAK_", ferr); if (results.u.t.ctrl_size != res[inx].cEpC) { printf("*** ERROR inx=%d, results.ctrl_size=%d, cEpC=%d\n", inx, (int) results.u.t.ctrl_size, (int) res[inx].cEpC); assert(results.u.t.ctrl_size == res[inx].cEpC); } if (results.u.t.data_size != (uint) res[inx].cEpD) { printf("*** ERROR inx=%d, results.data_size=%d, cEpD=%d\n", inx, (int) results.u.t.data_size, (int) res[inx].cEpD); assert(results.u.t.data_size == res[inx].cEpD); } expR3 = 0x0; // no-data if (res[inx].cEpD > 0) expR3 |= 0x2; // data if (results.u.t.errm != expR3) { printf("*** ERROR inx=%d, results.errm=%x, expR3=%x\n", inx, results.u.t.errm, expR3); assert(results.u.t.errm == expR3); } } else { do { lerr = XWAIT(LREQ, -1); TEST_CHK_WAITIGNORE(lerr); lerr = XMSG_LISTEN_((short *) &sre, // sre 0, // listenopts 0); // listenertag } while (lerr == XSRETYPE_NOWORK); if (sre.sre_reqCtrlSize != res[inx].sEqC) { printf("*** ERROR inx=%d, sre.sre_reqCtrlSize=%d, sEqC=%d\n", inx, sre.sre_reqCtrlSize, res[inx].sEqC); assert(sre.sre_reqCtrlSize == res[inx].sEqC); } if (sre.sre_reqDataSize != res[inx].sEqD) { printf("*** ERROR inx=%d, sre.sre_reqDataSize=%d, sEqD=%d\n", inx, sre.sre_reqDataSize, res[inx].sEqD); assert(sre.sre_reqDataSize == res[inx].sEqD); } ferr = XMSG_READCTRL_(sre.sre_msgId, // msgid ctrl_buffer, // reqctrl res[inx].sQc); // bytecount util_check("XMSG_READCTRL_", ferr); ferr = XMSG_READDATA_(sre.sre_msgId, // msgid recv_buffer, // reqdata res[inx].sQd); // bytecount util_check("XMSG_READDATA_", ferr); XMSG_REPLY_(sre.sre_msgId, // msgid (short *) recv_buffer, // replyctrl res[inx].sPc, // replyctrlsize recv_buffer, // replydata res[inx].sPd, // replydatasize 0, // errorclass NULL); // newphandle } } if (client) { ferr = msg_mon_close_process(TPT_REF(phandle)); TEST_CHK_FEOK(ferr); printf("if there were no asserts, all is well\n"); } ferr = msg_mon_process_shutdown(); TEST_CHK_FEOK(ferr); util_test_finish(client); return 0; }
int main(int argc, char *argv[]) { int exit; int ferr; bool ldone; int lerr; int msgid; int nid; int oid; int pid; TPT_DECL (phandle); char recv_buffer[BUFSIZ]; short recv_buffer2[BUFSIZ]; RT results; MS_SRE sre; MS_Mon_Transid_Type transid; ferr = msfs_util_init_role(true, &argc, &argv, msg_debug_hook); TEST_CHK_FEOK(ferr); util_test_start(true); ferr = msg_mon_process_startup(true); // system messages TEST_CHK_FEOK(ferr); msg_mon_enable_mon_messages(true); ferr = msg_mon_get_process_info((char *) "$srv", &nid, &pid); TEST_CHK_FEOK(ferr); ferr = msg_mon_open_process((char *) "$srv", // name TPT_REF(phandle), &oid); TEST_CHK_FEOK(ferr); TRANSID_SET_NULL(transid); ferr = msg_mon_deregister_death_notification(nid, pid, transid); TEST_CHK_FEOK(ferr); ferr = msg_mon_register_death_notification(nid, pid); TEST_CHK_FEOK(ferr); ferr = XMSG_LINK_(TPT_REF(phandle), // phandle &msgid, // msgid NULL, // reqctrl 0, // reqctrlsize recv_buffer2, // replyctrl 1, // replyctrlmax NULL, // reqdata 0, // reqdatasize recv_buffer, // replydata BUFSIZ, // replydatamax 0, // linkertag 0, // pri 0, // xmitclass XMSG_LINK_LDONEQ); // linkopts util_check("XMSG_LINK_", ferr); exit = 0; ldone = false; while (!exit) { do { lerr = XWAIT(LREQ|LDONE, -1); TEST_CHK_WAITIGNORE(lerr); if (lerr == LDONE) { ldone = true; break; } lerr = XMSG_LISTEN_((short *) &sre, // sre 0, // listenopts 0); // listenertag } while (lerr == XSRETYPE_NOWORK); if (ldone) { printf("LINK done\n"); lerr = XMSG_LISTEN_((short *) &sre, // sre XLISTEN_ALLOW_LDONEM, // listenopts 0); // listenertag assert(lerr == XSRETYPE_LDONE); ferr = XMSG_BREAK_(sre.sre_msgId, results.u.s, TPT_REF(phandle)); assert(ferr == XZFIL_ERR_OK); break; } ferr = XMSG_READDATA_(sre.sre_msgId, // msgid recv_buffer, // reqdata BUFSIZ); // bytecount util_check("XMSG_READDATA_", ferr); if (sre.sre_flags & XSRE_MON) { MS_Mon_Msg *msg = (MS_Mon_Msg *) recv_buffer; printf("cli: mon message, type=%d\n", msg->type); if (msg->type == MS_MsgType_ProcessDeath) { assert(msg->u.death.nid == nid); assert(msg->u.death.pid == pid); exit = 1; } else if (msg->type == MS_MsgType_Shutdown) { printf("cli: received cluster shutdown, level=%d\n", msg->u.shutdown.level); assert(msg->u.shutdown.level==MS_Mon_ShutdownLevel_Immediate); } } else printf("cli: NON-mon message\n"); XMSG_REPLY_(sre.sre_msgId, // msgid NULL, // replyctrl 0, // replyctrlsize NULL, // replydata 0, // replydatasize 0, // errorclass NULL); // newphandle } ferr = msg_mon_process_shutdown(); TEST_CHK_FEOK(ferr); util_test_finish(true); return 0; }