[LTP] [RFC][PATCH 2/3] tst_test: Allow test to suggest reboot via $TST_REBOOT
    Petr Vorel 
    pvorel@suse.cz
       
    Wed Jul 16 08:54:44 CEST 2025
    
    
  
Hi Cyril, all,
> Frameworks/tooling which run LTP can schedule reboot based on
> environment variable.
Cyril, you wanted to add this via struct tst_test (e.g. not using a new variable
in shell). That's indeed better (used by both C API and shell loader + having it
in metadata doc). But for a better integration with external frameworks (e.g.
kirk or openQA) it will still be needed to export some environment variable
(e.g. LTP_REBOOT) to notify the framework for a reboot.
And for IMA tests to be able to use it they will need to be converted to shell
loader (which requires to finish setup/cleanup support for shell loader [1]).
ima_setup.sh use quirk to use a loop device if TMPDIR is on tmpfs (some
IMA measurements are not supported on tmpfs). Because shell loader's struct
tst_test in JSON is not modifiable I will have to use always a loop device
(slower) and force some filesystem (previously tests were run on the filesystem
installed on TMPDIR, e.g. test on the filesystem chosen by distro/user).
Setting this whole patchset in patchwork as rejected.
Kind regards,
Petr
[1] https://patchwork.ozlabs.org/project/ltp/list/?series=460106&state=*
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> If useful, I should probably add it to C API as well
> (at least swapoff01.c and swapon01.c print also "reboot recommended").
>  doc/users/setup_tests.rst | 3 +++
>  testcases/lib/tst_test.sh | 7 ++++++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
> diff --git a/doc/users/setup_tests.rst b/doc/users/setup_tests.rst
> index ddcf00f027..0cdb86715f 100644
> --- a/doc/users/setup_tests.rst
> +++ b/doc/users/setup_tests.rst
> @@ -85,6 +85,9 @@ users.
>     * - LTP_ENABLE_DEBUG
>       - Enable debug info (value ``1`` or ``y``). Equivalent of ``-D`` parameter.
> +   * - TST_REBOOT
> +     - Environment variable set by LTP test to signalize that SUT should be rebooted.
> +
>  Environment variables for network tests
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  See :master:`testcases/network/README.md`.
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 2b797705e3..a450976f36 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -16,6 +16,7 @@ export TST_COUNT=1
>  export TST_ITERATIONS=1
>  export TST_TMPDIR_RHOST=0
>  export TST_LIB_LOADED=1
> +export TST_REBOOT=
>  . tst_ansi_color.sh
>  . tst_security.sh
> @@ -84,6 +85,10 @@ _tst_do_exit()
>  		[ -z "$TST_SKIP_LSM_WARNINGS" ] && _tst_check_security_modules
>  	fi
> +	if [ "$TST_REBOOT" = 1 ]; then
> +		tst_res TINFO "WARNING: reboot recommended due test changes"
> +	fi
    
    
More information about the ltp
mailing list