Small fixes to previous commit.
authorMarkus Kauppila
Sun, 05 Jun 2011 17:34:04 +0300
changeset 56831905dcc7ad20
parent 5682 a04cb565aed2
child 5684 d67b7490be36
Small fixes to previous commit.
test/test-automation/runner.c
     1.1 --- a/test/test-automation/runner.c	Sun Jun 05 16:10:10 2011 +0300
     1.2 +++ b/test/test-automation/runner.c	Sun Jun 05 17:34:04 2011 +0300
     1.3 @@ -256,10 +256,13 @@
     1.4   * Prints usage information
     1.5   */
     1.6  void printUsage() {
     1.7 -	  printf("Usage: ./runner [--in-proc] [--help]\n");
     1.8 +	  printf("Usage: ./runner [--in-proc] [--suite SUITE] [--test TEST] [--help]\n");
     1.9  	  printf("Options:\n");
    1.10 -	  printf(" --in-proc        Executes tests in-process\n");
    1.11 -	  printf(" --help           Print this help\n");
    1.12 +	  printf("    --in-proc        Executes tests in-process\n");
    1.13 +	  printf(" -t --test TEST      Executes only tests with given name\n");
    1.14 +	  printf(" -s --suite SUITE    Executes only the given test suite\n");
    1.15 +
    1.16 +	  printf(" -h --help           Print this help\n");
    1.17  }
    1.18  
    1.19  
    1.20 @@ -285,17 +288,35 @@
    1.21        }
    1.22        else if(SDL_strcmp(arg, "--test") == 0 || SDL_strcmp(arg, "-t") == 0) {
    1.23      	  only_selected_test = 1;
    1.24 -    	  char *testName = argv[++i]; //!< \todo fixme what if i == argc? segfault?
    1.25 +    	  char *testName = NULL;
    1.26  
    1.27 -    	  memset(selected_test_name, 0, NAME_BUFFER_SIZE); // unnecessary?
    1.28 +    	  if( (i + 1) < argc)  {
    1.29 +    		  testName = argv[++i];
    1.30 +    	  }  else {
    1.31 +    		  printf("runner: test name is missing\n");
    1.32 +    		  printUsage();
    1.33 +    		  exit(1);
    1.34 +    	  }
    1.35 +
    1.36 +    	  memset(selected_test_name, 0, NAME_BUFFER_SIZE);
    1.37      	  strcpy(selected_test_name, testName);
    1.38        }
    1.39        else if(SDL_strcmp(arg, "--suite") == 0 || SDL_strcmp(arg, "-s") == 0) {
    1.40      	  only_selected_suite = 1;
    1.41 -    	  char *suiteName = argv[++i]; //!< \todo fixme what if i == argc? segfault?
    1.42  
    1.43 -    	  memset(selected_suite_name, 0, NAME_BUFFER_SIZE); // unnecessary?
    1.44 +    	  char *suiteName = NULL;
    1.45 +    	  if( (i + 1) < argc)  {
    1.46 +    		  suiteName = argv[++i];
    1.47 +    	  }  else {
    1.48 +    		  printf("runner: suite name is missing\n");
    1.49 +    		  printUsage();
    1.50 +    		  exit(1);
    1.51 +    	  }
    1.52 +
    1.53 +    	  memset(selected_suite_name, 0, NAME_BUFFER_SIZE);
    1.54      	  strcpy(selected_suite_name, suiteName);
    1.55 +
    1.56 +    	  printf("%s\n", selected_suite_name);
    1.57        }
    1.58        else {
    1.59      	  printf("runner: unknown command '%s'\n", arg);
    1.60 @@ -331,12 +352,20 @@
    1.61  
    1.62  		if(only_selected_suite)	{
    1.63  			// extract the suite name. Rips the tests/ and file suffix from the suite name
    1.64 -			char buffer[32];
    1.65 +			char buffer[NAME_BUFFER_SIZE];
    1.66  			int len = strlen(testSuiteName);
    1.67 -			int copy = len - 6 - 6;
    1.68 -			memcpy(buffer, testSuiteName + 6, copy);
    1.69 -			//printf("%s\n", buffer);
    1.70 -			//char *name = strndup(testSuiteName[5], 32);
    1.71 +
    1.72 +//! \todo Fix this, it's rather horrible way to do it
    1.73 +#define DIR_NAME_LENGTH 6
    1.74 +#if defined(linux) || defined( __linux)
    1.75 +#define FILE_EXT_LENGTH 3
    1.76 +#else
    1.77 +#define FILE_EXT_LENGTH 6
    1.78 +#endif
    1.79 +			int length = len - DIR_NAME_LENGTH - FILE_EXT_LENGTH;
    1.80 +
    1.81 +			memset(buffer, 0, NAME_BUFFER_SIZE);
    1.82 +			memcpy(buffer, testSuiteName + 6, length);
    1.83  
    1.84  			if(SDL_strncmp(selected_suite_name, buffer, NAME_BUFFER_SIZE) != 0) {
    1.85  				continue;