diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-10-19 21:45:18 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-10-19 21:45:18 +0200 |
commit | 76f0b94bb0b2994d639353530c5b251d0f1a204b (patch) | |
tree | 9ed50628aac34f89a37637bab2fc4915b86b5eb4 /unittest/mytap | |
parent | 4e46d8e5bff140f2549841167dc4b65a3c0a645d (diff) | |
parent | 5dc1a2231f55bacc9aaf0e24816f3d9c2ee1f21d (diff) | |
download | mariadb-git-76f0b94bb0b2994d639353530c5b251d0f1a204b.tar.gz |
merge with 5.3
sql/sql_insert.cc:
CREATE ... IF NOT EXISTS may do nothing, but
it is still not a failure. don't forget to my_ok it.
******
CREATE ... IF NOT EXISTS may do nothing, but
it is still not a failure. don't forget to my_ok it.
sql/sql_table.cc:
small cleanup
******
small cleanup
Diffstat (limited to 'unittest/mytap')
-rw-r--r-- | unittest/mytap/tap.c | 90 |
1 files changed, 87 insertions, 3 deletions
diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c index f7a6d881421..05407a442f0 100644 --- a/unittest/mytap/tap.c +++ b/unittest/mytap/tap.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. + Copyright (c) 2011, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,6 +28,10 @@ #include <string.h> #include <signal.h> +static ulong start_timer(void); +static void end_timer(ulong start_time,char *buff); +static void nice_time(double sec,char *buff,my_bool part_second); + /* Visual Studio 2003 does not know vsnprintf but knows _vsnprintf. We don't put this #define elsewhere because we prefer my_vsnprintf @@ -126,7 +131,7 @@ emit_endl() static void handle_core_signal(int signo) { - BAIL_OUT("Signal %d thrown", signo); + BAIL_OUT("Signal %d thrown\n", signo); } void @@ -136,6 +141,8 @@ BAIL_OUT(char const *fmt, ...) va_start(ap, fmt); fprintf(tapout, "Bail out! "); vfprintf(tapout, fmt, ap); + diag("%d tests planned, %d failed, %d was last executed", + g_test.plan, g_test.failed, g_test.last); emit_endl(); va_end(ap); exit(255); @@ -159,6 +166,7 @@ typedef struct signal_entry { } signal_entry; static signal_entry install_signal[]= { + { SIGINT, handle_core_signal }, { SIGQUIT, handle_core_signal }, { SIGILL, handle_core_signal }, { SIGABRT, handle_core_signal }, @@ -182,6 +190,7 @@ static signal_entry install_signal[]= { }; int skip_big_tests= 1; +ulong start_time= 0; void plan(int count) @@ -189,6 +198,8 @@ plan(int count) char *config= getenv("MYTAP_CONFIG"); size_t i; + start_time= start_timer(); + if (config) skip_big_tests= strcmp(config, "big"); @@ -286,6 +297,7 @@ skip(int how_many, char const *fmt, ...) } } + void todo_start(char const *message, ...) { @@ -301,7 +313,10 @@ todo_end() *g_test.todo = '\0'; } -int exit_status() { +int exit_status() +{ + char buff[60]; + /* If there were no plan, we write one last instead. */ @@ -320,10 +335,79 @@ int exit_status() { diag("Failed %d tests!", g_test.failed); return EXIT_FAILURE; } + if (start_time) + { + end_timer(start_time, buff); + printf("Test took %s\n", buff); + fflush(stdout); + } return EXIT_SUCCESS; } +#if defined(__WIN__) || defined(__NETWARE__) +#include <time.h> +#else +#include <sys/times.h> +#ifdef _SC_CLK_TCK // For mit-pthreads +#undef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC (sysconf(_SC_CLK_TCK)) +#endif +#endif + +static ulong start_timer(void) +{ +#if defined(__WIN__) || defined(__NETWARE__) + return clock(); +#else + struct tms tms_tmp; + return times(&tms_tmp); +#endif +} + + +/** + Write as many as 52+1 bytes to buff, in the form of a legible + duration of time. + + len("4294967296 days, 23 hours, 59 minutes, 60.00 seconds") -> 52 +*/ + +static void nice_time(double sec,char *buff, my_bool part_second) +{ + ulong tmp; + if (sec >= 3600.0*24) + { + tmp=(ulong) (sec/(3600.0*24)); + sec-=3600.0*24*tmp; + buff+= sprintf(buff, "%ld %s", tmp, tmp > 1 ? " days " : " day "); + } + if (sec >= 3600.0) + { + tmp=(ulong) (sec/3600.0); + sec-=3600.0*tmp; + buff+= sprintf(buff, "%ld %s", tmp, tmp > 1 ? " hours " : " hour "); + } + if (sec >= 60.0) + { + tmp=(ulong) (sec/60.0); + sec-=60.0*tmp; + buff+= sprintf(buff, "%ld min ", tmp); + } + if (part_second) + sprintf(buff,"%.2f sec",sec); + else + sprintf(buff,"%d sec",(int) sec); +} + + +static void end_timer(ulong start_time,char *buff) +{ + nice_time((double) (start_timer() - start_time) / + CLOCKS_PER_SEC,buff,1); +} + + /** @mainpage Testing C and C++ using MyTAP |