X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=eglib%2Ftest%2Ftest.c;h=7c870e9c7665a3a074cf4763ca3ed33271b90716;hb=3ac86282de54fb61719007622afa260cc0cd46e0;hp=f3204325d8a27930224a297b7284e2c5e9cccf96;hpb=645c832709723d607cd43d410a291273ded7b725;p=mono.git diff --git a/eglib/test/test.c b/eglib/test/test.c index f3204325d8a..7c870e9c766 100644 --- a/eglib/test/test.c +++ b/eglib/test/test.c @@ -26,16 +26,26 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif + +#include #include #include #include #include -#include #include +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef G_OS_WIN32 +#include +#endif #include "test.h" +extern gint global_passed, global_tests; static gchar *last_result = NULL; gboolean @@ -76,7 +86,7 @@ run_group(Group *group, gint iterations, gboolean quiet, start_time_group = get_timestamp(); for(i = 0; tests[i].name != NULL; i++) { - gchar *result; + gchar *result = ""; gboolean iter_pass, run; iter_pass = FALSE; @@ -133,6 +143,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) { @@ -157,8 +170,13 @@ FAILED(const gchar *format, ...) 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); + n = g_vasprintf(&ret, format, args); va_end(args); if(n == -1) { @@ -168,14 +186,16 @@ FAILED(const gchar *format, ...) last_result = ret; return ret; +#endif } 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; } /* @@ -190,7 +210,7 @@ eg_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens) gchar *strtok_save, **vector; gchar *token, *token_c; gint size = 1; - gint token_length; + size_t token_length; g_return_val_if_fail(string != NULL, NULL); g_return_val_if_fail(delimiter != NULL, NULL); @@ -252,3 +272,4 @@ eg_strfreev (gchar **str_array) } +