Bug #56591 Please remove exec echo from test
Submitted: 6 Sep 2010 12:05 Modified: 8 Feb 2011 10:17
Reporter: Vladislav Vaintroub Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Tests Severity:S3 (Non-critical)
Version: OS:Windows
Assigned to: Bjørn Munch CPU Architecture:Any

[6 Sep 2010 12:05] Vladislav Vaintroub
Description:
echo.exe is compiled and redistributed on Windows (again, after the fix for bug#56547). Its functionality is not documented, echo.exe it just sits in bin directory and interfers with cmd.exe builtin "echo". The only usage of the echo.exe is in tests, typically  one-liners like
--exec echo "foo" > file

Not only "exec" in tests is considered harmful, but also echo.exe is useless to the end-user.
Please remove all usages of that "echo" from the test suite, and echo.exe from the distribution.

How to repeat:
see mysql.test for example of "exec echo" misuse

Suggested fix:
replace exec echo with something better, like mysqltests builtin
write_file. 
for usages in stdin redirections/pipes, find a more clean way to express
--exec echo "foo" | mysql

without exec. Perl can definitely do stdin redirection.
[9 Sep 2010 21:12] Vladislav Vaintroub
Internal echo support everything, and definitely redirection. exec should not be used for anything but mysql stuff. Distributing echo.exe that is neither documented nor has anything to do with mysql server or client is embarassing, sort of. Next thing to distribute would be rm.exe, and the next after that is our own bash.exe
[21 Dec 2010 12:19] Bjørn Munch
Using write_file may actually be unsafe, see Bug #58515. As for using Perl methods, that's not an option; this is done by the mysqltest client (written in C), not the Perl script.

exec echo is also needed with pipes in some places; this cannot be done using any other existing construct.

echo.exe isn't the only non-documented binary we ship with the test framework; there is also safe_process.exe.
[21 Dec 2010 12:39] Vladislav Vaintroub
Bjorn, I fail to understand arguments in Bug#58515. This does not sound like a  fix or a problem that would be well understood. How echo.exe is supposed to fix the fact that Windows does not remove file until last handle to it is closed (I suppose this would be what is described there as "under heavy load Windows cannot be trusted" ;)?
[21 Dec 2010 12:48] Bjørn Munch
The problem was that the file was deleted by mtr but when mysqltest shortly after did a write_file, it failed because the file still existed. This had only been observed on Windows with I think, and only after we started using
--parallel.

The reason the "exec echo" alternative works is that it doesn't care whether or not the file already exists.
[8 Feb 2011 10:17] Bjørn Munch
Closing to get it off my list