public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 01/13] lib: tst_sys_conf: Add two functions
Date: Fri, 27 Dec 2024 10:04:42 +0100	[thread overview]
Message-ID: <20241227090442.GA308652@pevik> (raw)
In-Reply-To: <20241218184518.16190-2-chrubis@suse.cz>

Hi Cyril,

> Add two functions to read/write integer values from/to sysfs or procfs
> files.

> With that we replace the get_sys_tune() and set_sys_tune() from
> testcases/kernel/mem/lib/mem.c with a better implementation.

> We also remove the inclusion of the mem library from tunables, since
> it's no longer needed there.

+1

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Minor formatting notes below.

> +/**
> + * TST_SYS_CONF_LONG_SET()

I wonder how to silence warning when there is no short description.

include/tst_sys_conf.h:32: [kernel-doc WARN] : missing initial short description of 'TST_SYS_CONF_LONG_SET'

> + *
> + * Sets a sysfs or procfs file and optionally checks that it was set correctly.
> + *
> + * @param path A path to a sysfs or a procfs file.
> + * @param val A long int value to be written to the file.
> + * @param check If non-zero the library reads the file back and checks that the

nit: please fix these before merge (doxygen => sphinx syntax):

include/tst_sys_conf.h:32: [kernel-doc WARN] : no description found for parameter 'path'
include/tst_sys_conf.h:32: [kernel-doc WARN] : no description found for parameter 'val'
include/tst_sys_conf.h:32: [kernel-doc WARN] : no description found for parameter 'check'

> + *              value is the one we have written there. If not the library calls
> + *              tst_brk(TBROK, ...).
> + */


> +#define TST_SYS_CONF_LONG_SET(path, val, check) \
> +	tst_sys_conf_long_set_(__FILE__, __LINE__, path, val, check)
> +
> +void tst_sys_conf_long_set_(const char *file, const int lineno,
> +                            const char *path, long val, int check);
> +
> +
> +/**
> + * TST_SYS_CONF_LONG_GET()
> + *
> + * Gets a sysfs or procfs file value and converts it to long.
> + *
> + * @param path A path to a sysfs or a procfs file.
And here:

include/tst_sys_conf.h:50: [kernel-doc WARN] : no description found for parameter 'path'

> + */
> +#define TST_SYS_CONF_LONG_GET(path) \
> +	tst_sys_conf_long_get_(__FILE__, __LINE__, path)
> +
> +long tst_sys_conf_long_get_(const char *file, const int lineno,
> +                            const char *path);
> +
>  #endif
> diff --git a/lib/tst_sys_conf.c b/lib/tst_sys_conf.c
> index c0981dcb1..f962fc124 100644
> --- a/lib/tst_sys_conf.c
> +++ b/lib/tst_sys_conf.c
> @@ -145,3 +145,32 @@ void tst_sys_conf_restore(int verbose)
>  	}
>  }

> +long tst_sys_conf_long_get_(const char *file, const int lineno,
> +                            const char *path)
nit: could you please use tabs instead of spaces?
Because it triggers warnings:

$ make check-tst_sys_conf
CHECK lib/tst_sys_conf.c
tst_sys_conf.c:149: ERROR: code indent should use tabs where possible
tst_sys_conf.c:149: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:159: ERROR: code indent should use tabs where possible
tst_sys_conf.c:159: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:161: ERROR: code indent should use tabs where possible
tst_sys_conf.c:161: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:163: ERROR: code indent should use tabs where possible
tst_sys_conf.c:163: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:165: ERROR: code indent should use tabs where possible
tst_sys_conf.c:165: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:170: ERROR: code indent should use tabs where possible
tst_sys_conf.c:170: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:171: ERROR: code indent should use tabs where possible
tst_sys_conf.c:171: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:172: ERROR: code indent should use tabs where possible
tst_sys_conf.c:173: ERROR: code indent should use tabs where possible
tst_sys_conf.c:173: WARNING: please, no spaces at the start of a line
tst_sys_conf.c:174: ERROR: code indent should use tabs where possible
tst_sys_conf.c:174: WARNING: please, no spaces at the start of a line


