if the test name on the command line is "-", read Lua script from the standard input.

This commit is contained in:
Alexey Kopytov
2017-02-01 10:56:05 +03:00
parent d017ae0c85
commit 2a3ca019cb
3 changed files with 24 additions and 4 deletions

View File

@ -61,8 +61,9 @@ The general command line syntax for sysbench is:
`memory`, `cpu`, etc.), or a name of one of the bundled Lua scripts
(e.g. `oltp_read_only`), or a *path* to a custom Lua script. If no
test name is specified on the command line (and thus, there is no
*command* too, as in that case it would be parsed as a *testname*),
then sysbench expects a Lua script to execute on its standard input.
*command* too, as in that case it would be parsed as a *testname*), or
the test name is a dash ("`-`"), then sysbench expects a Lua script to
execute on its standard input.
- *command* is an optional argument that will be passed by sysbench to
the built-in test or script specified with *testname*. *command*

View File

@ -1430,7 +1430,7 @@ int main(int argc, char *argv[])
print_header();
if (sb_globals.testname != NULL)
if (sb_globals.testname != NULL && strcmp(sb_globals.testname, "-"))
{
/* Is it a built-in test name? */
test = find_test(sb_globals.testname);
@ -1468,6 +1468,8 @@ int main(int argc, char *argv[])
}
else
{
sb_globals.testname = NULL;
if (SB_ISATTY())
log_text(LOG_NOTICE, "Reading the script from the standard input:\n");

View File

@ -85,7 +85,7 @@
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 0.0000/0.00
execution time (avg/stddev): *.*/0.00 (glob)
########################################################################
Command line options tests
@ -317,3 +317,20 @@ Command line options tests
argv[3] = cmdline.lua
argv[4] = prepare
sysbench.cmdline.command = prepare
$ sysbench - <<EOF
> print("hello")
> EOF
sysbench * (glob)
hello
$ sysbench - prepare <<EOF
> function prepare()
> print("prepare")
> end
> print("global")
> EOF
sysbench * (glob)
global