void
LogAMessage (const char *const pMsg)
Concurrency | rsSequentialConcurrency | Visibility | rsProtected |
Code
// This method takes the input string pMsg and prefixes it with
// "$# MSG <i> <m> #$ " where <i> is the instance index and <m> is the current
// message index.
// The message is sent to the test harness as a LogMessage. LogMessage's are
// sent to the Rose Realtime log..
// NOTE: this method relies on the member variables nInstanceIndex and
// nCurrentMessageIndex being set to the correct values. The driver generator
// for Quality Architect generates code to set the values in the driver state machine.
// nInstanceIndex is not necessarily the left-to-right instance number from
// the sequence diagram. Use the "Find In" context menu on the generated
// test driver to see the instance index value.
// nCurrentMessageIndex is not necessarily the top-to-bottom message number
// from the sequence diagram. Use the "Find In" context menu on the generated
// test driver to see the message index value.
int nTotalLen = 0;
int nILen;
int nMLen;
int nMsgLen;
char istr[30];
char mstr[30];
nILen = RTFormat::_int(nInstanceIndex, istr, 30);
nMLen = RTFormat::_int(nCurrentMessageIndex, mstr, 30);
nMsgLen = RTMemoryUtil::strlen(pMsg);
nTotalLen = 7 + nILen + 1 + nMLen + 4 + nMsgLen + 1;
char *pFailMsg = new char [nTotalLen];
if (!pFailMsg)
{
RQARTExceptionCode exCode = eRQARTMemoryError;
RQART_Exception.error(RTTypedValue(&exCode)).raise();
return;
}
char *pStr = pFailMsg;
RTMemoryUtil::strcpy(pStr, "$# MSG ");
pStr += 7;
RTMemoryUtil::strcpy(pStr, istr);
pStr += nILen;
RTMemoryUtil::strcpy(pStr, " ");
pStr += 1;
RTMemoryUtil::strcpy(pStr, mstr);
pStr += nMLen;
RTMemoryUtil::strcpy(pStr, " #$ ");
pStr += 4;
RTMemoryUtil::strcpy(pStr, pMsg);
RTString rtStr(pFailMsg);
delete [] pFailMsg;
RQART_TestHarness.LogMessage(rtStr).send();
Parameter pMsg