static void test_battery_result(void) { char **testNames = bbattery_TestNames; double *pVal = bbattery_pVal; double pSuspect = 0.001; test_print("bbattery_NTests = %d", bbattery_NTests); for (int i = 0; i < bbattery_NTests; i++) { /* That test was not done: pVal = -1. */ if (pVal[i] < 0.0) { test_res(i, testNames, pVal, "SKIP"); continue; } /* That test passed or failed. */ if ((pVal[i] >= pSuspect) && (pVal[i] <= 1.0 - pSuspect)) { test_res(i, testNames, pVal, "PASS"); } else { test_res(i, testNames, pVal, "FAIL"); test_failed++; } } }
static void open_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg) { globus_result_t res; int ctr; test_info_t * info; globus_bool_t data = GLOBUS_FALSE; info = (test_info_t *) user_arg; test_res(GLOBUS_XIO_TEST_FAIL_FINISH_OPEN, result, __LINE__, __FILE__); globus_mutex_lock(&info->mutex); { for(ctr = 0; ctr < info->write_count; ctr++) { res = globus_xio_register_write( handle, info->buffer, info->buffer_length, info->buffer_length, NULL, write_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_PASS_WRITE, res, __LINE__, __FILE__); data = GLOBUS_TRUE; } for(ctr = 0; ctr < info->read_count; ctr++) { res = globus_xio_register_read( handle, info->buffer, info->buffer_length, info->buffer_length, NULL, read_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_PASS_READ, res, __LINE__, __FILE__); data = GLOBUS_TRUE; } if(!data) { res = globus_xio_register_close( handle, NULL, close_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } } globus_mutex_unlock(&info->mutex); }
static void open_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg) { globus_result_t res; globus_byte_t * buffer; globus_size_t buffer_length; globus_size_t nbytes; int ctr; buffer = globus_l_test_info.buffer; buffer_length = globus_l_test_info.buffer_length; globus_mutex_lock(&globus_l_mutex); { for(ctr = 0; ctr < OP_COUNT; ctr++) { res = globus_xio_register_write( handle, buffer, buffer_length, buffer_length, NULL, data_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_register_read( handle, buffer, buffer_length, buffer_length, NULL, data_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_write( handle, buffer, buffer_length, buffer_length, &nbytes, NULL); res = globus_xio_read( handle, buffer, buffer_length, buffer_length, &nbytes, NULL); } } globus_mutex_unlock(&globus_l_mutex); }
int main( int argc, char ** argv) { unsigned char buffer[LINE_LEN]; globus_size_t nbytes; globus_result_t res; globus_xio_attr_t attr; char * opts = NULL; if(argc < 2) { fprintf(stderr, "usage: %s url\n", argv[0]); return -1; } if(argc > 2) { opts = argv[2]; } globus_module_activate(GLOBUS_XIO_MODULE); globus_xio_attr_init(&attr); globus_xio_handle_t myhandle; res = globus_xio_handle_create_from_url( &myhandle, argv[1], attr, opts); test_res(res, __LINE__); res = globus_xio_open(myhandle, argv[1], attr); test_res(res, __LINE__); while(res == GLOBUS_SUCCESS) { res = globus_xio_read(myhandle, buffer, LINE_LEN, 1, &nbytes, NULL); buffer[nbytes] = '\0'; printf("%s", buffer); } if(!globus_xio_error_is_eof(res)) { printf("Error before EOF\n"); test_res(res, __LINE__); } globus_xio_close(myhandle, NULL); globus_xio_attr_destroy(attr); globus_module_deactivate(GLOBUS_XIO_MODULE); return 0; }
static void data_cb( globus_xio_handle_t handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { globus_result_t res; char * timeout_type; timeout_type = (char *) user_arg; if(strcmp(timeout_type, "D") == 0) { if(!result_is_timeout(result) && globus_l_timeout) { failed_exit("Read/Write did not timeout."); } } globus_mutex_lock(&globus_l_mutex); { res = globus_xio_register_close( handle, NULL, close_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } globus_mutex_unlock(&globus_l_mutex); }
static void data_cb( globus_xio_handle_t handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { globus_result_t res; globus_mutex_lock(&globus_l_mutex); { res = globus_xio_register_close( handle, NULL, close_cb, user_arg); if(globus_l_close_called) { if(res == GLOBUS_SUCCESS) { failed_exit("close should have failed the second time.\n"); } } else { test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } globus_l_close_called = GLOBUS_TRUE; } globus_mutex_unlock(&globus_l_mutex); }
int Test_Domain(SaHpiSessionIdT session) { int retval = SAF_TEST_UNKNOWN; // On each domain, test the domain event log. retval = test_res(session, SAHPI_UNSPECIFIED_RESOURCE_ID); return (retval); }
int main( int argc, char ** argv) { globus_xio_driver_t tcp_driver; globus_xio_driver_t ftp_driver; globus_xio_stack_t stack; globus_xio_handle_t xio_handle; char * cs; globus_result_t res; char line[LINE_LEN]; globus_bool_t done = GLOBUS_FALSE; globus_size_t nbytes; globus_xio_server_t server_handle; globus_module_activate(GLOBUS_XIO_MODULE); globus_xio_stack_init(&stack, NULL); res = globus_xio_driver_load("tcp", &tcp_driver); test_res(res, __LINE__); res = globus_xio_stack_push_driver(stack, tcp_driver); test_res(res, __LINE__); res = globus_xio_driver_load("gssapi_ftp", &ftp_driver); test_res(res, __LINE__); res = globus_xio_stack_push_driver(stack, ftp_driver); test_res(res, __LINE__); globus_xio_server_create(&server_handle, NULL, stack); globus_xio_server_get_contact_string(server_handle, &cs); fprintf(stdout, "Contact: %s\n", cs); globus_xio_server_accept(&xio_handle, server_handle); res = globus_xio_open(xio_handle, NULL, NULL); test_res(res, __LINE__); res = globus_xio_write(xio_handle, "220 hello\r\n", strlen("220 hello\r\n"), strlen("220 hello\r\n"), &nbytes, NULL); test_res(res, __LINE__); while(!done) { res = globus_xio_read( xio_handle, line, LINE_LEN, 1, &nbytes, NULL); test_res(res, __LINE__); line[nbytes] = '\0'; fprintf(stdout, "%s", line); } globus_xio_close(xio_handle, NULL); globus_module_activate(GLOBUS_XIO_MODULE); return 0; }
int Test_Resource(SaHpiSessionIdT session, SaHpiRptEntryT rpt_entry, callback2_t func) { int retval = SAF_TEST_UNKNOWN; if (rpt_entry.ResourceCapabilities & SAHPI_CAPABILITY_EVENT_LOG) retval = test_res(session, rpt_entry.ResourceId); else // This resource does not support Event logs retval = SAF_TEST_NOTSUPPORT; return (retval); }
static void globus_l_done_cb( globus_gridftp_server_control_t server, globus_result_t res, void * user_arg) { fprintf(stdout, "Done callback received\n"); test_res(res, __LINE__); globus_mutex_lock(&globus_l_mutex); { globus_l_done = GLOBUS_TRUE; globus_cond_signal(&globus_l_cond); } globus_mutex_unlock(&globus_l_mutex); }
static void accept_cb( globus_xio_server_t server, globus_xio_handle_t handle, globus_result_t result, void * user_arg) { globus_xio_handle_t * h; test_res(GLOBUS_XIO_TEST_FAIL_FINISH_ACCEPT, result, __LINE__, __FILE__); h = (globus_xio_handle_t *) user_arg; globus_mutex_lock(&globus_l_mutex); { *h = handle; globus_l_accepted = GLOBUS_TRUE; globus_cond_signal(&globus_l_cond); } globus_mutex_unlock(&globus_l_mutex); }
static void data_cb( globus_xio_handle_t handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { globus_result_t res; globus_mutex_lock(&globus_l_mutex); { res = globus_xio_close( handle, NULL); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); globus_l_closed = GLOBUS_TRUE; globus_cond_signal(&globus_l_cond); } globus_mutex_unlock(&globus_l_mutex); }
int main( int argc, char ** argv) { globus_xio_driver_t tcp_driver; globus_xio_driver_t ftp_driver; globus_xio_stack_t stack; globus_xio_handle_t xio_handle; char * cs; char * subject; globus_result_t res; char line[LINE_LEN]; globus_bool_t done = GLOBUS_FALSE; globus_size_t nbytes; globus_xio_attr_t attr; int len; if(argc < 2) { fprintf(stderr, "arg error: <contact string> <subject>\n"); return 1; } globus_module_activate(GLOBUS_XIO_MODULE); globus_xio_stack_init(&stack, NULL); res = globus_xio_driver_load("tcp", &tcp_driver); test_res(res, __LINE__); res = globus_xio_stack_push_driver(stack, tcp_driver); test_res(res, __LINE__); res = globus_xio_driver_load("gssapi_ftp", &ftp_driver); test_res(res, __LINE__); res = globus_xio_stack_push_driver(stack, ftp_driver); test_res(res, __LINE__); cs = argv[argc - 1]; subject = argv[argc - 2]; res = globus_xio_handle_create(&xio_handle, stack); test_res(res, __LINE__); res = globus_xio_attr_init(&attr); test_res(res, __LINE__); res = globus_xio_attr_cntl(attr, ftp_driver, GLOBUS_XIO_GSSAPI_ATTR_TYPE_SUBJECT, subject); test_res(res, __LINE__); res = globus_xio_open(xio_handle, cs, attr); test_res(res, __LINE__); while(!done) { if(fgets(line, LINE_LEN, stdin) == NULL) { done = GLOBUS_TRUE; } else { len = strlen(line); line[len] = '\r'; len++; line[len] = '\n'; len++; res = globus_xio_write( xio_handle, line, len, len, &nbytes, NULL); test_res(res, __LINE__); } } globus_xio_close(xio_handle, NULL); globus_module_deactivate(GLOBUS_XIO_MODULE); return 0; }
int main( int argc, char ** argv) { globus_xio_stack_t stack; globus_xio_stack_t mode_e_stack; globus_xio_handle_t xio_handle; globus_xio_server_t server; globus_xio_attr_t attr = NULL; char * cs = NULL; globus_result_t res; int ctr; int num_streams = 1; globus_bool_t be_server = GLOBUS_FALSE; int rc; char filename[FILE_NAME_LEN]; FILE * fp; rc = globus_module_activate(GLOBUS_XIO_MODULE); globus_assert(rc == GLOBUS_SUCCESS); res = globus_xio_driver_load("mode_e", &mode_e_driver); test_res(res); res = globus_xio_driver_load("ordering", &ordering_driver); test_res(res); res = globus_xio_stack_init(&stack, NULL); test_res(res); res = globus_xio_stack_push_driver(stack, mode_e_driver); test_res(res); res = globus_xio_stack_push_driver(stack, ordering_driver); test_res(res); res = globus_xio_driver_load("tcp", &tcp_driver); test_res(res); res = globus_xio_stack_init(&mode_e_stack, NULL); test_res(res); res = globus_xio_stack_push_driver(mode_e_stack, tcp_driver); test_res(res); if (argc < 4) { help(); exit(1); } test_res(globus_xio_attr_init(&attr)); test_res(globus_xio_attr_cntl( attr, mode_e_driver, GLOBUS_XIO_MODE_E_SET_STACK, mode_e_stack)); for(ctr = 1; ctr < argc; ctr++) { if(strcmp(argv[ctr], "-h") == 0) { help(); return 0; } else if(strcmp(argv[ctr], "-c") == 0) { if (argc < 5) { help(); exit(1); } cs = argv[ctr + 1]; ctr++; } else if(strcmp(argv[ctr], "-s") == 0) { be_server = GLOBUS_TRUE; } else if(strcmp(argv[ctr], "-p") == 0) { if (argc < 6) { help(); exit(1); } port = atoi(argv[ctr+1]); /* test_res(globus_xio_attr_cntl( attr, mode_e_driver, GLOBUS_XIO_MODE_E_APPLY_ATTR_CNTLS, attr_cntl_cb));*/ } else if(strcmp(argv[ctr], "-P") == 0) { if (argc < 6) { help(); exit(1); } num_streams = atoi(argv[ctr+1]); test_res(globus_xio_attr_init(&attr)); test_res(globus_xio_attr_cntl( attr, ordering_driver, GLOBUS_XIO_ORDERING_SET_MAX_READ_COUNT, num_streams)); test_res(globus_xio_attr_cntl( attr, mode_e_driver, GLOBUS_XIO_MODE_E_SET_NUM_STREAMS, num_streams)); } else if(strcmp(argv[ctr], "-f") == 0) { if (ctr + 1 < argc) { strcpy(filename, argv[ctr + 1]); } else { help(); exit(1); } } } if (!be_server && (!cs || !*cs)) { help(); exit(1); } if(be_server) { globus_size_t size = CHUNK_SIZE + 1; int i, nbytes; res = globus_xio_server_create(&server, attr, stack); test_res(res); globus_xio_server_get_contact_string(server, &cs); fprintf(stdout, "Contact: %s\n", cs); res = globus_xio_server_accept(&xio_handle, server); test_res(res); res = globus_xio_open(xio_handle, NULL, attr); test_res(res); fp = fopen(filename, "w"); while(1) { char * buffer; buffer = (char *) globus_malloc(size); for (i=0; i<size; i++) buffer[i] = '\0'; res = globus_xio_read( xio_handle, buffer, size - 1, 1, &nbytes, NULL); fputs(buffer, fp); if (res != GLOBUS_SUCCESS) break; } res = globus_xio_close(xio_handle, NULL); test_res(res); res = globus_xio_server_close(server); test_res(res); res = globus_xio_driver_unload(mode_e_driver); test_res(res); rc = globus_module_deactivate(GLOBUS_XIO_MODULE); globus_assert(rc == GLOBUS_SUCCESS); } else { globus_size_t size = CHUNK_SIZE + 1; int nbytes; int i,x; res = globus_xio_handle_create(&xio_handle, stack); test_res(res); res = globus_xio_stack_destroy(stack); test_res(res); res = globus_xio_open(xio_handle, cs, attr); test_res(res); globus_mutex_init(&mutex, NULL); globus_cond_init(&cond, NULL); fp = fopen(filename, "r"); globus_mutex_lock(&mutex); while(!feof(fp)) { char * buffer; buffer = (char *) globus_malloc(size); for (i = 0; i < size; i++) buffer[i] = '\0'; x = fread(buffer, CHUNK_SIZE, 1, fp); nbytes = strlen(buffer); res = globus_xio_register_write( xio_handle, buffer, nbytes, nbytes, NULL, write_cb, NULL); test_res(res); ++y; } fclose(fp); /* test_res(globus_xio_data_descriptor_init(&dd, xio_handle)); test_res(globus_xio_data_descriptor_cntl( dd, mode_e_driver, GLOBUS_XIO_MODE_E_SEND_EOD, GLOBUS_TRUE)); res = globus_xio_write( xio_handle, buffer, nbytes, nbytes, &nbytes, NULL); test_res(res); */ while(y) { globus_cond_wait(&mutex, &cond); } globus_mutex_unlock(&mutex); res = globus_xio_close(xio_handle, attr); test_res(res); res = globus_xio_driver_unload(mode_e_driver); test_res(res); res = globus_xio_driver_unload(ordering_driver); test_res(res); rc = globus_module_deactivate(GLOBUS_XIO_MODULE); globus_assert(rc == GLOBUS_SUCCESS); globus_mutex_destroy(&mutex); globus_cond_destroy(&cond); } return 0; }
int timeout_main( int argc, char ** argv) { int rc; globus_xio_stack_t stack; globus_xio_handle_t handle; globus_result_t res; globus_xio_attr_t attr; int secs; int usecs; globus_reltime_t delay; int div = 5; globus_l_closed = GLOBUS_FALSE; globus_l_timeout = GLOBUS_TRUE; rc = globus_module_activate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); res = globus_xio_attr_init(&attr); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_stack_init(&stack, NULL); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); parse_parameters(argc, argv, stack, attr); GlobusTimeReltimeGet(globus_l_test_info.delay, secs, usecs); if(secs == 0 && usecs < USEC_THRESHHOLD) { fprintf(stderr, "ERROR: delay time must be at least %d usecs.\n", USEC_THRESHHOLD); return 1; } GlobusTimeReltimeSet(delay, secs/div, usecs/div); /* set up timeouts */ if(strcmp(argv[argc-1], "O") == 0) { res = globus_xio_attr_cntl(attr, NULL, GLOBUS_XIO_ATTR_SET_TIMEOUT_OPEN, timeout_cb, &delay, NULL); } else if(strcmp(argv[argc-1], "D") == 0) { res = globus_xio_attr_cntl(attr, NULL, GLOBUS_XIO_ATTR_SET_TIMEOUT_READ, timeout_cb, &delay, NULL); res = globus_xio_attr_cntl(attr, NULL, GLOBUS_XIO_ATTR_SET_TIMEOUT_WRITE, timeout_cb, &delay, NULL); } else if(strcmp(argv[argc-1], "C") == 0) { res = globus_xio_attr_cntl(attr, NULL, GLOBUS_XIO_ATTR_SET_TIMEOUT_CLOSE, timeout_cb, &delay, NULL); } else { fprintf(stderr, "ERROR: No timeout registered.\n"); return 1; } test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); globus_mutex_init(&globus_l_mutex, NULL); globus_cond_init(&globus_l_cond, NULL); res = globus_xio_handle_create(&handle, stack); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_register_open( handle, "whatever", attr, open_cb, argv[argc-1]); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); globus_mutex_lock(&globus_l_mutex); { while(!globus_l_closed) { globus_cond_wait(&globus_l_cond, &globus_l_mutex); } } globus_mutex_unlock(&globus_l_mutex); /* run again with an ignored time out */ globus_l_closed = GLOBUS_FALSE; globus_l_timeout = GLOBUS_FALSE; res = globus_xio_handle_create(&handle, stack); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_register_open( handle, "whatever", attr, open_cb, argv[argc-1]); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); globus_mutex_lock(&globus_l_mutex); { while(!globus_l_closed) { globus_cond_wait(&globus_l_cond, &globus_l_mutex); } } globus_mutex_unlock(&globus_l_mutex); /* shut it down */ globus_xio_attr_destroy(attr); globus_xio_stack_destroy(stack); test_common_end(); rc = globus_module_deactivate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); fprintf(stdout, "Success.\n"); return 0; }
static void open_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg) { globus_result_t res; globus_byte_t * buffer; globus_size_t buffer_length; char * timeout_type; buffer = globus_l_test_info.buffer; buffer_length = globus_l_test_info.buffer_length; timeout_type = (char *) user_arg; globus_mutex_lock(&globus_l_mutex); { if(strcmp(timeout_type, "O") == 0) { if(!result_is_timeout(result) && globus_l_timeout) { failed_exit("Open did not timeout."); } else if(result == GLOBUS_SUCCESS) { res = globus_xio_register_close( handle, NULL, close_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } else { globus_l_closed = GLOBUS_TRUE; globus_cond_signal(&globus_l_cond); } } else { if(globus_l_test_info.write_count > 0) { res = globus_xio_register_write( handle, buffer, buffer_length, buffer_length, NULL, data_cb, user_arg); } else { res = globus_xio_register_read( handle, buffer, buffer_length, buffer_length, NULL, data_cb, user_arg); } test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } } globus_mutex_unlock(&globus_l_mutex); }
static void read_cb( globus_xio_handle_t handle, globus_result_t result, globus_byte_t * buffer, globus_size_t len, globus_size_t nbytes, globus_xio_data_descriptor_t data_desc, void * user_arg) { test_info_t * info; globus_result_t res; if(!globus_xio_error_is_eof(result) && !globus_xio_error_is_canceled(result)) { test_res(GLOBUS_XIO_TEST_FAIL_FINISH_READ, result, __LINE__, __FILE__); } info = (test_info_t *) user_arg; globus_mutex_lock(&info->mutex); { if(len < nbytes) { failed_exit("read wait for has failed"); } else if(nbytes > len) { failed_exit("too many bytes were read."); } info->nread += nbytes; if(info->nread >= info->total_read_bytes && !info->read_done) { info->closed++; info->read_done = GLOBUS_TRUE; if(info->closed == 2 || info->write_count == 0) { res = globus_xio_register_close( handle, NULL, close_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } } else if(!info->read_done) { res = globus_xio_register_read( handle, info->buffer, info->buffer_length, info->buffer_length, NULL, read_cb, user_arg); test_res(GLOBUS_XIO_TEST_FAIL_PASS_READ, res, __LINE__, __FILE__); } } globus_mutex_unlock(&info->mutex); }
int space_main( int argc, char ** argv) { int rc; globus_xio_stack_t stack; globus_xio_handle_t handle; globus_result_t res; globus_xio_attr_t attr; globus_condattr_t condattr; globus_l_closed = GLOBUS_FALSE; globus_l_close_called = GLOBUS_FALSE; rc = globus_module_activate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); res = globus_xio_attr_init(&attr); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_stack_init(&stack, NULL); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); parse_parameters(argc, argv, stack, attr); globus_callback_space_init(&globus_l_space, NULL); globus_condattr_init(&condattr); globus_condattr_setspace(&condattr, globus_l_space); globus_mutex_init(&globus_l_mutex, NULL); globus_cond_init(&globus_l_cond, &condattr); res = globus_xio_handle_create(&handle, stack); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_attr_cntl(attr, NULL, GLOBUS_XIO_ATTR_SET_SPACE, globus_l_space); res = globus_xio_register_open( handle, "whatever", attr, open_cb, argv[argc-1]); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); globus_mutex_lock(&globus_l_mutex); { while(!globus_l_closed) { globus_cond_wait(&globus_l_cond, &globus_l_mutex); } } globus_mutex_unlock(&globus_l_mutex); globus_xio_attr_destroy(attr); globus_xio_stack_destroy(stack); test_common_end(); globus_callback_space_destroy(globus_l_space); rc = globus_module_deactivate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); fprintf(stdout, "Success.\n"); return 0; }
static void open_cb( globus_xio_handle_t handle, globus_result_t result, void * user_arg) { globus_result_t res; globus_byte_t * buffer; globus_size_t buffer_length; char * timeout_type; int mask = 0; buffer = globus_l_test_info.buffer; buffer_length = globus_l_test_info.buffer_length; timeout_type = (char *) user_arg; if(strcmp(timeout_type, "O") == 0) { if(!result_is_cancel(result)) { failed_exit("Open was not canceled."); } else { globus_mutex_lock(&globus_l_mutex); { globus_l_closed = GLOBUS_TRUE; globus_cond_signal(&globus_l_cond); } globus_mutex_unlock(&globus_l_mutex); } } else { if(globus_l_test_info.write_count > 0) { res = globus_xio_register_write( handle, buffer, buffer_length, buffer_length, NULL, data_cb, user_arg); mask = GLOBUS_XIO_CANCEL_WRITE; } else { res = globus_xio_register_read( handle, buffer, buffer_length, buffer_length, NULL, data_cb, user_arg); mask = GLOBUS_XIO_CANCEL_READ; } test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); if(strcmp(timeout_type, "D") == 0) { res = globus_xio_handle_cancel_operations( handle, mask); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } } }
int framework_main( int argc, char ** argv) { int rc; globus_xio_stack_t stack; globus_xio_handle_t handle; globus_xio_attr_t attr; globus_result_t res; globus_xio_server_t server; globus_l_closed = GLOBUS_FALSE; globus_l_accepted = GLOBUS_FALSE; rc = globus_module_activate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); globus_mutex_init(&globus_l_mutex, NULL); globus_cond_init(&globus_l_cond, NULL); res = globus_xio_attr_init(&attr); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_stack_init(&stack, NULL); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); parse_parameters(argc, argv, stack, attr); if(globus_l_test_info.server) { res = globus_xio_server_create(&server, attr, stack); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_server_register_accept( server, accept_cb, &handle); test_res(GLOBUS_XIO_TEST_FAIL_PASS_ACCEPT, res, __LINE__, __FILE__); globus_mutex_lock(&globus_l_mutex); { while(!globus_l_accepted) { globus_cond_wait(&globus_l_cond, &globus_l_mutex); } } globus_mutex_unlock(&globus_l_mutex); } else { res = globus_xio_handle_create(&handle, stack); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } res = globus_xio_register_open( handle, "whatever", attr, open_cb, (void *)&globus_l_test_info); test_res(GLOBUS_XIO_TEST_FAIL_PASS_OPEN, res, __LINE__, __FILE__); globus_mutex_lock(&globus_l_mutex); { while(!globus_l_closed) { globus_cond_wait(&globus_l_cond, &globus_l_mutex); } } globus_mutex_unlock(&globus_l_mutex); globus_xio_attr_destroy(attr); globus_xio_stack_destroy(stack); if(globus_l_test_info.server) { res = globus_xio_server_close(server); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); } test_common_end(); rc = globus_module_deactivate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); fprintf(stdout, "Success.\n"); return 0; }
int cancel_main( int argc, char ** argv) { int rc; globus_xio_stack_t stack; globus_xio_handle_t handle; globus_result_t res; globus_xio_attr_t attr; int opt_offset; int secs; int usecs; globus_l_closed = GLOBUS_FALSE; rc = globus_module_activate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); res = globus_xio_attr_init(&attr); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_stack_init(&stack, NULL); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); parse_parameters(argc, argv, stack, attr); GlobusTimeReltimeGet(globus_l_test_info.delay, secs, usecs); if(secs == 0 && usecs < USEC_THRESHHOLD) { fprintf(stderr, "ERROR: delay time must be at least %d usecs.\n", USEC_THRESHHOLD); return 1; } globus_mutex_init(&globus_l_mutex, NULL); globus_cond_init(&globus_l_cond, NULL); res = globus_xio_handle_create(&handle, stack); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); res = globus_xio_register_open( handle, "whatever", attr, open_cb, argv[argc-1]); test_res(GLOBUS_XIO_TEST_FAIL_NONE, res, __LINE__, __FILE__); if(strcmp(argv[argc-1], "O") == 0) { res = globus_xio_handle_cancel_operations( handle, GLOBUS_XIO_CANCEL_OPEN); } globus_mutex_lock(&globus_l_mutex); { while(!globus_l_closed) { globus_cond_wait(&globus_l_cond, &globus_l_mutex); } } globus_mutex_unlock(&globus_l_mutex); globus_xio_attr_destroy(attr); globus_xio_stack_destroy(stack); test_common_end(); rc = globus_module_deactivate(GLOBUS_XIO_MODULE); globus_assert(rc == 0); fprintf(stdout, "Success.\n"); return 0; }
int main( int argc, char ** argv) { globus_xio_driver_t tcp_driver; globus_xio_stack_t stack; globus_xio_handle_t xio_handle; globus_xio_server_t xio_server; globus_result_t res; char * cs; globus_gridftp_server_control_attr_t ftp_attr; globus_gridftp_server_control_t ftp_server; globus_xio_system_socket_t system_handle; globus_module_activate(GLOBUS_XIO_MODULE); globus_module_activate(GLOBUS_GRIDFTP_SERVER_CONTROL_MODULE); globus_mutex_init(&gs_l_mutex, NULL); globus_cond_init(&gs_l_cond, NULL); /* * set up the xio handle */ res = globus_xio_driver_load("tcp", &tcp_driver); test_res(res, __LINE__); res = globus_xio_stack_init(&stack, NULL); test_res(res, __LINE__); res = globus_xio_stack_push_driver(stack, tcp_driver); test_res(res, __LINE__); res = globus_xio_server_create(&xio_server, NULL, stack); test_res(res, __LINE__); globus_xio_stack_destroy(stack); res = globus_xio_server_get_contact_string(xio_server, &cs); test_res(res, __LINE__); fprintf(stdout, "%s\n", cs); globus_free(cs); res = globus_xio_server_accept(&xio_handle, xio_server); test_res(res, __LINE__); fprintf(stdout, "xio connection esstablished.\n"); /* * server connection is all set up, hand it to server_lib */ res = globus_gridftp_server_control_init(&ftp_server); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_init(&ftp_attr); test_res(res, __LINE__); globus_xio_server_close(xio_server); if(argc > 1) { globus_gridftp_server_control_attr_set_security( ftp_attr, GLOBUS_GRIDFTP_SERVER_LIBRARY_GSSAPI | GLOBUS_GRIDFTP_SERVER_LIBRARY_NONE); } else { globus_gridftp_server_control_attr_set_security( ftp_attr, GLOBUS_GRIDFTP_SERVER_LIBRARY_NONE); } res = globus_gridftp_server_control_attr_set_auth( ftp_attr, auth_func, NULL); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_set_resource( ftp_attr, globus_l_resource_cb, NULL); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_set_list( ftp_attr, list_cb, NULL); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_set_idle_time( ftp_attr, 900, 60); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_set_banner( ftp_attr, "This is 1 line of banner\nthis is line 2\nline 3"); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_set_message( ftp_attr, "Setting the message after login, 1 line\n"); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_set_log( ftp_attr, logging_func, GLOBUS_GRIDFTP_SERVER_CONTROL_LOG_ALL, NULL); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_data_functions( ftp_attr, active_connect, NULL, passive_connect, NULL, data_destroy_cb, NULL); res = globus_gridftp_server_control_attr_add_send( ftp_attr, NULL, transfer, NULL); test_res(res, __LINE__); res = globus_gridftp_server_control_attr_add_recv( ftp_attr, NULL, transfer, NULL); test_res(res, __LINE__); res = globus_xio_handle_cntl(xio_handle, tcp_driver, GLOBUS_XIO_TCP_GET_HANDLE, &system_handle); test_res(res, __LINE__); globus_gsc_959_command_add( ftp_server, "SITE MINE", globus_gs_cmd_site, GLOBUS_GSC_COMMAND_POST_AUTH, 2, 2, "SITE <sp> MINE!!!!", NULL); globus_mutex_lock(&globus_l_mutex); { res = globus_gridftp_server_control_start( ftp_server, ftp_attr, system_handle, globus_l_done_cb, FTP_USER_ARG); test_res(res, __LINE__); while(!globus_l_done) { globus_cond_wait(&globus_l_cond, &globus_l_mutex); } } globus_mutex_unlock(&globus_l_mutex); globus_xio_close(xio_handle, NULL); fprintf(stdout, "Ending...\n"); res = globus_gridftp_server_control_attr_destroy(ftp_attr); test_res(res, __LINE__); res = globus_gridftp_server_control_destroy(ftp_server); test_res(res, __LINE__); globus_module_deactivate(GLOBUS_GRIDFTP_SERVER_CONTROL_MODULE); globus_module_deactivate(GLOBUS_XIO_MODULE); return 0; }
int main( int argc, char ** argv) { globus_xio_driver_t driver; globus_xio_stack_t stack; globus_xio_handle_t xio_handle; char * cs; globus_result_t res; char line[LINE_LEN]; int ctr; globus_bool_t done = GLOBUS_FALSE; globus_size_t nbytes; if(argc < 2) { help(); return 1; } globus_module_activate(GLOBUS_XIO_MODULE); globus_xio_stack_init(&stack, NULL); for(ctr = 1; ctr < argc - 1; ctr++) { if(strcmp(argv[ctr], "-h") == 0) { help(); return 0; } else if(strcmp(argv[ctr], "-D") == 0 && ctr + 1 < argc - 1) { ctr++; globus_xio_driver_load(argv[ctr], &driver); globus_xio_stack_push_driver(stack, driver); } } cs = argv[argc - 1]; res = globus_xio_handle_create(&xio_handle, stack); test_res(res); globus_xio_open(xio_handle, cs, NULL); while(!done) { if(fgets(line, LINE_LEN, stdin) == NULL) { done = GLOBUS_TRUE; } else { int len; len = strlen(line); res = globus_xio_write( xio_handle, line, len, len, &nbytes, NULL); test_res(res); } } globus_xio_close(xio_handle, NULL); globus_module_activate(GLOBUS_XIO_MODULE); return 0; }