test/test-automation/src/libSDLtest/plain_logger.c
author Markus Kauppila <markus.kauppila@gmail.com>
Sun, 28 Aug 2011 20:27:25 +0300
changeset 5844 fa860270f65c
parent 5811 36707a804e66
child 5868 33245988e8a2
permissions -rw-r--r--
Option --show-tests prints test description.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5811
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     1
/*
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     2
  Copyright (C) 2011 Markus Kauppila <markus.kauppila@gmail.com>
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     3
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     4
  This software is provided 'as-is', without any express or implied
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     6
  arising from the use of this software.
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     7
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    10
  freely, subject to the following restrictions:
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    11
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    12
  1. The origin of this software must not be misrepresented; you must not
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    13
     claim that you wrote the original software. If you use this software
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    14
     in a product, an acknowledgment in the product documentation would be
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    15
     appreciated but is not required.
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    16
  2. Altered source versions must be plainly marked as such, and must not be
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    17
     misrepresented as being the original software.
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    18
  3. This notice may not be removed or altered from any source distribution.
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    19
*/
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    20
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    21
#ifndef _PLAIN_LOGGER
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    22
#define _PLAIN_LOGGER
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    23
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    24
#include "stdio.h"
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    25
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    26
#include "../../include/SDL_test.h"
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    27
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    28
#include "../runner/logger.h"
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    29
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    30
#include "logger_helpers.h"
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    31
#include "plain_logger.h"
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    32
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    33
/*! Current indentationt level */
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    34
static int indentLevel;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    35
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    36
/*! Logging level of the logger */
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    37
static Level level = LOGGER_TERSE;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    38
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    39
//! Handle to log file
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    40
static FILE *logFile;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    41
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    42
/*!
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    43
 * Prints out the output of the logger
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    44
 *
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    45
 * \param currentIndentLevel The currently used indentation level
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    46
 * \param message The message to be printed out
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    47
 */
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    48
int
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    49
Output(const int currentIndentLevel, const char *message, ...)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    50
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    51
	if(logFile == NULL) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    52
		fprintf(stderr, "logfile is NULL\n");
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    53
		exit(3);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    54
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    55
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    56
	int indent = 0;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    57
	for( ; indent < currentIndentLevel; ++indent) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    58
		fprintf(logFile, "  "); // \todo make configurable?
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    59
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    60
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    61
	char buffer[1024];
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    62
	memset(buffer, 0, 1024);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    63
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    64
	va_list list;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    65
	va_start(list, message);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    66
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    67
	SDL_vsnprintf(buffer, 1024, message, list);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    68
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    69
	va_end(list);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    70
	fprintf(logFile, "%s\n", buffer);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    71
	fflush(logFile);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    72
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    73
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    74
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    75
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    76
PlainRunStarted(int parameterCount, char *runnerParameters[], char *runSeed,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    77
			    time_t eventTime, LoggerData *data)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    78
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    79
	if(data == NULL) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    80
		fprintf(stderr, "Logger data is NULL\n");
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    81
		exit(3);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    82
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    83
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    84
	// Set up the logging destination
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    85
	if(data->stdoutEnabled == 1) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    86
		logFile = stdout;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    87
	} else {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    88
		logFile = fopen(data->filename, "w");
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    89
		if(logFile == NULL) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    90
			fprintf(stderr, "Log file %s couldn't opened\n", data->filename);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    91
			exit(3);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    92
		}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    93
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    94
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    95
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    96
	level = data->level;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    97
	//printf("Debug: %d == %d\n", level, data->level);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    98
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
    99
	Output(indentLevel, "Test run started at %s", TimestampToString(eventTime));
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   100
	Output(indentLevel, "Fuzzer seed is: %s", runSeed);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   101
	Output(indentLevel, "Runner parameters: ");
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   102
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   103
	int counter = 0;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   104
	for(counter = 0; counter < parameterCount; counter++) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   105
		char *parameter = runnerParameters[counter];
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   106
		Output(indentLevel, "\t%s", parameter);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   107
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   108
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   109
	Output(indentLevel, "");
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   110
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   111
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   112
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   113
PlainRunEnded(int testCount, int suiteCount, int testPassCount, int testFailCount,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   114
			  int testSkippedCount, time_t endTime, double totalRuntime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   115
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   116
	Output(indentLevel, "Ran %d tests in %0.5f seconds from %d suites.",
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   117
			testCount, totalRuntime, suiteCount);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   118
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   119
	Output(indentLevel, "%d tests passed", testPassCount);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   120
	Output(indentLevel, "%d tests failed", testFailCount);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   121
	Output(indentLevel, "%d tests skipped", testSkippedCount);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   122
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   123
	fclose(logFile);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   124
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   125
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   126
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   127
PlainSuiteStarted(const char *suiteName, time_t eventTime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   128
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   129
	Output(indentLevel++, "Executing tests from %s", suiteName);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   130
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   131
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   132
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   133
PlainSuiteEnded(int testsPassed, int testsFailed, int testsSkipped,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   134
           time_t endTime, double totalRuntime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   135
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   136
	Output(--indentLevel, "Suite executed. %d passed, %d failed and %d skipped. Total runtime %0.5f seconds",
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   137
			testsPassed, testsFailed, testsSkipped, totalRuntime);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   138
	Output(indentLevel, "");
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   139
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   140
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   141
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   142
PlainTestStarted(const char *testName, const char *suiteName,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   143
				const char *testDescription, Uint64 execKey, time_t startTime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   144
{
5844
fa860270f65c Option --show-tests prints test description.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5811
diff changeset
   145
	Output(indentLevel, "Executing test: %s (in %s). Exec key: %llX", testName, suiteName, execKey);
fa860270f65c Option --show-tests prints test description.
Markus Kauppila <markus.kauppila@gmail.com>
parents: 5811
diff changeset
   146
	Output(indentLevel++, "Test description: %s", testDescription);
5811
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   147
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   148
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   149
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   150
PlainTestEnded(const char *testName, const char *suiteName,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   151
          int testResult, time_t endTime, double totalRuntime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   152
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   153
	switch(testResult) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   154
		case TEST_RESULT_PASS:
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   155
			Output(--indentLevel, "%s: ok", testName);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   156
			break;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   157
		case TEST_RESULT_FAILURE:
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   158
			Output(--indentLevel, "%s: failed", testName);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   159
			break;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   160
		case TEST_RESULT_NO_ASSERT:
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   161
			Output(--indentLevel, "%s: failed -> no assert", testName);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   162
			break;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   163
		case TEST_RESULT_SKIPPED:
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   164
			Output(--indentLevel, "%s: skipped", testName);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   165
			break;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   166
		case TEST_RESULT_KILLED:
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   167
			Output(--indentLevel, "%s: killed, exceeded timeout", testName);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   168
			break;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   169
		case TEST_RESULT_SETUP_FAILURE:
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   170
			Output(--indentLevel, "%s: killed, setup failure", testName);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   171
			break;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   172
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   173
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   174
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   175
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   176
PlainAssert(const char *assertName, int assertResult, const char *assertMessage,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   177
		time_t eventTime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   178
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   179
	// Log passed asserts only on VERBOSE level
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   180
	if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   181
		return ;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   182
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   183
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   184
	const char *result = (assertResult) ? "passed" : "failed";
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   185
	Output(indentLevel, "%s: %s - %s", assertName, result, assertMessage);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   186
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   187
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   188
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   189
PlainAssertWithValues(const char *assertName, int assertResult, const char *assertMessage,
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   190
		int actualValue, int expectedValue, time_t eventTime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   191
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   192
	// Log passed asserts only on VERBOSE level
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   193
	if(level <= LOGGER_TERSE && assertResult == ASSERT_PASS) {
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   194
		return ;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   195
	}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   196
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   197
	const char *result = (assertResult) ? "passed" : "failed";
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   198
	Output(indentLevel, "%s: %s (expected %d, actualValue %d) - %s",
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   199
			assertName, result, expectedValue, actualValue, assertMessage);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   200
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   201
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   202
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   203
PlainAssertSummary(int numAsserts, int numAssertsFailed, int numAssertsPass, time_t eventTime)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   204
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   205
	Output(indentLevel, "Assert summary: %d failed, %d passed (total: %d)",
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   206
			numAssertsFailed, numAssertsPass, numAsserts);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   207
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   208
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   209
void
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   210
PlainLog(time_t eventTime, char *fmt, ...)
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   211
{
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   212
	// create the log message
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   213
	va_list args;
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   214
	char logMessage[1024];
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   215
	memset(logMessage, 0, sizeof(logMessage));
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   216
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   217
	va_start( args, fmt );
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   218
	SDL_vsnprintf( logMessage, sizeof(logMessage), fmt, args );
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   219
	va_end( args );
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   220
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   221
	Output(indentLevel, "%s", logMessage);
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   222
}
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   223
36707a804e66 Trying to fix linux compatibility -> libSDLtest.* is now installed
Markus Kauppila <markus.kauppila@gmail.com>
parents:
diff changeset
   224
#endif