int main(int argc, char *argv[]) { size_t size; int version; CMEM_BlockAttrs attrs; int i; int c; non_interactive_flag = FALSE; while ((c = getopt(argc, argv, "n")) != -1) { switch (c) { case 'n': non_interactive_flag = TRUE; break; default: fprintf(stderr, "Usage: %s [-n] <Number of bytes to allocate>\n", argv[0]); fprintf(stderr, " -n: non-interactive mode (no ENTER prompts)\n"); exit(EXIT_FAILURE); } } if ((argc - optind + 1) != 2) { fprintf(stderr, "Usage: %s [-n] <Number of bytes to allocate>\n", argv[0]); fprintf(stderr, " -n: non-interactive mode (no ENTER prompts)\n"); exit(EXIT_FAILURE); } errno = 0; size = strtol(argv[optind], NULL, 0); if (errno) { fprintf(stderr, "Bad argument ('%s'), strtol() set errno %d\n", argv[optind], errno); exit(EXIT_FAILURE); } /* First initialize the CMEM module */ if (CMEM_init() == -1) { fprintf(stderr, "Failed to initialize CMEM\n"); exit(EXIT_FAILURE); } printf("CMEM initialized.\n"); version = CMEM_getVersion(); if (version == -1) { fprintf(stderr, "Failed to retrieve CMEM version\n"); exit(EXIT_FAILURE); } printf("CMEM version = 0x%x\n", version); testMap(size); testAllocPhys(size); testCMA(size); if (CMEM_getNumBlocks(&nblocks)) { fprintf(stderr, "Failed to retrieve number of blocks\n"); exit(EXIT_FAILURE); } printf("\n# of CMEM blocks (doesn't include possible CMA global 'block'): %d\n", nblocks); if (nblocks) { for (i = 0; i < nblocks; i++) { if (CMEM_getBlockAttrs(i, &attrs) == -1) { fprintf(stderr, "Failed to retrieve CMEM memory block %d bounds\n", i); } else { printf("CMEM memory block %d: phys start = %#llx, size = %#llx\n", i, (unsigned long long)attrs.phys_base, attrs.size); } testHeap(size, i); testHeap(size, i); testPools(size, i); testPools(size, i); testCache(size, i); } } else { printf(" no physical block found, not performing block-based testing\n"); } /* block 'nblocks' is the special CMEM CMA "block" */ testPools(size, CMEM_CMABLOCKID); printf("\nexiting...\n"); if (CMEM_exit() < 0) { fprintf(stderr, "Failed to finalize the CMEM module\n"); } printf("...test done\n"); exit(EXIT_SUCCESS); }
int main(int argc, char **argv) { if (argc != 4) { usage(); } url = argv[1]; char *username = argv[2]; char *password = argv[3]; xmlInitParser(); xmlKeepBlanksDefault(0); xen_init(); curl_global_init(CURL_GLOBAL_ALL); #define CLEANUP \ do { \ xen_session_logout(session); \ curl_global_cleanup(); \ xen_fini(); \ xmlCleanupParser(); \ } while(0) \ xen_session *session = xen_session_login_with_password(call_func, NULL, username, password, xen_api_latest_version); /* --------------------------------------------------------------------- Read host, capabilities and API vsn --------------------------------------------------------------------- */ testConsoles(session); testCrashdumps(session); testHosts(session); testHostCpus(session); testHostCrashdumps(session); testHostMetricss(session); testHostPatchs(session); testNetworks(session); testPBDs(session); testPIFs(session); testPIFMetricss(session); testPools(session); testSMs(session); testSRs(session); testTasks(session); testVBDs(session); testVBDMetricss(session); testVDIs(session); testVIFs(session); testVIFMetricss(session); testVMs(session); testVMGuestMetricss(session); testVMMetricss(session); if (session->api_version == xen_api_version_1_1) { printf( "Rio connection detected; skipping getting records on Bonds, Patches, and VLANs\n\n"); } else { testBonds(session); testPoolPatchs(session); testVLANs(session); } printf("\n\n"); CLEANUP; return 0; }