OpenClovis Logo

API Usage Examples
OpenClovis Test API

Code Examples. More...

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;
}
/*
* 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;
}

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