1LTP Shell Test API 2================== 3 4NOTE: See also 5 https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines[Test Writing Guidelines], 6 https://github.com/linux-test-project/ltp/wiki/C-Test-API[C Test API]. 7 81 Writing a testcase in shell 9----------------------------- 10 11LTP supports testcases to be written in a portable shell too. 12 13There is a shell library modeled closely to the C interface at 14'testcases/lib/tst_test.sh'. 15 16WARNING: All identifiers starting with 'TST_' or 'tst_' are reserved for the 17 test library. 18 191.1 Basic test interface 20~~~~~~~~~~~~~~~~~~~~~~~~ 21 22[source,sh] 23------------------------------------------------------------------------------- 24#!/bin/sh 25# SPDX-License-Identifier: GPL-2.0-or-later 26# This is a basic test for true shell builtin 27 28TST_TESTFUNC=do_test 29. tst_test.sh 30 31do_test() 32{ 33 true 34 ret=$? 35 36 if [ $ret -eq 0 ]; then 37 tst_res TPASS "true returned 0" 38 else 39 tst_res TFAIL "true returned $ret" 40 fi 41} 42 43tst_run 44------------------------------------------------------------------------------- 45 46TIP: To execute this test the 'tst_test.sh' library must be in '$PATH'. If you 47 are executing the test from a git checkout you can run it as 48 'PATH="$PATH:../../lib" ./foo01.sh' 49 50The shell library expects test setup, cleanup and the test function executing 51the test in the '$TST_SETUP', '$TST_CLEANUP' and '$TST_TESTFUNC' variables. 52 53Both '$TST_SETUP' and '$TST_CLEANUP' are optional. 54 55The '$TST_TESTFUNC' may be called several times if more than one test 56iteration was requested by passing right command line options to the test. 57 58The '$TST_CLEANUP' may be called even in the middle of the setup and must be 59able to clean up correctly even in this situation. The easiest solution for 60this is to keep track of what was initialized and act accordingly in the 61cleanup. 62 63WARNING: Similar to the C library, calling 'tst_brk' in the $TST_CLEANUP does 64 not exit the test and 'TBROK' is converted to 'TWARN'. 65 66Notice also the 'tst_run' shell API function called at the end of the test that 67actually starts the test. 68 69WARNING: cleanup function is called only after 'tst_run' has been started. 70Calling 'tst_brk' in shell libraries, e.g. 'tst_test.sh' or 'tst_net.sh' does 71not trigger calling it. 72 73[source,sh] 74------------------------------------------------------------------------------- 75#!/bin/sh 76# SPDX-License-Identifier: GPL-2.0-or-later 77# Example test with tests in separate functions 78 79TST_TESTFUNC=test 80TST_CNT=2 81. tst_test.sh 82 83test1() 84{ 85 tst_res TPASS "Test $1 passed" 86} 87 88test2() 89{ 90 tst_res TPASS "Test $1 passed" 91} 92 93tst_run 94# output: 95# foo 1 TPASS: Test 1 passed 96# foo 2 TPASS: Test 2 passed 97------------------------------------------------------------------------------- 98 99If '$TST_CNT' is set, the test library looks if there are functions named 100'$\{TST_TESTFUNC\}1', ..., '$\{TST_TESTFUNC\}$\{TST_CNT\}' and if these are 101found they are executed one by one. The test number is passed to it in the '$1'. 102 103[source,sh] 104------------------------------------------------------------------------------- 105#!/bin/sh 106# SPDX-License-Identifier: GPL-2.0-or-later 107# Example test with tests in a single function 108 109TST_TESTFUNC=do_test 110TST_CNT=2 111. tst_test.sh 112 113do_test() 114{ 115 case $1 in 116 1) tst_res TPASS "Test $1 passed";; 117 2) tst_res TPASS "Test $1 passed";; 118 esac 119} 120 121tst_run 122# output: 123# foo 1 TPASS: Test 1 passed 124# foo 2 TPASS: Test 2 passed 125------------------------------------------------------------------------------- 126 127Otherwise, if '$TST_CNT' is set but there is no '$\{TST_TESTFUNC\}1', etc., 128the '$TST_TESTFUNC' is executed '$TST_CNT' times and the test number is passed 129to it in the '$1'. 130 131[source,sh] 132------------------------------------------------------------------------------- 133#!/bin/sh 134# SPDX-License-Identifier: GPL-2.0-or-later 135# Example test with tests in a single function, using $TST_TEST_DATA and 136# $TST_TEST_DATA_IFS 137 138TST_TESTFUNC=do_test 139TST_TEST_DATA="foo:bar:d dd" 140TST_TEST_DATA_IFS=":" 141. tst_test.sh 142 143do_test() 144{ 145 tst_res TPASS "Test $1 passed with data '$2'" 146} 147 148tst_run 149# output: 150# foo 1 TPASS: Test 1 passed with data 'foo' 151# foo 2 TPASS: Test 1 passed with data 'bar' 152# foo 3 TPASS: Test 1 passed with data 'd dd' 153------------------------------------------------------------------------------- 154 155It's possible to pass data for function with '$TST_TEST_DATA'. Optional 156'$TST_TEST_DATA_IFS' is used for splitting, default value is space. 157 158[source,sh] 159------------------------------------------------------------------------------- 160#!/bin/sh 161# SPDX-License-Identifier: GPL-2.0-or-later 162# Example test with tests in a single function, using $TST_TEST_DATA and $TST_CNT 163 164TST_TESTFUNC=do_test 165TST_CNT=2 166TST_TEST_DATA="foo bar" 167. tst_test.sh 168 169do_test() 170{ 171 case $1 in 172 1) tst_res TPASS "Test $1 passed with data '$2'";; 173 2) tst_res TPASS "Test $1 passed with data '$2'";; 174 esac 175} 176 177tst_run 178# output: 179# foo 1 TPASS: Test 1 passed with data 'foo' 180# foo 2 TPASS: Test 2 passed with data 'foo' 181# foo 3 TPASS: Test 1 passed with data 'bar' 182# foo 4 TPASS: Test 2 passed with data 'bar' 183------------------------------------------------------------------------------- 184 185'$TST_TEST_DATA' can be used with '$TST_CNT'. If '$TST_TEST_DATA_IFS' not specified, 186space as default value is used. Of course, it's possible to use separate functions. 187 1881.2 Library environment variables and functions for shell 189~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 190 191Similarily to the C library various checks and preparations can be requested 192simply by setting right '$TST_NEEDS_FOO'. 193 194[options="header"] 195|============================================================================= 196| Variable name | Action done 197| 'TST_NEEDS_ROOT' | Exit the test with 'TCONF' unless executed under root. 198| | Alternatively the 'tst_require_root' command can be used. 199| 'TST_NEEDS_TMPDIR' | Create test temporary directory and cd into it. 200| 'TST_NEEDS_DEVICE' | Prepare test temporary device, the path to testing 201 device is stored in '$TST_DEVICE' variable. 202 The option implies 'TST_NEEDS_TMPDIR'. 203| 'TST_NEEDS_CMDS' | String with command names that has to be present for 204 the test (see below). 205| 'TST_NEEDS_MODULE' | Test module name needed for the test (see below). 206| 'TST_NEEDS_DRIVERS' | Checks kernel drivers support for the test. 207| 'TST_NEEDS_KCONFIGS' | Checks kernel kconfigs support for the test (see below). 208| 'TST_NEEDS_KCONFIGS_IFS' | Used for splitting '$TST_NEEDS_KCONFIGS' variable, 209 default value is comma, it only supports single character. 210| 'TST_TIMEOUT' | Maximum timeout set for the test in sec. Must be int >= 1, 211 or -1 (special value to disable timeout), default is 300. 212 Variable is meant be set in tests, not by user. 213 It's an equivalent of `tst_test.timeout` in C, can be set 214 via 'tst_set_timeout(timeout)' after test has started. 215|============================================================================= 216 217[options="header"] 218|============================================================================= 219| Function name | Action done 220| 'tst_set_timeout(timeout)' | Maximum timeout set for the test in sec. 221 See 'TST_TIMEOUT' variable. 222|============================================================================= 223 224NOTE: Network tests (see testcases/network/README.md) use additional variables 225and functions in 'tst_net.sh'. 226 227Checking for presence of commands 228+++++++++++++++++++++++++++++++++ 229 230[source,sh] 231------------------------------------------------------------------------------- 232#!/bin/sh 233 234... 235 236TST_NEEDS_CMDS="modinfo modprobe" 237. tst_test.sh 238 239... 240 241------------------------------------------------------------------------------- 242 243Setting '$TST_NEEDS_CMDS' to a string listing required commands will check for 244existence each of them and exits the test with 'TCONF' on first missing. 245 246Alternatively the 'tst_require_cmds()' function can be used to do the same on 247runtime, since sometimes we need to the check at runtime too. 248 249'tst_check_cmds()' can be used for requirements just for a particular test 250as it doesn't exit (it issues 'tst_res TCONF'). Expected usage is: 251 252[source,sh] 253------------------------------------------------------------------------------- 254#!/bin/sh 255 256TST_TESTFUNC=do_test 257. tst_test.sh 258 259do_test() 260{ 261 tst_check_cmds cmd || return 262 cmd --foo 263 ... 264} 265 266tst_run 267------------------------------------------------------------------------------- 268 269Locating kernel modules 270+++++++++++++++++++++++ 271 272The LTP build system can build kernel modules as well, setting 273'$TST_NEEDS_MODULE' to module name will cause the library to look for the 274module in a few possible paths. 275 276If module was found the path to it will be stored into '$TST_MODPATH' 277variable, if module wasn't found the test will exit with 'TCONF'. 278 279Alternatively the 'tst_require_module()' function can be used to do the same 280at runtime. 281 2821.3 Optional command line parameters 283~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 284 285[source,sh] 286------------------------------------------------------------------------------- 287#!/bin/sh 288# SPDX-License-Identifier: GPL-2.0-or-later 289# Optional test command line parameters 290 291TST_OPTS="af:" 292TST_USAGE=usage 293TST_PARSE_ARGS=parse_args 294TST_TESTFUNC=do_test 295 296. tst_test.sh 297 298ALTERNATIVE=0 299MODE="foo" 300 301usage() 302{ 303 cat << EOF 304usage: $0 [-a] [-f <foo|bar>] 305 306OPTIONS 307-a Enable support for alternative foo 308-f Specify foo or bar mode 309EOF 310} 311 312parse_args() 313{ 314 case $1 in 315 a) ALTERNATIVE=1;; 316 f) MODE="$2";; 317 esac 318} 319 320do_test() 321{ 322 ... 323} 324 325tst_run 326------------------------------------------------------------------------------- 327 328The 'getopts' string for optional parameters is passed in the '$TST_OPTS' 329variable. There are a few default parameters that cannot be used by a test, 330these can be listed with passing help '-h' option to any test. 331 332The function that prints the usage is passed in '$TST_USAGE', the help for 333the options implemented in the library is appended when usage is printed. 334 335Lastly the function '$PARSE_ARGS' is called with the option name in the '$1' 336and, if option has argument, its value in the '$2'. 337 338[source,sh] 339------------------------------------------------------------------------------- 340#!/bin/sh 341# SPDX-License-Identifier: GPL-2.0-or-later 342# Optional test positional parameters 343 344TST_POS_ARGS=3 345TST_USAGE=usage 346TST_TESTFUNC=do_test 347 348. tst_test.sh 349 350usage() 351{ 352 cat << EOF 353usage: $0 [min] [max] [size] 354 355EOF 356} 357 358min="$1" 359max="$2" 360size="$3" 361 362do_test() 363{ 364 ... 365} 366 367tst_run 368------------------------------------------------------------------------------- 369 370You can also request a number of positional parameters by setting the 371'$TST_POS_ARGS' variable. If you do, these will be available as they were 372passed directly to the script in '$1', '$2', ..., '$n'. 373 3741.4 Useful library functions 375~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 376 377Retrieving configuration variables 378++++++++++++++++++++++++++++++++++ 379 380You may need to retrieve configuration values such as PAGESIZE, there is 381'getconf' but as some system may not have it, you are advised to use 382'tst_getconf' instead. Note that it implements subset of 'getconf' 383system variables used by the testcases only. 384 385[source,sh] 386------------------------------------------------------------------------------- 387# retrieve PAGESIZE 388pagesize=`tst_getconf PAGESIZE` 389------------------------------------------------------------------------------- 390 391Sleeping for subsecond intervals 392++++++++++++++++++++++++++++++++ 393 394Albeit there is a sleep command available basically everywhere not all 395implementations can support sleeping for less than one second. And most of the 396time sleeping for a second is too much. Therefore LTP includes 'tst_sleep' 397that can sleep for defined amount of seconds, milliseconds or microseconds. 398 399[source,sh] 400------------------------------------------------------------------------------- 401# sleep for 100 milliseconds 402tst_sleep 100ms 403------------------------------------------------------------------------------- 404 405Retry a function call multiple times 406++++++++++++++++++++++++++++++++++++ 407 408Sometimes an LTP test needs to retry a function call multiple times because 409the system is not ready to process it successfully on the first try. The LTP 410library has useful tools to handle the call retry automatically. 411'TST_RETRY_FUNC()' will keep retrying for up to 1 second. If you want a custom 412time limit use 'TST_RETRY_FN_EXP_BACKOFF()'. Both methods return the value 413returned by the last 'FUNC' call. 414 415The delay between retries starts at 1 microsecond and doubles after each call. 416The retry loop ends when the function call succeeds or when the next delay 417exceeds the specified time (1 second for 'TST_RETRY_FUNC()'). The maximum 418delay is multiplied by TST_TIMEOUT_MUL. The total cumulative delay may be up 419to twice as long as the adjusted maximum delay. 420 421The C version of 'TST_RETRY_FUNC()' is a macro which takes two arguments: 422 423* 'FUNC' is the complete function call with arguments which should be retried 424 multiple times. 425* 'SUCCESS_CHECK' is a macro or function which will validate 'FUNC' return 426 value. 'FUNC' call was successful if 'SUCCESS_CHECK(ret)' evaluates to 427 non-zero. 428 429Both retry methods clear 'errno' before every 'FUNC' call so your 430'SUCCESS_CHECK' can look for specific error codes as well. The LTP library 431also includes predefined 'SUCCESS_CHECK' macros for the most common call 432conventions: 433 434* 'TST_RETVAL_EQ0()' - The call was successful if 'FUNC' returned 0 or NULL 435* 'TST_RETVAL_NOTNULL()' - The call was successful if 'FUNC' returned any 436 value other than 0 or NULL. 437* 'TST_RETVAL_GE0()' - The call was successful if 'FUNC' returned value >= 0. 438 439[source,c] 440------------------------------------------------------------------------------- 441/* Keep trying for 1 second */ 442TST_RETRY_FUNC(FUNC, SUCCESS_CHECK) 443 444/* Keep trying for up to 2*N seconds */ 445TST_RETRY_FN_EXP_BACKOFF(FUNC, SUCCESS_CHECK, N) 446------------------------------------------------------------------------------- 447 448The shell version of 'TST_RETRY_FUNC()' is simpler and takes slightly 449different arguments: 450 451* 'FUNC' is a string containing the complete function or program call with 452 arguments. 453* 'EXPECTED_RET' is a single expected return value. 'FUNC' call was successful 454 if the return value is equal to EXPECTED_RET. 455 456[source,sh] 457------------------------------------------------------------------------------- 458# Keep trying for 1 second 459TST_RETRY_FUNC "FUNC arg1 arg2 ..." "EXPECTED_RET" 460 461# Keep trying for up to 2*N seconds 462TST_RETRY_FN_EXP_BACKOFF "FUNC arg1 arg2 ..." "EXPECTED_RET" "N" 463------------------------------------------------------------------------------- 464 465Checking for integers 466+++++++++++++++++++++ 467 468[source,sh] 469------------------------------------------------------------------------------- 470# returns zero if passed an integer parameter, non-zero otherwise 471tst_is_int "$FOO" 472------------------------------------------------------------------------------- 473 474Checking for integers and floating point numbers 475++++++++++++++++++++++++++++++++++++++++++++++++ 476 477[source,sh] 478------------------------------------------------------------------------------- 479# returns zero if passed an integer or floating point number parameter, 480# non-zero otherwise 481tst_is_num "$FOO" 482------------------------------------------------------------------------------- 483 484Obtaining random numbers 485++++++++++++++++++++++++ 486 487There is no '$RANDOM' in portable shell, use 'tst_random' instead. 488 489[source,sh] 490------------------------------------------------------------------------------- 491# get random integer between 0 and 1000 (including 0 and 1000) 492tst_random 0 1000 493------------------------------------------------------------------------------- 494 495Formatting device with a filesystem 496+++++++++++++++++++++++++++++++++++ 497 498The 'tst_mkfs' helper will format device with the filesystem. 499 500[source,sh] 501------------------------------------------------------------------------------- 502# format test device with ext2 503tst_mkfs ext2 $TST_DEVICE 504# default params are $TST_FS_TYPE $TST_DEVICE 505tst_mkfs 506# optional parameters 507tst_mkfs ext4 /dev/device -T largefile 508------------------------------------------------------------------------------- 509 510Mounting and unmounting filesystems 511+++++++++++++++++++++++++++++++++++ 512 513The 'tst_mount' and 'tst_umount' helpers are a safe way to mount/umount 514a filesystem. 515 516The 'tst_mount' mounts '$TST_DEVICE' of '$TST_FS_TYPE' (optional) to 517'$TST_MNTPOINT' (defaults to mntpoint), optionally using the 518'$TST_MNT_PARAMS'. The '$TST_MNTPOINT' directory is created if it didn't 519exist prior to the function call. 520 521If the path passed (optional, must be absolute path, defaults to '$TST_MNTPOINT') 522to the 'tst_umount' is not mounted (present in '/proc/mounts') it's noop. 523Otherwise it retries to umount the filesystem a few times on failure. 524This is a workaround since there are daemons dumb enough to probe all newly 525mounted filesystems, and prevents them from being umounted shortly after they 526were mounted. 527 528ROD and ROD_SILENT 529++++++++++++++++++ 530 531These functions supply the 'SAFE_MACROS' used in C although they work and are 532named differently. 533 534[source,sh] 535------------------------------------------------------------------------------- 536ROD_SILENT command arg1 arg2 ... 537 538# is shorthand for: 539 540command arg1 arg2 ... > /dev/null 2>&1 541if [ $? -ne 0 ]; then 542 tst_brk TBROK "..." 543fi 544 545 546ROD command arg1 arg2 ... 547 548# is shorthand for: 549 550ROD arg1 arg2 ... 551if [ $? -ne 0 ]; then 552 tst_brk TBROK "..." 553fi 554------------------------------------------------------------------------------- 555 556WARNING: Keep in mind that output redirection (to a file) happens in the 557 caller rather than in the ROD function and cannot be checked for 558 write errors by the ROD function. 559 560As a matter of a fact doing +ROD echo a > /proc/cpuinfo+ would work just fine 561since the 'ROD' function will only get the +echo a+ part that will run just 562fine. 563 564[source,sh] 565------------------------------------------------------------------------------- 566# Redirect output to a file with ROD 567ROD echo foo \> bar 568------------------------------------------------------------------------------- 569 570Note the '>' is escaped with '\', this causes that the '>' and filename are 571passed to the 'ROD' function as parameters and the 'ROD' function contains 572code to split '$@' on '>' and redirects the output to the file. 573 574EXPECT_PASS{,_BRK} and EXPECT_FAIL{,_BRK} 575+++++++++++++++++++++++++++++++++++++++++ 576 577[source,sh] 578------------------------------------------------------------------------------- 579EXPECT_PASS command arg1 arg2 ... [ \> file ] 580EXPECT_FAIL command arg1 arg2 ... [ \> file ] 581------------------------------------------------------------------------------- 582 583'EXPECT_PASS' calls 'tst_res TPASS' if the command exited with 0 exit code, 584and 'tst_res TFAIL' otherwise. 'EXPECT_FAIL' does vice versa. 585 586Output redirection rules are the same as for the 'ROD' function. In addition 587to that, 'EXPECT_FAIL' always redirects the command's stderr to '/dev/null'. 588 589There are also 'EXPECT_PASS_BRK' and 'EXPECT_FAIL_BRK', which works the same way 590except breaking a test when unexpected action happen. 591 592It's possible to detect whether expected value happened: 593[source,sh] 594------------------------------------------------------------------------------- 595if ! EXPECT_PASS command arg1 2\> /dev/null; then 596 continue 597fi 598------------------------------------------------------------------------------- 599 600tst_kvcmp 601+++++++++ 602 603This command compares the currently running kernel version given conditions 604with syntax similar to the shell test command. 605 606[source,sh] 607------------------------------------------------------------------------------- 608# Exit the test if kernel version is older or equal to 2.6.8 609if tst_kvcmp -le 2.6.8; then 610 tst_brk TCONF "Kernel newer than 2.6.8 is needed" 611fi 612 613# Exit the test if kernel is newer than 3.8 and older than 4.0.1 614if tst_kvcmp -gt 3.8 -a -lt 4.0.1; then 615 tst_brk TCONF "Kernel must be older than 3.8 or newer than 4.0.1" 616fi 617------------------------------------------------------------------------------- 618 619[options="header"] 620|======================================================================= 621| expression | description 622| -eq kver | Returns true if kernel version is equal 623| -ne kver | Returns true if kernel version is not equal 624| -gt kver | Returns true if kernel version is greater 625| -ge kver | Returns true if kernel version is greater or equal 626| -lt kver | Returns true if kernel version is lesser 627| -le kver | Returns true if kernel version is lesser or equal 628| -a | Does logical and between two expressions 629| -o | Does logical or between two expressions 630|======================================================================= 631 632The format for kernel version has to either be with one dot e.g. '2.6' or with 633two dots e.g. '4.8.1'. 634 635.tst_fs_has_free 636[source,sh] 637------------------------------------------------------------------------------- 638#!/bin/sh 639 640... 641 642# whether current directory has 100MB free space at least. 643if ! tst_fs_has_free . 100MB; then 644 tst_brkm TCONF "Not enough free space" 645fi 646 647... 648------------------------------------------------------------------------------- 649 650The 'tst_fs_has_free' shell interface returns 0 if the specified free space is 651satisfied, 1 if not, and 2 on error. 652 653The second argument supports suffixes kB, MB and GB, the default unit is Byte. 654 655.tst_retry 656[source,sh] 657------------------------------------------------------------------------------- 658#!/bin/sh 659 660... 661 662# Retry ping command three times 663tst_retry "ping -c 1 127.0.0.1" 664 665if [ $? -ne 0 ]; then 666 tst_resm TFAIL "Failed to ping 127.0.0.1" 667else 668 tst_resm TPASS "Successfully pinged 127.0.0.1" 669fi 670 671... 672------------------------------------------------------------------------------- 673 674The 'tst_retry' function allows you to retry a command after waiting small 675amount of time until it succeeds or until given amount of retries has been 676reached (default is three attempts). 677 6781.5 Restarting daemons 679~~~~~~~~~~~~~~~~~~~~~~ 680 681Restarting system daemons is a complicated task for two reasons. 682 683* There are different init systems 684 (SysV init, systemd, etc...) 685 686* Daemon names are not unified between distributions 687 (apache vs httpd, cron vs crond, various syslog variations) 688 689To solve these problems LTP has 'testcases/lib/daemonlib.sh' library that 690provides functions to start/stop/query daemons as well as variables that store 691correct daemon name. 692 693.Supported operations 694|============================================================================== 695| start_daemon() | Starts daemon, name is passed as first parameter. 696| stop_daemon() | Stops daemon, name is passed as first parameter. 697| restart_daemon() | Restarts daemon, name is passed as first parameter. 698| status_daemon() | Detect daemon status (exit code: 0: running, 1: not running). 699|============================================================================== 700 701.Variables with detected names 702|============================================================================== 703| CROND_DAEMON | Cron daemon name (cron, crond). 704| SYSLOG_DAEMON | Syslog daemon name (syslog, syslog-ng, rsyslog). 705|============================================================================== 706 707.Cron daemon restart example 708[source,sh] 709------------------------------------------------------------------------------- 710#!/bin/sh 711# SPDX-License-Identifier: GPL-2.0-or-later 712# Cron daemon restart example 713 714TCID=cron01 715TST_COUNT=1 716. test.sh 717. daemonlib.sh 718 719... 720 721restart_daemon $CROND_DAEMON 722 723... 724 725tst_exit 726------------------------------------------------------------------------------- 727 7281.6 Access to the checkpoint interface 729~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 730 731The shell library provides an implementation of the checkpoint interface 732compatible with the C version. All 'TST_CHECKPOINT_*' functions are available. 733 734In order to initialize checkpoints '$TST_NEEDS_CHECKPOINTS' must be set to '1' 735before the inclusion of 'tst_test.sh': 736 737[source,sh] 738------------------------------------------------------------------------------- 739#!/bin/sh 740 741TST_NEEDS_CHECKPOINTS=1 742. tst_test.sh 743------------------------------------------------------------------------------- 744 745Since both the implementations are compatible, it's also possible to start 746a child binary process from a shell test and synchronize with it. This process 747must have checkpoints initialized by calling 'tst_reinit()'. 748 7491.7 Parsing kernel .config 750~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 751The shell library provides an implementation of the kconfig parsing interface 752compatible with the C version. 753 754It's possible to pass kernel kconfig list for tst_require_kconfigs API with 755'$TST_NEEDS_KCONFIGS'. 756Optional '$TST_NEEDS_KCONFIGS_IFS' is used for splitting, default value is comma. 757 758------------------------------------------------------------------------------- 759#!/bin/sh 760TST_NEEDS_KCONFIGS="CONFIG_EXT4_FS, CONFIG_QUOTACTL=y" 761 762. tst_test.sh 763------------------------------------------------------------------------------- 764