[LTP] [PATCH v2] Refactor timer_getoverrun test using new LTP API

Cyril Hrubis chrubis@suse.cz
Mon Oct 30 14:56:06 CET 2023


Hi!
> +	switch (tst_variant) {
> +	case 0:
> +		SAFE_TIMER_CREATE(CLOCK_REALTIME, &ev, &timer);
> +		TST_EXP_POSITIVE(timer_getoverrun(timer));
> +
> +		/* glibc causes SIGSEGV where timer_getoverrun() fails with EINVAL */
> +#ifndef __GLIBC__
> +		TST_EXP_FAIL(timer_getoverrun((timer_t)-1), EINVAL);
> +#endif

I wonder if we should even keep it here, the most likely end result is
that we will have to add to this ifdef once other libc implementations
attempt to interpret the id before passing it to kernel. Maybe we should
just remove it and save our future time.

> +		break;
> +	case 1:
> +		tst_syscall(__NR_timer_create, CLOCK_REALTIME, &ev, &timer);
> +		TST_EXP_POSITIVE(tst_syscall(__NR_timer_getoverrun, timer));
> +		TST_EXP_FAIL(tst_syscall(__NR_timer_getoverrun, -1), EINVAL);

There are actually two different cases that can cause EINVAL in the
kernel, first obvious case is that we id > INT_MAX, the second case is
failed lookup. I suppose that the -1 gets casted to unsigned long long
in kernel and ends up > INT_MAX.

I guess to trigger the second case we can call timer_delete(timer); and
then test it as:
		TST_EXP_FAIL(tst_syscall(__NR_timer_getoverrun, timer), EINVAL);

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list