Skip to content

Commit

Permalink
[Doc update] Exec-test environment variables
Browse files Browse the repository at this point in the history
This commit updates avocado documentation to describe defining
environment variables in exec-tests by user.

Signed-off-by: Jan Richter <[email protected]>
  • Loading branch information
richtja committed Apr 26, 2024
1 parent d4e2cde commit 01d9d1c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/source/guides/writer/chapters/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ by ``avocado exec-path`` (if any). Also, the example test
Environment Variables for Tests
-------------------------------

Avocado's environment variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Avocado exports some information, including test parameters, as environment
variables to the running test. Here is a list of the variables that Avocado
currently exports to exec-test tests in default:
Expand Down Expand Up @@ -69,3 +72,21 @@ currently exports to exec-test tests in default:
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+
| `***` | All variables from --mux-yaml | TIMEOUT=60; IO_WORKERS=10; VM_BYTES=512M; ... |
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+

User's environment variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You can also let avocado set your own environment variables. For that, you need
to pass the environment variables as keyword arguments (``kwargs``) to the exec-tests.
Here is an example of Job API which passes ``SLEEP_LENGTH`` to sleeptest.sh to set
the time for which the test should sleep:

.. literalinclude:: ../../../../../examples/jobs/custom_exec_test.py

And now we can see that sleeptest.sh can use ``SLEEP_LENGTH`` environment
variable:

.. literalinclude:: ../../../../../examples/tests/sleeptest.sh

.. note:: All environment variables set by avocado will be accessible only during
the test runtime and it won't change your environment.

0 comments on commit 01d9d1c

Please sign in to comment.