From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2580E9143 for ; Wed, 31 May 2017 11:21:07 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2017 02:21:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,422,1491289200"; d="scan'208";a="863078239" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.223.223]) by FMSMGA003.fm.intel.com with ESMTP; 31 May 2017 02:21:05 -0700 From: Bruce Richardson To: Robert Sanford Cc: dev@dpdk.org, Bruce Richardson Date: Wed, 31 May 2017 10:16:21 +0100 Message-Id: <20170531091621.203189-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170531091621.203189-1-bruce.richardson@intel.com> References: <20170428132538.15995-1-bruce.richardson@intel.com> <20170531091621.203189-1-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 3/3] test/test: add test for multiple timer expiries X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 May 2017 09:21:07 -0000 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 --- 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