int main(int argc, char **argv) { char opt; int n = 0, x = 0; gw_client_t * gw_session; int num_users, i; gw_msg_user_t * user_status; struct sigaction act; gw_return_code_t rc; /* ---------------------------------------------------------------- */ /* Parse arguments */ /* ---------------------------------------------------------------- */ opterr = 0; optind = 1; while((opt = getopt(argc,argv,"nhx"))!= -1) switch(opt) { case 'n': n = 1; break; case 'x': x = 1; break; case 'h': printf("%s", usage); exit(0); break; case '?': fprintf(stderr,"error: invalid option \'%c\'\n",optopt); printf("%s", susage); exit(1); break; } /* ---------------------------------------------------------------- */ /* Connect to GWD */ /* ---------------------------------------------------------------- */ gw_session = gw_client_init(); if ( gw_session == NULL ) { fprintf(stderr,"Could not connect to gwd\n"); return (-1); } act.sa_handler = signal_handler; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); sigaction(SIGTERM||SIGINT,&act,NULL); /* ---------------------------------------------------------------- */ /* Get job or pool status */ /* ---------------------------------------------------------------- */ rc = gw_client_user_status(&user_status, &num_users); if (rc == GW_RC_SUCCESS) { if (x){ // A.L: It would be nice to include all this settings for header and footer // in the gw_client_print_user_xml function char command[]="gwuser"; int xml_header_flag = 1, xml_footer_flag = 1; if ( xml_header_flag ){ gw_print_xml_header(command); xml_header_flag = 0; } for (i=0;i<num_users;i++){ gw_client_print_user_xml(&(user_status[i])); } if ( xml_footer_flag ){ gw_print_xml_footer(command); xml_footer_flag = 0; } } else { if (!n) gw_client_print_user_header(); for (i=0;i<num_users;i++) gw_client_print_user(&(user_status[i])); } gw_client_finalize(); } else { fprintf(stderr,"FAILED: %s\n",gw_ret_code_string(rc)); gw_client_finalize(); return -1; } return 0; }
int main(int argc, char **argv) { int job_id[MAX_JOBS_WAIT]; int i; int number_of_jobs; int array_id = -1; int error = 0; char opt; int exit_code; int * exit_codes; int a = 0, A = 0, v = 0, k = 0; signed long timeout = -1; gw_client_t * gw_session; gw_boolean_t any = GW_FALSE; struct sigaction act; gw_return_code_t rc; /* ---------------------------------------------------------------- */ /* Parse arguments */ /* ---------------------------------------------------------------- */ opterr = 0; optind = 1; while((opt = getopt(argc,argv,":hkavt:A:"))!= -1) switch(opt) { case 'h': printf("%s", usage); exit(0); break; case 'v': v = 1; break; case 'a': a = 1; any = GW_TRUE; break; case 'A': A = 1; array_id = atoi(optarg); break; case 't': timeout = atoi(optarg); break; case 'k': k = 1; break; case '?': fprintf(stderr,"error: invalid option \'%c\'\n",optopt); printf("%s", susage); exit(1); break; case ':': fprintf(stderr,"error: must provide an argument for option \'%c\'\n", optopt); printf("%s", susage); exit(1); break; } /* ---------------------------------------------------------------- */ /* Connect to GWD */ /* ---------------------------------------------------------------- */ gw_session = gw_client_init(); if ( gw_session == NULL ) { fprintf(stderr,"Could not connect to gwd\n"); return (-1); } act.sa_handler = signal_handler; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); sigaction(SIGTERM||SIGINT,&act,NULL); /* ---------------------------------------------------------------- */ /* Set job id array */ /* ---------------------------------------------------------------- */ if (!A) { if (optind < argc) { number_of_jobs = 0; while ( optind < argc ) { job_id[number_of_jobs++] = atoi(argv[optind++]); if (number_of_jobs >= (MAX_JOBS_WAIT - 1) ) { fprintf(stderr,"FAILED: Max number of jobs reached\n"); error = 1; } } job_id[number_of_jobs] = -1; } else { printf("%s",susage); error = 1; } } else { rc = gw_client_job_status_all( ); if (rc == GW_RC_SUCCESS) { number_of_jobs = 0; for (i=0; i<gw_client.number_of_jobs; i++) if (gw_client.job_pool[i] != NULL) if (gw_client.job_pool[i]->array_id == array_id) { job_id[number_of_jobs++] = gw_client.job_pool[i]->id; if (number_of_jobs>=(MAX_JOBS_WAIT - 1)) { fprintf(stderr,"FAILED: Max number of jobs reached\n"); error = 1; } } job_id[number_of_jobs] = -1; if (number_of_jobs == 0) { fprintf(stderr,"FAILED: failed bad array id\n"); error = 1; } } else { fprintf(stderr,"FAILED: %s\n",gw_ret_code_string(rc)); error = 1; } } if (error) { gw_client_finalize(); return -1; } /* ---------------------------------------------------------------- */ /* Wait for the jobs */ /* ---------------------------------------------------------------- */ if ( number_of_jobs == 1 ) { rc = gw_client_wait(job_id[0], &exit_code, timeout); if ( rc == GW_RC_SUCCESS ) { if (v) { printf("%i\n",exit_code); } if (!k) { gw_client_job_signal(job_id[0],GW_CLIENT_SIGNAL_KILL,GW_FALSE); } } } else { rc = gw_client_wait_set(job_id,&exit_codes,any,timeout); if (rc == GW_RC_SUCCESS) { if (any) { if (v) { printf("%i: %i\n",job_id[0],exit_codes[0]); } if (!k) { gw_client_job_signal(job_id[0],GW_CLIENT_SIGNAL_KILL,GW_FALSE); } } else { for (i=0; i<number_of_jobs; i++) { if (v) { printf("%-4i: %i\n",job_id[i],exit_codes[i]); } if (!k) { gw_client_job_signal(job_id[i],GW_CLIENT_SIGNAL_KILL,GW_FALSE); } } } } free(exit_codes); } gw_client_finalize(); if ( rc != GW_RC_SUCCESS) { fprintf(stderr,"FAILED: %s\n",gw_ret_code_string(rc)); return -1; } else return 0; }
void gw_scheduler_loop(gw_scheduler_function_t scheduler, void *user_arg) { int end = 0; int error = 0; fd_set in_pipes; int rc,j,i; char c; char str[GW_SCHED_MSG_WIDTH]; char act[GW_SCHED_FIELD_WIDTH]; char id1[GW_SCHED_FIELD_WIDTH]; char id2[GW_SCHED_FIELD_WIDTH]; char at1[GW_SCHED_FIELD_WIDTH]; char at2[GW_SCHED_FIELD_WIDTH]; char at3[GW_SCHED_FIELD_WIDTH]; int hid, uid, jid, aid, np; int uslots, ajobs, fixed_priority; int rjobs; float txfr,texe,tsus; char * GW_LOCATION; char * log; char * conf = NULL; char * error_str = NULL; char * name; int length; time_t the_time, deadline; gw_scheduler_t sched; gw_client_t * gw_session = NULL; gw_return_code_t gwrc; gw_migration_reason_t reason; gw_msg_job_t job_status; /* ------------------------------- */ /* Init environment ang log file */ /* ------------------------------- */ GW_LOCATION = getenv("GW_LOCATION"); if(GW_LOCATION == NULL) { error = 1; error_str = strdup("GW_LOCATION environment variable is undefined."); gw_scheduler_print('E',"%s\n",error_str); } else { length = strlen(GW_LOCATION); log =(char *) malloc(sizeof(char)*12 + sizeof(GW_VAR_DIR)); conf=(char *) malloc(sizeof(char)*(length + sizeof(GW_ETC_DIR) + 13)); sprintf(log, GW_VAR_DIR "/sched.log"); sprintf(conf,"%s/" GW_ETC_DIR "/sched.conf",GW_LOCATION); rc = truncate(log, 0); fd_log = fopen(log,"a"); if (fd_log == NULL) { error = 1; error_str = strdup(strerror(errno)); gw_scheduler_print('E',"Could not open file %s - %s\n", log,error_str); } else setbuf(fd_log,NULL); free(log); } setbuf(stdout,NULL); /* ----------------------------------- */ /* Scheduler Initialization */ /* ----------------------------------- */ gw_scheduler_init(&sched); gw_sch_conf_init(&(sched.sch_conf)); rc = gw_sch_loadconf(&(sched.sch_conf), conf); if (rc != 0 ) { gw_scheduler_print('E',"Parsing scheduler configuration file %s, using defaults.\n",conf); } free(conf); the_time = time(NULL); sched.next_user_window = the_time + (time_t) (sched.sch_conf.window_size * 86400); sched.next_host_window = the_time + (time_t) 86400; gw_scheduler_print('I',"Scheduler successfully started.\n"); /* ----------------------------------- */ /* Scheduler Loop */ /* ----------------------------------- */ while (!end) { FD_ZERO(&in_pipes); FD_SET (0,&in_pipes); rc = select(1, &in_pipes, NULL, NULL, NULL); if (rc == -1) { end = 1; gw_scheduler_print('E',"Error in select() - %s\n",strerror(errno)); } j = 0; do { rc = read(0, (void *) &c, sizeof(char)); str[j++] = c; }while ( rc > 0 && c != '\n' ); str[j] = '\0'; if (rc <= 0) { end = 1; } rc = sscanf(str,"%s %s %s %s %s %[^\n]",act,id1,id2,at1,at2,at3); #ifdef GWSCHEDDEBUG gw_scheduler_print('D',"Message received from gwd \"%s %s %s %s %s %s\"\n", act,id1,id2,at1,at2,at3); #endif if (strcmp(act, "INIT") == 0 ) { if (error == 0) printf("INIT - SUCCESS -\n"); else { printf("INIT - FAILURE %s\n",error_str); end = 1; } } else if (strcmp(act, "FINALIZE") == 0 ) { gw_client_finalize(); printf("FINALIZE - SUCCESS -"); end = 1; } else if (strcmp(act, "HOST_MONITOR") == 0 ) { /* Add or update a given host: * HOST_MONITOR HID USLOTS RJOBS NAME - */ hid = atoi(id1); uslots = atoi(id2); rjobs = atoi(at1); name = at2; gw_scheduler_add_host(&sched,hid,uslots,rjobs,name); } else if (strcmp(act, "USER_ADD") == 0 ) { /* Add a user: * USER_ADD UID ASLOTS RSLOTS NAME - */ uid = atoi(id1); ajobs = atoi(id2); rjobs = atoi(at1); name = at2; gw_scheduler_add_user(&sched,uid,ajobs,rjobs,name); } else if (strcmp(act, "USER_DEL") == 0 ) { /* Remove an user * USER_DEL UID - - - - */ uid = atoi(id1); gw_scheduler_del_user(&sched,uid); } else if (strcmp(act, "JOB_DEL") == 0 ) { /* Remove an job * JOB_DEL JID - - - - */ jid = atoi(id1); gw_scheduler_job_del(&sched,jid,0); } else if (strcmp(act, "JOB_FAILED") == 0 ) { /* A job has failed, update user host statistics * JOB_FAILED HID UID REASON - - */ hid = atoi(id1); uid = atoi(id2); reason = (gw_migration_reason_t) atoi(at1); gw_scheduler_job_failed(&sched,hid,uid,reason); } else if (strcmp(act, "JOB_SUCCESS") == 0 ) { /* A job has been successfully executed, update user host statistics * JOB_SUCCESS HID UID XFR SUS EXE */ hid = atoi(id1); uid = atoi(id2); txfr = atof(at1); tsus = atof(at2); texe = atof(at3); gw_scheduler_job_success(&sched,hid,uid,txfr,tsus,texe); } else if (strcmp(act, "JOB_SCHEDULE") == 0 ) { /* A job need schedule add it to the job list * JOB_SCHEDULE JID AID UID REASON - */ jid = atoi(id1); aid = atoi(id2); uid = atoi(at1); reason = (gw_migration_reason_t) atoi(at2); if (gw_session == NULL) { gw_session = gw_client_init(); if (gw_session == NULL) { gw_scheduler_print('E',"Error creating a GW session.\n"); } } gwrc = gw_client_job_status(jid, &job_status); if ( gwrc == GW_RC_SUCCESS ) { fixed_priority = job_status.fixed_priority; np = job_status.np; deadline = job_status.start_time + job_status.deadline; } else { gw_scheduler_print('E',"Error getting job information, will use default values.\n"); fixed_priority = 0; np = 1; deadline = 0; } gw_scheduler_job_add(&sched,jid,aid,np,reason, fixed_priority,uid,deadline); } else if (strcmp(act, "SCHEDULE") == 0 ) { #ifdef GWSCHEDDEBUG gw_scheduler_print('D',"JOBS:%i HOSTS:%i USERS:%i\n", sched.num_jobs,sched.num_hosts,sched.num_users); #endif if ( (sched.num_hosts > 0) && (sched.num_users > 0) && (sched.num_jobs > 0)) { for (i=0;i<sched.num_hosts;i++) sched.hosts[i].dispatched = 0; for (i=0;i<sched.num_users;i++) sched.users[i].dispatched = 0; gw_scheduler_matching_arrays(&sched); if (sched.sch_conf.disable == 0) gw_scheduler_job_policies (&sched); scheduler(&sched,user_arg); } the_time = time(NULL); if ( the_time > sched.next_user_window) { #ifdef GWSCHEDDEBUG gw_scheduler_print('D',"Updating window shares.\n"); #endif sched.next_user_window = time(NULL) + (time_t) (sched.sch_conf.window_size * 86400); gw_scheduler_user_update_windows(&sched); } #ifdef HAVE_LIBDB if ( the_time > sched.next_host_window) { #ifdef GWSCHEDDEBUG gw_scheduler_print('D',"Updating host usage.\n"); #endif sched.next_host_window = time(NULL) + (time_t) 86400; gw_scheduler_update_usage_host(&sched); } #endif printf("SCHEDULE_END - SUCCESS -\n"); } else { gw_scheduler_print('E',"Unknown action from core %s\n.",act); } } if (error == 0) fclose(fd_log); }
int main(int argc, char **argv) { int job_id = -1; int array_id = -1; char opt; int a = 0, k = 0, t = 0, o = 0, s = 0, r = 0, l = 0, A = 0, hard=0; gw_client_t * gw_session; gw_boolean_t blocking = GW_TRUE; gw_client_signal_t signal = GW_CLIENT_SIGNAL_KILL; struct sigaction act; gw_return_code_t rc; int mrc; /* ---------------------------------------------------------------- */ /* Parse arguments */ /* ---------------------------------------------------------------- */ opterr = 0; optind = 1; while((opt = getopt(argc, argv, ":haktosrl9A:")) != -1) switch(opt) { case 'a': a = 1; blocking = GW_FALSE; break; case 't': t = 1; signal = GW_CLIENT_SIGNAL_STOP; break; case 'o': o = 1; signal = GW_CLIENT_SIGNAL_HOLD; break; case 's': s = 1; signal = GW_CLIENT_SIGNAL_RESCHEDULE; break; case 'r': r = 1; signal = GW_CLIENT_SIGNAL_RESUME; break; case 'l': l = 1; signal = GW_CLIENT_SIGNAL_RELEASE; break; case 'k': k = 1; signal = GW_CLIENT_SIGNAL_KILL; break; case '9': hard = 1; signal = GW_CLIENT_SIGNAL_KILL_HARD; break; case 'A': A = 1; array_id = atoi(optarg); break; case 'h': printf("%s", usage); exit(0); break; case '?': fprintf(stderr,"error: invalid option \'%c\'\n",optopt); printf("%s", susage); exit(1); break; case ':': fprintf(stderr,"error: must provide an argument for option \'%c\'\n", optopt); printf("%s", susage); exit(1); break; } if ( t+o+s+r+l+k+hard > 1 ) { printf("%s", susage); exit(1); } if (!A) { if (!(optind < argc)) { printf("%s", susage); return -1; } } /* ---------------------------------------------------------------- */ /* Connect to GWD */ /* ---------------------------------------------------------------- */ gw_session = gw_client_init(); if ( gw_session == NULL ) { fprintf(stderr,"Could not connect to gwd\n"); return (-1); } act.sa_handler = signal_handler; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); sigaction(SIGTERM||SIGINT,&act,NULL); if (A) { rc = gw_client_array_signal (array_id, signal, blocking); if ( rc != GW_RC_SUCCESS) { fprintf(stderr,"FAILED: failed could not signal one or more jobs!\n"); mrc = -1; } else mrc = 0; } else { for (;optind<argc;optind++) { job_id = atoi(argv[optind]); rc = gw_client_job_signal (job_id, signal, blocking); if ( rc != GW_RC_SUCCESS) { fprintf(stderr,"FAILED: %s (job %i)\n", gw_ret_code_string(rc),job_id); mrc = -1; } } } gw_client_finalize(); return mrc; }
int main(int argc, char **argv) { int job_id = -1; char opt; int c = 0, n = 0, f = 0, x = 0; int delay = 0; gw_client_t * gw_session; gw_msg_job_t job_status; struct sigaction act; gw_return_code_t rc; char * hostname = NULL; char * username = NULL; char * outoption = NULL; char jobstate = '&'; // If not set to other value all job states will be printed // (see gw_check_state in gw_cmds_common.c) int i; int array_id = -1; /* ---------------------------------------------------------------- */ /* Parse arguments */ /* ---------------------------------------------------------------- */ opterr = 0; optind = 1; while((opt = getopt(argc, argv, ":nfxhc:u:r:s:o:A:")) != -1) switch(opt) { case 'c': c = 1; delay = atoi(optarg); break; case 'n': n = 1; break; case 'f': f = 1; break; case 'x': x = 1; break; case 'u': username = strdup(optarg); break; case 'r': hostname = strdup(optarg); break; case 's': jobstate = strdup(optarg)[0]; switch(jobstate) { case 'i': case 'p': case 'h': case 'w': case 'e': case 's': case 'k': case 'm': case 'z': case 'f': break; default: printf("ERROR: Job state must be one of {i,p,h,w,e,s,k,m,z,f}\n"); printf("%s", susage); return (-1); break; } break; case 'o': outoption = strdup(optarg); int seen_t=0; for(i=0;i<strlen(outoption);i++) switch(outoption[i]) { case 't': if(seen_t) { printf("ERROR: options t and T are mutually exclusive\n"); printf("%s", susage); return (-1); } seen_t++; break; case 'T': if(seen_t) { printf("ERROR: options t and T are mutually exclusive\n"); printf("%s", susage); return (-1); } seen_t++; break; case 'e': case 's': case 'u': case 'j': case 'h': case 'x': case 'i': case 'f': case 'p': case 'J': case 'y': case 'n': break; default: printf("ERROR: Output format must be constructed with {e,s,u,j,t,h,x,i,p,J,y,n}\n"); printf("%s", susage); return (-1); break; } break; case 'A': array_id = atoi(optarg); break; case 'h': printf("%s", usage); exit(0); break; case '?': fprintf(stderr,"error: invalid option \'%c\'\n",optopt); printf("%s", susage); exit(1); break; case ':': fprintf(stderr,"error: must provide an argument for option \'%c\'\n", optopt); printf("%s", susage); exit(1); break; } if ( optind < argc) job_id = atoi(argv[optind]); /* ---------------------------------------------------------------- */ /* Connect to GWD */ /* ---------------------------------------------------------------- */ gw_session = gw_client_init(); if ( gw_session == NULL ) { if(username != NULL) free(username); if(hostname != NULL) free(hostname); if(outoption != NULL) free(outoption); fprintf(stderr,"Could not connect to gwd\n"); return (-1); } act.sa_handler = signal_handler; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); sigaction(SIGTERM||SIGINT,&act,NULL); /* ---------------------------------------------------------------- */ /* Get job or pool status */ /* ---------------------------------------------------------------- */ do { if (c) { cls(); move(0,0); } if (job_id != -1){ rc = gw_client_job_status(job_id, &job_status); } else { rc = gw_client_job_status_all( ); } if (rc == GW_RC_SUCCESS) { if (f) { if (job_id != -1) gw_client_print_status_full(&job_status); else gw_client_print_pool_status_full(username, hostname, jobstate, array_id); } else if (x) { char command[]=GW_PS_COMMAND_XML; char command_open[GW_PS_COMMAND_OPEN_SIZE_XML]; if ( username == NULL && hostname == NULL ){ sprintf (command_open, "%s", command); } else if ( username != NULL && hostname == NULL ){ sprintf (command_open, "%s USERNAME=\"%s\"", command, username); } else if ( username == NULL && hostname != NULL ){ sprintf (command_open, "%s HOSTNAME=\"%s\"", command, hostname); } else if ( username != NULL && hostname != NULL ){ sprintf (command_open, "%s USERNAME=\"%s\" HOSTNAME=\"%s\"", command, username, hostname); } gw_print_xml_header(command_open); if (job_id != -1){ gw_client_print_status_xml(&job_status); } else { gw_client_print_pool_status_xml(username, hostname, jobstate, array_id); } gw_print_xml_footer(command); } else { if (!n) gw_client_print_status_header(outoption); if (job_id != -1) gw_client_print_status(&job_status, outoption); else gw_client_print_pool_status(username, hostname, jobstate, outoption, array_id); } } else { if(username != NULL) free(username); if(hostname != NULL) free(hostname); if(outoption != NULL) free(outoption); fprintf(stderr,"FAILED: %s\n",gw_ret_code_string(rc)); gw_client_finalize(); return -1; } sleep(delay); } while(c); if(username != NULL) free(username); if(hostname != NULL) free(hostname); if(outoption != NULL) free(outoption); return 0; }
int main(int argc, char **argv) { char lock[PATH_MAX]; char *reason; char *jt_dir; char *server_hostname; char opt; char *GW_LOCATION; int test_index = 0; int failed = 0; int i,j=0; // loop indexes int check_gwd = 1; int params; struct stat buf; printf("GridWay gwtest v%s\n",TEST_VERSION); fflush(NULL); opterr = 0; optind = 1; j++; params = argc; while((opt = getopt(argc, argv, "chs:")) != -1) switch(opt) { case 'h': display_help(); exit(0); break; case 'c': check_gwd = 0; j++; params--; break; case 's': server_hostname = strdup(optarg); change_jts(server_hostname); j+=2; params-=2; break; } // Check args if(params>1) for(;j<argc;j++) { i=atoi(*(argv+j)); if(i<=24 && i>0) { test_matrix[i-1].execute=1; printf("Test %d \"%s\" enabled.\n",i,test_matrix[i-1].test_name); } } else for(i=0;test_matrix[i].test_name;i++) test_matrix[i].execute=1; printf("Checking system and environment."); fflush(NULL); // Check proxy if(check_proxy()!=0) { printf("\nCould not find a valid proxy.\n"); exit(-1); } printf("."); fflush(NULL); // Check environment GW_LOCATION=getenv("GW_LOCATION"); if(GW_LOCATION==NULL) { printf("GW_LOCATION is not set.\n"); exit(-1); } printf("."); fflush(NULL); // Start gwd, fails if already started snprintf(lock, PATH_MAX - 1, GW_VAR_DIR "/.lock"); printf("."); fflush(NULL); if(check_gwd==1) if( stat(lock,&buf) == 0 ) { fprintf(stderr,"\nError! Lock file %s exists. Please ensure gwd is not running before attempting the tests (or use the -c option).\n",lock); exit(-1); } printf("."); fflush(NULL); // TODO -- gwd.conf if(check_gwd==1) system("gwd -c"); sleep(1); printf("."); fflush(NULL); // Change to job template dir jt_dir = (char *) malloc (sizeof(char)*(strlen(GW_LOCATION) + sizeof(GW_TEST_DIR) + 6)); sprintf(jt_dir, "%s/" GW_TEST_DIR "/jt", GW_LOCATION); chdir(jt_dir); printf("."); fflush(NULL); // connect to gwd gw_session = gw_client_init(); printf(".done\n"); fflush(NULL); printf("gwd started, starting tests ... \n"); fflush(NULL); /**------------------------------------------ * 1.Normal Execution (SINGLE) * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 1: Normal Execution (SINGLE)\n"); fflush(NULL); // Test normal execution if(strcmp(reason=normal_execution(0),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 1 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 2.Normal Execution (BULK) * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 2: Normal Execution (BULK)\n"); fflush(NULL); // Test normal execution if(strcmp(reason=normal_execution_bulk(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 2 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 3.Pre Wrapper * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 3: Pre Wrapper\n"); fflush(NULL); // Test normal execution if(strcmp(reason=normal_execution(1),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 3 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 4.Prolog Fail (Fake Stdin) No Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 4: Prolog Fail (Fake Stdin) No Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=prolog_fail(0),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 4 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 5.Prolog Fail (Fake Stdin) Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 5: Prolog Fail (Fake Stdin) Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=prolog_fail(1),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 5 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 6.Prolog Fail (Fake Input) No Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 6: Prolog Fail (Fake Input) No Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=prolog_fail(2),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 6 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 7.Prolog Fail (Fake Executable) No Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 7: Prolog Fail (Fake Executable) No Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=prolog_fail(3),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 7 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 8.Prolog Fail (Fake Stdin) No Reschedule (BULK) * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 8: Prolog Fail (Fake Stdin) No Reschedule (BULK)\n"); fflush(NULL); // Test normal execution if(strcmp(reason=prolog_fail_bulk(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 8 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 9.Execution Fail No Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 9: Execution Fail No Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=execution_fail(0),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 9 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 10.Execution Fail Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 10: Execution Fail Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=execution_fail(1),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 10 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 11.Hold Release * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 11: Hold Release\n"); fflush(NULL); // Test normal execution if(strcmp(reason=hold_release(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 11 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 12.Stop Resume * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 12: Stop Resume\n"); fflush(NULL); // Test normal execution if(strcmp(reason=stop_resume(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 12 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 13.Kill Sync * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 13: Kill Sync\n"); fflush(NULL); // Test normal execution if(strcmp(reason=kill_sync(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 13 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 14.Kill Async * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 14: Kill Async\n"); fflush(NULL); // Test normal execution if(strcmp(reason=kill_async(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 14 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 15.Kill Hard * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 15: Kill Hard\n"); fflush(NULL); // Test normal execution if(strcmp(reason=kill_hard(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 15 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 16.Migrate * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 16: Migrate\n"); fflush(NULL); // Test normal execution if(strcmp(reason=migrate(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 16 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 17.Checkpoint local * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 17: Checkpoint local\n"); fflush(NULL); // Test normal execution if(strcmp(reason=checkpoint(0),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 17 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 18.Checkpoint remote server * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 18: Checkpoint remote server\n"); fflush(NULL); // Test normal execution if(strcmp(reason=checkpoint(1),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 18 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 19.Wait timeout * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 19: Wait timeout\n"); fflush(NULL); // Test normal execution if(strcmp(reason=wait_timeout(0),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 19 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 20.Wait zero timeout * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 20: Wait zero timeout\n"); fflush(NULL); // Test normal execution if(strcmp(reason=wait_timeout(1),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 20 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 21.Input Output files * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 21: Input Output files\n"); fflush(NULL); // Test normal execution if(strcmp(reason=input_output(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 21 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 22.Epilog Fail (Fake Output) No Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 22: Epilog Fail (Fake Output) No Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=epilog_fail(0),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 22 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 23.Epilog Fail (Fake Output) Reschedule * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 23: Epilog Fail (Fake Output) Reschedule\n"); fflush(NULL); // Test normal execution if(strcmp(reason=epilog_fail(1),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 23 finished. Result = %s\n",reason); fflush(NULL); free(reason); } /**------------------------------------------ * 24.Epilog Fail (Fake Output) No Reschedule (BULK) * ------------------------------------------*/ if(test_matrix[test_index++].execute) { printf("Beggining of test 24: Epilog Fail (Fake Output) No Reschedule (BULK)\n"); fflush(NULL); // Test normal execution if(strcmp(reason=epilog_fail_bulk(),"OK")==0) test_matrix[test_index-1].success = 0; else test_matrix[test_index-1].reason = strdup(reason); printf("Test 24 finished. Result = %s\n",reason); fflush(NULL); free(reason); } // Disconnect from gwd gw_client_finalize(); // Get rid of output clutter system("rm std* > /dev/null 2>&1"); system("rm ee* > /dev/null 2>&1"); system("rm oo* > /dev/null 2>&1"); system("rm env* > /dev/null 2>&1"); unlink("outfile"); // Display results for(i=0; i < test_index; i++) { if(test_matrix[i].execute) { if(!test_matrix[i].success) printf("[OK] [%d] Test %s was successful.\n",i+1,test_matrix[i].test_name); else { printf("[ER] [%d] Test %s failed, reason = %s\n", i+1,test_matrix[i].test_name,test_matrix[i].reason); failed++; } } } if(!failed) printf("All GridWay tests successful.\n"); else printf("%d test(s) failed, please report the bug to [email protected].\n",failed); if(check_gwd==1) exit_gwd(); exit(0); }