[LTP] [PATCH v11 1/2] lib: Extend tst_assert_ulong() with enum flags
Cyril Hrubis
chrubis@suse.cz
Wed Sep 23 13:17:35 CEST 2026
Hi!
> > +
> > + if (flags & TST_ASSERT_SATURATED_INT) {
> > + if (sys_val_64 > (unsigned long long)INT_MAX)
> > + expected_val = (unsigned long)INT_MAX;
> > + else
> > + expected_val = (unsigned long)sys_val_64;
> > + } else if (flags & TST_ASSERT_TRUNC_32BIT) {
>
> In 32bit compat mode `unsigned long` becomes 32bit, so we can simply do:
>
> void tst_assert_ulong(const char *file, const int lineno, const char *path, unsigned long val)
> {
> unsigned long long sys_val;
>
> safe_file_scanf(file, lineno, NULL, path, "%llu", &sys_val);
>
> if (val == (unsigned long)sys_val) {
> tst_res_(file, lineno, TPASS, "%s = %lu", path, val);
> return;
> }
>
> tst_res_(file, lineno, TFAIL, "%s != %lu got %lu",
> path, val, (unsigned long)sys_val);
> }
>
> And then, inside the test:
>
> if (tst_is_compat_mode() && info.shmmax == INT_MAX)
> tst_res(TPASS, "shmmax clamped to INT_MAX in compat mode");
As I commented on the patch from pvorel, I do not like the blind TPASS
here. Either we put the saturated logic into the test library, or we
need to open-code it here.
> else
> TST_ASSERT_ULONG(PATH_KERN_SHMMAX, info.shmmax);
>
> TST_ASSERT_ULONG(PATH_KERN_SHMMNI, info.shmmni);
> TST_ASSERT_ULONG(PATH_KERN_SHMALL, info.shmall);
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list