summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqltest.c12
-rw-r--r--mysql-test/include/mysqltest-x.inc2
-rw-r--r--mysql-test/t/mysqltest.test13
3 files changed, 22 insertions, 5 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 33702e9d1d2..78d873468c4 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -2169,8 +2169,10 @@ int read_line(char *buf, int size)
if (feof(cur_file->file))
{
found_eof:
- if (cur_file->file != stdin)
+ if (cur_file->file != stdin){
my_fclose(cur_file->file, MYF(0));
+ cur_file->file= 0;
+ }
my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
cur_file->file_name= 0;
lineno--;
@@ -2556,10 +2558,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
argument= buff;
}
fn_format(buff, argument, "", "", 4);
- DBUG_ASSERT(cur_file->file == 0);
+ DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
if (!(cur_file->file=
my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME))))
- die("Could not open %s: errno = %d", argument, errno);
+ die("Could not open %s: errno = %d", buff, errno);
+ cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
break;
}
case 'm':
@@ -3746,9 +3749,8 @@ int main(int argc, char **argv)
embedded_server_args,
(char**) embedded_server_groups))
die("Can't initialize MySQL server");
- if (cur_file == file_stack)
+ if (cur_file == file_stack && cur_file->file == 0)
{
- DBUG_ASSERT(cur_file->file == 0);
cur_file->file= stdin;
cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
}
diff --git a/mysql-test/include/mysqltest-x.inc b/mysql-test/include/mysqltest-x.inc
new file mode 100644
index 00000000000..dd1468aed07
--- /dev/null
+++ b/mysql-test/include/mysqltest-x.inc
@@ -0,0 +1,2 @@
+echo Output from mysqltest-x.inc;
+
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index bfb1919e75c..4c23f915503 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -792,6 +792,19 @@ select "a" as col1, "c" as col2;
--error 1
--exec echo "save_master_pos; sync_with_master a;" | $MYSQL_TEST 2>&1
+
+# ----------------------------------------------------------------------------
+# Test mysqltest arguments
+# ----------------------------------------------------------------------------
+
+# -x <file_name>, use the file specified after -x as the test file
+--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc
+--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc
+--exec $MYSQL_TEST --result_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc
+--error 1
+--exec $MYSQL_TEST -x non_existing_file.inc
+
+
# ----------------------------------------------------------------------------
# TODO Test queries, especially their errormessages... so it's easy to debug
# new scripts and diagnose errors