Minor refactorings.
authorMarkus Kauppila
Mon, 06 Jun 2011 18:37:53 +0300
changeset 56874a61fa7362ed
parent 5686 a7d699502230
child 5688 bbc19d6aaddb
Minor refactorings.
test/test-automation/runner.c
     1.1 --- a/test/test-automation/runner.c	Mon Jun 06 18:15:19 2011 +0300
     1.2 +++ b/test/test-automation/runner.c	Mon Jun 06 18:37:53 2011 +0300
     1.3 @@ -255,7 +255,8 @@
     1.4  /*!
     1.5   * Prints usage information
     1.6   */
     1.7 -void printUsage() {
     1.8 +void
     1.9 +printUsage() {
    1.10  	  printf("Usage: ./runner [--in-proc] [--suite SUITE] [--test TEST] [--help]\n");
    1.11  	  printf("Options:\n");
    1.12  	  printf("    --in-proc        Executes tests in-process\n");
    1.13 @@ -344,17 +345,16 @@
    1.14  		char buffer[NAME_BUFFER_SIZE];
    1.15  		int len = strlen(testSuiteName);
    1.16  
    1.17 -//! \todo Fix this, it's rather horrible way to do it
    1.18 -#define DIR_NAME_LENGTH 6
    1.19 +		const int dirNameLength = 6;
    1.20  #if defined(linux) || defined( __linux)
    1.21 -#define FILE_EXT_LENGTH 3
    1.22 +		const int fileExtLength = 3;
    1.23  #else
    1.24 -#define FILE_EXT_LENGTH 6
    1.25 +		const int fileExtLength = 6;
    1.26  #endif
    1.27 -		int length = len - DIR_NAME_LENGTH - FILE_EXT_LENGTH;
    1.28 +		int length = len - dirNameLength - fileExtLength;
    1.29  
    1.30  		memset(buffer, 0, NAME_BUFFER_SIZE);
    1.31 -		memcpy(buffer, testSuiteName + DIR_NAME_LENGTH, length);
    1.32 +		memcpy(buffer, testSuiteName + dirNameLength, length);
    1.33  
    1.34  		retVal = SDL_strncmp(selected_suite_name, buffer, NAME_BUFFER_SIZE) == 0;
    1.35  	}
    1.36 @@ -377,53 +377,50 @@
    1.37  	// print: Testing against SDL version fuu (rev: bar) if verbose == true
    1.38  
    1.39  	int failureCount = 0, passCount = 0;
    1.40 +	char *testSuiteName = NULL;
    1.41 +	int suiteCounter = 0;
    1.42  
    1.43  	const Uint32 startTicks = SDL_GetTicks();
    1.44 -
    1.45  	char **testSuiteNames = ScanForTestSuites();
    1.46  
    1.47 -	char *testSuiteName = NULL;
    1.48 -	int suiteCounter = 0;
    1.49  	for(testSuiteName = testSuiteNames[suiteCounter]; testSuiteName; testSuiteName = testSuiteNames[++suiteCounter]) {
    1.50  		// if the current suite isn't selected, go to next suite
    1.51 -		if(SuiteIsSelected(testSuiteName) == 0) {
    1.52 -			continue;
    1.53 -		}
    1.54 +		if(SuiteIsSelected(testSuiteName)) {
    1.55 +			void *suite = LoadTestSuite(testSuiteName);
    1.56 +			TestCaseReference **tests = QueryTestCases(suite);
    1.57 +
    1.58 +			TestCaseReference *reference = NULL;
    1.59 +			int counter = 0;
    1.60 +			for(reference = tests[counter]; reference; reference = tests[++counter]) {
    1.61 +				if(only_selected_test && SDL_strncmp(selected_test_name, reference->name, NAME_BUFFER_SIZE) != 0) {
    1.62 +					continue;
    1.63 +				}
    1.64 +
    1.65 +				if(reference->enabled == TEST_DISABLED) {
    1.66 +					printf("Test %s (in %s) disabled. Omitting...\n", reference->name, testSuiteName);
    1.67 +				} else {
    1.68 +					printf("Executing %s (in %s):\n", reference->name, testSuiteName);
    1.69  
    1.70 -		void *suite = LoadTestSuite(testSuiteName);
    1.71 -		TestCaseReference **tests = QueryTestCases(suite);
    1.72 +					int retVal = ExecuteTest(suite, reference);
    1.73  
    1.74 -		TestCaseReference *reference = NULL;
    1.75 -		int counter = 0;
    1.76 -		for(reference = tests[counter]; reference; reference = tests[++counter]) {
    1.77 -			if(only_selected_test && SDL_strncmp(selected_test_name, reference->name, NAME_BUFFER_SIZE) != 0) {
    1.78 -				continue;
    1.79 +					if(retVal) {
    1.80 +						failureCount++;
    1.81 +						if(retVal == 2) {
    1.82 +							printf("%s (in %s): FAILED -> No asserts\n", reference->name, testSuiteName);
    1.83 +						} else {
    1.84 +							printf("%s (in %s): FAILED\n", reference->name, testSuiteName);
    1.85 +						}
    1.86 +					} else {
    1.87 +						passCount++;
    1.88 +						printf("%s (in %s): ok\n", reference->name, testSuiteName);
    1.89 +					}
    1.90 +				}
    1.91 +
    1.92 +				printf("\n");
    1.93  			}
    1.94  
    1.95 -			if(reference->enabled == TEST_DISABLED) {
    1.96 -				printf("Test %s (in %s) disabled. Omitting...\n", reference->name, testSuiteName);
    1.97 -			} else {
    1.98 -				printf("Executing %s (in %s):\n", reference->name, testSuiteName);
    1.99 -
   1.100 -				int retVal = ExecuteTest(suite, reference);
   1.101 -
   1.102 -				if(retVal) {
   1.103 -					failureCount++;
   1.104 -					if(retVal == 2) {
   1.105 -						printf("%s (in %s): FAILED -> No asserts\n", reference->name, testSuiteName);
   1.106 -					} else {
   1.107 -						printf("%s (in %s): FAILED\n", reference->name, testSuiteName);
   1.108 -					}
   1.109 -				} else {
   1.110 -					passCount++;
   1.111 -					printf("%s (in %s): ok\n", reference->name, testSuiteName);
   1.112 -				}
   1.113 -			}
   1.114 -
   1.115 -			printf("\n");
   1.116 +			SDL_UnloadObject(suite);
   1.117  		}
   1.118 -
   1.119 -		SDL_UnloadObject(suite);
   1.120  	}
   1.121  
   1.122  	const Uint32 endTicks = SDL_GetTicks();