Commit b079a624 authored by Simon Morlat's avatar Simon Morlat

improve logging of results for windows and linux

parent 7cbc9c9b
...@@ -51,14 +51,14 @@ ...@@ -51,14 +51,14 @@
#ifdef _WIN32 #ifdef _WIN32
#ifdef WINAPI_FAMILY_PHONE_APP
extern void OutputDebugStringPrintf(const char *fmt, ...); extern void OutputDebugStringPrintf(const char *fmt, ...);
#define fprintf(file, fmt, ...) OutputDebugStringPrintf(fmt, ##__VA_ARGS__) #define fprintf(file, fmt, ...) OutputDebugStringPrintf(fmt, ##__VA_ARGS__)
#endif #elif defined(ANDROID)
#endif extern void AndroidPrintf(FILE *file, const char *fmt, ...);
#ifdef ANDROID
extern void AndroidPrintf(FILE *stream, const char *fmt, ...);
#define fprintf(file, fmt, ...) AndroidPrintf(file, fmt, ##__VA_ARGS__) #define fprintf(file, fmt, ...) AndroidPrintf(file, fmt, ##__VA_ARGS__)
#else
extern void otherPrintf(FILE *file, const char *fmt, ...);
#define fprintf(file, fmt, ...) otherPrintf(file, fmt, ##__VA_ARGS__)
#endif #endif
cunit_trace_handler_t CU_trace_handler = NULL; cunit_trace_handler_t CU_trace_handler = NULL;
......
...@@ -86,16 +86,17 @@ ...@@ -86,16 +86,17 @@
#include "CUnit_intl.h" #include "CUnit_intl.h"
#ifdef _WIN32 #ifdef _WIN32
#ifdef WINAPI_FAMILY_PHONE_APP
extern void OutputDebugStringPrintf(const char *fmt, ...); extern void OutputDebugStringPrintf(const char *fmt, ...);
#define fprintf(file, fmt, ...) OutputDebugStringPrintf(fmt, ##__VA_ARGS__) #define fprintf(file, fmt, ...) OutputDebugStringPrintf(fmt, ##__VA_ARGS__)
#endif #elif defined(ANDROID)
#endif
#ifdef ANDROID
extern void AndroidPrintf(FILE *file, const char *fmt, ...); extern void AndroidPrintf(FILE *file, const char *fmt, ...);
#define fprintf(file, fmt, ...) AndroidPrintf(file, fmt, ##__VA_ARGS__) #define fprintf(file, fmt, ...) AndroidPrintf(file, fmt, ##__VA_ARGS__)
#else
extern void otherPrintf(FILE *file, const char *fmt, ...);
#define fprintf(file, fmt, ...) otherPrintf(file, fmt, ##__VA_ARGS__)
#endif #endif
/*================================================================= /*=================================================================
* Global/Static Definitions * Global/Static Definitions
*=================================================================*/ *=================================================================*/
......
...@@ -53,13 +53,12 @@ ...@@ -53,13 +53,12 @@
#include "TestDB.h" #include "TestDB.h"
#include "Util.h" #include "Util.h"
extern cunit_trace_handler_t CU_trace_handler;
#ifdef _WIN32 #ifdef _WIN32
#ifdef WINAPI_FAMILY_PHONE_APP
#include <stdarg.h> #include <stdarg.h>
#include <winsock2.h> #include <winsock2.h>
extern cunit_trace_handler_t CU_trace_handler;
void OutputDebugStringPrintf(const char *fmt, ...) { void OutputDebugStringPrintf(const char *fmt, ...) {
char msg[512]; char msg[512];
...@@ -70,6 +69,7 @@ void OutputDebugStringPrintf(const char *fmt, ...) { ...@@ -70,6 +69,7 @@ void OutputDebugStringPrintf(const char *fmt, ...) {
if (CU_trace_handler) { if (CU_trace_handler) {
CU_trace_handler(1, fmt, args); CU_trace_handler(1, fmt, args);
} else { } else {
#ifdef _MSC_VER
len = vsnprintf(msg, sizeof(msg), fmt, args); len = vsnprintf(msg, sizeof(msg), fmt, args);
if (len > 0) { if (len > 0) {
#ifndef _UNICODE #ifndef _UNICODE
...@@ -79,17 +79,16 @@ void OutputDebugStringPrintf(const char *fmt, ...) { ...@@ -79,17 +79,16 @@ void OutputDebugStringPrintf(const char *fmt, ...) {
mbstowcs(tmp, msg, len); mbstowcs(tmp, msg, len);
OutputDebugString(tmp); OutputDebugString(tmp);
free(tmp); free(tmp);
#endif #endif
#endif
} }
} }
va_end(args); va_end(args);
} }
#endif #elif defined(ANDROID)
#endif
#ifdef ANDROID
#include <android/log.h> #include <android/log.h>
extern cunit_trace_handler_t CU_trace_handler;
void AndroidPrintf(FILE *file, const char *fmt, ...) { void AndroidPrintf(FILE *file, const char *fmt, ...) {
char msg[512]; char msg[512];
...@@ -105,6 +104,21 @@ void AndroidPrintf(FILE *file, const char *fmt, ...) { ...@@ -105,6 +104,21 @@ void AndroidPrintf(FILE *file, const char *fmt, ...) {
} }
va_end(args); va_end(args);
} }
#else
void otherPrintf(FILE *file, const char *fmt, ...){
va_list args;
int error = (file == stderr);
va_start(args, fmt);
if (CU_trace_handler) {
CU_trace_handler((error)?1:0, fmt, args);
} else {
vfprintf(file, fmt, args);
}
va_end(args);
}
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment