diff options
author | unknown <msvensson@pilot.blaudden> | 2007-04-05 13:54:24 +0200 |
---|---|---|
committer | unknown <msvensson@pilot.blaudden> | 2007-04-05 13:54:24 +0200 |
commit | fd14e73c26ee54c54005389f6244a05dbe22dc6d (patch) | |
tree | 352da2fc64eac0dca1eb0feb43e089bf377d3d2a | |
parent | 309b7a3bd334df5696d85109ba840c08dee1b5e2 (diff) | |
parent | 390a0ede48b42ee41fd26f21dfed088b98dff396 (diff) | |
download | mariadb-git-fd14e73c26ee54c54005389f6244a05dbe22dc6d.tar.gz |
Merge pilot.blaudden:/home/msvensson/mysql/mysql-4.1-maint
into pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint
client/mysqltest.c:
Auto merged
-rw-r--r-- | client/mysqltest.c | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 8b3b22bbbbc..e68b115dfb3 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -810,27 +810,65 @@ void free_used_memory() } +static void cleanup_and_exit(int exit_code) +{ + free_used_memory(); + my_end(MY_CHECK_ERROR); + + if (!silent) + { + switch (exit_code) + { + case 1: + printf("not ok\n"); + break; + case 0: + printf("ok\n"); + break; + case 62: + printf("skipped\n"); + break; + default: + printf("unknown exit code: %d\n", exit_code); + DBUG_ASSERT(0); + } + } + + exit(exit_code); +} + void die(const char *fmt, ...) { + static int dying= 0; va_list args; DBUG_ENTER("die"); DBUG_PRINT("enter", ("start_lineno: %d", start_lineno)); + /* + Protect against dying twice + first time 'die' is called, try to write log files + second time, just exit + */ + if (dying) + cleanup_and_exit(1); + /* Print the error message */ - va_start(args, fmt); + fprintf(stderr, "mysqltest: "); + if (cur_file && cur_file != file_stack) + fprintf(stderr, "In included file \"%s\": ", + cur_file->file_name); + if (start_lineno > 0) + fprintf(stderr, "At line %u: ", start_lineno); if (fmt) { - fprintf(stderr, "mysqltest: "); - if (cur_file && cur_file != file_stack) - fprintf(stderr, "In included file \"%s\": ", - cur_file->file_name); - if (start_lineno > 0) - fprintf(stderr, "At line %u: ", start_lineno); + va_start(args, fmt); vfprintf(stderr, fmt, args); - fprintf(stderr, "\n"); - fflush(stderr); + va_end(args); } - va_end(args); + else + fprintf(stderr, "unknown error"); + fprintf(stderr, "\n"); + fflush(stderr); /* Dump the result that has been accumulated so far to .log file */ if (result_file_name && ds_res.length) @@ -840,14 +878,7 @@ void die(const char *fmt, ...) if (result_file_name && ds_warning_messages.length) dump_warning_messages(); - /* Clean up and exit */ - free_used_memory(); - my_end(MY_CHECK_ERROR); - - if (!silent) - printf("not ok\n"); - - exit(1); + cleanup_and_exit(1); } @@ -880,14 +911,7 @@ void abort_not_supported_test(const char *fmt, ...) } va_end(args); - /* Clean up and exit */ - free_used_memory(); - my_end(MY_CHECK_ERROR); - - if (!silent) - printf("skipped\n"); - - exit(62); + cleanup_and_exit(62); } @@ -6397,14 +6421,9 @@ int main(int argc, char **argv) dump_warning_messages(); timer_output(); - free_used_memory(); - my_end(MY_CHECK_ERROR); - /* Yes, if we got this far the test has suceeded! Sakila smiles */ - if (!silent) - printf("ok\n"); - exit(0); - return 0; /* Keep compiler happy */ + cleanup_and_exit(0); + return 0; /* Keep compiler happy too */ } |