Commit 798d341b authored by unknown's avatar unknown

--result-file in mysqltest works nicely now

added a new test case that relies on --result-file


client/mysqltest.c:
  allow a mix of --result-file and @ result file specifications
mysql-test/mysql-test-run:
  -record option
  -R options to mysql-test so taht result files will be compared
parent 078c05d5
No related merge requests found
......@@ -127,6 +127,7 @@ typedef struct dyn_string
DYN_STRING ds_res;
void dyn_string_init(DYN_STRING* ds);
void dyn_string_end(DYN_STRING* ds);
void dyn_string_append(DYN_STRING* ds, const char* str, int len);
int dyn_string_cmp(DYN_STRING* ds, const char* fname);
void reject_dump(const char* record_file, char* buf, int size);
......@@ -160,6 +161,13 @@ void dyn_string_init(DYN_STRING* ds)
ds->len = 0;
ds->max_len = DS_CHUNK;
}
void dyn_string_end(DYN_STRING* ds)
{
my_free(ds->str, MYF(0));
memset(ds, 0, sizeof(*ds)); /* safety */
}
void dyn_string_append(DYN_STRING* ds, const char* str, int len)
{
int new_len;
......@@ -1017,10 +1025,13 @@ int run_query(MYSQL* mysql, struct query* q)
unsigned long* lengths;
char* val;
int len;
DYN_STRING *ds = &ds_res;
DYN_STRING ds_tmp;
dyn_string_init(&ds_tmp);
if(!result_file && q->record_file[0])
if( q->record_file[0])
{
ds_res.len = 0;
ds = &ds_tmp;
}
......@@ -1075,11 +1086,11 @@ int run_query(MYSQL* mysql, struct query* q)
num_fields = mysql_num_fields(res);
for( i = 0; i < num_fields; i++)
{
dyn_string_append(&ds_res, fields[i].name, 0);
dyn_string_append(&ds_res, "\t", 1);
dyn_string_append(ds, fields[i].name, 0);
dyn_string_append(ds, "\t", 1);
}
dyn_string_append(&ds_res, "\n", 1);
dyn_string_append(ds, "\n", 1);
while((row = mysql_fetch_row(res)))
......@@ -1096,11 +1107,11 @@ int run_query(MYSQL* mysql, struct query* q)
len = 4;
}
dyn_string_append(&ds_res, val, len);
dyn_string_append(&ds_res, "\t", 1);
dyn_string_append(ds, val, len);
dyn_string_append(ds, "\t", 1);
}
dyn_string_append(&ds_res, "\n", 1);
dyn_string_append(ds, "\n", 1);
}
if(record)
......@@ -1108,11 +1119,11 @@ int run_query(MYSQL* mysql, struct query* q)
if(!q->record_file[0] && !result_file)
die("Missing result file");
if(!result_file)
str_to_file(q->record_file, ds_res.str, ds_res.len);
str_to_file(q->record_file, ds->str, ds->len);
}
else if(!result_file && q->record_file[0])
{
error = check_result(&ds_res, q->record_file);
error = check_result(ds, q->record_file);
}
end:
......@@ -1266,10 +1277,11 @@ int main(int argc, char** argv)
close_cons();
if(result_file)
if(!record)
if(!record && ds_res.len)
error |= check_result(&ds_res, result_file);
else
str_to_file(result_file, ds_res.str, ds_res.len);
dyn_string_end(&ds_res);
if (!silent) {
if(error)
......
......@@ -141,6 +141,12 @@ if [ "$1" = "-force" ] ; then
shift 1
fi
if [ "$1" = "-record" ] ; then
RECORD=1
shift 1
fi
if [ "$1" = "-gcov" ];
then
if [ x$BINARY_DIST = x1 ] ; then
......@@ -300,7 +306,7 @@ start_master()
{
cd $BASEDIR # for gcov
#start master
master_args="--no-defaults --log-bin \
master_args="--no-defaults --log-bin=master-bin \
--server-id=1 \
--basedir=$MY_BASEDIR \
--port=$MASTER_MYPORT \
......@@ -330,7 +336,7 @@ start_slave()
--master-host=127.0.0.1 \
--master-port=$MASTER_MYPORT \
--exit-info=256 \
--log-bin --log-slave-updates \
--log-bin=slave-bin --log-slave-updates \
--basedir=$MY_BASEDIR \
--datadir=$SLAVE_MYDDIR \
--pid-file=$SLAVE_MYPID \
......@@ -433,6 +439,11 @@ run_testcase ()
master_opt_file=$TESTDIR/$tname-master.opt
slave_opt_file=$TESTDIR/$tname-slave.opt
SKIP_SLAVE=`$EXPR \( $tname : rpl \) = 0`
if [ x$RECORD = x1 ]; then
extra_flags="-r"
else
extra_flags=""
fi
if [ -f $master_opt_file ] ;
then
......@@ -466,7 +477,8 @@ run_testcase ()
cd $MYSQL_TEST_DIR
if [ -f $tf ] ; then
mytime=`$TIME -p $MYSQL_TEST < $tf 2> $TIMEFILE`
mytime=`$TIME -p $MYSQL_TEST -R r/$tname.result $extra_flags \
< $tf 2> $TIMEFILE`
res=$?
if [ $res != 1 ]; then
......@@ -547,13 +559,21 @@ $ECHO $DASH72
if [ -z $1 ] ;
then
if [ x$RECORD = x1 ]; then
echo "Will not run in record mode without a specific test case"
else
for tf in $TESTDIR/*.$TESTSUFFIX
do
run_testcase $tf
done
fi
else
tf=$TESTDIR/$1.$TESTSUFFIX
if [ -f $tf ] ; then
run_testcase $tf
else
echo "Test case $tf does not exist"
fi
fi
$ECHO $DASH72
......
File Position Binlog_do_db Binlog_ignore_db
master-bin.001 73
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
127.0.0.1 root 9306 1 4 Yes
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
127.0.0.1 root 9306 1 73 No
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
127.0.0.1 root 9306 1 73 Yes
Master_Host Master_User Master_Port Connect_retry Log_File Pos Slave_Running Replicate_do_db Replicate_ignore_db
127.0.0.1 root 9306 1 173 Yes
File Position Binlog_do_db Binlog_ignore_db
master-bin.001 73
n
1
2
3
source include/master-slave.inc;
connection master;
show master status;
connection slave;
show slave status;
change master to master_log_pos=73;
sleep 1;
slave stop;
change master to master_log_pos=73;
show slave status;
slave start;
show slave status;
change master to master_log_pos=173;
show slave status;
connection master;
show master status;
drop table if exists foo;
create table foo (n int);
insert into foo values (1),(2),(3);
connection slave;
change master to master_log_pos=73;
sleep 0.3;
select * from foo;
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