[LTP] [PATCH v9 1/2] lib: Extend tst_assert_ulong() with enum flags
Petr Vorel
pvorel@suse.cz
Wed Sep 2 11:04:18 CEST 2026
Hi Wei,
> Introduce enum tst_assert_flags (including TST_ASSERT_NONE,
> TST_ASSERT_SATURATED_INT, and TST_ASSERT_TRUNC_32BIT) to
> tst_assert_ulong(). This enables type-safe handling of 32-bit
> compat-mode truncation and clamping behaviors on 64-bit kernels
> when verifying sysfs/procfs limits.
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> include/tst_assert.h | 36 +++++++++++++++++++++++++++++++-----
> lib/tst_assert.c | 26 ++++++++++++++++++++------
> 2 files changed, 51 insertions(+), 11 deletions(-)
> diff --git a/include/tst_assert.h b/include/tst_assert.h
> index dcb62dfea..9154b7249 100644
> --- a/include/tst_assert.h
> +++ b/include/tst_assert.h
> @@ -21,14 +21,40 @@ void tst_assert_int(const char *file, const int lineno,
> #define TST_ASSERT_FILE_INT(path, prefix, val) \
> tst_assert_file_int(__FILE__, __LINE__, path, prefix, val)
> -/*
> - * Same as tst_assert_int() but for unsigned long.
> +/**
> + * enum tst_assert_flags - Flags for tst_assert_ulong().
nit: I'd use "Bitwise flags" as you write below.
> + *
> + * @TST_ASSERT_NONE: No flags, default direct comparison.
> + * @TST_ASSERT_SATURATED_INT: Clamps the value at %INT_MAX if it exceeds it.
> + * @TST_ASSERT_TRUNC_32BIT: Keeps only the low 32 bits of the read value,
> + * truncating any higher bits.
> + */
> +enum tst_assert_flags {
> + TST_ASSERT_NONE = 0x00,
IMHO TST_ASSERT_NONE is overkill, I'd just use 0. But others might have a
different opinion.
> + TST_ASSERT_SATURATED_INT = 0x01,
> + TST_ASSERT_TRUNC_32BIT = 0x02,
Also, I'd use decimal numbers instead of hexadecimal when we have just 3 values
(specially 0x00 looks really strange).
The rest LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
More information about the ltp
mailing list