Example #1
0
static void
get_load(int mult, int *ret_r_total, int *ret_t_total)
{
     static double old_r_total = 0;
     static double old_t_total = 0;

     double r_total = 0, t_total = 0;

     input_output( &r_total, &t_total );

     *ret_r_total = ((r_total + old_r_total + old_r_total + old_r_total) / 3.0)*mult;
     *ret_t_total = ((t_total + old_t_total + old_t_total + old_t_total) / 3.0)*mult;

     old_r_total = r_total;
     old_t_total = t_total;
}
Example #2
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);
	
}