> +{
> +	long ret;
> +
> +	safe_file_scanf(file, lineno, NULL, path, "%ld", &ret);
> +
> +	return ret;
> +}
> +
> +void tst_sys_conf_long_set_(const char *file, const int lineno,
> +                            const char *path, long val, int check)
> +{
> +        tst_res_(file, lineno, TINFO, "Setting %s to %ld", path, val);
> +
> +        safe_file_printf(file, lineno, NULL, path, "%ld", val);
> +
> +        if (check) {
> +		long read_val;
nit: obviously also here are tabs and spaces mixed. Minor, but worth to fix
before merge.

Maybe we would benefit to add .editorconfig [1] (see examples [2] [3]).

Also maybe to save indent?

if (!check)
	return;

Kind regards,
Petr


> +
> +		safe_file_scanf(file, lineno, NULL, path, "%ld", &read_val);
> +
> +                if (val != read_val)
> +                        tst_brk_(file, lineno, TBROK,
> +			         "Wrote %ld to %s but read back %ld",
> +                                 val, path, read_val);
> +        }
> +
> +}

[1] https://editorconfig.org/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/.editorconfig
[3] https://git.busybox.net/buildroot/tree/.editorconfig

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2024-12-27  9:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-18 18:45 [LTP] [PATCH 00/13] Get rid of testcases/kernel/mem/lib library Cyril Hrubis
2024-12-18 18:45 ` [LTP] [PATCH 01/13] lib: tst_sys_conf: Add two functions Cyril Hrubis
2024-12-19  3:10   ` Li Wang
2024-12-27  9:04   ` Petr Vorel [this message]
2024-12-18 18:45 ` [LTP] [PATCH 02/13] lib: Replace path_exist() with tst_path_exists() Cyril Hrubis
2024-12-19 14:31   ` Petr Vorel
2024-12-19 15:04     ` Cyril Hrubis
2024-12-20  8:02       ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 03/13] lib: Add tst_mapping_in_range() Cyril Hrubis
2024-12-27 10:25   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 04/13] testcases/kernel/mem: Move get_a_numa_node() Cyril Hrubis
2024-12-27 10:27   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 05/13] testcases/kernel/mem: Move update_shm_size() Cyril Hrubis
2024-12-27 10:34   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 06/13] testcases/kernel/mem: Move check_hugepage() + PATH_THP Cyril Hrubis
2024-12-27 10:48   ` Petr Vorel
2025-02-07 17:00     ` Cyril Hrubis
2025-02-10  9:16       ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 07/13] testcases/kernel/mem: Move NUMA bits to numa_helper.h Cyril Hrubis
2024-12-27 11:01   ` Petr Vorel
2024-12-27 11:09   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 08/13] testcases/kernel/mem: Move oom() fucntions to oom tests Cyril Hrubis
2024-12-27 11:06   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 09/13] testcases/kernel/mem: Move KSM bits to ksm tests Cyril Hrubis
2024-12-19  2:52   ` Li Wang
2024-12-19  2:55     ` Li Wang
2024-12-19  9:08     ` Cyril Hrubis
2024-12-19  9:11       ` Li Wang
2024-12-27 11:15   ` Petr Vorel
2024-12-27 11:36   ` Petr Vorel
2025-02-10 11:17     ` Cyril Hrubis
2024-12-27 11:37   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 10/13] mem/swapping: Remove mem/lib refrence Cyril Hrubis
2024-12-27 11:42   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 11/13] mem/vma: Remove mem/lib dependency Cyril Hrubis
2024-12-27 11:44   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 12/13] mem/hugetlb: Remove mem/lib depenency Cyril Hrubis
2024-12-27 11:47   ` Petr Vorel
2024-12-18 18:45 ` [LTP] [PATCH 13/13] testcases/kernel/mem: Remove library Cyril Hrubis
2024-12-27 11:48   ` Petr Vorel
2024-12-18 18:58 ` [LTP] [PATCH 00/13] Get rid of testcases/kernel/mem/lib library Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241227090442.GA308652@pevik \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox