[LTP] [PATCH v2 1/3] save_restore: Introduce new struct field for flags

Li Wang liwang@redhat.com
Sat Nov 12 09:27:25 CET 2022


Martin Doucha <mdoucha@suse.cz> wrote:


>
> diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt
> index 8844d9f2f..63e5acec8 100644
> --- a/doc/c-test-api.txt
> +++ b/doc/c-test-api.txt
> @@ -1605,35 +1605,33 @@ LTP library can be instructed to save and restore
> value of specified
>  field 'save_restore'. It is a NULL-terminated array of struct
>  'tst_path_val' where each tst_path_val.path represents a file, whose
>  value is saved at the beginning and restored at the end of the test.
> -If non-NULL value is passed it is written to the respective file at
> -the beginning of the test. Only the first line of a specified file
> -is saved and restored.
> -
> -Pathnames can be optionally prefixed to specify how strictly (during
> -'store') are handled errors:
> -
> -* (no prefix) - test ends with 'TCONF', if file doesn't exist
> -* '?'         - test prints info message and continues,
> -                if file doesn't exist or open/read fails
> -* '!'         - test ends with 'TBROK', if file doesn't exist
> +If non-NULL string is passed in tst_path_val.val, it is written
> +to the respective file at the beginning of the test. Only the first line
> +of a specified file is saved and restored.
> +
> +By default, the test will end with TCONF if the file is read-only or
> +does not exist. If the optional write of new value fails, the test will
> end
> +with 'TBROK'. This behavior can be changed using tst_path_val.flags:
> +
> +* 'TST_SR_FAIL_MISSING' – End test with 'TBROK' if the file does not exist
> +* 'TST_SR_SKIP_MISSING' – Continue without saving the file if it does not
> exist
> +* 'TST_SR_FAIL_RO' – End test with 'TBROK' if the file is read-only
> +* 'TST_SR_SKIP_RO' – Continue without saving the file if it is read-only
> +* 'TST_SR_IGNORE_ERR' – Ignore errors when writing new value into the file
> +* 'TST_SR_REQUIRED' – Equivalent to 'TST_SR_FAIL_MISSING | TST_SR_FAIL_RO'
> +* 'TST_SR_COND_ACCESS' – Equivalent to 'TST_SR_SKIP_MISSING |
> TST_SR_SKIP_RO'
>
>  'restore' is always strict and will TWARN if it encounters any error.
>
>  [source,c]
>
>  -------------------------------------------------------------------------------
> -static void setup(void)
> -{
> -       FILE_PRINTF("/proc/sys/kernel/core_pattern", "/mypath");
> -       SAFE_TRY_FILE_PRINTF("/proc/sys/user/max_user_namespaces", "%d",
> 10);
> -}
> -
>  static struct tst_test test = {
>         ...
>         .setup = setup,
>         .save_restore = (const struct tst_path_val[]) {
> -               {"/proc/sys/kernel/core_pattern", NULL},
> -               {"?/proc/sys/user/max_user_namespaces", NULL},
> -               {"!/sys/kernel/mm/ksm/run", "1"},
> +               {"/proc/sys/kernel/core_pattern", NULL, 0},
> +               {"/proc/sys/user/max_user_namespaces", NULL,
> TST_SR_IF_ACCESS},
>

This should be TST_SR_COND_ACCESS ^

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20221112/6078181c/attachment.htm>


More information about the ltp mailing list