From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 855D3E5D for ; Tue, 12 Dec 2017 10:40:29 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 01:40:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,394,1508828400"; d="scan'208";a="2059772" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga007.jf.intel.com with ESMTP; 12 Dec 2017 01:40:28 -0800 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Tue, 12 Dec 2017 09:53:22 +0000 Message-Id: <20171212095324.35420-3-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171212095324.35420-1-jasvinder.singh@intel.com> References: <1503488186-90047-2-git-send-email-cristian.dumitrescu@intel.com> <20171212095324.35420-1-jasvinder.singh@intel.com> Subject: [dpdk-dev] [PATCH v2 2/4] test/test_meter: update meter test 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: Tue, 12 Dec 2017 09:40:30 -0000 From: Cristian Dumitrescu Modify the unit test to accomodate the changes in the apis. Signed-off-by: Cristian Dumitrescu --- test/test/test_meter.c | 194 +++++++++++++++++++++++++++++-------------------- 1 file changed, 115 insertions(+), 79 deletions(-) diff --git a/test/test/test_meter.c b/test/test/test_meter.c index 26b0565..b6d133a 100644 --- a/test/test/test_meter.c +++ b/test/test/test_meter.c @@ -82,43 +82,43 @@ static inline int tm_test_srtcm_config(void) { #define SRTCM_CFG_MSG "srtcm_config" - struct rte_meter_srtcm sm; + struct rte_meter_srtcm_profile sp; struct rte_meter_srtcm_params sparams1; /* invalid parameter test */ - if(rte_meter_srtcm_config(NULL, NULL) == 0) + if (rte_meter_srtcm_profile_config(NULL, NULL) == 0) melog(SRTCM_CFG_MSG); - if(rte_meter_srtcm_config(&sm, NULL) == 0) + if (rte_meter_srtcm_profile_config(&sp, NULL) == 0) melog(SRTCM_CFG_MSG); - if(rte_meter_srtcm_config(NULL, &sparams) == 0) + if (rte_meter_srtcm_profile_config(NULL, &sparams) == 0) melog(SRTCM_CFG_MSG); /* cbs and ebs can't both be zero */ sparams1 = sparams; sparams1.cbs = 0; sparams1.ebs = 0; - if(rte_meter_srtcm_config(&sm, &sparams1) == 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0) melog(SRTCM_CFG_MSG); /* cir should never be 0 */ sparams1 = sparams; sparams1.cir = 0; - if(rte_meter_srtcm_config(&sm, &sparams1) == 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams1) == 0) melog(SRTCM_CFG_MSG); /* one of ebs and cbs can be zero, should be successful */ sparams1 = sparams; sparams1.ebs = 0; - if(rte_meter_srtcm_config(&sm, &sparams1) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0) melog(SRTCM_CFG_MSG); sparams1 = sparams; sparams1.cbs = 0; - if(rte_meter_srtcm_config(&sm, &sparams1) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams1) != 0) melog(SRTCM_CFG_MSG); /* usual parameter, should be successful */ - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) melog(SRTCM_CFG_MSG); return 0; @@ -131,47 +131,47 @@ tm_test_srtcm_config(void) static inline int tm_test_trtcm_config(void) { - struct rte_meter_trtcm tm; + struct rte_meter_trtcm_profile tp; struct rte_meter_trtcm_params tparams1; #define TRTCM_CFG_MSG "trtcm_config" /* invalid parameter test */ - if(rte_meter_trtcm_config(NULL, NULL) == 0) + if (rte_meter_trtcm_profile_config(NULL, NULL) == 0) melog(TRTCM_CFG_MSG); - if(rte_meter_trtcm_config(&tm, NULL) == 0) + if (rte_meter_trtcm_profile_config(&tp, NULL) == 0) melog(TRTCM_CFG_MSG); - if(rte_meter_trtcm_config(NULL, &tparams) == 0) + if (rte_meter_trtcm_profile_config(NULL, &tparams) == 0) melog(TRTCM_CFG_MSG); /* cir, cbs, pir and pbs never be zero */ tparams1 = tparams; tparams1.cir = 0; - if(rte_meter_trtcm_config(&tm, &tparams1) == 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0) melog(TRTCM_CFG_MSG); tparams1 = tparams; tparams1.cbs = 0; - if(rte_meter_trtcm_config(&tm, &tparams1) == 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0) melog(TRTCM_CFG_MSG); tparams1 = tparams; tparams1.pbs = 0; - if(rte_meter_trtcm_config(&tm, &tparams1) == 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0) melog(TRTCM_CFG_MSG); tparams1 = tparams; tparams1.pir = 0; - if(rte_meter_trtcm_config(&tm, &tparams1) == 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0) melog(TRTCM_CFG_MSG); /* pir should be greater or equal to cir */ tparams1 = tparams; tparams1.pir = tparams1.cir - 1; - if(rte_meter_trtcm_config(&tm, &tparams1) == 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams1) == 0) melog(TRTCM_CFG_MSG" pir < cir test"); /* usual parameter, should be successful */ - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) melog(TRTCM_CFG_MSG); return 0; @@ -184,41 +184,50 @@ static inline int tm_test_srtcm_color_blind_check(void) { #define SRTCM_BLIND_CHECK_MSG "srtcm_blind_check" + struct rte_meter_srtcm_profile sp; struct rte_meter_srtcm sm; uint64_t time; uint64_t hz = rte_get_tsc_hz(); /* Test green */ - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_BLIND_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_blind_check( - &sm, time, TM_TEST_SRTCM_CBS_DF - 1) + if (rte_meter_srtcm_color_blind_check( + &sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1) != e_RTE_METER_GREEN) melog(SRTCM_BLIND_CHECK_MSG" GREEN"); /* Test yellow */ - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_BLIND_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_blind_check( - &sm, time, TM_TEST_SRTCM_CBS_DF + 1) + if (rte_meter_srtcm_color_blind_check( + &sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1) != e_RTE_METER_YELLOW) melog(SRTCM_BLIND_CHECK_MSG" YELLOW"); - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_BLIND_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_blind_check( - &sm, time, (uint32_t)sm.ebs - 1) != e_RTE_METER_YELLOW) + if (rte_meter_srtcm_color_blind_check( + &sm, &sp, time, (uint32_t)sp.ebs - 1) != e_RTE_METER_YELLOW) melog(SRTCM_BLIND_CHECK_MSG" YELLOW"); /* Test red */ - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_BLIND_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_blind_check( - &sm, time, TM_TEST_SRTCM_EBS_DF + 1) + if (rte_meter_srtcm_color_blind_check( + &sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1) != e_RTE_METER_RED) melog(SRTCM_BLIND_CHECK_MSG" RED"); @@ -235,41 +244,50 @@ tm_test_trtcm_color_blind_check(void) #define TRTCM_BLIND_CHECK_MSG "trtcm_blind_check" uint64_t time; + struct rte_meter_trtcm_profile tp; struct rte_meter_trtcm tm; uint64_t hz = rte_get_tsc_hz(); /* Test green */ - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_BLIND_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_blind_check( - &tm, time, TM_TEST_TRTCM_CBS_DF - 1) + if (rte_meter_trtcm_color_blind_check( + &tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1) != e_RTE_METER_GREEN) melog(TRTCM_BLIND_CHECK_MSG" GREEN"); /* Test yellow */ - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_BLIND_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_blind_check( - &tm, time, TM_TEST_TRTCM_CBS_DF + 1) + if (rte_meter_trtcm_color_blind_check( + &tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1) != e_RTE_METER_YELLOW) melog(TRTCM_BLIND_CHECK_MSG" YELLOW"); - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_BLIND_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_blind_check( - &tm, time, TM_TEST_TRTCM_PBS_DF - 1) + if (rte_meter_trtcm_color_blind_check( + &tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1) != e_RTE_METER_YELLOW) melog(TRTCM_BLIND_CHECK_MSG" YELLOW"); /* Test red */ - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_BLIND_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_BLIND_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_blind_check( - &tm, time, TM_TEST_TRTCM_PBS_DF + 1) + if (rte_meter_trtcm_color_blind_check( + &tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1) != e_RTE_METER_RED) melog(TRTCM_BLIND_CHECK_MSG" RED"); @@ -291,36 +309,45 @@ tm_test_srtcm_aware_check (enum rte_meter_color in[4], enum rte_meter_color out[4]) { #define SRTCM_AWARE_CHECK_MSG "srtcm_aware_check" + struct rte_meter_srtcm_profile sp; struct rte_meter_srtcm sm; uint64_t time; uint64_t hz = rte_get_tsc_hz(); - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_AWARE_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_aware_check( - &sm, time, TM_TEST_SRTCM_CBS_DF - 1, in[0]) != out[0]) + if (rte_meter_srtcm_color_aware_check( + &sm, &sp, time, TM_TEST_SRTCM_CBS_DF - 1, in[0]) != out[0]) melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]); - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_AWARE_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_aware_check( - &sm, time, TM_TEST_SRTCM_CBS_DF + 1, in[1]) != out[1]) + if (rte_meter_srtcm_color_aware_check( + &sm, &sp, time, TM_TEST_SRTCM_CBS_DF + 1, in[1]) != out[1]) melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]); - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_AWARE_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_aware_check( - &sm, time, TM_TEST_SRTCM_EBS_DF - 1, in[2]) != out[2]) + if (rte_meter_srtcm_color_aware_check( + &sm, &sp, time, TM_TEST_SRTCM_EBS_DF - 1, in[2]) != out[2]) melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]); - if(rte_meter_srtcm_config(&sm, &sparams) != 0) + if (rte_meter_srtcm_profile_config(&sp, &sparams) != 0) + melog(SRTCM_AWARE_CHECK_MSG); + if (rte_meter_srtcm_config(&sm, &sp) != 0) melog(SRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_srtcm_color_aware_check( - &sm, time, TM_TEST_SRTCM_EBS_DF + 1, in[3]) != out[3]) + if (rte_meter_srtcm_color_aware_check( + &sm, &sp, time, TM_TEST_SRTCM_EBS_DF + 1, in[3]) != out[3]) melog(SRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]); return 0; @@ -346,7 +373,7 @@ tm_test_srtcm_color_aware_check(void) out[1] = e_RTE_METER_YELLOW; out[2] = e_RTE_METER_YELLOW; out[3] = e_RTE_METER_RED; - if(tm_test_srtcm_aware_check(in, out) != 0) + if (tm_test_srtcm_aware_check(in, out) != 0) return -1; /** @@ -358,7 +385,7 @@ tm_test_srtcm_color_aware_check(void) out[1] = e_RTE_METER_YELLOW; out[2] = e_RTE_METER_YELLOW; out[3] = e_RTE_METER_RED; - if(tm_test_srtcm_aware_check(in, out) != 0) + if (tm_test_srtcm_aware_check(in, out) != 0) return -1; /** @@ -370,7 +397,7 @@ tm_test_srtcm_color_aware_check(void) out[1] = e_RTE_METER_RED; out[2] = e_RTE_METER_RED; out[3] = e_RTE_METER_RED; - if(tm_test_srtcm_aware_check(in, out) != 0) + if (tm_test_srtcm_aware_check(in, out) != 0) return -1; return 0; @@ -389,36 +416,45 @@ tm_test_trtcm_aware_check (enum rte_meter_color in[4], enum rte_meter_color out[4]) { #define TRTCM_AWARE_CHECK_MSG "trtcm_aware_check" + struct rte_meter_trtcm_profile tp; struct rte_meter_trtcm tm; uint64_t time; uint64_t hz = rte_get_tsc_hz(); - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_AWARE_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_aware_check( - &tm, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0]) + if (rte_meter_trtcm_color_aware_check( + &tm, &tp, time, TM_TEST_TRTCM_CBS_DF - 1, in[0]) != out[0]) melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[0], out[0]); - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_AWARE_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_aware_check( - &tm, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1]) + if (rte_meter_trtcm_color_aware_check( + &tm, &tp, time, TM_TEST_TRTCM_CBS_DF + 1, in[1]) != out[1]) melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[1], out[1]); - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_AWARE_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_aware_check( - &tm, time, TM_TEST_TRTCM_PBS_DF - 1, in[2]) != out[2]) + if (rte_meter_trtcm_color_aware_check( + &tm, &tp, time, TM_TEST_TRTCM_PBS_DF - 1, in[2]) != out[2]) melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[2], out[2]); - if(rte_meter_trtcm_config(&tm, &tparams) != 0) + if (rte_meter_trtcm_profile_config(&tp, &tparams) != 0) + melog(TRTCM_AWARE_CHECK_MSG); + if (rte_meter_trtcm_config(&tm, &tp) != 0) melog(TRTCM_AWARE_CHECK_MSG); time = rte_get_tsc_cycles() + hz; - if(rte_meter_trtcm_color_aware_check( - &tm, time, TM_TEST_TRTCM_PBS_DF + 1, in[3]) != out[3]) + if (rte_meter_trtcm_color_aware_check( + &tm, &tp, time, TM_TEST_TRTCM_PBS_DF + 1, in[3]) != out[3]) melog(TRTCM_AWARE_CHECK_MSG" %u:%u", in[3], out[3]); return 0; @@ -444,7 +480,7 @@ tm_test_trtcm_color_aware_check(void) out[1] = e_RTE_METER_YELLOW; out[2] = e_RTE_METER_YELLOW; out[3] = e_RTE_METER_RED; - if(tm_test_trtcm_aware_check(in, out) != 0) + if (tm_test_trtcm_aware_check(in, out) != 0) return -1; in[0] = in[1] = in[2] = in[3] = e_RTE_METER_YELLOW; @@ -452,7 +488,7 @@ tm_test_trtcm_color_aware_check(void) out[1] = e_RTE_METER_YELLOW; out[2] = e_RTE_METER_YELLOW; out[3] = e_RTE_METER_RED; - if(tm_test_trtcm_aware_check(in, out) != 0) + if (tm_test_trtcm_aware_check(in, out) != 0) return -1; in[0] = in[1] = in[2] = in[3] = e_RTE_METER_RED; @@ -460,7 +496,7 @@ tm_test_trtcm_color_aware_check(void) out[1] = e_RTE_METER_RED; out[2] = e_RTE_METER_RED; out[3] = e_RTE_METER_RED; - if(tm_test_trtcm_aware_check(in, out) != 0) + if (tm_test_trtcm_aware_check(in, out) != 0) return -1; return 0; @@ -472,22 +508,22 @@ tm_test_trtcm_color_aware_check(void) static int test_meter(void) { - if(tm_test_srtcm_config() != 0 ) + if (tm_test_srtcm_config() != 0) return -1; - if(tm_test_trtcm_config() != 0 ) + if (tm_test_trtcm_config() != 0) return -1; - if(tm_test_srtcm_color_blind_check() != 0) + if (tm_test_srtcm_color_blind_check() != 0) return -1; - if(tm_test_trtcm_color_blind_check()!= 0) + if (tm_test_trtcm_color_blind_check() != 0) return -1; - if(tm_test_srtcm_color_aware_check()!= 0) + if (tm_test_srtcm_color_aware_check() != 0) return -1; - if(tm_test_trtcm_color_aware_check()!= 0) + if (tm_test_trtcm_color_aware_check() != 0) return -1; return 0; -- 2.9.3