[LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK

Cyril Hrubis chrubis@suse.cz
Thu Nov 7 14:23:59 CET 2019


Hi!
> +#include <errno.h>
> +#include <sys/prctl.h>
> +#include "lapi/prctl.h"
> +#include "tst_timer_test.h"
> +
> +int sample_fn(int clk_id, long long usec)
> +{
> +	struct timespec t = tst_us_to_timespec(usec);
> +
> +	TEST(prctl(PR_SET_TIMERSLACK, 200000));

This is a bit more complicated.

First of all it does not make sense to set the timerslack in the sample
function. It should be done once in the test setup.

Also in the tst_timer_test.c we store the timerslack value in the
timer_setup(), which executes the test setup() at the end of the
function, so we would have to move the part that gets the timerslack()
after the test setup() function so that the library includes the newly
set timerslack in the calculation.

> +	if (TST_RET != 0) {
> +		tst_res(TFAIL | TTERRNO,
> +			"prctl(), returned %li", TST_RET);
> +		return 1;
> +	}
> +
> +	tst_timer_start(clk_id);
> +	TEST(nanosleep(&t, NULL));
> +	tst_timer_stop();
> +	tst_timer_sample();
> +
> +	if (TST_RET != 0) {
> +		tst_res(TFAIL | TTERRNO,
> +			"nanosleep() returned %li", TST_RET);
> +		return 1;
> +	}
> +
> +	return 0;
> +}
> +
> +static struct tst_test test = {
> +	.scall = "prctl()",
> +	.sample = sample_fn,
> +};
> -- 
> 2.18.1
> 
> 
> 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list