• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. SPDX-License-Identifier: GPL-2.0-or-later
2
3Installation and tests execution
4================================
5
6Basics requirements to build LTP are the following:
7
8* git
9* autoconf
10* automake
11* make
12* gcc
13* m4
14* pkgconf / pkg-config
15* libc headers
16* linux headers
17
18.. code-block:: console
19
20   $ git clone --recurse-submodules https://github.com/linux-test-project/ltp.git
21   $ cd ltp
22   $ make autotools
23   $ ./configure
24
25.. note::
26
27   For optional library dependencies, take a look at the scripts inside :master:`ci/`
28   directory.
29
30Running single tests
31--------------------
32
33LTP provides the possibility to build and run single tests:
34
35.. code-block:: console
36
37   $ cd testcases/kernel/syscalls/foo
38   $ make
39   $ PATH=$PATH:$PWD ./foo01
40
41Shell testcases are a bit more complicated, since they need to setup ``PATH``
42as well as to compiled binary helpers:
43
44.. code-block:: console
45
46   $ cd testcases/lib
47   $ make
48   $ cd ../commands/foo
49   $ PATH=$PATH:$PWD:$PWD/../../lib/ ./foo01.sh
50
51Open Posix Testsuite has it's own build system which needs Makefiles to be
52generated first:
53
54.. code-block:: console
55
56   $ ./configure --with-open-posix-testsuite
57   $ cd testcases/open_posix_testsuite/
58   $ make generate-makefiles
59   $ cd conformance/interfaces/foo
60   $ make
61   $ ./foo_1-1.run-test
62
63Compiling and installing all testcases
64--------------------------------------
65
66To compile all tests is really simple:
67
68.. code-block:: console
69
70   $ make
71
72   $ # install LTP inside /opt/ltp by default
73   $ make install
74
75.. note::
76
77   Some tests will be disabled if ``configure`` script won't find the build
78   dependencies.
79
80Running tests
81-------------
82
83To run all the test suites
84
85.. code-block:: console
86
87   $ cd /opt/ltp
88
89   $ # run syscalls testing suite
90   $ ./kirk -f ltp -r syscalls
91
92.. note::
93
94   Many test cases have to be executed as root.
95
96Test suites (e.g. syscalls) are defined in the ``runtest`` directory. Each file
97contains a list of test cases in a simple format.
98
99Each test case has its own executable or script that can directly executed:
100
101.. code-block:: console
102
103   $ testcases/bin/abort01
104
105   $ # some tests have arguments
106   $ testcases/bin/mesgq_nstest -m none
107
108   $ # vast majority of tests have a help
109   $ testcases/bin/ioctl01 -h
110
111   $ # Many require certain environment variables to be set
112   $ LTPROOT=/opt/ltp PATH="$PATH:$LTPROOT/testcases/bin" testcases/bin/wc01.sh
113
114Most commonly, the ``PATH`` variable needs to be set and also ``LTPROOT``, but
115there are a number of other variables which usually ``kirk`` sets for you.
116
117.. note::
118
119   All shell scripts need the ``PATH`` to be set. However, this is not limited
120   to shell scripts and some C based tests need environment variables as well.
121   They usually raise a configuration error when this is needed.
122
123Network tests
124-------------
125
126Network tests usually require a certain setup that is described in
127:master:`testcases/network/README.md`.
128