xref: /aosp_15_r20/external/ltp/doc/users/setup_tests.rst (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1.. SPDX-License-Identifier: GPL-2.0-or-later
2
3Tests setup
4===========
5
6The internal LTP library provides a set of features that permits to customize
7tests behavior by setting environment variables and using specific tests
8arguments.
9
10Library environment variables
11-----------------------------
12
13Following environment variables are expected to be set by LTP users. Therefore,
14with some exceptions, they have ``LTP_`` prefix. Environment variables with
15``TST_`` prefix are used inside LTP shell API and should **not** be set by
16users.
17
18.. list-table::
19   :header-rows: 1
20
21   * - Variable
22     - Note
23
24   * - KCONFIG_PATH
25     - The path to the kernel config file, (if not set, it tries the usual paths
26       ``/boot/config-RELEASE`` or ``/proc/config.gz``)
27
28   * - KCONFIG_SKIP_CHECK
29     - Skip kernel config check if variable set (not set by default)
30
31   * - LTPROOT
32     - Prefix for installed LTP.  **Should be always set**, since some tests
33       need it to use data files (``LTP_DATAROOT``). LTP is by default installed
34       into ``/opt/ltp``
35
36   * - LTP_COLORIZE_OUTPUT
37     - By default LTP colorizes it's output unless it's redirected to a pipe or
38       file. Force colorized output behavior: ``y`` or ``1``: always colorize,
39       ``n`` or ``0``: never colorize.
40
41   * - LTP_DEV
42     - Path to the block device to be used. C Language: ``.needs_device = 1``.
43       Shell language: ``TST_NEEDS_DEVICE=1``.
44
45   * - LTP_SINGLE_FS_TYPE
46     - Testing only - specifies filesystem instead all supported
47       (for tests with ``.all_filesystems``).
48
49   * - LTP_DEV_FS_TYPE
50     - Filesystem used for testing (default: ``ext2``).
51
52   * - LTP_TIMEOUT_MUL
53     - Multiplies timeout, must be number >= 0.1 (> 1 is useful for slow
54       machines to avoid unexpected timeout).
55
56   * - LTP_RUNTIME_MUL
57     - Multiplies maximal test iteration runtime. Tests that run for more than a
58       second or two are capped on runtime. You can scale the default runtime
59       both up and down with this multiplier. This is not yet implemented in the
60       shell API.
61
62   * - LTP_VIRT_OVERRIDE
63     - Overrides virtual machine detection in the test library. Setting it to
64       empty string, tells the library that system is not a virtual machine.
65       Other possible values are ``kvm``, ``xen``, ``zvm`` and ``microsoft``
66       that describe different types supervisors.
67
68   * - PATH
69     - It's required to adjust path: ``PATH="$PATH:$LTPROOT/testcases/bin"``
70
71   * - TMPDIR
72     - Base directory for template directory (C language: ``.needs_tmpdir = 1``
73       and shell: ``TST_NEEDS_TMPDIR=1``). Must be an absolute path (default:
74       '/tmp').
75
76   * - LTP_NO_CLEANUP
77     - Disable running test cleanup (defined in ``TST_CLEANUP``).
78       Shell API only.
79
80   * - LTP_ENABLE_DEBUG
81     - Enable debug info (value ``1`` or ``y``). Equivalent of ``-D`` parameter.
82
83Test execution time and timeout
84-------------------------------
85
86The limit on how long a test can run does compose of two parts: ``max_runtime``
87and ``timeout``. The limit does apply to a single test variant. That means, for
88example, that tests which run for all available filesystems will apply this
89limit for a single filesystem only.
90
91The ``max_runtime`` is a cap on how long the ``run()`` function can take and for
92most testcases this part is set to zero. For tests that do run for more than a
93second or two the ``max_runtime`` has to be defined and the ``run()`` function
94has to check actively how much runtime is left.
95
96Test runtime can be scaled up and down with ``LTP_RUNTIME_MUL`` environment
97variable or set on a command-line by the ``-I`` parameter. However,
98setting the runtime too low will cause long running tests to exit prematurely,
99possibly before having a chance to actually test anything.
100
101The timeout is a limit for test setup and cleanup and it's also a safety
102margin for the runtime accounting. It's currently set to 30 seconds but it may
103change later. If your target machine is too slow, it can be scaled up with the
104``LTP_TIMEOUT_MUL`` environment variable.
105