public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/3] epoll_wait/epoll_wait02.c: add new testcase
Date: Thu, 28 Jan 2016 17:35:17 +0100	[thread overview]
Message-ID: <20160128163517.GB12679@rei.lan> (raw)
In-Reply-To: <1451472257-29472-2-git-send-email-fenggw-fnst@cn.fujitsu.com>

Hi!
> +
> +		if (TEST_RETURN != 0) {
> +			tst_resm(TFAIL, "epoll_wait() unexpectedly get %li, "
                                                            ^
						     Should rather be:
					"returned %li, expected 0"

The sentence does not make sense as it is.

> +				 "expected 0", TEST_RETURN);
> +			continue;
> +		}
> +
> +		elapsed_ms = tst_timer_elapsed_ms();
> +
> +		if (elapsed_ms < sleep_ms) {
> +			tst_resm(TFAIL, "epoll_wait() woken up too early %llims, "
> +				 "expected %llims", elapsed_ms, sleep_ms);
> +			continue;
> +		}
> +
> +		if (elapsed_ms - sleep_ms > threshold) {
> +			tst_resm(TFAIL, "epoll_wait() slept too long %llims, "
> +				 "expected %llims, threshold %i",
> +				 elapsed_ms, sleep_ms, threshold);
> +			continue;
> +		}
> +
> +		tst_resm(TPASS, "epoll_wait() slept %llims, expected %llims, "
> +			 "threshold %i", elapsed_ms, sleep_ms, threshold);
> +	}
> +
> +	cleanup();
> +	tst_exit();
> +}
> +
> +static void setup(void)
> +{
> +	tst_timer_check(CLOCK_MONOTONIC);
> +
> +	SAFE_PIPE(NULL, fds);
> +
> +	epfd = epoll_create(1);
> +	if (epfd == -1) {
> +		tst_brkm(TBROK | TERRNO, cleanup,
> +			 "failed to create epoll instance");
> +	}
> +
> +	epevs[0].events = EPOLLIN;
> +	epevs[0].data.fd = fds[0];
> +
> +	if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[0], &epevs[0])) {
> +		tst_brkm(TBROK | TERRNO, cleanup,
> +			 "failed to register epoll target");
> +	}
> +}
> +
> +static void cleanup(void)
> +{
> +	if (epfd > 0 && close(epfd))
> +		tst_resm(TWARN | TERRNO, "failed to close epfd");
> +
> +	if (close(fds[0]))
> +		tst_resm(TWARN | TERRNO, "close(fds[0]) failed");
> +
> +	if (close(fds[1]))
> +		tst_resm(TWARN | TERRNO, "close(fds[1]) failed");
> +}
> +
> +static void help(void)
> +{
> +	printf("  -s      epoll_wait() timeout length in ms\n");
> +}

The rest looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2016-01-28 16:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-30 10:44 [LTP] [PATCH 1/3] epoll_wait/epoll_wait01.c: add new testcase Guangwen Feng
2015-12-30 10:44 ` [LTP] [PATCH 2/3] epoll_wait/epoll_wait02.c: " Guangwen Feng
2016-01-28 16:35   ` Cyril Hrubis [this message]
2015-12-30 10:44 ` [LTP] [PATCH 3/3] epoll_wait/epoll_wait03.c: " Guangwen Feng
2016-01-28 17:16   ` Cyril Hrubis
2016-01-06  1:19 ` [LTP] [PATCH 4/4] epoll_wait/epoll_wait04.c: " Guangwen Feng
2016-01-28 17:24   ` Cyril Hrubis
2016-01-28 16:19 ` [LTP] [PATCH 1/3] epoll_wait/epoll_wait01.c: " Cyril Hrubis
2016-02-01  5:28   ` Guangwen Feng
2016-02-17 10:51     ` [LTP] [PATCH v2 " Guangwen Feng
2016-02-17 10:51       ` [LTP] [PATCH v2 2/3] epoll_wait/epoll_wait02.c: " Guangwen Feng
2016-02-25 12:37         ` Cyril Hrubis
2016-02-17 10:51       ` [LTP] [PATCH v2 3/3] epoll_wait/epoll_wait03.c: " Guangwen Feng
2016-02-25 13:52         ` [LTP] [PATCH v2 3/3] llistxattr/llistxattr03.c: " Cyril Hrubis
2016-02-24 16:11       ` [LTP] [PATCH v2 1/3] epoll_wait/epoll_wait01.c: " 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=20160128163517.GB12679@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox