test/test-automation/src/runner/runner.c
changeset 5843 66dc563da07e
parent 5842 2ea6b78e504f
child 5844 fa860270f65c
equal deleted inserted replaced
5842:2ea6b78e504f 5843:66dc563da07e
   967  *
   967  *
   968  * \return Logger data structure (that needs be deallocated)
   968  * \return Logger data structure (that needs be deallocated)
   969  */
   969  */
   970 LoggerData *
   970 LoggerData *
   971 SetUpLogger(const int log_stdout_enabled, const int xml_enabled, const int xsl_enabled,
   971 SetUpLogger(const int log_stdout_enabled, const int xml_enabled, const int xsl_enabled,
   972 			const int custom_xsl_enabled, const char *defaultXslSheet)
   972 			const int custom_xsl_enabled, const char *defaultXslSheet, const time_t timestamp)
   973 {
   973 {
   974 	LoggerData *loggerData = SDL_malloc(sizeof(LoggerData));
   974 	LoggerData *loggerData = SDL_malloc(sizeof(LoggerData));
   975 	if(loggerData == NULL) {
   975 	if(loggerData == NULL) {
   976 		fprintf(stderr, "Error: Logger data structure not allocated.");
   976 		fprintf(stderr, "Error: Logger data structure not allocated.");
   977 		return NULL;
   977 		return NULL;
   990 
   990 
   991 		// create directory (if it doesn't exist yet)
   991 		// create directory (if it doesn't exist yet)
   992 		unsigned int mode = S_IRWXU | S_IRGRP | S_ISUID;
   992 		unsigned int mode = S_IRWXU | S_IRGRP | S_ISUID;
   993 		mkdir(log_directory, mode);
   993 		mkdir(log_directory, mode);
   994 
   994 
   995 		char *timeString = TimestampToStringWithFormat(time(0), "%Y%m%d_%H:%M:%S");
   995 		char *timeString = TimestampToStringWithFormat(timestamp, "%Y%m%d_%H:%M:%S");
   996 
   996 
   997 
   997 
   998 		/* Combine and create directory for log file */
   998 		/* Combine and create directory for log file */
   999 		const Uint32 directoryLength = SDL_strlen(log_directory);
   999 		const Uint32 directoryLength = SDL_strlen(log_directory);
  1000 		const Uint32 basenameLength = SDL_strlen(log_basename);
  1000 		const Uint32 basenameLength = SDL_strlen(log_basename);
  1374 			fprintf(stderr, "Error: Generating harness seed failed\n");
  1374 			fprintf(stderr, "Error: Generating harness seed failed\n");
  1375 			return 2;
  1375 			return 2;
  1376 		}
  1376 		}
  1377 	}
  1377 	}
  1378 
  1378 
       
  1379 	const time_t startTimestamp = time(0);
       
  1380 
  1379 	LoggerData *loggerData = SetUpLogger(log_stdout_enabled, xml_enabled,
  1381 	LoggerData *loggerData = SetUpLogger(log_stdout_enabled, xml_enabled,
  1380 			xsl_enabled, custom_xsl_enabled, defaultXSLStylesheet);
  1382 			xsl_enabled, custom_xsl_enabled, defaultXSLStylesheet, startTimestamp);
  1381 	if(loggerData == NULL) {
  1383 	if(loggerData == NULL) {
  1382 		printf("Failed to create a logger.\n");
  1384 		printf("Failed to create a logger.\n");
  1383 		return 2;
  1385 		return 2;
  1384 	}
  1386 	}
  1385 
  1387 
  1390 		}
  1392 		}
  1391 		printf("Test report is created to: %s\n", loggerData->filename);
  1393 		printf("Test report is created to: %s\n", loggerData->filename);
  1392 		fflush(stdout);
  1394 		fflush(stdout);
  1393 	}
  1395 	}
  1394 
  1396 
  1395 	RunStarted(argc, argv, runSeed, time(0), loggerData);
  1397 	RunStarted(argc, argv, runSeed, startTimestamp, loggerData);
  1396 
  1398 
  1397 	// logger data is no longer used
  1399 	// logger data is no longer used
  1398 	SDL_free(loggerData->filename);
  1400 	SDL_free(loggerData->filename);
  1399 	SDL_free(loggerData);
  1401 	SDL_free(loggerData);
  1400 
  1402