[LTP] [PATCH] setfsgid01: Rewrite using new LTP API

Petr Vorel pvorel@suse.cz
Sat Oct 22 00:58:39 CEST 2022


Hi Avinesh,

> Rewrite using new API and add test setfsgid(-1) which will always
> fail but will determine if the preceding setfsgid() call changed
> the filesystem group ID as expected.
+1

Thanks, merged with fix below.

> -		gid = getegid();
> -		GID16_CHECK(gid, setfsgid, cleanup);
> -
> -		TEST(SETFSGID(cleanup, gid));
> -
> -		if (TEST_RETURN == -1) {
> -			tst_resm(TFAIL | TTERRNO,
> -				"setfsgid() failed unexpectedly");
> -			continue;
> -		}
> -
> -		if (TEST_RETURN != gid) {
> -			tst_resm(TFAIL, "setfsgid() returned %ld, expected %d",
> -				 TEST_RETURN, gid);
> -		} else {
> -			tst_resm(TPASS,
> -				"setfsgid() returned expected value : %ld",
> -				TEST_RETURN);
> -		}
> -	}
...
> +	gid = getegid();
> +	GID16_CHECK(gid, setfsgid);

> -static void cleanup(void)
> -{
> +	SAFE_SETEUID(0);
> +	TST_EXP_VAL(setfsgid(nobody_gid), gid);
> +	TST_EXP_VAL(setfsgid(-1), nobody_gid);
> +	TST_EXP_VAL_SILENT(setfsgid(gid), nobody_gid);

NOTE: all of these needed to be SETFSGID(), otherwise setfsgid01_16 would
happily test 32-bit version instead of 16-bit version.

Kind regards,
Petr


More information about the ltp mailing list