/** * main: Starts with an RPTable of 10 resources (one with data), adds 5 rdr * to first resource and 2 to the last one. * Invokes oh_flush on the table. * Should return without crashing and there should be no resources left * in the table. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); guint i; gchar *data = "My data."; if (oh_add_resource(rptable, rptentries, data, 1)) return 1; for (i = 1; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries + i, NULL, 0)) return 1; } for (i = 0; i < 5; i++) { if (oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, rdrs + i, NULL, 0)) return 1; } for (; i < 7; i++) { if (oh_add_rdr(rptable, rptentries[9].ResourceId, rdrs + i, NULL, 0)) return 1; } oh_flush_rpt(rptable); if (oh_get_resource_by_id(rptable, SAHPI_FIRST_ENTRY)) return 1; return 0; }
static int process_resource_event(struct oh_handler *h, RPTable *rpt, struct oh_event *e) { int rv; data_access_lock(); if (e->type == OH_ET_RESOURCE_DEL) { rv = oh_remove_resource(rpt,e->u.res_del_event.resource_id); } else { struct oh_resource_data *rd = g_malloc0(sizeof(struct oh_resource_data)); if (!rd) { dbg("Couldn't allocate resource data"); return SA_ERR_HPI_ERROR; } rd->handler = h; rd->controlled = 0; rd->auto_extract_timeout = get_default_hotswap_auto_extract_timeout(); rv = oh_add_resource(rpt,&(e->u.res_event.entry),rd,0); } data_access_unlock(); return rv; }
/** * main: Starting with an empty RPTable, adds 2 resources to it. * Fetches the resource back by using an entity path not present in the table. * Passes the test if the interface returns NULL, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); if (oh_add_resource(rptable, rptentries, NULL, 1)) return 1; if (oh_add_resource(rptable, rptentries+1, NULL, 1)) return 1; if (oh_get_resource_by_ep(rptable, &(rptentries[2].ResourceEntity))) return 1; return 0; }
/** * main: Adds 100 resources to RPTable. Fetches the hundredth resource * and times how long it took to fetch it. Fails if it can't get the resource. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); guint i = 0; struct timeval start, end; SaHpiRptEntryT *tmpentry = NULL; for (i = 1; i <= 10000; i++) { rptentries[0].ResourceId = i; rptentries[0].ResourceEntity.Entry[0].EntityLocation = i; oh_add_resource(rptable, rptentries, NULL, 0); } gettimeofday(&start, NULL); /*printf("Started at %ld.%ld\n",start.tv_sec,start.tv_usec);*/ if (!(tmpentry = oh_get_resource_by_ep(rptable, &(rptentries[0].ResourceEntity)))) return 1; gettimeofday(&end, NULL); /*printf("Ended at %ld.%ld\n",end.tv_sec,end.tv_usec);*/ printf("%ld.%ld seconds elapsed.\n",(long)(end.tv_sec - start.tv_sec),(long)(end.tv_usec - start.tv_usec)); return 0; }
/** * main: Starts with an RPTable of 10 resources, adds 1 rdr * to first resource. Fetches rdr by its type and num and compares * with original. A failed comparison means the test failed, * otherwise the test passed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); SaHpiEntryIdT record_id; SaHpiRdrT *tmprdr = NULL; guint i = 0; for (i = 0; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries + i, NULL, 0)) return 1; } if (oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, sensors, NULL,0)) return 1; record_id = get_rdr_uid(sensors[0].RdrType, sensors[0].RdrTypeUnion.SensorRec.Num); sensors[0].RecordId = record_id; tmprdr = oh_get_rdr_by_type(rptable, SAHPI_FIRST_ENTRY, sensors[0].RdrType, sensors[0].RdrTypeUnion.SensorRec.Num); if (!tmprdr || memcmp(sensors, tmprdr, sizeof(SaHpiRdrT))) return 1; return 0; }
/** * main: Starts with an RPTable of 10 resources, adds 5 rdr * to first resource. Fetches sensors ++in sequence by record id and compares * with original. A failed comparison means the test failed, * otherwise the test passed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); SaHpiRdrT *tmprdr = NULL; guint i = 0; for (i = 0; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries + i, NULL, 0)) return 1; } for (i = 0; i < 5; i++) { if (oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, sensors + i, NULL,0)) return 1; } for (i = 0, tmprdr = oh_get_rdr_by_id(rptable, SAHPI_FIRST_ENTRY, SAHPI_FIRST_ENTRY); tmprdr; tmprdr = oh_get_rdr_next(rptable, SAHPI_FIRST_ENTRY, tmprdr->RecordId)) { if (memcmp(sensors + (i++), tmprdr, sizeof(SaHpiRdrT))) return 1; } return 0; }
/** * main: Starting with a NULL RPTable, adds a NULL resource to it. * Passes the test if the interface returns an error, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { if (!oh_add_resource(NULL, NULL, NULL, 0)) return 1; return 0; }
/** * main: Starts with an RPTable of 10 resources and fetches * them randomly by the ResourceId and compares them against the original * resource. A failed comparison means the test failed, * otherwise the test passed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); guint i = 0, k = 0; GSList *resources = NULL; for (i = 0; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries + i, NULL, 0)) return 1; else resources = g_slist_append(resources, rptentries + i); } for (; resources; i--) { SaHpiRptEntryT *randentry = NULL, *tmpentry = NULL; GSList *tmpnode = NULL; k = (guint) (((gfloat)i)*rand()/(RAND_MAX+1.0)); tmpnode = g_slist_nth(resources, k); randentry = (SaHpiRptEntryT *)tmpnode->data; tmpentry = oh_get_resource_by_id(rptable, randentry->ResourceId); if (!tmpentry || memcmp(randentry, tmpentry, sizeof(SaHpiRptEntryT))) return 1; else { resources = g_slist_remove_link(resources, tmpnode); g_slist_free_1(tmpnode); } } return 0; }
static int process_resource_event(struct oh_event *e) { int rv; RPTable *rpt = NULL; struct oh_domain *d = NULL; struct oh_event hpie; d = oh_get_domain(e->did); if(!d) { dbg("Domain %d doesn't exist", e->did); return -1; } rpt = &(d->rpt); memset(&hpie, 0, sizeof(hpie)); if (e->type == OH_ET_RESOURCE_DEL) { rv = oh_remove_resource(rpt,e->u.res_event.entry.ResourceId); trace("Resource %d in Domain %d has been REMOVED.", e->u.res_event.entry.ResourceId, e->did); hpie.did = e->did; hpie.u.hpi_event.event.Severity = e->u.res_event.entry.ResourceSeverity; hpie.u.hpi_event.event.Source = e->u.res_event.entry.ResourceId; hpie.u.hpi_event.event.EventType = SAHPI_ET_RESOURCE; hpie.u.hpi_event.event.EventDataUnion.ResourceEvent.ResourceEventType = SAHPI_RESE_RESOURCE_FAILURE; } else { struct oh_resource_data *rd = g_malloc0(sizeof(struct oh_resource_data)); if (!rd) { dbg("Couldn't allocate resource data"); return SA_ERR_HPI_OUT_OF_MEMORY; } rd->hid = e->hid; rd->controlled = 0; rd->auto_extract_timeout = get_default_hotswap_auto_extract_timeout(); rv = oh_add_resource(rpt,&(e->u.res_event.entry),rd,0); trace("Resource %d in Domain %d has been ADDED.", e->u.res_event.entry.ResourceId, e->did); hpie.did = e->did; hpie.u.hpi_event.event.Severity = e->u.res_event.entry.ResourceSeverity; hpie.u.hpi_event.event.Source = e->u.res_event.entry.ResourceId; hpie.u.hpi_event.event.EventType = SAHPI_ET_RESOURCE; hpie.u.hpi_event.event.EventDataUnion.ResourceEvent.ResourceEventType = SAHPI_RESE_RESOURCE_ADDED; } oh_release_domain(d); if (rv == SA_OK) { rv = process_hpi_event(&hpie); } return rv; }
static int rpt_cache_resources_add( RPTable *temp_rptable, SaHpiRptEntryT *rpt_cache_buff, struct resource_data *remote_res_data, int num_entries) { int status = SA_OK; int i; /* append entity root to resource entity paths */ for (i=0; i < num_entries; i++) { if (!(&remote_res_data[i])) { dbg("remote_resdata pointer NULL"); status = SA_ERR_HPI_ERROR; break; } rpt_cache_buff[i].ResourceId = oh_uid_from_entity_path(&rpt_cache_buff[i].ResourceEntity); /* add the resource */ if ( oh_add_resource( temp_rptable, &rpt_cache_buff[i], &remote_res_data[i], 0 ) ) { status = SA_ERR_HPI_ERROR; dbg("oh_add_resource failed for resource %d", i); } } return(status); }
/** * main: Starts with an RPTable of 10 resources, multiple rdrs * on some resources. Remove resource. Check if resource was removed * searching for it in sequence. If not fail, else passed test. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); SaHpiRptEntryT *tmpentry = NULL; guint i = 0; for (i = 0; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries + i, NULL, 0)) return 1; } for (i = 0; i < 5; i++) { if (oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, rdrs + i, NULL,0)) return 1; } for (; i < 7; i++) { if (oh_add_rdr(rptable, rptentries[9].ResourceId, rdrs + i, NULL,0)) return 1; } oh_remove_resource(rptable, rptentries[0].ResourceId); for (tmpentry = oh_get_resource_by_id(rptable, SAHPI_FIRST_ENTRY); tmpentry; tmpentry = oh_get_resource_next(rptable, tmpentry->ResourceId)) { if (tmpentry->ResourceId == rptentries[0].ResourceId) return 1; } return 0; }
/** * main: Adds 2 resources to an rpt table. * Fetches the 2nd resource through the get_next call * using a NULL table. * Passes the test if the interface returns NULL, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); if (oh_add_resource(rptable, rptentries, NULL, 1)) return 1; if (oh_add_resource(rptable, rptentries + 1, NULL, 1)) return 1; if (oh_get_resource_next(NULL, rptentries[0].ResourceId)) return 1; return 0; }
static void mc_add(ipmi_mc_t *mc, struct oh_handler_state *handler) { struct ohoi_resource_info *ohoi_res_info; struct oh_event *e; struct ohoi_handler *ipmi_handler = handler->data; ohoi_res_info = g_malloc0(sizeof(*ohoi_res_info)); if (!ohoi_res_info) { dbg("Out of space"); return; } ohoi_res_info->type = OHOI_RESOURCE_MC; ohoi_res_info->u.mc_id = ipmi_mc_convert_to_id(mc); e = malloc(sizeof(*e)); if (!e) { dbg("Out of space"); return; } memset(e, 0, sizeof(*e)); e->type = OH_ET_RESOURCE; get_mc_entity_event(mc, &(e->u.res_event.entry), ipmi_handler); /* add to rptcache */ oh_add_resource(handler->rptcache, &(e->u.res_event.entry), ohoi_res_info, 1); }
static void add_entity_event(ipmi_entity_t *entity, struct oh_handler_state *handler) { struct ohoi_resource_info *ohoi_res_info; SaHpiRptEntryT entry; int rv; dbg("adding ipmi entity: %s", ipmi_entity_get_entity_id_string(entity)); struct ohoi_handler *ipmi_handler = handler->data; ohoi_res_info = g_malloc0(sizeof(*ohoi_res_info)); if (!ohoi_res_info) { dbg("Out of memory"); return; } ohoi_res_info->type = OHOI_RESOURCE_ENTITY; ohoi_res_info->u.entity_id= ipmi_entity_convert_to_id(entity); // entity_rpt_set_updated(ohoi_res_info, handler->data); get_entity_event(entity, &entry, ipmi_handler); rv = oh_add_resource(handler->rptcache, &entry, ohoi_res_info, 1); if (rv) { dbg("oh_add_resource failed for %d = %s\n", entry.ResourceId, oh_lookup_error(rv)); } }
bool cIpmiResource::Populate() { if ( m_populate == false ) { // create rpt entry stdlog << "populate resource: " << EntityPath() << ".\n"; struct oh_event *e = (struct oh_event *)g_malloc0( sizeof( struct oh_event ) ); if ( !e ) { stdlog << "out of space !\n"; return false; } memset( e, 0, sizeof( struct oh_event ) ); e->type = OH_ET_RESOURCE; if ( Create( e->u.res_event.entry ) == false ) { g_free( e ); return false; } // assign the hpi resource id to ent, so we can find // the resource for a given entity m_resource_id = e->u.res_event.entry.ResourceId; // add the resource to the resource cache int rv = oh_add_resource( Domain()->GetHandler()->rptcache, &(e->u.res_event.entry), this, 1 ); if ( rv != 0 ) { stdlog << "Can't add resource to plugin cache !\n"; g_free( e ); return false; } stdlog << "cIpmiResource::Populate OH_ET_RESOURCE Event resource " << m_resource_id << "\n"; Domain()->AddHpiEvent( e ); if ( m_sel ) PopulateSel(); m_populate = true; } for( int i = 0; i < NumRdr(); i++ ) { cIpmiRdr *rdr = GetRdr( i ); if ( rdr->Populate() == false ) return false; } return true; }
/** * main: Starting with an empty RPTable, adds 1 NULL resource to it. * Passes the test if the interface returns an error, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); if (!oh_add_resource(rptable, NULL, NULL, 0)) return 1; return 0; }
/** * main: Invokes rpt_diff with new_rdr param as NULL. * If it returns error, the test passes, otherwise it failed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *curr_table = (RPTable *)g_malloc0(sizeof(RPTable)); RPTable *new_table = (RPTable *)g_malloc0(sizeof(RPTable)); GSList *new_res = NULL, *gone_res = NULL, *gone_rdr = NULL; oh_init_rpt(curr_table); oh_init_rpt(new_table); if (oh_add_resource(curr_table, rptentries, NULL, 0)) return 1; if (oh_add_resource(new_table, rptentries + 1, NULL, 0)) return 1; rpt_diff(curr_table, new_table, &new_res, NULL, &gone_res, &gone_rdr); return 0; }
/** * main: Starting with an empty RPTable, adds 1 resource to it * that has an invalid Resource Id like SAHPI_DOMAIN_CONTROLLER_ID. * Passes the test if the interface returns an error, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); rptentries[0].ResourceId = SAHPI_DOMAIN_CONTROLLER_ID; if (!oh_add_resource(rptable, rptentries, NULL, 0)) return 1; return 0; }
/** * main: Starting with an empty RPTable, adds 1 resource to it * that has an invalid Resource Id like SAHPI_FIRST_ENTRY. * Passes the test if the interface returns an error, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); rptentries[0].ResourceId = SAHPI_FIRST_ENTRY; if (!oh_add_resource(rptable, rptentries, NULL, 0)) return 1; return 0; }
/** * main: Starting with an empty RPTable, adds 1 resource to it with data. * Fetches the data back using a NULL table as a parameter. * Passes the test if the interface returns NULL, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); gchar *data = "My data"; if (oh_add_resource(rptable, rptentries, data, KEEP_RPT_DATA)) return 1; if (oh_get_resource_data(NULL, rptentries[0].ResourceId)) return 1; return 0; }
/** * main: Starting with an empty RPTable, adds 1 resource to it * and tries to fetch it by the ResourceId and compare it against * the original resource. A failed comparison means the test * failed, otherwise the test passed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); SaHpiRptEntryT *tmpentry = NULL; if (oh_add_resource(rptable, rptentries, NULL, 0)) return 1; tmpentry = oh_get_resource_by_id(rptable, rptentries[0].ResourceId); if (!tmpentry || memcmp(rptentries, tmpentry, sizeof(SaHpiRptEntryT))) return 1; return 0; }
/** * main: Starting with an empty RPTable, adds 10 resources to it * and then adds 1 rdr to it using a Resource Id not present in the table. * Passes the test if the interface returns an error, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); guint i; for (i = 0; rptentries[i].ResourceId; i++) { if (oh_add_resource(rptable, rptentries+i, NULL, 0)) return 1; } if (!oh_add_rdr(rptable, 1234567, rdrs, NULL, 1)) return 1; return 0; }
static int process_resource_event(struct oh_handler *h, RPTable *rpt, struct oh_event *e) { int rv; data_access_lock(); if (e->type == OH_ET_RESOURCE_DEL) { rv = oh_remove_resource(rpt,e->u.res_del_event.resource_id); } else { rv = oh_add_resource(rpt,&(e->u.res_event.entry),h); } data_access_unlock(); return rv; }
/** * main: Starting with an empty RPTable, adds 1 resource to it. * Checks rpt info to see if update count was updated. * If not updated, the test failed, otherwise the test passed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); SaHpiUint32T update_count; update_count = rptable->update_count; if (oh_add_resource(rptable, rptentries, NULL, 0)) return 1; if (rptable->update_count != update_count + 1) return 1; return 0; }
/** * main: Starts with an RPTable of 1 resource, adds 1 rdr with data * to first resource. Fetches data using a SAHPI_FIRST_ENTRY as the Record Id. * Success if the interface returns an ok, otherwise there was a failure. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); gchar *data = "My data"; if (oh_add_resource(rptable, rptentries, NULL, 1)) return 1; if (oh_add_rdr(rptable, rptentries[0].ResourceId, rdrs, data, 1)) return 1; if (!oh_get_rdr_data(rptable, rptentries[0].ResourceId, SAHPI_FIRST_ENTRY)) return 1; return 0; }
/** * main: Starts with an RPTable of 1 resource, adds 1 rdr with data * to first resource. Fetches data using a Resource Id not present in the table. * Success if the interface returns an error, otherwise there was a failure. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); gchar *data = "My data"; if (oh_add_resource(rptable, rptentries, NULL, 1)) return 1; if (oh_add_rdr(rptable, rptentries[0].ResourceId, sensors, data, 1)) return 1; if (oh_get_rdr_data(rptable, 1234567, sensors[0].RecordId)) return 1; return 0; }
/** * main: Starts with an RPTable of 10 resources, adds 5 rdr * to first resource. Fetches rdrs randomly by type and compares * with original. A failed comparison means the test failed, * otherwise the test passed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); GSList *records = NULL; guint i = 0; for (i = 0; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries + i, NULL, 0)) return 1; } for (i = 0; i < 5; i++) { if (oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, rdrs + i, NULL,0)) return 1; else records = g_slist_append(records, rdrs + i); } for (; records; i--) { SaHpiRdrT *tmprdr = NULL, *randrdr = NULL; GSList *tmpnode = NULL; guint k = (guint) (((gfloat)i)*rand()/(RAND_MAX+1.0)); tmpnode = g_slist_nth(records, k); randrdr = (SaHpiRdrT *)tmpnode->data; randrdr->RecordId = get_rdr_uid(randrdr->RdrType, randrdr->RdrTypeUnion.SensorRec.Num); tmprdr = oh_get_rdr_by_type(rptable, SAHPI_FIRST_ENTRY, randrdr->RdrType, randrdr->RdrTypeUnion.SensorRec.Num); if (!tmprdr || memcmp(randrdr, tmprdr, sizeof(SaHpiRdrT))) return 1; else { records = g_slist_remove_link(records, tmpnode); g_slist_free_1(tmpnode); } } return 0; }
/** * main: resource must NOT have SAHPI_CAPABILITY_AGGREGATE_STATUS capability, * sensor num should be between SAHPI_STANDARD_SENSOR_MIN and * SAHPI_STANDARD_SENSOR_MAX and less than SENSOR_AGGREGATE_MAX. * With these conditions, oh_add_rdr is expected to return an error. * This is because for a sensor to have a num in the reserved range, * the resource must have SAHPI_CAPABILITY_AGGREGATE_STATUS capability * set. * If so, the test passes, otherwise it failed. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); oh_init_rpt(rptable); guint i; rptentries[0].ResourceCapabilities = rptentries[0].ResourceCapabilities & 0xFFFFDFFF; for (i = 0; rptentries[i].ResourceId; i++) { if (oh_add_resource(rptable, rptentries+i, NULL, 0)) return 1; } rdrs[0].RdrTypeUnion.SensorRec.Num = SAHPI_STANDARD_SENSOR_MIN; if (!oh_add_rdr(rptable, SAHPI_FIRST_ENTRY, rdrs, NULL, 1)) return 1; return 0; }
/** * main: Starts with an RPTable of 1 resource, adds 5 rdrs to first resource. * Fetches an rdr by id using a NULL table. * Success if the interface returns an error, otherwise there was a failure. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); guint i; if (oh_add_resource(rptable, rptentries, NULL, 1)) return 1; for (i = 0; i < 5; i++) { if (oh_add_rdr(rptable, rptentries[0].ResourceId, rdrs+i, NULL, 1)) return 1; } if (oh_get_rdr_by_id(NULL, rptentries[0].ResourceId, rdrs[0].RecordId)) return 1; return 0; }
/** * main: Starting with an empty RPTable, adds 1 resource to it * and then adds 1 rdr to it. Removes rdr using a special value like * SAHPI_FIRST_ENTRY. * Passes the test if the interface returns ok, else it fails. * * Return value: 0 on success, 1 on failure **/ int main(int argc, char **argv) { RPTable *rptable = (RPTable *)g_malloc0(sizeof(RPTable)); guint i; for (i = 0; rptentries[i].ResourceId != 0; i++) { if (oh_add_resource(rptable, rptentries+i, NULL, 0)) return 1; } if (oh_add_rdr(rptable, rptentries[0].ResourceId, rdrs, NULL, 1)) return 1; if (oh_remove_rdr(rptable, rptentries[0].ResourceId, SAHPI_FIRST_ENTRY)) return 1; return 0; }