mysqltest client - Tool used for executing a .test file. More...
#include "client/mysqltest/error_names.h"
#include "client/mysqltest/expected_errors.h"
#include "client/mysqltest/expected_warnings.h"
#include "client/mysqltest/logfile.h"
#include "client/mysqltest/secondary_engine.h"
#include "client/mysqltest/utils.h"
#include <algorithm>
#include <chrono>
#include <cmath>
#include <limits>
#include <new>
#include <regex>
#include <sstream>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <mysql_async.h>
#include <mysql_version.h>
#include <mysqld_error.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <poll.h>
#include <sys/time.h>
#include <sys/wait.h>
#include "caching_sha2_passwordopt-vars.h"
#include "client/client_priv.h"
#include "m_ctype.h"
#include "map_helpers.h"
#include "mf_wcomp.h"
#include "my_compiler.h"
#include "my_config.h"
#include "my_dbug.h"
#include "my_default.h"
#include "my_dir.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "my_pointer_arithmetic.h"
#include "my_stacktrace.h"
#include "my_systime.h"
#include "my_thread_local.h"
#include "prealloced_array.h"
#include "print_version.h"
#include "sql_common.h"
#include "template_utils.h"
#include "typelib.h"
#include "violite.h"
#include "welcome_copyright_notice.h"
#include "sslopt-vars.h"
#include "caching_sha2_passwordopt-longopts.h"
#include "sslopt-longopts.h"
#include "sslopt-case.h"
mysqltest client - Tool used for executing a .test file.
See The MySQL Test Framework for more information.
Abort process.
Append state change information (received through Ok packet) to the output.
Fetch warnings generated by server while executing a query and append them to warnings buffer 'ds'.
Check if second argument "ONCE" to disable_warnings or enable_warnings command is specified.
If yes, filter out the keyword "ONCE" from the argument string.
Connect to a server and handle connection errors in case they occur.
This function will try to establish a connection to server and handle possible errors in the same manner as if "connect" was usual SQL-statement. If an error is expected it will ignore it once it occurs and log the "statement" to the query log. Unlike safe_connect() it won't do several attempts.
Display the optimizer trace produced by the last executed statement.
Copy the source file to destination file.
Copy will fail if the destination file exists. Retry of the command can happen optionally with an interval of one second between each retry if the command fails.
Copy files from source directory to destination directory, by matching a specified file name pattern.
Copy will fail if no files match the pattern. It will fail if source directory is empty and/or there are no files in it. Copy will also fail if source directory or destination directory or both do not exist. Retry of the command can happen optionally with an interval of one second between each retry if the command fails.
Compare the two files.
Success if 2 files are same, failure if the files are different or either file does not exist.
Disable or don't execute the statements or commands appear after this command until the execution is enabled by 'enable_testcase' command.
If test cases are already disabled, then throw an error and abort the test execution.
This command also takes a mandatory parameter specifying the bug number.
Check if the bug number argument to disable_testcase is in a proper format.
Create a list of disabled warnings that should be suppressed for the next statements until enabled by enable_warnings command.
disable_warnings command can take an optional argument specifying a warning or a comma separated list of warnings to be disabled. The warnings specified should be in symbolic error name format.
disable_warnings command can also take a second optional argument, which when specified will suppress the warnings for next statement only. The second argument must be a "ONCE" keyword.
Create a list of enabled warnings that should be enabled for the next statements until disabled by disable_warnings command.
enable_warnings command can take an optional argument specifying a warning or a comma separated list of warnings to be enabled. The warnings specified should be in symbolic error name format.
enable_warnings command can also take a second optional argument, which when specified will enable the warnings for next statement only. The second argument must be a "ONCE" keyword.
Create a list of error values that the next statement is expected to return.
Each error must be an error number or an SQLSTATE value or a symbolic error name representing an error.
SQLSTATE value must start with 'S'. It is also possible to specify client errors with 'error' command.
Execute the shell command using the popen() library call.
References to variables within the command are replaced with the corresponding values. Use “\$” to specify a literal “$” character.
The error code returned from the subprocess is checked against the expected error array, previously set with the –error command. It can thus be used to execute a command that shall fail.
Check if specified file exists.
Retry of the command can happen optionally with an interval of one second between each retry if the command fails.
Moves a file to destination file.
Retry of the command can happen optionally with an interval of one second between each retry if the command fails.
Removes the file passed as the argument and retries a specified number of times, if it is unsuccessful.
Removes the files in the specified directory, by matching the file name pattern.
Retry of the command can happen optionally with an interval of one second between each retry if the command fails.
Shutdown or kill the server.
If timeout is set to 0 the server is killed or terminated immediately. Otherwise the shutdown command is first sent and then it waits for the server to terminate within 'timeout' seconds. If it has not terminated before 'timeout' seconds the command will fail.
Evaluate the warning list argument specified with either disable_warnings or enable_warnings command and replace the variables with actual values if there exist any.
Template function that frees memory of the dynamic string passed to the function.
Frees the memory of dynamic strings passed to the function.
It accepts a variable number of dynamic strings, and through recursion, frees the memory. The other template function which calls dynstr_free() is called here.
Get an error code corresponding to a warning name.
The warning name specified is in symbolic error name format.
Handle errors which occurred during execution of mysqltest commands like 'move_file', 'remove_file' etc which are used to perform file system operations.
Handle disabling of warnings.
Handle enabling of warnings.
Handle errors which occurred during execution of a query.
Handle absence of errors after execution.
Abort test run if the query succeeds and was expected to fail with an error.
Handle one warning which occurred during execution of a query.
Handle warnings which occurred during execution of a query.
Initializes the regular substitution expression to be used in the result output of test.
Check if process is active.
kill process.
Record how many milliseconds it took to execute the test file up until the current line and write it to .progress file.
Check whether given error is in list of expected errors.
Check whether a given warning is in list of disabled or enabled warnings.
Execute all substitutions on val.
Parse the warning list argument specified with disable_warnings or enable_warnings command.
Check if the second argument "ONCE" is specified, if yes, set once_property flag.
Create a command from a set of lines.
Converts lines returned by read_line into a command, this involves parsing the first word in the read line to find the command type.
A '
--' comment may contain a valid query as the first word after the comment start. Thus it's always checked to see if that is the case. The advantage with this approach is to be able to execute commands terminated by new line '
' regardless how many "delimiter" it contain.
Reset property value to the old value for all properties which are set for the next statement only, i.e properties specified using keyword "ONCE" argument.
Run query using MySQL C API.
Run query using prepared statement C API.
Save error code returned by a mysqltest command in '$__error' variable.
Function to check if a protocol's regular expression matches the query string.
Change the current connection to the given st_connection, and update $mysql_get_server_version and $CURRENT_CONNECTION accordingly.
Set a property value to either 0 or 1 for a disable_X or a enable_X command, and the new value set will be applicable for next statement only.
After that, property value will be reset back to the old value.
Set a property value to either 0 or 1 for a disable_X or a enable_X command.
Show the diff of two files using the systems builtin diff command.
If no such diff command exist, just dump the content of the two files and inform about how to get "diff"
Variable '$DISABLED_WARNINGS_LIST' contains comma separated list of disabled warnings and variable '$ENABLED_WARNINGS_LIST' contains comma separated list of enabled warnings.
Update the value of these two variables with the latest list of disabled and enabled warnings. The value of these variables will be empty if there are no disabled or enabled warnings.
These variables will always contain the latest list of disabled and enabled warnings, and can be referenced inside a test or inside a test utility file to access the current list of disabled or enabled warnings.
Check if the bug number argument to disable_testcase is in a proper format.
Bug number argument should follow 'BUG::XXXX' format
Test case or the result file names may use alphanumeric characters (A-Z, a-z, 0-9), dash ('-') or underscore ('_'), but should not start with dash or underscore.
Check if a file name conatins any other special characters. If yes, throw an error and abort the test run.
Convert between error numbers and error names/strings.
The variable '$var' will be populated with error number if the argument is string. The variable var will be populated with error string if the argument is number.