OpenClovis Logo

API Usage Examples

Code Examples.

Code Examples.


The following code block shall create test group for testing simple container test.

/* Main test function which does TestGroup Initialize & finalize
* calling num of test cases also.
* Our intention is here to write a test group which tests the container.
*/
ClRcT clTestContainer(void)
{
//Initialize the test group with proper string
clTestGroupInitialize(("container test group"));
//Call list of test cases like following
clTestCase(("Container Create test"), clTestContainerCreate());
clTestCase(("Container Delete test"), clTestContainerDelete());
//Fianlize the test group
return CL_OK;
}
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
#define CL_OK
Every thing is OK.
Definition: clCommonErrors.h:68
#define clTestGroupInitialize(name)
Start up the Test infrastructure.
Definition: clTestApi.h:111
#define clTestGroupFinalize()
Stop the Test infrastructure.
Definition: clTestApi.h:127
#define clTestCase(name, test)
Run a test case.
Definition: clTestApi.h:176
/*
* The following test case does the test for container
* It does malfunction for container create, without that we can't proceed.
* add some nodes to that using clTest api.
* Print using clTestPrint
* Failure print using clTestFailure
*/
clTestContainerCreate(void)
{
ClRcT rc = CL_OK;
/* Call test case mal function, if the container is not created, just
* return from here
*/
clTestCaseMalfunction(("BIC.CNT.TC001: Container create test"),
(CL_OK == (rc=clTestContainerCreate(CL_CNT_LIST, CL_TST_CNT_CB_STRUCT,
CL_CNT_UNIQUE_KEY, CL_TRUE, &hCntHead))), return rc);
/* test the nodeAddtion function whether returning CL_OK */
clTest(("NodeAdd:"), (rc = clTestCntNodeAdd(hCntHead, 2)) == CL_OK,
("rc [0x %x]", rc));
clTest(("NodeAdd:"), (rc = clTestCntNodeAdd(hCntHead, 3)) == CL_OK,
("rc [0x %x]", rc));
clTest(("NodeAdd:"), (rc = clTestCntNodeAdd(hCntHead, 4)) == CL_OK,
("rc [0x %x]", rc));
clTest(("NodeAdd:"), (rc = clTestCntNodeAdd(hCntHead, 5)) == CL_OK,
("rc [0x %x]", rc));
clTestPrint(("Test is going on"));
clTest(("Container size get"),(rc=clCntSizeGet(hCntHead, &size)) == CL_OK,
("rc [0x %x]", rc));
if( size != 4 )
{
clTestFailure(("Container size get & num of nodes are not proper"));
}
clTest(("Container Delete:"), (rc = clCntDelete(hCntHead)) == CL_OK,
("rc [0x %x]", rc));
clTestSuccess(("Successfully ran the simple container test"));
return CL_OK;
}
ClRcT clCntSizeGet(CL_IN ClCntHandleT containerHandle, CL_OUT ClUint32T *pSize)
Returns the size of the Container.
ClRcT clCntDelete(CL_IN ClCntHandleT containerHandle)
Destroys the Container.
@ CL_CNT_UNIQUE_KEY
Container contains unique key.
Definition: clCntApi.h:115
#define CL_TRUE
define the Truth
Definition: clCommon.h:59
#define clTestSuccess(__string)
Indicate that a test passed.
Definition: clTestApi.h:441
#define clTest(string, predicate, errorPrintf)
Run an individual test.
Definition: clTestApi.h:330
#define clTestPrint(x)
Print something to the test console.
Definition: clTestApi.h:474
#define clTestCaseMalfunction(reason, predicate, execOnFailure)
Indicate that this test case cannot be completed, if the predicate fails.
Definition: clTestApi.h:297

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen