From: Bruce Richardson <bruce.richardson@intel.com>
To: Robert Sanford <rsanford@akamai.com>
Cc: dev@dpdk.org, Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH 3/3] test/test: add test for multiple timer expiries
Date: Wed, 31 May 2017 10:16:21 +0100 [thread overview]
Message-ID: <20170531091621.203189-4-bruce.richardson@intel.com> (raw)
In-Reply-To: <20170531091621.203189-1-bruce.richardson@intel.com>
The API for the rte_timer callbacks has been modified to allow us to return
the number of times a periodic callback would have been called. Test this
capability by adding a new unit test.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
test/test/test_timer.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/test/test/test_timer.c b/test/test/test_timer.c
index 0b86d3c..299171c 100644
--- a/test/test/test_timer.c
+++ b/test/test/test_timer.c
@@ -1,7 +1,7 @@
/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -565,6 +565,54 @@ timer_sanity_check(void)
}
static int
+test_multiple_timeouts(void)
+{
+ struct rte_timer pt; /* a periodic timer */
+ uint64_t hz = rte_get_timer_hz();
+
+ RTE_LOG(INFO, TESTTIMER, "Running multiple-expiry tests\n");
+
+ rte_timer_init(&pt);
+ /* set timer for 1/100th of a second */
+ rte_timer_reset(&pt, hz/100, PERIODICAL, rte_lcore_id(),
+ timer_stress2_cb, NULL);
+ cb_count = 0;
+
+ /* delay for 1/10th second */
+ rte_delay_us(100000);
+ rte_timer_manage();
+ if (cb_count != 10) {
+ RTE_LOG(ERR, TESTTIMER,
+ "Unexpected callback count. Expected 10, got %d\n",
+ cb_count);
+ return -1;
+ }
+
+ /* should be no further expiries just yet */
+ rte_timer_manage();
+ if (cb_count > 10) {
+ RTE_LOG(ERR, TESTTIMER,
+ "Premature callbacks got. Expected only 10, got %d\n",
+ cb_count);
+ return -1;
+ }
+
+ /* delay 2/100ths of a second and check for two more expiries */
+ rte_delay_us(20000);
+ rte_timer_manage();
+ if (cb_count != 12) {
+ RTE_LOG(ERR, TESTTIMER,
+ "Unexpected callback count. Expected 12, got %d\n",
+ cb_count);
+ return -1;
+ }
+
+ RTE_LOG(INFO, TESTTIMER, "Multiple-expiry tests passed\n");
+
+ return 0;
+}
+
+static int
test_timer(void)
{
unsigned i;
@@ -625,6 +673,10 @@ test_timer(void)
rte_timer_stop_sync(&mytiminfo[i].tim);
}
+ /* sanity test for multiple timeouts between timer_manage calls */
+ if (test_multiple_timeouts() < 0)
+ return -1;
+
rte_timer_dump_stats(stdout);
return TEST_SUCCESS;
--
2.9.4
prev parent reply other threads:[~2017-05-31 9:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-28 13:25 [dpdk-dev] [RFC PATCH] timer: inform periodic timers of multiple expiries Bruce Richardson
2017-04-28 13:29 ` Bruce Richardson
2017-04-28 13:30 ` Bruce Richardson
2017-05-31 9:16 ` [dpdk-dev] [PATCH 0/3] " Bruce Richardson
2017-05-31 9:16 ` [dpdk-dev] [PATCH 1/3] " Bruce Richardson
2017-06-30 10:14 ` Olivier Matz
2017-06-30 12:06 ` Bruce Richardson
2017-05-31 9:16 ` [dpdk-dev] [PATCH 2/3] timer: add symbol versions for ABI compatibility Bruce Richardson
2017-05-31 9:16 ` Bruce Richardson [this message]
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=20170531091621.203189-4-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=rsanford@akamai.com \
/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;
as well as URLs for NNTP newsgroup(s).