Commit 65fa527a authored by unknown's avatar unknown

Improve error messages

Write test results to var/log
Add test for "source" and variable expansion


client/mysqltest.c:
  Improve error messages
  Write .reject file to the location specified by --logdir
mysql-test/mysql-test-run.pl:
  Pass logdir to mysqltest, to get test results written to var/log
mysql-test/r/mysqltest.result:
  Update test results
mysql-test/t/mysqltest.test:
  Add test for "source" and variable expansion
  Update test after writing result in var/log
parent c2f6f8b6
...@@ -1125,7 +1125,7 @@ void cat_file(DYNAMIC_STRING* ds, const char* filename) ...@@ -1125,7 +1125,7 @@ void cat_file(DYNAMIC_STRING* ds, const char* filename)
char buff[512]; char buff[512];
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0) if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
die("Failed to open file %s", filename); die("Failed to open file '%s'", filename);
while((len= my_read(fd, (byte*)&buff, while((len= my_read(fd, (byte*)&buff,
sizeof(buff), MYF(0))) > 0) sizeof(buff), MYF(0))) > 0)
{ {
...@@ -1364,7 +1364,7 @@ int compare_files2(File fd, const char* filename2) ...@@ -1364,7 +1364,7 @@ int compare_files2(File fd, const char* filename2)
if ((fd2= my_open(filename2, O_RDONLY, MYF(0))) < 0) if ((fd2= my_open(filename2, O_RDONLY, MYF(0))) < 0)
{ {
my_close(fd, MYF(0)); my_close(fd, MYF(0));
die("Failed to open second file: %s", filename2); die("Failed to open second file: '%s'", filename2);
} }
while((len= my_read(fd, (byte*)&buff, while((len= my_read(fd, (byte*)&buff,
sizeof(buff), MYF(0))) > 0) sizeof(buff), MYF(0))) > 0)
...@@ -1421,7 +1421,7 @@ int compare_files(const char* filename1, const char* filename2) ...@@ -1421,7 +1421,7 @@ int compare_files(const char* filename1, const char* filename2)
int error; int error;
if ((fd= my_open(filename1, O_RDONLY, MYF(0))) < 0) if ((fd= my_open(filename1, O_RDONLY, MYF(0))) < 0)
die("Failed to open first file: %s", filename1); die("Failed to open first file: '%s'", filename1);
error= compare_files2(fd, filename2); error= compare_files2(fd, filename2);
...@@ -1447,12 +1447,12 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) ...@@ -1447,12 +1447,12 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
{ {
int error; int error;
File fd; File fd;
char ds_temp_file_path[FN_REFLEN]; char temp_file_path[FN_REFLEN];
DBUG_ENTER("dyn_string_cmp"); DBUG_ENTER("dyn_string_cmp");
DBUG_PRINT("enter", ("fname: %s", fname)); DBUG_PRINT("enter", ("fname: %s", fname));
if ((fd= create_temp_file(ds_temp_file_path, NULL, if ((fd= create_temp_file(temp_file_path, NULL,
"tmp", O_CREAT | O_SHARE | O_RDWR, "tmp", O_CREAT | O_SHARE | O_RDWR,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
die("Failed to create temporary file for ds"); die("Failed to create temporary file for ds");
...@@ -1464,15 +1464,15 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) ...@@ -1464,15 +1464,15 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
{ {
my_close(fd, MYF(0)); my_close(fd, MYF(0));
/* Remove the temporary file */ /* Remove the temporary file */
my_delete(ds_temp_file_path, MYF(0)); my_delete(temp_file_path, MYF(0));
die("Failed to write to '%s'", ds_temp_file_path); die("Failed to write file '%s'", temp_file_path);
} }
error= compare_files2(fd, fname); error= compare_files2(fd, fname);
my_close(fd, MYF(0)); my_close(fd, MYF(0));
/* Remove the temporary file */ /* Remove the temporary file */
my_delete(ds_temp_file_path, MYF(0)); my_delete(temp_file_path, MYF(0));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -1498,6 +1498,9 @@ void check_result(DYNAMIC_STRING* ds) ...@@ -1498,6 +1498,9 @@ void check_result(DYNAMIC_STRING* ds)
DBUG_ASSERT(result_file_name); DBUG_ASSERT(result_file_name);
DBUG_PRINT("enter", ("result_file_name: %s", result_file_name)); DBUG_PRINT("enter", ("result_file_name: %s", result_file_name));
if (access(result_file_name, F_OK) != 0)
die("The specified result file does not exist: '%s'", result_file_name);
switch (dyn_string_cmp(ds, result_file_name)) switch (dyn_string_cmp(ds, result_file_name))
{ {
case RESULT_OK: case RESULT_OK:
...@@ -1507,12 +1510,15 @@ void check_result(DYNAMIC_STRING* ds) ...@@ -1507,12 +1510,15 @@ void check_result(DYNAMIC_STRING* ds)
/* Fallthrough */ /* Fallthrough */
case RESULT_CONTENT_MISMATCH: case RESULT_CONTENT_MISMATCH:
{ {
/* Result mismatched, dump results to .reject file and then show the diff */ /*
Result mismatched, dump results to .reject file
and then show the diff
*/
char reject_file[FN_REFLEN]; char reject_file[FN_REFLEN];
fn_format(reject_file, result_file_name, "", ".reject", str_to_file(fn_format(reject_file, result_file_name, opt_logdir, ".reject",
MY_REPLACE_EXT); *opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT :
DBUG_PRINT("enter", ("reject_file_name: %s", reject_file)); MY_REPLACE_EXT),
str_to_file(reject_file, ds->str, ds->length); ds->str, ds->length);
dynstr_set(ds, NULL); /* Don't create a .log file */ dynstr_set(ds, NULL); /* Don't create a .log file */
...@@ -2121,7 +2127,7 @@ int open_file(const char *name) ...@@ -2121,7 +2127,7 @@ int open_file(const char *name)
if (!(cur_file->file = my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0)))) if (!(cur_file->file = my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
{ {
cur_file--; cur_file--;
die("Could not open file %s", buff); die("Could not open file '%s'", buff);
} }
cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
cur_file->lineno=1; cur_file->lineno=1;
...@@ -4980,7 +4986,7 @@ void read_embedded_server_arguments(const char *name) ...@@ -4980,7 +4986,7 @@ void read_embedded_server_arguments(const char *name)
embedded_server_args[0]= (char*) ""; /* Progname */ embedded_server_args[0]= (char*) ""; /* Progname */
} }
if (!(file=my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME)))) if (!(file=my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
die("Failed to open file %s", buff); die("Failed to open file '%s'", buff);
while (embedded_server_arg_count < MAX_EMBEDDED_SERVER_ARGS && while (embedded_server_arg_count < MAX_EMBEDDED_SERVER_ARGS &&
(str=fgets(argument,sizeof(argument), file))) (str=fgets(argument,sizeof(argument), file)))
......
...@@ -4677,6 +4677,7 @@ sub run_mysqltest ($) { ...@@ -4677,6 +4677,7 @@ sub run_mysqltest ($) {
mtr_add_arg($args, "--skip-safemalloc"); mtr_add_arg($args, "--skip-safemalloc");
mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir);
mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir); mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir);
mtr_add_arg($args, "--logdir=%s/log", $opt_vardir);
# Log line number and time for each line in .test file # Log line number and time for each line in .test file
mtr_add_arg($args, "--mark-progress") mtr_add_arg($args, "--mark-progress")
......
...@@ -293,7 +293,7 @@ var5 from query that returns no row ...@@ -293,7 +293,7 @@ var5 from query that returns no row
failing query in let failing query in let
mysqltest: At line 1: Error running query 'failing query': 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing query' at line 1 mysqltest: At line 1: Error running query 'failing query': 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing query' at line 1
mysqltest: At line 1: Missing required argument 'filename' to command 'source' mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open file ./non_existingFile mysqltest: At line 1: Could not open file './non_existingFile'
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1 mysqltest: In included file "MYSQLTEST_VARDIR/tmp/error.sql": At line 1: query 'garbage ' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
...@@ -352,6 +352,8 @@ here is the sourced script ...@@ -352,6 +352,8 @@ here is the sourced script
In loop In loop
here is the sourced script here is the sourced script
here is the sourced script here is the sourced script
"hello"
"hello"
mysqltest: At line 1: Missing argument to sleep mysqltest: At line 1: Missing argument to sleep
mysqltest: At line 1: Missing argument to real_sleep mysqltest: At line 1: Missing argument to real_sleep
mysqltest: At line 1: Invalid argument to sleep "abc" mysqltest: At line 1: Invalid argument to sleep "abc"
...@@ -485,7 +487,7 @@ insert into t1 values (1); ...@@ -485,7 +487,7 @@ insert into t1 values (1);
select 'select-me'; select 'select-me';
insertz 'error query'' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insertz 'error query'' at line 1 insertz 'error query'' failed: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insertz 'error query'' at line 1
More results from queries before failure can be found in MYSQLTEST_VARDIR/tmp/bug11731.log More results from queries before failure can be found in MYSQLTEST_VARDIR/log/bug11731.log
drop table t1; drop table t1;
Multi statement using expected error Multi statement using expected error
create table t1 (a int primary key); create table t1 (a int primary key);
...@@ -538,7 +540,7 @@ mysqltest: At line 1: File already exist: 'MYSQLTEST_VARDIR/tmp/test_file1.tmp' ...@@ -538,7 +540,7 @@ mysqltest: At line 1: File already exist: 'MYSQLTEST_VARDIR/tmp/test_file1.tmp'
Some data Some data
for cat_file command for cat_file command
of mysqltest of mysqltest
mysqltest: At line 1: Failed to open file non_existing_file mysqltest: At line 1: Failed to open file 'non_existing_file'
mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists' mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists'
mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file'
mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file'
......
...@@ -854,6 +854,19 @@ while ($num) ...@@ -854,6 +854,19 @@ while ($num)
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc --remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
--write_file $MYSQLTEST_VARDIR/tmp/sourced.inc
echo "hello";
EOF
let $x= sourced;
source $MYSQLTEST_VARDIR/tmp/$x.inc;
let $x= $MYSQLTEST_VARDIR;
source $x/tmp/sourced.inc;
--remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Test sleep command # Test sleep command
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
...@@ -1422,7 +1435,7 @@ select "this will be executed"; ...@@ -1422,7 +1435,7 @@ select "this will be executed";
--exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1 --exec $MYSQL_TEST -x $MYSQLTEST_VARDIR/tmp/query.sql -R $MYSQLTEST_VARDIR/tmp/zero_length_file.result > /dev/null 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result; remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.result;
remove_file $MYSQLTEST_VARDIR/tmp/zero_length_file.reject; remove_file $MYSQLTEST_VARDIR/log/zero_length_file.reject;
# #
# Test that a test file that does not generate any output fails. # Test that a test file that does not generate any output fails.
...@@ -1490,7 +1503,7 @@ drop table t1; ...@@ -1490,7 +1503,7 @@ drop table t1;
--exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out --exec test -s $MYSQLTEST_VARDIR/tmp/bug11731.out
drop table t1; drop table t1;
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out; remove_file $MYSQLTEST_VARDIR/tmp/bug11731.out;
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.log; remove_file $MYSQLTEST_VARDIR/log/bug11731.log;
remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql; remove_file $MYSQLTEST_VARDIR/tmp/bug11731.sql;
# #
......
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