version 1.3, 2002/01/14 19:39:56
|
version 1.4, 2002/03/09 01:17:10
|
|
|
// | // |
// Author: Sushma Fernandes (sushma_fernandes@hp.com) | // Author: Sushma Fernandes (sushma_fernandes@hp.com) |
// | // |
// Modified By: |
// Modified By: Jenny Yu (jenny_yu@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
const char* FILE1 = "testtracer1.trace"; | const char* FILE1 = "testtracer1.trace"; |
const char* FILE2 = "testtracer2.trace"; | const char* FILE2 = "testtracer2.trace"; |
const char* FILE3 = "testtracer1.trace"; | const char* FILE3 = "testtracer1.trace"; |
|
const char* FILE4 = "testtracer4.trace"; |
| |
// | // |
// Reads the last trace message from a given trace file and compares the | // Reads the last trace message from a given trace file and compares the |
|
|
| |
Uint32 test19() | Uint32 test19() |
{ | { |
const char* METHOD_NAME = "test19"; |
const char* METHOD_NAME = "test18"; |
String components = "InvalidComp,Config"; |
Tracer::setTraceComponents("Config,InvalidComp"); |
Tracer::isValid(components); |
|
Tracer::setTraceComponents("InvalidComp"); |
|
Tracer::setTraceLevel(Tracer::LEVEL4); | Tracer::setTraceLevel(Tracer::LEVEL4); |
Tracer::traceBuffer(__FILE__,__LINE__,TRC_CONFIG,Tracer::LEVEL1, |
Tracer::traceBuffer(__FILE__,__LINE__,TRC_CONFIG,Tracer::LEVEL4, |
"This Message should appear in",3); |
"This Message should appear in",4); |
Tracer::traceBuffer(TRC_CONFIG,Tracer::LEVEL1, |
Tracer::traceBuffer(TRC_CONFIG,Tracer::LEVEL4, |
"This Message should appear in",3); |
"This Message should appear in",4); |
return(compare(FILE3,"This")); | return(compare(FILE3,"This")); |
} | } |
| |
|
// |
|
// Description: |
|
// Trace a string. |
|
// Calls the _traceString() method |
|
// should log a trace message |
|
// |
|
// Type: |
|
// Positive |
|
// |
|
// return 0 if the test passed |
|
// return 1 if the test failed |
|
// |
|
|
|
Uint32 test20() |
|
{ |
|
const char* METHOD_NAME = "test20"; |
|
Tracer::setTraceFile(FILE4); |
|
Tracer::setTraceComponents("ALL"); |
|
Tracer::setTraceLevel(Tracer::LEVEL4); |
|
|
|
PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME); |
|
Tracer::trace(__FILE__,__LINE__,TRC_CONFIG,Tracer::LEVEL4, |
|
"Test Message for Level4 in test20"); |
|
return(compare(FILE4,"Test Message for Level4 in test20")); |
|
} |
|
|
|
// |
|
// Description: |
|
// Trace a CIMException. |
|
// Calls the traceCIMException() method |
|
// should log a trace message |
|
// |
|
// Type: |
|
// Positive |
|
// |
|
// return 0 if the test passed |
|
// return 1 if the test failed |
|
// |
|
|
|
Uint32 test21() |
|
{ |
|
const char* METHOD_NAME = "test21"; |
|
Tracer::setTraceFile(FILE4); |
|
Tracer::setTraceComponents("ALL"); |
|
Tracer::setTraceLevel(Tracer::LEVEL4); |
|
|
|
PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME); |
|
|
|
// test tracing CIMException |
|
try |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION( |
|
CIM_ERR_NOT_SUPPORTED, |
|
"CIM Exception Message for Level4 in test21."); |
|
} |
|
catch (CIMException e) |
|
{ |
|
Tracer::traceCIMException(TRC_CONFIG,Tracer::LEVEL4, e); |
|
} |
|
|
|
return 0; |
|
} |
|
|
|
// |
|
// Description: |
|
// Trace a string using macro. |
|
// should log a trace message |
|
// |
|
// Type: |
|
// Positive |
|
// |
|
// return 0 if the test passed |
|
// return 1 if the test failed |
|
// |
|
Uint32 test22() |
|
{ |
|
const char* METHOD_NAME = "test22"; |
|
Tracer::setTraceFile(FILE4); |
|
Tracer::setTraceComponents("ALL"); |
|
Tracer::setTraceLevel(Tracer::LEVEL4); |
|
|
|
PEG_METHOD_ENTER(TRC_CONFIG, METHOD_NAME); |
|
|
|
PEG_TRACE_STRING(TRC_CONFIG,Tracer::LEVEL4,"Test message for Level4 in test22."); |
|
|
|
return(compare(FILE4,"Test message for Level4 in test22.")); |
|
} |
|
|
int main() | int main() |
{ | { |
| |
|
|
System::removeFile(FILE1); | System::removeFile(FILE1); |
System::removeFile(FILE2); | System::removeFile(FILE2); |
System::removeFile(FILE3); | System::removeFile(FILE3); |
|
System::removeFile(FILE4); |
if (test1() == 0) | if (test1() == 0) |
{ | { |
cout << "Tracer test (test1) failed" << endl; | cout << "Tracer test (test1) failed" << endl; |
|
|
cout << "Tracer test (test19) failed" << endl; | cout << "Tracer test (test19) failed" << endl; |
exit(1); | exit(1); |
} | } |
|
if (test20() != 0) |
|
{ |
|
cout << "Tracer test (test20) failed" << endl; |
|
exit(1); |
|
} |
|
if (test21() != 0) |
|
{ |
|
cout << "Tracer test (test21) failed" << endl; |
|
exit(1); |
|
} |
|
if (test22() != 0) |
|
{ |
|
cout << "Tracer test (test22) failed" << endl; |
|
exit(1); |
|
} |
cout << "+++++ passed all tests" << endl; | cout << "+++++ passed all tests" << endl; |
System::removeFile(FILE1); | System::removeFile(FILE1); |
System::removeFile(FILE2); | System::removeFile(FILE2); |
System::removeFile(FILE3); | System::removeFile(FILE3); |
|
System::removeFile(FILE4); |
return 0; | return 0; |
#endif | #endif |
} | } |