projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix the quiet build code so it works with a separate build dir too.
[mono.git]
/
eglib
/
test
/
test.c
diff --git
a/eglib/test/test.c
b/eglib/test/test.c
index 355d00b117af45765f2039269b7794f5cdcee986..6dd7bf47469a891c8ca708bf157b99f04936fd02 100644
(file)
--- a/
eglib/test/test.c
+++ b/
eglib/test/test.c
@@
-26,15
+26,33
@@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
-#include <sys/time.h>
#include <glib.h>
#include <glib.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef G_OS_WIN32
+#include <winsock2.h>
+#endif
#include "test.h"
#include "test.h"
+extern gint global_passed, global_tests;
+
+#ifndef HAVE_VASPRINTF
+ /* systen does not provide a vasprintf function, use the one
+ provided within eglib itself */
+extern int vasprintf(char **ret, const char *format, va_list ap);
+#endif
+
static gchar *last_result = NULL;
gboolean
static gchar *last_result = NULL;
gboolean
@@
-75,7
+93,7
@@
run_group(Group *group, gint iterations, gboolean quiet,
start_time_group = get_timestamp();
for(i = 0; tests[i].name != NULL; i++) {
start_time_group = get_timestamp();
for(i = 0; tests[i].name != NULL; i++) {
- gchar *result;
+ gchar *result
= ""
;
gboolean iter_pass, run;
iter_pass = FALSE;
gboolean iter_pass, run;
iter_pass = FALSE;
@@
-132,6
+150,9
@@
run_group(Group *group, gint iterations, gboolean quiet,
}
}
}
}
+ global_passed += passed;
+ global_tests += total;
+
if(!quiet) {
gdouble pass_percentage = ((gdouble)passed / (gdouble)total) * 100.0;
if(time) {
if(!quiet) {
gdouble pass_percentage = ((gdouble)passed / (gdouble)total) * 100.0;
if(time) {
@@
-156,6
+177,11
@@
FAILED(const gchar *format, ...)
va_list args;
gint n;
va_list args;
gint n;
+#if !defined(HAVE_VASPRINTF) && !defined(_EGLIB_MAJOR)
+ /* We are linked against the real glib, no vasprintf */
+ g_assert_not_reached ();
+ return NULL;
+#else
va_start(args, format);
n = vasprintf(&ret, format, args);
va_end(args);
va_start(args, format);
n = vasprintf(&ret, format, args);
va_end(args);
@@
-167,14
+193,16
@@
FAILED(const gchar *format, ...)
last_result = ret;
return ret;
last_result = ret;
return ret;
+#endif
}
gdouble
get_timestamp()
{
}
gdouble
get_timestamp()
{
- struct timeval tp;
- gettimeofday(&tp, NULL);
- return (gdouble)tp.tv_sec + (1.e-6) * tp.tv_usec;
+ /* FIXME: We should use g_get_current_time here */
+ GTimeVal res;
+ g_get_current_time (&res);
+ return res.tv_sec + (1.e-6) * res.tv_usec;
}
/*
}
/*
@@
-189,7
+217,7
@@
eg_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens)
gchar *strtok_save, **vector;
gchar *token, *token_c;
gint size = 1;
gchar *strtok_save, **vector;
gchar *token, *token_c;
gint size = 1;
-
gin
t token_length;
+
size_
t token_length;
g_return_val_if_fail(string != NULL, NULL);
g_return_val_if_fail(delimiter != NULL, NULL);
g_return_val_if_fail(string != NULL, NULL);
g_return_val_if_fail(delimiter != NULL, NULL);
@@
-251,3
+279,4
@@
eg_strfreev (gchar **str_array)
}
}
+