Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
d6584a92
Commit
d6584a92
authored
Feb 20, 2007
by
msvensson@pilot.blaudden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "diff_files" command to mysqltest
parent
26432d16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
1 deletion
+110
-1
client/mysqltest.c
client/mysqltest.c
+75
-1
mysql-test/t/mysqltest.test
mysql-test/t/mysqltest.test
+35
-0
No files found.
client/mysqltest.c
View file @
d6584a92
...
@@ -273,7 +273,7 @@ enum enum_commands {
...
@@ -273,7 +273,7 @@ enum enum_commands {
Q_DISABLE_PARSING
,
Q_ENABLE_PARSING
,
Q_DISABLE_PARSING
,
Q_ENABLE_PARSING
,
Q_REPLACE_REGEX
,
Q_REMOVE_FILE
,
Q_FILE_EXIST
,
Q_REPLACE_REGEX
,
Q_REMOVE_FILE
,
Q_FILE_EXIST
,
Q_WRITE_FILE
,
Q_COPY_FILE
,
Q_PERL
,
Q_DIE
,
Q_EXIT
,
Q_WRITE_FILE
,
Q_COPY_FILE
,
Q_PERL
,
Q_DIE
,
Q_EXIT
,
Q_CHMOD_FILE
,
Q_APPEND_FILE
,
Q_CAT_FILE
,
Q_CHMOD_FILE
,
Q_APPEND_FILE
,
Q_CAT_FILE
,
Q_DIFF_FILES
,
Q_UNKNOWN
,
/* Unknown command. */
Q_UNKNOWN
,
/* Unknown command. */
Q_COMMENT
,
/* Comments, ignored. */
Q_COMMENT
,
/* Comments, ignored. */
...
@@ -359,6 +359,7 @@ const char *command_names[]=
...
@@ -359,6 +359,7 @@ const char *command_names[]=
"chmod"
,
"chmod"
,
"append_file"
,
"append_file"
,
"cat_file"
,
"cat_file"
,
"diff_files"
,
0
0
};
};
...
@@ -2223,6 +2224,78 @@ void do_cat_file(struct st_command *command)
...
@@ -2223,6 +2224,78 @@ void do_cat_file(struct st_command *command)
}
}
/*
SYNOPSIS
do_diff_files
command called command
DESCRIPTION
diff_files <file1> <file2>;
Fails if the two files differ.
*/
void
do_diff_files
(
struct
st_command
*
command
)
{
int
error
=
0
;
int
fd
,
fd2
;
uint
len
,
len2
;
char
buff
[
512
],
buff2
[
512
];
static
DYNAMIC_STRING
ds_filename
;
static
DYNAMIC_STRING
ds_filename2
;
const
struct
command_arg
diff_file_args
[]
=
{
"file1"
,
ARG_STRING
,
TRUE
,
&
ds_filename
,
"First file to diff"
,
"file2"
,
ARG_STRING
,
TRUE
,
&
ds_filename2
,
"Second file to diff"
};
DBUG_ENTER
(
"do_diff_files"
);
check_command_args
(
command
,
command
->
first_argument
,
diff_file_args
,
sizeof
(
diff_file_args
)
/
sizeof
(
struct
command_arg
),
' '
);
if
((
fd
=
my_open
(
ds_filename
.
str
,
O_RDONLY
,
MYF
(
0
)))
<
0
)
die
(
"Failed to open first file %s"
,
ds_filename
.
str
);
if
((
fd2
=
my_open
(
ds_filename2
.
str
,
O_RDONLY
,
MYF
(
0
)))
<
0
)
{
my_close
(
fd
,
MYF
(
0
));
die
(
"Failed to open second file %s"
,
ds_filename2
.
str
);
}
while
((
len
=
my_read
(
fd
,
(
byte
*
)
&
buff
,
sizeof
(
buff
),
MYF
(
0
)))
>
0
)
{
if
((
len2
=
my_read
(
fd2
,
(
byte
*
)
&
buff2
,
sizeof
(
buff2
),
MYF
(
0
)))
!=
len
)
{
/* File 2 was smaller */
error
=
1
;
break
;
}
if
((
memcmp
(
buff
,
buff2
,
len
)))
{
/* Content of this part differed */
error
=
1
;
break
;
}
}
if
(
my_read
(
fd2
,
(
byte
*
)
&
buff2
,
sizeof
(
buff2
),
MYF
(
0
))
>
0
)
{
/* File 1 was smaller */
error
=
1
;
}
my_close
(
fd
,
MYF
(
0
));
my_close
(
fd2
,
MYF
(
0
));
dynstr_free
(
&
ds_filename
);
dynstr_free
(
&
ds_filename2
);
handle_command_error
(
command
,
error
);
DBUG_VOID_RETURN
;
}
/*
/*
SYNOPSIS
SYNOPSIS
do_perl
do_perl
...
@@ -5989,6 +6062,7 @@ int main(int argc, char **argv)
...
@@ -5989,6 +6062,7 @@ int main(int argc, char **argv)
case
Q_FILE_EXIST
:
do_file_exist
(
command
);
break
;
case
Q_FILE_EXIST
:
do_file_exist
(
command
);
break
;
case
Q_WRITE_FILE
:
do_write_file
(
command
);
break
;
case
Q_WRITE_FILE
:
do_write_file
(
command
);
break
;
case
Q_APPEND_FILE
:
do_append_file
(
command
);
break
;
case
Q_APPEND_FILE
:
do_append_file
(
command
);
break
;
case
Q_DIFF_FILES
:
do_diff_files
(
command
);
break
;
case
Q_CAT_FILE
:
do_cat_file
(
command
);
break
;
case
Q_CAT_FILE
:
do_cat_file
(
command
);
break
;
case
Q_COPY_FILE
:
do_copy_file
(
command
);
break
;
case
Q_COPY_FILE
:
do_copy_file
(
command
);
break
;
case
Q_CHMOD_FILE
:
do_chmod_file
(
command
);
break
;
case
Q_CHMOD_FILE
:
do_chmod_file
(
command
);
break
;
...
...
mysql-test/t/mysqltest.test
View file @
d6584a92
...
@@ -1517,6 +1517,41 @@ cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
...
@@ -1517,6 +1517,41 @@ cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp;
--
error
1
--
error
1
--
exec
echo
"cat_file non_existing_file;"
|
$MYSQL_TEST
2
>&
1
--
exec
echo
"cat_file non_existing_file;"
|
$MYSQL_TEST
2
>&
1
# ----------------------------------------------------------------------------
# test for diff_files
# ----------------------------------------------------------------------------
--
write_file
$MYSQLTEST_VARDIR
/
tmp
/
diff1
.
tmp
Some
data
for
diff_file
command
of
mysqltest
EOF
--
write_file
$MYSQLTEST_VARDIR
/
tmp
/
diff2
.
tmp
Some
data
for
diff_file
command
of
mysqltest
EOF
--
write_file
$MYSQLTEST_VARDIR
/
tmp
/
diff3
.
tmp
Some
other
data
for
diff_file
command
of
mysqltest
EOF
# Compare equal files
--
diff_files
$MYSQLTEST_VARDIR
/
tmp
/
diff1
.
tmp
$MYSQLTEST_VARDIR
/
tmp
/
diff2
.
tmp
--
diff_files
$MYSQLTEST_VARDIR
/
tmp
/
diff2
.
tmp
$MYSQLTEST_VARDIR
/
tmp
/
diff1
.
tmp
# Compare files that differ
--
error
1
--
diff_files
$MYSQLTEST_VARDIR
/
tmp
/
diff3
.
tmp
$MYSQLTEST_VARDIR
/
tmp
/
diff2
.
tmp
--
error
1
--
diff_files
$MYSQLTEST_VARDIR
/
tmp
/
diff1
.
tmp
$MYSQLTEST_VARDIR
/
tmp
/
diff3
.
tmp
# Compare equal files, again...
--
diff_files
$MYSQLTEST_VARDIR
/
tmp
/
diff1
.
tmp
$MYSQLTEST_VARDIR
/
tmp
/
diff2
.
tmp
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# test for file_exist
# test for file_exist
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment