[LTP] [PATCH v3 35/36] keyctl38: Test KEYCTL_WATCH_KEY add and remove

Cyril Hrubis chrubis@suse.cz
Fri Sep 18 17:53:21 CEST 2026


Hi!
> +static void run(void)
> +{
> +	int pipefd[2];
> +
> +	TEST(pipe2(pipefd, O_NOTIFICATION_PIPE));
> +	if (TST_RET < 0) {
> +		if (TST_ERR == ENOPKG)
> +			tst_brk(TCONF | TTERRNO, "CONFIG_WATCH_QUEUE is not set");
> +		if (TST_ERR == EINVAL)
> +			tst_brk(TCONF | TTERRNO, "O_NOTIFICATION_PIPE is not supported");
> +		tst_brk(TBROK | TTERRNO, "pipe2(O_NOTIFICATION_PIPE) failed");
> +	}
> +
> +	SAFE_IOCTL(pipefd[0], IOC_WATCH_QUEUE_SET_SIZE, 256);
> +
> +	TST_EXP_PASS(keyctl(KEYCTL_WATCH_KEY, key, pipefd[0], 1),
> +		     "KEYCTL_WATCH_KEY add watch on key");
> +
> +	TST_EXP_PASS(keyctl(KEYCTL_WATCH_KEY, key, pipefd[0], -1),
> +		     "KEYCTL_WATCH_KEY remove watch on key");
> +
> +	TST_EXP_PASS(keyctl(KEYCTL_WATCH_KEY, KEY_SPEC_SESSION_KEYRING,
> +			    pipefd[0], 2),
> +		     "KEYCTL_WATCH_KEY add watch on session keyring");
> +
> +	TST_EXP_PASS(keyctl(KEYCTL_WATCH_KEY, KEY_SPEC_SESSION_KEYRING,
> +			    pipefd[0], -1),
> +		     "KEYCTL_WATCH_KEY remove watch on session keyring");
> +
> +	SAFE_CLOSE(pipefd[0]);
> +	SAFE_CLOSE(pipefd[1]);

I guess that this test is pretty much incomplete, we should actually do
something with the key, i.e. set key attributes and then check that the
notification pipe got the right event.

So I would skip the notification pipe tests for the release, there is
quite a lot of missing features here.


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list