All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK
Date: Thu, 7 Nov 2019 14:23:59 +0100	[thread overview]
Message-ID: <20191107132359.GE22352@rei.lan> (raw)
In-Reply-To: <1570767798-26685-2-git-send-email-xuyang2018.jy@cn.fujitsu.com>

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

  reply	other threads:[~2019-11-07 13:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09 10:51 [LTP] [PATCH v3] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK Yang Xu
2019-10-09 12:19 ` Cyril Hrubis
2019-10-11  4:23   ` [LTP] [PATCH v4 1/2] " Yang Xu
2019-10-11  4:23     ` [LTP] [PATCH v4 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
2019-11-07 13:23       ` Cyril Hrubis [this message]
2019-11-08 11:21         ` Yang Xu
2019-10-21 13:00     ` [LTP] [PATCH v4 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK Yang Xu
2019-11-07 13:05     ` Cyril Hrubis
2019-11-08 11:03       ` Yang Xu
2019-11-08 12:00       ` [LTP] [PATCH v5 " Yang Xu
2019-11-08 12:00         ` [LTP] [PATCH v5 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
2019-11-15 16:35           ` Cyril Hrubis
2019-11-18  1:21             ` Yang Xu
2019-11-18  2:34             ` [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK Yang Xu
2019-11-18  2:34               ` [LTP] [PATCH v6 2/2] syscalls/prctl09: New timer sample test for PR_SET_TIMERSLACK Yang Xu
2019-11-25 11:07                 ` Cyril Hrubis
2019-11-20  6:54               ` [LTP] [PATCH v6 1/2] lib/tst_timer_test: move test setup function before PR_GET_TIMERSLACK Yang Xu
2019-11-25 10:18                 ` Yang Xu
2019-11-15  9:01         ` [LTP] [PATCH v5 1/2] syscalls/prctl08: New test for prctl() with PR_{SET, GET}_TIMERSLACK Yang Xu
2019-11-15 16:34         ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191107132359.GE22352@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.