int cmd_ridlist(ibp_connect_context_t *cc, char **argv, int argc) { ibp_depot_t depot; ibp_ridlist_t ridlist; char srid[1024]; int i; ibp_op_t op; int err, timeout; if (argc < 2) { printf("cmd_ridlist: Not enough parameters. Received %d need 3\n", argc); return(0); } store_depot(&depot, argv, 1); timeout = atoi(argv[2]); set_ibp_query_resources_op(&op, &depot, &ridlist, timeout, NULL, cc); err = ibp_sync_command(&op); if (err != IBP_OK) { printf("cmd_ridlist: Error %s(%d)\n", _ibp_error_map[-err], err); return(0); } printf("Resource list for %s:%s (%d resources)\n", argv[0], argv[1], ridlist_get_size(&ridlist)); for (i=0; i<ridlist_get_size(&ridlist); i++) { ibp_rid2str(ridlist_get_element(&ridlist, i), srid); printf("%s\n", srid); } return(0); }
ibp_depot_t *generate_depot_list(int *n_depots, ibp_depot_t *depot_list) { int n, i, j, err; rid_t skip_rid, rid; ibp_depot_t *dl; op_generic_t *gop; ibp_ridlist_t rlist; //*** 1st Query the depot resources *** gop = new_ibp_query_resources_op(ic, depot_list, &rlist, ibp_timeout); err = ibp_sync_command(ibp_get_iop(gop)); if (err != IBP_OK) { printf("Can't query the depot RID list! err=%d\n", err); abort(); } // printf("Number of resources: %d\n", ridlist_get_size(&rlist)); // for (i=0; i<ridlist_get_size(&rlist); i++) { // printf(" %d: %s\n", i, ibp_rid2str(ridlist_get_element(&rlist, i), rbuf)); // } //** Now generate the list n = ridlist_get_size(&rlist); dl = (ibp_depot_t *)malloc(sizeof(ibp_depot_t)*n); if (n < 2) { printf("RID list to short! n=%d\n", n); abort(); } skip_rid = depot_list->rid; j = 0; for (i=0; i<n; i++) { rid = ridlist_get_element(&rlist, i); if (ibp_compare_rid(skip_rid, rid) != 0) { //** See if we skip it set_ibp_depot(&(dl[j]), depot_list->host, depot_list->port, rid); j++; } } gop_free(gop, OP_DESTROY); *n_depots = j; return(dl); }
int main(int argc, char **argv) { ibp_depotinfo_t *depotinfo; ibp_depot_t depot1, depot2; ibp_attributes_t attr; ibp_timer_t timer; ibp_capset_t *caps, *caps2, *caps4; ibp_capset_t caps3, caps5; ibp_capstatus_t astat; ibp_alias_capstatus_t alias_stat; int err, i, len, offset; int bufsize = 1024*1024; char wbuf[bufsize]; char rbuf[bufsize]; char *host1, *host2; int port1, port2; rid_t rid1, rid2; failed_tests = 0; if (argc < 6) { printf("ibp_test [-d loglevel] [-config ibp.cfg] host1 port1 rid1 host2 port2 rid2\n"); printf("\n"); printf(" 2 depots are requred to test depot-depot copies.\n"); printf(" Can use the same depot if necessary\n"); printf("\n"); printf("\n"); return(-1); } ibp_init(); //** Initialize IBP //*** Read in the arguments *** i = 1; if (strcmp(argv[i], "-d") == 0) { i++; set_log_level(atoi(argv[i])); i++; } if (strcmp(argv[i], "-config") == 0) { //** Read the config file i++; ibp_load_config(argv[i]); i++; } host1 = argv[i]; i++; port1 = atoi(argv[i]); i++; rid1 = ibp_str2rid(argv[i]); i++; host2 = argv[i]; i++; port2 = atoi(argv[i]); i++; rid2 = ibp_str2rid(argv[i]); i++; //*** Print the ibp client version *** printf("\n"); printf("================== IBP Client Version =================\n"); printf("%s\n", ibp_client_version()); //*** Init the structures *** ibp_timeout = 5; set_ibp_depot(&depot1, host1, port1, rid1); set_ibp_depot(&depot2, host2, port2, rid2); set_ibp_attributes(&attr, time(NULL) + 60, IBP_HARD, IBP_BYTEARRAY); set_ibp_timer(&timer, ibp_timeout, ibp_timeout); //printf("Before allocate\n"); fflush(stdout); //*** Perform single allocation caps = IBP_allocate(&depot1, &timer, bufsize, &attr); if (caps == NULL) { printf("Error!!!! ibp_errno = %d\n", IBP_errno); return(1); } else { printf("Read: %s\n", caps->readCap); printf("Write: %s\n", caps->writeCap); printf("Manage: %s\n", caps->manageCap); } printf("ibp_manage(IBP_PROBE):-----------------------------------\n"); memset(&astat, 0, sizeof(astat)); err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_PROBE, 0, &astat); if (err == 0) { printf("read count = %d\n", astat.readRefCount); printf("write count = %d\n", astat.writeRefCount); printf("current size = %d\n", astat.currentSize); printf("max size = %lu\n", astat.maxSize); printf("duration = %ld\n", astat.attrib.duration - time(NULL)); printf("reliability = %d\n", astat.attrib.reliability); printf("type = %d\n", astat.attrib.type); } else { failed_tests++; printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } printf("ibp_manage(IBP_DECR for write cap):-----------------------------------\n"); err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_DECR, IBP_WRITECAP, &astat); if (err != 0) { printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_PROBE, 0, &astat); if (err == 0) { printf("read count = %d\n", astat.readRefCount); printf("write count = %d\n", astat.writeRefCount); printf("current size = %d\n", astat.currentSize); printf("max size = %lu\n", astat.maxSize); printf("duration = %lu\n", astat.attrib.duration - time(NULL)); printf("reliability = %d\n", astat.attrib.reliability); printf("type = %d\n", astat.attrib.type); } else { failed_tests++; printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } printf("ibp_manage(IBP_CHNG - incresing size to 2MB and changing duration to 20 sec):-----------------------------------\n"); set_ibp_attributes(&(astat.attrib), time(NULL) + 20, IBP_HARD, IBP_BYTEARRAY); astat.maxSize = 2*1024*1024; err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_CHNG, 0, &astat); if (err != 0) { printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_PROBE, 0, &astat); if (err == 0) { printf("read count = %d\n", astat.readRefCount); printf("write count = %d\n", astat.writeRefCount); printf("current size = %d\n", astat.currentSize); printf("max size = %lu\n", astat.maxSize); printf("duration = %lu\n", astat.attrib.duration - time(NULL)); printf("reliability = %d\n", astat.attrib.reliability); printf("type = %d\n", astat.attrib.type); } else { failed_tests++; printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } //**** Basic Write tests **** printf("write tests..................................\n"); for (i=0; i<bufsize; i++) wbuf[i] = '0'; len = 3*bufsize/4; err = IBP_store(get_ibp_cap(caps, IBP_WRITECAP), &timer, wbuf, len); if (err != len) { failed_tests++; printf("Error with IBP_store1! wrote=%d err=%d\n", err, IBP_errno); } len = bufsize - len; err = IBP_store(get_ibp_cap(caps, IBP_WRITECAP), &timer, wbuf, len); if (err != len) { failed_tests++; printf("Error with IBP_store2! wrote=%d err=%d\n", err, IBP_errno); } for (i=0; i<bufsize; i++) wbuf[i] = '1'; len = bufsize/2; offset = 10; err = IBP_write(get_ibp_cap(caps, IBP_WRITECAP), &timer, wbuf, len, offset); if (err != len) { failed_tests++; printf("Error with IBP_Write! wrote=%d err=%d\n", err, IBP_errno); } printf("ibp_load test...............................\n"); len = bufsize; offset = 0; err = IBP_load(get_ibp_cap(caps, IBP_READCAP), &timer, rbuf, len, offset); if (err != len) { failed_tests++; printf("Error with IBP_load! wrote=%d err=%d\n", err, IBP_errno); } else { rbuf[50] = '\0'; printf("rbuf=%s\n", rbuf); } printf("ibp_copy test................................\n"); //*** Perform single allocation caps2 = IBP_allocate(&depot2, &timer, bufsize, &attr); if (caps2 == NULL) { failed_tests++; printf("Error with allocation of dest cap!!!! ibp_errno = %d\n", IBP_errno); return(1); } else { printf("dest Read: %s\n", caps2->readCap); printf("dest Write: %s\n", caps2->writeCap); printf("dest Manage: %s\n", caps2->manageCap); } err = IBP_copy(get_ibp_cap(caps, IBP_READCAP), get_ibp_cap(caps2, IBP_WRITECAP), &timer, &timer, 1024, 0); if (err != 1024) { failed_tests++; printf("ibp_copy size = %d * ibp_errno=%d\n", err, IBP_errno); } printf("ibp_phoebus_copy test................................\n"); //*** Perform single allocation caps4 = IBP_allocate(&depot2, &timer, bufsize, &attr); if (caps4 == NULL) { printf("Error with allocation of dest cap!!!! ibp_errno = %d\n", IBP_errno); failed_tests++; return(1); } else { printf("dest Read: %s\n", caps4->readCap); printf("dest Write: %s\n", caps4->writeCap); printf("dest Manage: %s\n", caps4->manageCap); } err = IBP_phoebus_copy(NULL, get_ibp_cap(caps, IBP_READCAP), get_ibp_cap(caps4, IBP_WRITECAP), &timer, &timer, 1024, 0); if (err != 1024) { failed_tests++; printf("ibp_copy size = %d * ibp_errno=%d\n", err, IBP_errno); } //** Remove the cap err = IBP_manage(get_ibp_cap(caps4, IBP_MANAGECAP), &timer, IBP_DECR, IBP_READCAP, &astat); if (err != 0) { failed_tests++; printf("Error deleting phoebus dest cap error = %d * ibp_errno=%d\n", err, IBP_errno); } destroy_ibp_capset(caps4); caps4 = NULL; printf("ibp_manage(IBP_DECR):-Removing allocations----------------------------------\n"); err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_DECR, IBP_READCAP, &astat); if (err != 0) { failed_tests++; printf("ibp_manage(decr) for caps1 error = %d * ibp_errno=%d\n", err, IBP_errno); } err = IBP_manage(get_ibp_cap(caps2, IBP_MANAGECAP), &timer, IBP_DECR, IBP_READCAP, &astat); if (err != 0) { failed_tests++; printf("ibp_manage(decr) for caps2 error = %d * ibp_errno=%d\n", err, IBP_errno); } printf("ibp_status: IBP_ST_INQ--------------------------------------------------------\n"); depotinfo = IBP_status(&depot1, IBP_ST_INQ, &timer, "ibp", 10,11,12); if (depotinfo != NULL) { printf("rid=%d * duration=%ld\n", depotinfo->rid, depotinfo->Duration); printf("hc=" LL " hs=" LL " ha=" LL "\n",depotinfo->HardConfigured, depotinfo->HardServed, depotinfo->HardAllocable); printf("tc=" LL " ts=" LL " tu=" LL "\n", depotinfo->TotalConfigured, depotinfo->TotalServed, depotinfo->TotalUsed); } else { failed_tests++; printf("ibp_status error=%d\n", IBP_errno); } //** Perform some basic async R/W alloc/remove tests base_async_test(2, &depot1); //** Now do a few of the extra tests for async only ibp_op_t op; //*** Print the depot version *** set_ibp_version_op(&op, &depot1, rbuf, sizeof(rbuf), ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err == IBP_OK) { printf("Printing depot version information......................................\n"); printf("%s\n", rbuf); } else { failed_tests++; printf("Error getting ibp_version. err=%d\n", err); } //*** Query the depot resources *** ibp_ridlist_t rlist; set_ibp_query_resources_op(&op, &depot1, &rlist, ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err == IBP_OK) { printf("Number of resources: %d\n", ridlist_get_size(&rlist)); for (i=0; i<ridlist_get_size(&rlist); i++) { printf(" %d: %s\n", i, ibp_rid2str(ridlist_get_element(&rlist, i), rbuf)); } } else { failed_tests++; printf("Error querying depot resource list. err=%d\n", err); } perform_user_rw_tests(&depot1); //** Perform the "user" version of the R/W functions //----------------------------------------------------------------------------------------------------- //** check ibp_rename **** printf("Testing IBP_RENAME...............................................\n"); caps = IBP_allocate(&depot1, &timer, bufsize, &attr); if (caps == NULL) { failed_tests++; printf("Error!!!! ibp_errno = %d\n", IBP_errno); return(1); } else { printf("Original Cap..............\n"); printf("Read: %s\n", caps->readCap); printf("Write: %s\n", caps->writeCap); printf("Manage: %s\n", caps->manageCap); } //** Upload the data char *data = "This is a test...."; len = strlen(data)+1; err = IBP_store(get_ibp_cap(caps, IBP_WRITECAP), &timer, data, len); if (err != len) { failed_tests++; printf("Error with IBP_store1! wrote=%d err=%d\n", err, IBP_errno); } //** Rename the allocation set_ibp_rename_op(&op, caps2, get_ibp_cap(caps, IBP_MANAGECAP), ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error with ibp_rename. err=%d\n", err); } else { printf("Renamed Cap..............\n"); printf("Read: %s\n", caps2->readCap); printf("Write: %s\n", caps2->writeCap); printf("Manage: %s\n", caps2->manageCap); } //** Try reading the original which should fail rbuf[0] = '\0'; err = IBP_load(get_ibp_cap(caps, IBP_READCAP), &timer, rbuf, len, 0); if (err != len) { printf("Can't read the original cap after the rename which is good! Got err err=%d\n", err); } else { failed_tests++; printf("Oops! The read of the original cap succeeded! rbuf=%s\n", rbuf); } //** Try reading with the new cap rbuf[0] = '\0'; err = IBP_load(get_ibp_cap(caps2, IBP_READCAP), &timer, rbuf, len, 0); if (err == len) { if (strcmp(rbuf, data) == 0) { printf("Read using the new cap the original data!\n"); } else { failed_tests++; printf("Read some data with the new cap but it wasn't correct!\n"); printf("Original=%s\n", data); printf(" Got=%s\n", wbuf); } } else { failed_tests++; printf("Oops! Failed reading with new cap! err=%d\n", err); } //** Remove the cap err = IBP_manage(get_ibp_cap(caps2, IBP_MANAGECAP), &timer, IBP_DECR, IBP_READCAP, &astat); if (err != 0) { failed_tests++; printf("Error deleting new cap after rename caps2 error = %d * ibp_errno=%d\n", err, IBP_errno); } printf("Completed ibp_rename test...........................\n"); //----------------------------------------------------------------------------------------------------- //** check ibp_alias_allocate/manage **** //**** GOOD printf("Testing IBP_alias_ALLOCATE/MANAGE...............................................\n"); caps = IBP_allocate(&depot1, &timer, bufsize, &attr); if (caps == NULL) { failed_tests++; printf("Error!!!! ibp_errno = %d\n", IBP_errno); return(1); } else { printf("Original Cap..............\n"); printf("Read: %s\n", caps->readCap); printf("Write: %s\n", caps->writeCap); printf("Manage: %s\n", caps->manageCap); } set_ibp_alias_alloc_op(&op, caps2, get_ibp_cap(caps, IBP_MANAGECAP), 0, 0, 0, ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error with ibp_alias_alloc. err=%d\n", err); } else { printf("Alias Cap..............\n"); printf("Read: %s\n", caps2->readCap); printf("Write: %s\n", caps2->writeCap); printf("Manage: %s\n", caps2->manageCap); } err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_PROBE, 0, &astat); if (err == 0) { printf("Actual cap info\n"); printf(" read count = %d\n", astat.readRefCount); printf(" write count = %d\n", astat.writeRefCount); printf(" current size = %d\n", astat.currentSize); printf(" max size = %lu\n", astat.maxSize); printf(" duration = %lu\n", astat.attrib.duration - time(NULL)); printf(" reliability = %d\n", astat.attrib.reliability); printf(" type = %d\n", astat.attrib.type); } else { failed_tests++; printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } err = IBP_manage(get_ibp_cap(caps2, IBP_MANAGECAP), &timer, IBP_PROBE, 0, &astat); if (err == 0) { printf("Using alias to get actual cap info\n"); printf(" read count = %d\n", astat.readRefCount); printf(" write count = %d\n", astat.writeRefCount); printf(" current size = %d\n", astat.currentSize); printf(" max size = %lu\n", astat.maxSize); printf(" duration = %lu\n", astat.attrib.duration - time(NULL)); printf(" reliability = %d\n", astat.attrib.reliability); printf(" type = %d\n", astat.attrib.type); } else { failed_tests++; printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } set_ibp_alias_probe_op(&op, get_ibp_cap(caps2, IBP_MANAGECAP), &alias_stat, ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error with ibp_alias_probe. err=%d\n", err); } else { printf("Alias stat..............\n"); printf(" read count = %d\n", alias_stat.read_refcount); printf(" write count = %d\n", alias_stat.write_refcount); printf(" offset = " ST "\n", alias_stat.offset); printf(" size = " ST "\n", alias_stat.size); printf(" duration = %lu\n", alias_stat.duration - time(NULL)); } set_ibp_alias_alloc_op(&op, &caps3, get_ibp_cap(caps, IBP_MANAGECAP), 10, 40, 0, ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error with ibp_alias_alloc_op. err=%d\n", err); } else { printf("Alias Cap with range 10-50.............\n"); printf("Read: %s\n", caps3.readCap); printf("Write: %s\n", caps3.writeCap); printf("Manage: %s\n", caps3.manageCap); } err = IBP_manage(get_ibp_cap(&caps3, IBP_MANAGECAP), &timer, IBP_PROBE, 0, &astat); if (err == 0) { printf("Using limited alias to get actual cap info\n"); printf(" read count = %d\n", astat.readRefCount); printf(" write count = %d\n", astat.writeRefCount); printf(" current size = %d\n", astat.currentSize); printf(" max size = %lu *** This should be 40\n", astat.maxSize); printf(" duration = %lu\n", astat.attrib.duration - time(NULL)); printf(" reliability = %d\n", astat.attrib.reliability); printf(" type = %d\n", astat.attrib.type); } else { failed_tests++; printf("ibp_manage error = %d * ibp_errno=%d\n", err, IBP_errno); } printf("*append* using the full alias..................................\n"); for (i=0; i<bufsize; i++) wbuf[i] = '0'; err = IBP_store(get_ibp_cap(caps2, IBP_WRITECAP), &timer, wbuf, bufsize); if (err != bufsize) { failed_tests++; printf("Error with IBP_store! wrote=%d err=%d\n", err, IBP_errno); } printf("write using the limited alias..................................\n"); data = "This is a test."; len = strlen(data)+1; err = IBP_write(get_ibp_cap(&caps3, IBP_WRITECAP), &timer, data, len, 0); if (err != len) { failed_tests++; printf("Error with IBP_Write! wrote=%d err=%d\n", err, IBP_errno); } memcpy(&(wbuf[10]), data, strlen(data)+1); len = 10 + strlen(data)+1; err = IBP_load(get_ibp_cap(caps2, IBP_READCAP), &timer, rbuf, len, 0); if (err == len) { if (strcmp(rbuf, wbuf) == 0) { printf("Read using the new full alias the original data!\n"); printf(" read=%s\n", rbuf); } else { failed_tests++; printf("Read some data with the new cap but it wasn't correct!\n"); printf("Original=%s\n", wbuf); printf(" Got=%s\n", rbuf); } } else { failed_tests++; printf("Oops! Failed reading with new cap! err=%d\n", err); } //** Try to R/W beyond the end of the limited cap ** printf("attempting to R/W beyond the end of the limited alias......\n"); data = "This is a test."; len = strlen(data)+1; err = IBP_write(get_ibp_cap(&caps3, IBP_WRITECAP), &timer, data, len, 35); if (err != len) { printf("Correctly got an IBP_Write error! wrote=%d err=%d\n", err, IBP_errno); } else { failed_tests++; printf("Oops! Was able to write beyond the end of the limited cap with new cap!\n"); } err = IBP_load(get_ibp_cap(&caps3, IBP_READCAP), &timer, rbuf, len, 35); if (err != len) { printf("Correctly got an IBP_read error! wrote=%d err=%d\n", err, IBP_errno); } else { failed_tests++; printf("Oops! Was able to read beyond the end of the limited cap with new cap!\n"); } //** Perform a alias->alias copy. The src alias is restricted printf("Testing restricted alias->full alias depot-depot copy\n"); caps4 = IBP_allocate(&depot1, &timer, bufsize, &attr); if (caps == NULL) { failed_tests++; printf("alias-alias allocate Error!!!! ibp_errno = %d\n", IBP_errno); return(1); } else { printf("Depot-Depot copy OriginalDestiniation Cap..............\n"); printf("Read: %s\n", caps4->readCap); printf("Write: %s\n", caps4->writeCap); printf("Manage: %s\n", caps4->manageCap); } set_ibp_alias_alloc_op(&op, &caps5, get_ibp_cap(caps4, IBP_MANAGECAP), 0, 0, 0, ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error with ibp_alias_alloc_op. err=%d\n", err); } else { printf("Destination Alias Cap with full range.............\n"); printf("Read: %s\n", caps5.readCap); printf("Write: %s\n", caps5.writeCap); printf("Manage: %s\n", caps5.manageCap); } //BAD!!!!!!!!!!! //** Perform the copy data = "This is a test."; len = strlen(data)+1; err = IBP_copy(get_ibp_cap(&caps3, IBP_READCAP), get_ibp_cap(&caps5, IBP_WRITECAP), &timer, &timer, len, 0); if (err != len) { printf("ibp_copy size = %d * ibp_errno=%d\n", err, IBP_errno); } //** Load it back and verify ** err = IBP_load(get_ibp_cap(&caps5, IBP_READCAP), &timer, rbuf, len, 0); if (err == len) { if (strcmp(rbuf, data) == 0) { printf("Read using the new full alias the original data!\n"); printf(" read=%s\n", rbuf); } else { failed_tests++; printf("Read some data with the new cap but it wasn't correct!\n"); printf("Original=%s\n", data); printf(" Got=%s\n", rbuf); } } else { failed_tests++; printf("Oops! Failed reading with new cap! err=%d\n", err); } //** Remove the cap5 (full alias) set_ibp_alias_remove_op(&op, get_ibp_cap(&caps5, IBP_MANAGECAP), get_ibp_cap(caps4, IBP_MANAGECAP), ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error dest deleting alias cap error = %d\n", err); } //** Remove the dest cap err = IBP_manage(get_ibp_cap(caps4, IBP_MANAGECAP), &timer, IBP_DECR, IBP_READCAP, &astat); if (err != 0) { failed_tests++; printf("Error deleting dest caps error = %d * ibp_errno=%d\n", err, IBP_errno); } printf("completed alias depot->depot copy test\n"); //** Try to remove the cap2 (full alias) with a bad cap set_ibp_alias_remove_op(&op, get_ibp_cap(caps2, IBP_MANAGECAP), get_ibp_cap(&caps3, IBP_MANAGECAP), ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { printf("Correctly detected error deleting alias cap with an invalid master cap error = %d\n", err); } else { failed_tests++; printf("Oops! Was able to delete the alias with an invalid master cap!!!!!!!!\n"); } //** Remove the cap2 (full alias) set_ibp_alias_remove_op(&op, get_ibp_cap(caps2, IBP_MANAGECAP), get_ibp_cap(caps, IBP_MANAGECAP), ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error deleting alias cap error = %d\n", err); } printf("Try to read the deleted full falias. This should generate an error\n"); err = IBP_load(get_ibp_cap(caps2, IBP_READCAP), &timer, rbuf, len, 35); if (err != len) { printf("Correctly got an IBP_read error! wrote=%d err=%d\n", err, IBP_errno); } else { failed_tests++; printf("Oops! Was able to write beyond the end of the limited cap with new cap!\n"); } //** Remove the limited alias (cap3) set_ibp_alias_remove_op(&op, get_ibp_cap(&caps3, IBP_MANAGECAP), get_ibp_cap(caps, IBP_MANAGECAP), ibp_timeout, NULL, NULL); err = ibp_sync_command(&op); if (err != IBP_OK) { failed_tests++; printf("Error deleting the limited alias cap error = %d\n", err); } //** Remove the original cap err = IBP_manage(get_ibp_cap(caps, IBP_MANAGECAP), &timer, IBP_DECR, IBP_READCAP, &astat); if (err != 0) { failed_tests++; printf("Error deleting original caps error = %d * ibp_errno=%d\n", err, IBP_errno); } //GOOD!!!!!!!!!!!!!!!!!!!! printf("finished testing IBP_alias_ALLOCATE/MANAGE...............................................\n"); perform_splitmerge_tests(&depot1); perform_pushpull_tests(&depot1, &depot2); printf("\n\n"); printf("Final network connection counter: %d\n", network_counter(NULL)); printf("Tests that failed: %d\n", failed_tests); ibp_finalize(); return(0); }