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