提交 333fad73 编写于 作者: C Cleber Rosa

doc: formatting and wording changes to Wrap Process in test section

This is just a review followed by minor wording changes and some
heavier formatting changes.

Changes from v1:
* Wording changes suggested by Lucas.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 b3788c8a
Wrap process in tests Wrap process in tests
===================== =====================
Avocado allows the instrumentation of applications being Avocado allows the instrumentation of applications being run by a test
run by a test in a transparent way. in a transparent way. The user specifies a script ("the wrapper") to be
used to run the actual program called by the test.
The user specifies a script ("the wrapper") to be used to run the actual If the instrumentation script is implemented correctly, it should not
program called by the test. If the instrument is interfere with the test behavior. That is, the wrapper should avoid
implemented correctly, it should not interfere with the test behavior. changing the return status, standard output and standard error messages
of the original process.
So it means that the wrapper should avoid to change the return status, The user can be specific about which program to wrap, or if that is omitted,
standard output and standard error messages of the process. a global wrapper that will apply to all programs called by the test.
The user can optionally specify a target program to wrap.
Usage Usage
----- -----
...@@ -25,37 +25,35 @@ Example of a transparent way of running strace as a wrapper:: ...@@ -25,37 +25,35 @@ Example of a transparent way of running strace as a wrapper::
#!/bin/sh #!/bin/sh
exec strace -ff -o $AVOCADO_TEST_LOGDIR/strace.log -- $@ exec strace -ff -o $AVOCADO_TEST_LOGDIR/strace.log -- $@
To have all programs started by ``test.py`` wrapped with ``~/bin/my-wrapper.sh``::
Now you can run::
# run all programs started by test.py with ~/bin/my-wrapper.sh
$ scripts/avocado run --wrapper ~/bin/my-wrapper.sh tests/test.py $ scripts/avocado run --wrapper ~/bin/my-wrapper.sh tests/test.py
# run only my-binary (if/when started by a test) with ~/bin/my-wrapper.sh To have only ``my-binary`` wrapped with ``~/bin/my-wrapper.sh``::
$ scripts/avocado run --wrapper ~/bin/my-wrapper.sh:my-binary tests/test.py
$ scripts/avocado run --wrapper ~/bin/my-wrapper.sh:my-binary tests/test.py
Caveats Caveats
------- -------
* It is not possible to debug with GDB (`--gdb-run-bin`) and use * It is not possible to debug with GDB (`--gdb-run-bin`) and use
wrappers (`--wrapper`), both options together are incompatible. wrappers (`--wrapper`) at the same time. These two options are
mutually exclusive.
* You cannot set multiples (global) wrappers * You can only set one (global) wrapper. If you need functionality
-- like `--wrapper foo.sh --wrapper bar.sh` -- it will trigger an error. present in two wrappers, you have to combine those into a single
You should use a single script that performs both things wrapper script.
you are trying to achieve.
* The only process that can be wrapper are those that uses the Avocado * Only processes that are run with the :mod:`avocado.utils.process` APIs
module `avocado.utils.process` and the modules that make use of it, (and other API modules that make use of it, like mod:`avocado.utils.build`)
like `avocado.utils.build` and so on. are affected by this feature.
* If paths are not absolute, then the process name matches with the base name, * If paths are not absolute, then the process name matches with the base name,
so `--wrapper foo.sh:make` will match `/usr/bin/make`, `/opt/bin/make` so `--wrapper foo.sh:make` will match `/usr/bin/make`, `/opt/bin/make`
and `/long/path/to/make`. and `/long/path/to/make`.
* When you use a relative path to a script, it will use the current path * When you use a relative path to a script, it will use the current path
of the running Avocado program. of the running Avocado program. Example: If I'm running Avocado on
Example: If I'm running Avocado on `/home/user/project/avocado`, `/home/user/project/avocado`, then `avocado run --wrapper
then `avocado run --wrapper examples/wrappers/strace.sh datadir` will examples/wrappers/strace.sh datadir` will set the wrapper to
set the wrapper to `/home/user/project/avocado/examples/wrappers/strace.sh` `/home/user/project/avocado/examples/wrappers/strace.sh`
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册