Re: [LTP] [PATCH v4 2/2] setxattr02: Adapt test for kernel 7.1.0+ socket xattr support

Petr Vorel
2026-03-18T15:18:42Z

Hi Jan,

> +static bool socket_xattr_supported;
> +
> struct test_case {
> char *fname;
> char *key;
> @@ -57,7 +60,9 @@ struct test_case {
> int flags;
> int exp_err;
> int needskeyset;
> + bool check_xattr;

Maybe more readable would be 'check_kver' (I can change it before merge).

> };
> +
> static struct test_case tc[] = {
> { /* case 00, set attr to reg */
> .fname = FILENAME,
> @@ -115,6 +120,7 @@ static struct test_case tc[] = {
> .size = XATTR_TEST_VALUE_SIZE,
> .flags = XATTR_CREATE,
> .exp_err = EPERM,
> + .check_xattr = true,
> },
> };

> @@ -126,6 +132,9 @@ static void verify_setxattr(unsigned int i)
> XATTR_CREATE);
> }

> + if (tc[i].check_xattr && socket_xattr_supported)
> + tc[i].exp_err = 0;
> +
> TEST(setxattr(tc[i].fname, tc[i].key, tc[i].value, tc[i].size,
> tc[i].flags));

> @@ -185,6 +194,8 @@ static void setup(void)
> SAFE_MKNOD(CHR, S_IFCHR | 0777, dev);
> SAFE_MKNOD(BLK, S_IFBLK | 0777, 0);
> SAFE_MKNOD(SOCK, S_IFSOCK | 0777, 0);
> +
> + socket_xattr_supported = (tst_kvercmp(7, 1, 0) >= 0);

Brackets are not needed (not a mistake, but I'll remove it before merge).

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

Kind regards,
Petr