1f08c3bdfSopenharmony_ciLTP Test Writing Guidelines 2f08c3bdfSopenharmony_ci=========================== 3f08c3bdfSopenharmony_ci 4f08c3bdfSopenharmony_ciThis document describes LTP guidelines and is intended for anybody who want to 5f08c3bdfSopenharmony_ciwrite or modify a LTP testcase. It's not a definitive guide and it's not, by 6f08c3bdfSopenharmony_ciany means, a substitute for common sense. 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ciNOTE: See also 9f08c3bdfSopenharmony_ci https://github.com/linux-test-project/ltp/wiki/C-Test-API[C Test API], 10f08c3bdfSopenharmony_ci https://github.com/linux-test-project/ltp/wiki/Shell-Test-API[Shell Test API], 11f08c3bdfSopenharmony_ci https://github.com/linux-test-project/ltp/wiki/LTP-Library-API-Writing-Guidelines[LTP Library API Writing Guidelines]. 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_ciRules and recommendations which are "machine checkable" should be 14f08c3bdfSopenharmony_citagged with an ID like +LTP-XXX+. There will be a corresponding entry 15f08c3bdfSopenharmony_ciin 16f08c3bdfSopenharmony_cihttps://github.com/linux-test-project/ltp/tree/master/doc/rules.tsv[doc/rules.tsv]. When 17f08c3bdfSopenharmony_ciyou run 'make check' or 'make check-test' it will display these IDs as 18f08c3bdfSopenharmony_cia reference. 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_ci1. Guide to clean and understandable code 21f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ciFor testcases it's required that the source code is as easy to follow as 24f08c3bdfSopenharmony_cipossible. When a test starts to fail the failure has to be analyzed, clean 25f08c3bdfSopenharmony_citest codebase makes this task much easier and quicker. 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ciHere are some hints on how to write clean and understandable code, a few of 28f08c3bdfSopenharmony_cithese points are further discussed below: 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ci* First of all *Keep things simple* 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ci* Keep function and variable names short but descriptive 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_ci* Keep functions reasonably short and focused on a single task 35f08c3bdfSopenharmony_ci 36f08c3bdfSopenharmony_ci* Do not overcomment 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_ci* Be consistent 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_ci* Avoid deep nesting 41f08c3bdfSopenharmony_ci 42f08c3bdfSopenharmony_ci* DRY 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_ci1.1 Keep things simple 45f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~ 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ciFor all it's worth keep the testcases simple or better as simple as possible. 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ciThe kernel and libc are tricky beasts and the complexity imposed by their 50f08c3bdfSopenharmony_ciinterfaces is quite high. Concentrate on the interface you want to test and 51f08c3bdfSopenharmony_cifollow the UNIX philosophy. 52f08c3bdfSopenharmony_ci 53f08c3bdfSopenharmony_ciIt's a good idea to make the test as self-contained as possible too, ideally 54f08c3bdfSopenharmony_citests should not depend on tools or libraries that are not widely available. 55f08c3bdfSopenharmony_ci 56f08c3bdfSopenharmony_ciDo not reinvent the wheel! 57f08c3bdfSopenharmony_ci 58f08c3bdfSopenharmony_ci* Use LTP standard interface 59f08c3bdfSopenharmony_ci 60f08c3bdfSopenharmony_ci* Do not add custom PASS/FAIL reporting functions 61f08c3bdfSopenharmony_ci 62f08c3bdfSopenharmony_ci* Do not write Makefiles from scratch, use LTP build system instead 63f08c3bdfSopenharmony_ci 64f08c3bdfSopenharmony_ci* Etc. 65f08c3bdfSopenharmony_ci 66f08c3bdfSopenharmony_ci1.2 Keep functions and variable names short 67f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68f08c3bdfSopenharmony_ci 69f08c3bdfSopenharmony_ciChoosing a good name for an API functions or even variables is a difficult 70f08c3bdfSopenharmony_citask do not underestimate it. 71f08c3bdfSopenharmony_ci 72f08c3bdfSopenharmony_ciThere are a couple of customary names for different things that help people to 73f08c3bdfSopenharmony_ciunderstand code, for example: 74f08c3bdfSopenharmony_ci 75f08c3bdfSopenharmony_ci* For loop variables are usually named with a single letter 'i', 'j', ... 76f08c3bdfSopenharmony_ci 77f08c3bdfSopenharmony_ci* File descriptors 'fd' or 'fd_foo'. 78f08c3bdfSopenharmony_ci 79f08c3bdfSopenharmony_ci* Number of bytes stored in file are usually named as 'size' or 'len' 80f08c3bdfSopenharmony_ci 81f08c3bdfSopenharmony_ci* Etc. 82f08c3bdfSopenharmony_ci 83f08c3bdfSopenharmony_ci1.3 Do not overcomment 84f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~ 85f08c3bdfSopenharmony_ci 86f08c3bdfSopenharmony_ciComments can sometimes save you day but they can easily do more harm than 87f08c3bdfSopenharmony_cigood. There has been several cases where comments and actual implementation 88f08c3bdfSopenharmony_cidrifted slowly apart which yielded into API misuses and hard to find bugs. 89f08c3bdfSopenharmony_ciRemember there is only one thing worse than no documentation, wrong 90f08c3bdfSopenharmony_cidocumentation. 91f08c3bdfSopenharmony_ci 92f08c3bdfSopenharmony_ciIdeally everybody should write code that is obvious, which unfortunately isn't 93f08c3bdfSopenharmony_cialways possible. If there is a code that requires to be commented keep it 94f08c3bdfSopenharmony_cishort and to the point. These comments should explain *why* and not *how* 95f08c3bdfSopenharmony_cithings are done. 96f08c3bdfSopenharmony_ci 97f08c3bdfSopenharmony_ciNever ever comment the obvious. 98f08c3bdfSopenharmony_ci 99f08c3bdfSopenharmony_ciIn case of LTP testcases it's customary to add an asciidoc formatted comment 100f08c3bdfSopenharmony_ciparagraph with highlevel test description at the beginning of the file right 101f08c3bdfSopenharmony_ciunder the GPL SPDX header. This helps other people to understand the overall 102f08c3bdfSopenharmony_cigoal of the test before they dive into the technical details. It's also 103f08c3bdfSopenharmony_ciexported into generated documentation hence it should mostly explain what is 104f08c3bdfSopenharmony_citested. 105f08c3bdfSopenharmony_ci 106f08c3bdfSopenharmony_ci1.4 DRY (Code duplication) 107f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~ 108f08c3bdfSopenharmony_ci 109f08c3bdfSopenharmony_ciCopy & paste is a good servant but very poor master. If you are about to copy a 110f08c3bdfSopenharmony_cilarge part of the code from one testcase to another, think what would happen if 111f08c3bdfSopenharmony_ciyou find bug in the code that has been copied all around the tree. What about 112f08c3bdfSopenharmony_cimoving it to a library instead? 113f08c3bdfSopenharmony_ci 114f08c3bdfSopenharmony_ciThe same goes for short but complicated parts, whenever you are about to copy & 115f08c3bdfSopenharmony_cipaste a syscall wrapper that packs arguments accordingly to machine 116f08c3bdfSopenharmony_ciarchitecture or similarly complicated code, put it into a header instead. 117f08c3bdfSopenharmony_ci 118f08c3bdfSopenharmony_ci2 Coding style 119f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~ 120f08c3bdfSopenharmony_ci 121f08c3bdfSopenharmony_ci2.1 C coding style 122f08c3bdfSopenharmony_ci^^^^^^^^^^^^^^^^^^ 123f08c3bdfSopenharmony_ci 124f08c3bdfSopenharmony_ciLTP adopted Linux kernel coding style: 125f08c3bdfSopenharmony_cihttps://www.kernel.org/doc/html/latest/process/coding-style.html 126f08c3bdfSopenharmony_ci 127f08c3bdfSopenharmony_ciIf you aren't familiar with its rules please read it, it's a well written 128f08c3bdfSopenharmony_ciintroduction. 129f08c3bdfSopenharmony_ci 130f08c3bdfSopenharmony_ciRun `make check` in the test's directory and/or use `make check-$TCID`, 131f08c3bdfSopenharmony_ciit uses (among other checks) our vendored version of 132f08c3bdfSopenharmony_cihttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/checkpatch.pl[checkpatch.pl] 133f08c3bdfSopenharmony_ciscript from kernel git tree. 134f08c3bdfSopenharmony_ci 135f08c3bdfSopenharmony_ciNOTE: If `make check` does not report any problems, the code still may be wrong 136f08c3bdfSopenharmony_ci as all tools used for checking only look for common mistakes. 137f08c3bdfSopenharmony_ci 138f08c3bdfSopenharmony_ci2.1.1 LTP-004: Test executable symbols are marked static 139f08c3bdfSopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 140f08c3bdfSopenharmony_ci 141f08c3bdfSopenharmony_ciTest executables should not export symbols unnecessarily. This means 142f08c3bdfSopenharmony_cithat all top-level variables and functions should be marked with the 143f08c3bdfSopenharmony_cistatic keyword. The only visible symbols should be those included from 144f08c3bdfSopenharmony_cishared object files. 145f08c3bdfSopenharmony_ci 146f08c3bdfSopenharmony_ci2.2 Shell coding style 147f08c3bdfSopenharmony_ci^^^^^^^^^^^^^^^^^^^^^^ 148f08c3bdfSopenharmony_ci 149f08c3bdfSopenharmony_ciWhen writing testcases in shell write in *portable shell* only, it's a good 150f08c3bdfSopenharmony_ciidea to try to run the test using alternative shell (alternative to bash, for 151f08c3bdfSopenharmony_ciexample dash) too. 152f08c3bdfSopenharmony_ci 153f08c3bdfSopenharmony_ci*Portable shell* means Shell Command Language as defined by POSIX with an 154f08c3bdfSopenharmony_ciexception of few widely used extensions, namely 'local' keyword used inside of 155f08c3bdfSopenharmony_cifunctions and '-o' and '-a' test parameters (that are marked as obsolete in 156f08c3bdfSopenharmony_ciPOSIX). 157f08c3bdfSopenharmony_ci 158f08c3bdfSopenharmony_ciYou can either try to run the testcases on Debian which has '/bin/sh' pointing 159f08c3bdfSopenharmony_cito 'dash' by default or install 'dash' on your favorite distribution and use 160f08c3bdfSopenharmony_ciit to run the tests. If your distribution lacks 'dash' package you can always 161f08c3bdfSopenharmony_cicompile it from http://gondor.apana.org.au/~herbert/dash/files/[source]. 162f08c3bdfSopenharmony_ci 163f08c3bdfSopenharmony_ciRun `make check` in the test's directory and/or use `make check-$TCID.sh`, 164f08c3bdfSopenharmony_ciit uses (among other checks) our vendored version of 165f08c3bdfSopenharmony_cihttps://salsa.debian.org/debian/devscripts/raw/master/scripts/checkbashisms.pl[checkbashism.pl] 166f08c3bdfSopenharmony_cifrom Debian, that is used to check for non-portable shell code. 167f08c3bdfSopenharmony_ci 168f08c3bdfSopenharmony_ciNOTE: If `make check` does not report any problems, the code still may be wrong 169f08c3bdfSopenharmony_ci as `checkbashisms.pl` used for checking only looks for common mistakes. 170f08c3bdfSopenharmony_ci 171f08c3bdfSopenharmony_ciHere are some common sense style rules for shell 172f08c3bdfSopenharmony_ci 173f08c3bdfSopenharmony_ci* Keep lines under 80 chars 174f08c3bdfSopenharmony_ci 175f08c3bdfSopenharmony_ci* Use tabs for indentation 176f08c3bdfSopenharmony_ci 177f08c3bdfSopenharmony_ci* Keep things simple, avoid unnecessary subshells 178f08c3bdfSopenharmony_ci 179f08c3bdfSopenharmony_ci* Don't do confusing things (i.e. don't name your functions like common shell 180f08c3bdfSopenharmony_ci commands, etc.) 181f08c3bdfSopenharmony_ci 182f08c3bdfSopenharmony_ci* Quote variables 183f08c3bdfSopenharmony_ci 184f08c3bdfSopenharmony_ci* Be consistent 185f08c3bdfSopenharmony_ci 186f08c3bdfSopenharmony_ci3 Backwards compatibility 187f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~ 188f08c3bdfSopenharmony_ci 189f08c3bdfSopenharmony_ciLTP test should be as backward compatible as possible. Think of an enterprise 190f08c3bdfSopenharmony_cidistributions with long term support (more than five years since the initial 191f08c3bdfSopenharmony_cirelease) or of an embedded platform that needs to use several years old 192f08c3bdfSopenharmony_citoolchain supplied by the manufacturer. 193f08c3bdfSopenharmony_ci 194f08c3bdfSopenharmony_ciTherefore LTP test for more current features should be able to cope with older 195f08c3bdfSopenharmony_cisystems. It should at least compile fine and if it's not appropriate for the 196f08c3bdfSopenharmony_ciconfiguration it should return 'TCONF'. 197f08c3bdfSopenharmony_ci 198f08c3bdfSopenharmony_ciThere are several types of checks we use: 199f08c3bdfSopenharmony_ci 200f08c3bdfSopenharmony_ciThe *configure script* is usually used to detect availability of a function 201f08c3bdfSopenharmony_cideclarations in system headers. It's used to disable tests at compile time or 202f08c3bdfSopenharmony_cito enable fallback definitions. 203f08c3bdfSopenharmony_ci 204f08c3bdfSopenharmony_ciChecking the *errno* value is another type of runtime check. Most of the 205f08c3bdfSopenharmony_cisyscalls returns either 'EINVAL' or 'ENOSYS' when syscall was not implemented 206f08c3bdfSopenharmony_cior was disabled upon kernel compilation. 207f08c3bdfSopenharmony_ci 208f08c3bdfSopenharmony_ciLTP has kernel version detection that can be used to disable tests at runtime, 209f08c3bdfSopenharmony_ciunfortunately kernel version does not always corresponds to a well defined 210f08c3bdfSopenharmony_cifeature set as distributions tend to backport hundreds of patches while the 211f08c3bdfSopenharmony_cikernel version stays the same. Use with caution. 212f08c3bdfSopenharmony_ci 213f08c3bdfSopenharmony_ciLately we added kernel '.config' parser, a test can define a boolean 214f08c3bdfSopenharmony_ciexpression of kernel config variables that has to be satisfied in order for a 215f08c3bdfSopenharmony_citest to run. This is mostly used for kernel namespaces at the moment. 216f08c3bdfSopenharmony_ci 217f08c3bdfSopenharmony_ciSometimes it also makes sense to define a few macros instead of creating 218f08c3bdfSopenharmony_ciconfigure test. One example is Linux specific POSIX clock ids in 219f08c3bdfSopenharmony_ci'include/lapi/posix_clocks.h'. 220f08c3bdfSopenharmony_ci 221f08c3bdfSopenharmony_ci3.1 Dealing with messed up legacy code 222f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 223f08c3bdfSopenharmony_ci 224f08c3bdfSopenharmony_ciLTP still contains a lot of old and messy code and we are cleaning it up as 225f08c3bdfSopenharmony_cifast as we can but despite the decade of efforts there is still a lot. If you 226f08c3bdfSopenharmony_cistart modifying old or a messy testcase and your changes are more complicated 227f08c3bdfSopenharmony_cithan simple typo fixes you should convert the test into a new library first. 228f08c3bdfSopenharmony_ci 229f08c3bdfSopenharmony_ciIt's also much easier to review the changes if you split them into a smaller 230f08c3bdfSopenharmony_cilogical groups. The same goes for moving files. If you need a rename or move 231f08c3bdfSopenharmony_cifile do it in a separate patch. 232f08c3bdfSopenharmony_ci 233f08c3bdfSopenharmony_ci4 License 234f08c3bdfSopenharmony_ci~~~~~~~~~ 235f08c3bdfSopenharmony_ci 236f08c3bdfSopenharmony_ciCode contributed to LTP should be licensed under GPLv2+ (GNU GPL version 2 or 237f08c3bdfSopenharmony_ciany later version). 238f08c3bdfSopenharmony_ci 239f08c3bdfSopenharmony_ciUse `SPDX-License-Identifier: GPL-2.0-or-later` 240f08c3bdfSopenharmony_ci 241f08c3bdfSopenharmony_ci5 LTP Structure 242f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~ 243f08c3bdfSopenharmony_ci 244f08c3bdfSopenharmony_ciThe structure of LTP is quite simple. Each test is a binary written either in 245f08c3bdfSopenharmony_ciportable shell or C. The test gets a configuration via environment variables 246f08c3bdfSopenharmony_ciand/or command line parameters, it prints additional information into the 247f08c3bdfSopenharmony_cistdout and reports overall success/failure via the exit value. 248f08c3bdfSopenharmony_ci 249f08c3bdfSopenharmony_ciTests are generally placed under the 'testcases/' directory. Everything that 250f08c3bdfSopenharmony_ciis a syscall or (slightly confusingly) libc syscall wrapper goes under 251f08c3bdfSopenharmony_ci'testcases/kernel/syscalls/'. 252f08c3bdfSopenharmony_ci 253f08c3bdfSopenharmony_ciThen there is 'testcases/open_posix_testsuite/' which is a well maintained fork 254f08c3bdfSopenharmony_ciof the upstream project that has been dead since 2005 and also a number of 255f08c3bdfSopenharmony_cidirectories with tests for more specific features. 256f08c3bdfSopenharmony_ci 257f08c3bdfSopenharmony_ci5.1 Runtest Files 258f08c3bdfSopenharmony_ci^^^^^^^^^^^^^^^^^ 259f08c3bdfSopenharmony_ci 260f08c3bdfSopenharmony_ciThe list of tests to be executed is stored in runtest files under the 261f08c3bdfSopenharmony_ci'runtest/' directory. The default set of runtest files to be executed is 262f08c3bdfSopenharmony_cistored in 'scenario_groups/default'. When you add a test you should add 263f08c3bdfSopenharmony_cicorresponding entries into some runtest file(s) as well. 264f08c3bdfSopenharmony_ci 265f08c3bdfSopenharmony_ciFor syscall tests (these placed under 'testcases/kernel/syscalls/') use 266f08c3bdfSopenharmony_ci'runtest/syscalls' file, for kernel related tests for memory management we 267f08c3bdfSopenharmony_cihave 'runtest/mm', etc. 268f08c3bdfSopenharmony_ci 269f08c3bdfSopenharmony_ciIMPORTANT: The runtest files should have one entry per a test. Creating a 270f08c3bdfSopenharmony_ci wrapper that runs all your tests and adding it as a single test 271f08c3bdfSopenharmony_ci into runtest file is strongly discouraged. 272f08c3bdfSopenharmony_ci 273f08c3bdfSopenharmony_ci5.2 Datafiles 274f08c3bdfSopenharmony_ci^^^^^^^^^^^^^ 275f08c3bdfSopenharmony_ci 276f08c3bdfSopenharmony_ciIf your test needs datafiles to work, these should be put into a subdirectory 277f08c3bdfSopenharmony_cinamed 'datafiles' and installed into the 'testcases/data/$TCID' directory (to 278f08c3bdfSopenharmony_cido that you have to add 'INSTALL_DIR := testcases/data/TCID' into the 279f08c3bdfSopenharmony_ci'datafiles/Makefile'). 280f08c3bdfSopenharmony_ci 281f08c3bdfSopenharmony_ciYou can obtain path to datafiles via $TST_DATAROOT provided by test.sh 282f08c3bdfSopenharmony_ci'$TST_DATAROOT/...' 283f08c3bdfSopenharmony_cior via C function 'tst_dataroot()' provided by libltp: 284f08c3bdfSopenharmony_ci 285f08c3bdfSopenharmony_ci[source,c] 286f08c3bdfSopenharmony_ci------------------------------------------------------------------------------- 287f08c3bdfSopenharmony_ciconst char *dataroot = tst_dataroot(); 288f08c3bdfSopenharmony_ci------------------------------------------------------------------------------- 289f08c3bdfSopenharmony_ci 290f08c3bdfSopenharmony_ciDatafiles can also be accessed as '$LTPROOT/testcases/data/$TCID/...', 291f08c3bdfSopenharmony_cibut '$TST_DATAROOT' and 'tst_dataroot()' are preferred as these can be used 292f08c3bdfSopenharmony_ciwhen running testcases directly in git tree as well as from install 293f08c3bdfSopenharmony_cilocation. 294f08c3bdfSopenharmony_ci 295f08c3bdfSopenharmony_ciThe path is constructed according to these rules: 296f08c3bdfSopenharmony_ci 297f08c3bdfSopenharmony_ci1. if '$LTPROOT' is set, return '$LTPROOT/testcases/data/$TCID' 298f08c3bdfSopenharmony_ci2. else if 'tst_tmpdir()' was called return '$STARTWD/datafiles' 299f08c3bdfSopenharmony_ci (where '$STARTWD' is initial working directory as recorded by 'tst_tmpdir()') 300f08c3bdfSopenharmony_ci3. else return '$CWD/datafiles' 301f08c3bdfSopenharmony_ci 302f08c3bdfSopenharmony_ciSee 'testcases/commands/file/' for example. 303f08c3bdfSopenharmony_ci 304f08c3bdfSopenharmony_ci5.3 Subexecutables 305f08c3bdfSopenharmony_ci^^^^^^^^^^^^^^^^^^ 306f08c3bdfSopenharmony_ci 307f08c3bdfSopenharmony_ciIf your test needs to execute a binary, place it in the same directory as the 308f08c3bdfSopenharmony_citestcase and name the file starting with '${test_binary_name}_'. Once the 309f08c3bdfSopenharmony_citest is executed by the framework, the path to the directory with all LTP 310f08c3bdfSopenharmony_cibinaries is added to the '$PATH' and you can execute it just by its name. 311f08c3bdfSopenharmony_ci 312f08c3bdfSopenharmony_ciTIP: If you need to execute such test from the LTP tree, you can add path to 313f08c3bdfSopenharmony_ci current directory to '$PATH' manually with: 'PATH="$PATH:$PWD" ./foo01'. 314f08c3bdfSopenharmony_ci 315f08c3bdfSopenharmony_ci6 Test Contribution Checklist 316f08c3bdfSopenharmony_ci------------------------------ 317f08c3bdfSopenharmony_ci 318f08c3bdfSopenharmony_ciNOTE: See also 319f08c3bdfSopenharmony_ci https://github.com/linux-test-project/ltp/wiki/Maintainer-Patch-Review-Checklist[Maintainer Patch Review Checklist]. 320f08c3bdfSopenharmony_ci 321f08c3bdfSopenharmony_ci1. Test compiles and runs fine (check with `-i 10` too) 322f08c3bdfSopenharmony_ci2. `make check` does not emit any warnings for the test you are working on 323f08c3bdfSopenharmony_ci (hint: run it in the test's directory and/or use `make check-$TCID`) 324f08c3bdfSopenharmony_ci3. The runtest entries are in place 325f08c3bdfSopenharmony_ci4. Test binaries are added into corresponding '.gitignore' files 326f08c3bdfSopenharmony_ci5. Patches apply over the latest git 327f08c3bdfSopenharmony_ci 328f08c3bdfSopenharmony_ci6.1 About .gitignore files 329f08c3bdfSopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~ 330f08c3bdfSopenharmony_ci 331f08c3bdfSopenharmony_ciThere are numerous '.gitignore' files in the LTP tree. Usually there is a 332f08c3bdfSopenharmony_ci'.gitignore' file per a group of tests. The reason for this setup is simple. 333f08c3bdfSopenharmony_ciIt's easier to maintain a '.gitignore' file per directory with tests, rather 334f08c3bdfSopenharmony_cithan having single file in the project root directory. This way, we don't have 335f08c3bdfSopenharmony_cito update all the gitignore files when moving directories, and they get deleted 336f08c3bdfSopenharmony_ciautomatically when a directory with tests is removed. 337f08c3bdfSopenharmony_ci 338f08c3bdfSopenharmony_ci7 Testing pre-release kernel features 339f08c3bdfSopenharmony_ci------------------------------------- 340f08c3bdfSopenharmony_ci 341f08c3bdfSopenharmony_ciTests for features not yet in a mainline kernel release are accepted. However 342f08c3bdfSopenharmony_cithey must only be added to the +staging+ runtest file. Once a feature is part 343f08c3bdfSopenharmony_ciof the stable kernel ABI the associated test must be moved out of staging. 344f08c3bdfSopenharmony_ci 345f08c3bdfSopenharmony_ciThis is primarily to help test kernel RCs by avoiding the need to download 346f08c3bdfSopenharmony_ciseparate LTP patchsets. 347f08c3bdfSopenharmony_ci 348f08c3bdfSopenharmony_ci8 LTP C And Shell Test API Comparison 349f08c3bdfSopenharmony_ci------------------------------------- 350f08c3bdfSopenharmony_ci 351f08c3bdfSopenharmony_ciComparison of 352f08c3bdfSopenharmony_cihttps://github.com/linux-test-project/ltp/wiki/C-Test-API[C Test API] and 353f08c3bdfSopenharmony_cihttps://github.com/linux-test-project/ltp/wiki/Shell-Test-API[Shell Test API]. 354f08c3bdfSopenharmony_ci 355f08c3bdfSopenharmony_ci[options="header"] 356f08c3bdfSopenharmony_ci|================================================================================ 357f08c3bdfSopenharmony_ci| C API ('struct tst_test' members) | shell API ('$TST_*' environment variables) 358f08c3bdfSopenharmony_ci| '.all_filesystems' | 'TST_ALL_FILESYSTEMS' 359f08c3bdfSopenharmony_ci| '.bufs' | – 360f08c3bdfSopenharmony_ci| '.caps' | – 361f08c3bdfSopenharmony_ci| '.child_needs_reinit' | not applicable 362f08c3bdfSopenharmony_ci| '.cleanup' | 'TST_CLEANUP' 363f08c3bdfSopenharmony_ci| '.dev_extra_opts' | 'TST_DEV_EXTRA_OPTS' 364f08c3bdfSopenharmony_ci| '.dev_fs_opts' | 'TST_DEV_FS_OPTS' 365f08c3bdfSopenharmony_ci| '.dev_fs_type' | 'TST_FS_TYPE' 366f08c3bdfSopenharmony_ci| '.dev_min_size' | not applicable 367f08c3bdfSopenharmony_ci| '.format_device' | 'TST_FORMAT_DEVICE' 368f08c3bdfSopenharmony_ci| '.max_runtime' | – 369f08c3bdfSopenharmony_ci| '.min_cpus' | not applicable 370f08c3bdfSopenharmony_ci| '.min_kver' | 'TST_MIN_KVER' 371f08c3bdfSopenharmony_ci| '.min_mem_avail' | not applicable 372f08c3bdfSopenharmony_ci| '.mnt_flags' | 'TST_MNT_PARAMS' 373f08c3bdfSopenharmony_ci| '.min_swap_avail' | not applicable 374f08c3bdfSopenharmony_ci| '.mntpoint', '.mnt_data' | 'TST_MNTPOINT' 375f08c3bdfSopenharmony_ci| '.mount_device' | 'TST_MOUNT_DEVICE' 376f08c3bdfSopenharmony_ci| '.needs_cgroup_ctrls' | – 377f08c3bdfSopenharmony_ci| '.needs_checkpoints' | 'TST_NEEDS_CHECKPOINTS' 378f08c3bdfSopenharmony_ci| '.needs_cmds' | 'TST_NEEDS_CMDS' 379f08c3bdfSopenharmony_ci| '.needs_devfs' | – 380f08c3bdfSopenharmony_ci| '.needs_device' | 'TST_NEEDS_DEVICE' 381f08c3bdfSopenharmony_ci| '.needs_drivers' | 'TST_NEEDS_DRIVERS' 382f08c3bdfSopenharmony_ci| '.needs_kconfigs' | 'TST_NEEDS_KCONFIGS' 383f08c3bdfSopenharmony_ci| '.needs_overlay' | 384f08c3bdfSopenharmony_ci| '.needs_rofs' | – 385f08c3bdfSopenharmony_ci| '.needs_root' | 'TST_NEEDS_ROOT' 386f08c3bdfSopenharmony_ci| '.needs_tmpdir' | 'TST_NEEDS_TMPDIR' 387f08c3bdfSopenharmony_ci| '.options' | 'TST_PARSE_ARGS', 'TST_OPTS' 388f08c3bdfSopenharmony_ci| '.resource_files' | – 389f08c3bdfSopenharmony_ci| '.restore_wallclock' | not applicable 390f08c3bdfSopenharmony_ci| '.sample' | – 391f08c3bdfSopenharmony_ci| '.save_restore' | – 392f08c3bdfSopenharmony_ci| '.scall' | not applicable 393f08c3bdfSopenharmony_ci| '.setup' | 'TST_SETUP' 394f08c3bdfSopenharmony_ci| '.skip_filesystems' | 'TST_SKIP_FILESYSTEMS' 395f08c3bdfSopenharmony_ci| '.skip_in_compat' | – 396f08c3bdfSopenharmony_ci| '.skip_in_lockdown' | 'TST_SKIP_IN_LOCKDOWN' 397f08c3bdfSopenharmony_ci| '.skip_in_secureboot' | 'TST_SKIP_IN_SECUREBOOT' 398f08c3bdfSopenharmony_ci| '.supported_archs' | not applicable 399f08c3bdfSopenharmony_ci| '.tags' | – 400f08c3bdfSopenharmony_ci| '.taint_check' | – 401f08c3bdfSopenharmony_ci| '.tcnt' | 'TST_CNT' 402f08c3bdfSopenharmony_ci| '.tconf_msg' | not applicable 403f08c3bdfSopenharmony_ci| '.test', '.test_all' | 'TST_TESTFUNC' 404f08c3bdfSopenharmony_ci| '.test_variants' | – 405f08c3bdfSopenharmony_ci| '.timeout' | 'TST_TIMEOUT' 406f08c3bdfSopenharmony_ci| '.tst_hugepage' | not applicable 407f08c3bdfSopenharmony_ci| .format_device | 'TST_DEVICE' 408f08c3bdfSopenharmony_ci| not applicable | 'TST_NEEDS_KCONFIGS_IFS' 409f08c3bdfSopenharmony_ci| not applicable | 'TST_NEEDS_MODULE' 410f08c3bdfSopenharmony_ci| not applicable | 'TST_POS_ARGS' 411f08c3bdfSopenharmony_ci| not applicable | 'TST_USAGE' 412f08c3bdfSopenharmony_ci|================================================================================ 413