int Test_Rdr(SaHpiSessionIdT session_id, SaHpiResourceIdT resource_id, SaHpiRdrT rdr) { SaHpiBoolT enable, enable_old; SaErrorT val; SaHpiSensorNumT num; int ret = SAF_TEST_UNKNOWN; SaHpiSensorReadingT reading; /* Need to skip sensors which we can't set */ if (rdr.RdrType == SAHPI_SENSOR_RDR && rdr.RdrTypeUnion.SensorRec.EnableCtrl != SAHPI_FALSE) { num = rdr.RdrTypeUnion.SensorRec.Num; val = saHpiSensorEnableGet(session_id, resource_id, num, &enable_old); if (val != SA_OK) { e_print(saHpiSensorEnableGet, SA_OK, val); ret = SAF_TEST_UNRESOLVED; goto out; } if (enable_old) { enable = SAHPI_FALSE; val = saHpiSensorEnableSet(session_id, resource_id, num, enable); if (val != SA_OK) { e_print(saHpiSensorEnableSet, SA_OK, val); ret = SAF_TEST_UNRESOLVED; goto out1; } } val = saHpiSensorReadingGet(session_id, resource_id, num, &reading, NULL); if (val != SA_ERR_HPI_INVALID_REQUEST) { e_print(saHpiSensorReadingGet, val != SA_OK, val); ret = SAF_TEST_FAIL; } else ret = SAF_TEST_PASS; if (ret == SAF_TEST_UNKNOWN) ret = SAF_TEST_PASS; out1: val = saHpiSensorEnableSet(session_id, resource_id, num, enable_old); if (val != SA_OK) e_print(saHpiSensorEnableSet, SA_OK, val); } else ret = SAF_TEST_NOTSUPPORT; out: return ret; }
int Test_Rdr(SaHpiSessionIdT session, SaHpiResourceIdT resourceId, SaHpiRdrT rdr) { SaErrorT status; int retval = SAF_TEST_UNKNOWN; SaHpiSensorNumT s_num = rdr.RdrTypeUnion.SensorRec.Num; SaHpiBoolT Enable = SAHPI_FALSE; if (rdr.RdrType == SAHPI_SENSOR_RDR) { // // Call saHpiSensorEnableSet passing in a bad ResourceId // status = saHpiSensorEnableSet(session, INVALID_RESOURCE_ID, s_num, Enable); if (status != SA_ERR_HPI_INVALID_RESOURCE) { e_print(saHpiSensorEnableSet, SA_ERR_HPI_INVALID_RESOURCE, status); retval = SAF_TEST_FAIL; } else retval = SAF_TEST_PASS; } else retval = SAF_TEST_NOTSUPPORT; return (retval); }
int main(int argc, char **argv) { /* ************************ * Local variables * ***********************/ int testfail = 0; SaErrorT err; SaErrorT expected_err; SaHpiRptEntryT rptentry; SaHpiResourceIdT id = 0; SaHpiSessionIdT sessionid; SaHpiSensorNumT sid = 0; SaHpiBoolT enable = SAHPI_FALSE; /* ************************************* * Find a resource with Sensor type rdr * ************************************* */ err = tsetup(&sessionid); if (err != SA_OK) { printf("Error! Can not open session for test environment\n"); printf(" File=%s, Line=%d\n", __FILE__, __LINE__); return -1; } err = tfind_resource(&sessionid,SAHPI_CAPABILITY_SENSOR,SAHPI_FIRST_ENTRY, &rptentry, SAHPI_TRUE); if (err != SA_OK) { printf("Error! Can not find resources for test environment\n"); printf(" File=%s, Line=%d\n", __FILE__, __LINE__); err = tcleanup(&sessionid); return SA_OK; } id = rptentry.ResourceId; /************************** * Test: Invalid handle **************************/ expected_err = SA_ERR_HPI_INVALID_PARAMS; err = snmp_bc_set_sensor_enable(NULL, id, sid, enable); checkstatus(err, expected_err, testfail); /************************** * Test:Invalid resoruce id **************************/ expected_err = SA_ERR_HPI_INVALID_RESOURCE; err = saHpiSensorEnableSet(sessionid, 5000, sid, enable); checkstatus(err, expected_err, testfail); /************************** * Test: invalid sensor Id **************************/ expected_err = SA_ERR_HPI_NOT_PRESENT; err = saHpiSensorEnableSet(sessionid, id, 5000, enable); checkstatus(err, expected_err, testfail); /*************************** * Cleanup after all tests ***************************/ err = tcleanup(&sessionid); return testfail; }
int main(int argc, char **argv) { int number_resources=0, j; SaErrorT rv; SaHpiSessionIdT sessionid; SaHpiResourceIdT resourceid; SaHpiResourceIdT resourceid_list[RESOURCE_CAP_LENGTH] = {0}; SaHpiSensorNumT sensor_num; SaHpiSensorDataFormatT format; SaHpiCapabilitiesT capability = SAHPI_CAPABILITY_SENSOR; SaHpiBoolT val = SAHPI_TRUE; memset(&format, 0, sizeof(format)); printf("saHpiSensorReadingGet: Test for hpi sensor reading " "get function\n"); rv = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sessionid, NULL); if (rv != SA_OK) { printf("saHpiSessionOpen failed with error: %s\n", oh_lookup_error(rv)); return rv; } /* Discover the resources with sensor capability */ printf("\nListing the resource with sensor capability \n"); rv = discover_resources(sessionid, capability, resourceid_list, &number_resources); if (rv != SA_OK) { exit(-1); } printf("\nPlease enter the resource id: "); scanf("%d", &resourceid); printf("Press 1 for TEMPERATURE sensor\n"); printf("Press 2 for POWER sensor\n"); printf("Press 3 for FAN SPEED sensor\n"); printf("Enter your choice: "); scanf("%d", &sensor_num); switch (sensor_num) { case 1: sensor_num = OA_SOAP_RES_SEN_TEMP_NUM; format.BaseUnits = SAHPI_SU_DEGREES_C; break; case 2: sensor_num = OA_SOAP_RES_SEN_POWER_NUM; format.BaseUnits = SAHPI_SU_WATTS; break; case 3: sensor_num = OA_SOAP_RES_SEN_FAN_NUM; format.BaseUnits = SAHPI_SU_RPM; break; default : printf("Wrong choice. Exiting"); exit (-1); } printf("\nPlease enter whether you want to enable or disable " "this sensor for reading\n"); printf("Press 1 for Enable\n"); printf("Press 2 for Disable\n"); printf("Enter your choice:"); scanf("%d",&j); if (j == 1){ val=SAHPI_TRUE; }else if (j == 2){ val= SAHPI_FALSE; } format.ReadingType = SAHPI_SENSOR_READING_TYPE_FLOAT64; rv = saHpiSensorEnableSet(sessionid, resourceid, sensor_num, val); if (rv != SA_OK) { printf("saHpiSensorEnableSet failed with error: %s\n", oh_lookup_error(rv)); printf("Test case - FAIL\n"); exit(-1); } printf("\nTest case - PASS\n"); rv = saHpiSessionClose(sessionid); return 0; }