From: Gareth S B. <bes...@us...> - 2005-06-20 03:40:14
|
Update of /cvsroot/sblim/sfcc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28295 Modified Files: test.c Log Message: added tests for associators, associatornames, references, referencenames, setproperty, getproperty. Index: test.c =================================================================== RCS file: /cvsroot/sblim/sfcc/test.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test.c 20 Jun 2005 01:11:11 -0000 1.6 +++ test.c 20 Jun 2005 03:40:05 -0000 1.7 @@ -88,7 +88,7 @@ /* Setup a conncetion to the CIMOM */ cc = cmciConnect("localhost",NULL,NULL,NULL,NULL); - if (0) { + if (1) { /* Test enumClassNames() */ printf("\n----------------------------------------------------------\n"); printf("Testing enumClassNames() ...\n"); @@ -145,7 +145,7 @@ if (objectpath) CMRelease(objectpath); } - if (0) { + if (1) { /* Test enumInstanceNames() */ printf("\n----------------------------------------------------------\n"); printf("Testing enumInstanceNames() ...\n"); @@ -185,7 +185,7 @@ if (objectpath) CMRelease(objectpath); } - if (0) { + if (1) { /* Test getInstance() */ printf("\n----------------------------------------------------------\n"); printf("Testing getInstance() ...\n"); @@ -262,5 +262,129 @@ if (objectpath) CMRelease(objectpath); } + if (0) { + /* Test associators() */ + printf("\n----------------------------------------------------------\n"); + printf("Testing associators() ...\n"); + objectpath = newCMPIObjectPath("root/cimv2", "Linux_ComputerSystem", NULL); + CMAddKey(objectpath, "CreationClassName", "Linux_ComputerSystem", CMPI_chars); + CMAddKey(objectpath, "Name", _HOSTNAME, CMPI_chars); + enumeration = cc->ft->associators(cc, objectpath, "Linux_RunningOS", NULL, NULL, NULL, 0, NULL, &status); + + /* Print the results */ + printf("associators() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); + if (!status.rc) { + printf("result(s):\n"); + while (enumeration->ft->hasNext(enumeration, NULL)) { + CMPIData data = enumeration->ft->getNext(enumeration, NULL); + showInstance(data.value.inst); + } + } + if (enumeration) CMRelease(enumeration); + if (objectpath) CMRelease(objectpath); + } + + if (1) { + /* Test associatorNames() */ + printf("\n----------------------------------------------------------\n"); + printf("Testing associatorNames() ...\n"); + objectpath = newCMPIObjectPath("root/cimv2", "Linux_ComputerSystem", NULL); + CMAddKey(objectpath, "CreationClassName", "Linux_ComputerSystem", CMPI_chars); + CMAddKey(objectpath, "Name", _HOSTNAME, CMPI_chars); + enumeration = cc->ft->associatorNames(cc, objectpath, "Linux_RunningOS", NULL, NULL, NULL, &status); + + /* Print the results */ + printf("associatorNames() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); + if (!status.rc) { + printf("result(s):\n"); + while (enumeration->ft->hasNext(enumeration, NULL)) { + CMPIData data = enumeration->ft->getNext(enumeration, NULL); + showObjectPath(data.value.ref); + } + } + if (enumeration) CMRelease(enumeration); + if (objectpath) CMRelease(objectpath); + } + + if (0) { + /* Test references() */ + printf("\n----------------------------------------------------------\n"); + printf("Testing references() ...\n"); + objectpath = newCMPIObjectPath("root/cimv2", "Linux_ComputerSystem", NULL); + CMAddKey(objectpath, "CreationClassName", "Linux_ComputerSystem", CMPI_chars); + CMAddKey(objectpath, "Name", _HOSTNAME, CMPI_chars); + enumeration = cc->ft->references(cc, objectpath, NULL, NULL, 0, NULL, &status); + + /* Print the results */ + printf("references() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); + if (!status.rc) { + printf("result(s):\n"); + while (enumeration->ft->hasNext(enumeration, NULL)) { + CMPIData data = enumeration->ft->getNext(enumeration, NULL); + showInstance(data.value.inst); + } + } + if (enumeration) CMRelease(enumeration); + if (objectpath) CMRelease(objectpath); + } + + if (0) { + /* Test referenceNames() */ + printf("\n----------------------------------------------------------\n"); + printf("Testing referenceNames() ...\n"); + objectpath = newCMPIObjectPath("root/cimv2", "Linux_ComputerSystem", NULL); + CMAddKey(objectpath, "CreationClassName", "Linux_ComputerSystem", CMPI_chars); + CMAddKey(objectpath, "Name", _HOSTNAME, CMPI_chars); + enumeration = cc->ft->referenceNames(cc, objectpath, NULL, NULL, &status); + + /* Print the results */ + printf("referenceNames() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); + if (!status.rc) { + printf("result(s):\n"); + while (enumeration->ft->hasNext(enumeration, NULL)) { + CMPIData data = enumeration->ft->getNext(enumeration, NULL); + showObjectPath(data.value.ref); + } + } + if (enumeration) CMRelease(enumeration); + if (objectpath) CMRelease(objectpath); + } + + if (1) { + /* Test getProperty() */ + printf("\n----------------------------------------------------------\n"); + printf("Testing getProperty() ...\n"); + objectpath = newCMPIObjectPath("root/cimv2", "Linux_ComputerSystem", NULL); + CMAddKey(objectpath, "CreationClassName", "Linux_ComputerSystem", CMPI_chars); + CMAddKey(objectpath, "Name", _HOSTNAME, CMPI_chars); + CMPIData data = cc->ft->getProperty(cc, objectpath, "PrimaryOwnerName", &status); + + /* Print the results */ + printf("getProperty() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); + if (!status.rc) { + printf("result(s):\n"); + printf("PrimaryOwnerName=%s\n", (char*)(data.value.string)->hdl); + } + if (enumeration) CMRelease(enumeration); + if (objectpath) CMRelease(objectpath); + } + + if (1) { + /* Test setProperty() */ + printf("\n----------------------------------------------------------\n"); + printf("Testing setProperty() ...\n"); + objectpath = newCMPIObjectPath("root/cimv2", "Linux_ComputerSystem", NULL); + CMAddKey(objectpath, "CreationClassName", "Linux_ComputerSystem", CMPI_chars); + CMAddKey(objectpath, "Name", _HOSTNAME, CMPI_chars); + CMPIValue value; + value.string = newCMPIString("Gareth Bestor", NULL); + status = cc->ft->setProperty(cc, objectpath, "PrimaryOwnerName", &value, CMPI_chars); + + /* Print the results */ + printf("setProperty() rc=%d, msg=%s\n", status.rc, (status.msg)? (char *)status.msg->hdl : NULL); + if (enumeration) CMRelease(enumeration); + if (objectpath) CMRelease(objectpath); + } + return 0; } |