From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 279F643EDB; Mon, 22 Apr 2024 17:24:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6934D40E0F; Mon, 22 Apr 2024 17:24:08 +0200 (CEST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id 5580F40A7A for ; Mon, 22 Apr 2024 17:23:54 +0200 (CEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6eced6fd98aso4292315b3a.0 for ; Mon, 22 Apr 2024 08:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713799433; x=1714404233; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vUoWg1PmW5lW5J3wRKwEZ2HiqMBKq7APhRaCn0FUAC8=; b=oqZrNcbCyV8Dk2tgKGSK7stPCrNLnBQJgcNwJy2/ejB3Een5Amcriuy3Scr7MeXFHt ocmS4gx0g8brAACv/QjR01OUdFiFKocFGHdmeasaJ4KAkROicSubVe63ROsNfYVetNyj uI0Q607IABFDzfKLso4Dn8bvIAXaNP2QwlydPtZ+NUmsCMlJZ+Jwk+Q9hPxtmfxbpCmp A8Wo6VBeAUM54EdoPGVl/Yl+ZkQkZ9wrBtkqQL/n2iDQwLHdD9oGOBZmQ5zXmWPpPTQj HbCM6I8s2BrXFuVLmZNKlBUnV/T6K0AEjRz21Z+DAXJxH3vGyvQwz7THL7aV/iiTUUX3 dmyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713799433; x=1714404233; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vUoWg1PmW5lW5J3wRKwEZ2HiqMBKq7APhRaCn0FUAC8=; b=ubyxevOvx6a5LGL6NMc/mNMlqoeC7tlnWMz1atanzCwwbNKP603sFE2cU3LiSwhXi+ i7Q1Os37R2lq/GBLVYCGQHz5pLWBdCitf0/aDzg+Y//MmTZIcDik24mEPDN5L70mPOUh QV3lF2IKoCLPC/8i52zMa1AUFunnUAHn5foMXJemDq+aeRVmIzETc4w9onKXcdjAjcLJ 5NvEM1P/ffReuugeju2/RfOOQlNIDMWKgz2ZE5mIbnvWZx/N06/cgjWyqGpS+G3B+q77 jO17TlMuuiFWbebE0NDWa5u/Wb5Rtkrio2Rip2nAGc2qeMfowcUTDFgkMPN1CbVxpg9U BaFQ== X-Gm-Message-State: AOJu0Ywsubzlvk5SEVwkTnXQb3t1LZKNHsRRcDTGshXonHmXGz9Uzrcy Ovl0JY+fKoncGMvlCyQr873cxSBAxnMW108/j15GxdBOI2XnYb7d/E7LSsBBwSupAOXYG0Wu5Ee 9 X-Google-Smtp-Source: AGHT+IFlecSIlr/KWe7tHdfyocALerIlOsG4ocVGWVHcWJ7YXazTq9wSDC989H3rRNUuTS9mUyc/tw== X-Received: by 2002:a05:6a20:394e:b0:1a7:5780:1f4b with SMTP id r14-20020a056a20394e00b001a757801f4bmr16300750pzg.24.1713799433595; Mon, 22 Apr 2024 08:23:53 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id cb17-20020a056a02071100b0060063c4be3bsm1402783pgb.14.2024.04.22.08.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 08:23:53 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Reshma Pattan Subject: [PATCH v5 9/9] test: add more latencystats tests Date: Mon, 22 Apr 2024 08:21:39 -0700 Message-ID: <20240422152336.147553-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422152336.147553-1-stephen@networkplumber.org> References: <20240408195036.182545-1-stephen@networkplumber.org> <20240422152336.147553-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Look at the number of samples, min, max and average numbers to make sure they look correct. Forward for to make sure multiple samples are taken. Signed-off-by: Stephen Hemminger --- app/test/test_latencystats.c | 62 +++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c index 3369c8bb90..676a99d385 100644 --- a/app/test/test_latencystats.c +++ b/app/test/test_latencystats.c @@ -14,7 +14,7 @@ #include "sample_packet_forward.h" #include "test.h" -#define NUM_STATS 4 +#define NUM_STATS 5 #define LATENCY_NUM_PACKETS 10 #define QUEUE_ID 0 @@ -26,6 +26,7 @@ static struct rte_metric_name lat_stats_strings[NUM_STATS] = { {"avg_latency_ns"}, {"max_latency_ns"}, {"jitter_ns"}, + {"samples"}, }; /* Test case for latency init with metrics init */ @@ -141,10 +142,14 @@ static void test_latency_ring_free(void) static int test_latency_packet_forward(void) { + unsigned int i; int ret; struct rte_mbuf *pbuf[LATENCY_NUM_PACKETS] = { }; struct rte_mempool *mp; char poolname[] = "mbuf_pool"; + uint64_t end_cycles; + struct rte_metric_value values[NUM_STATS] = { }; + struct rte_metric_name names[NUM_STATS] = { }; ret = test_get_mbuf_from_pool(&mp, pbuf, poolname); if (ret < 0) { @@ -158,9 +163,41 @@ static int test_latency_packet_forward(void) return TEST_FAILED; } - ret = test_packet_forward(pbuf, portid, QUEUE_ID); - if (ret < 0) - printf("send pkts Failed\n"); + ret = rte_latencystats_get_names(names, NUM_STATS); + TEST_ASSERT((ret == NUM_STATS), "Test Failed to get metrics names"); + + ret = rte_latencystats_get(values, NUM_STATS); + TEST_ASSERT(ret == NUM_STATS, "Test failed to get results before forwarding"); + TEST_ASSERT(values[4].value == 0, "Samples not zero at start of test"); + + /* + * Want test to run long enough to collect sufficient samples + * but not so long that scheduler decides to reschedule it (1000 hz). + */ + end_cycles = rte_rdtsc() + rte_get_tsc_hz() / 2000; + do { + ret = test_packet_forward(pbuf, portid, QUEUE_ID); + if (ret < 0) + printf("send pkts Failed\n"); + } while (rte_rdtsc() < end_cycles); + + ret = rte_latencystats_get(values, NUM_STATS); + TEST_ASSERT(ret == NUM_STATS, "Test failed to get results after forwarding"); + + for (i = 0; i < NUM_STATS; i++) { + uint16_t k = values[i].key; + + printf("%s = %"PRIu64"\n", + names[k].name, values[i].value); + } + + TEST_ASSERT(values[4].value > 0, "No samples taken"); + TEST_ASSERT(values[0].value > 0, "Min latency should not be zero"); + TEST_ASSERT(values[1].value > 0, "Avg latency should not be zero"); + TEST_ASSERT(values[2].value > 0, "Max latency should not be zero"); + TEST_ASSERT(values[0].value < values[1].value, "Min latency > Avg latency"); + TEST_ASSERT(values[0].value < values[2].value, "Min latency > Max latency"); + TEST_ASSERT(values[1].value < values[2].value, "Avg latency > Max latency"); rte_eth_dev_stop(portid); test_put_mbuf_to_pool(mp, pbuf); @@ -180,22 +217,23 @@ unit_test_suite latencystats_testsuite = { */ TEST_CASE_ST(NULL, NULL, test_latency_init), - /* Test Case 2: Do packet forwarding for metrics - * calculation and check the latency metrics values - * are updated - */ - TEST_CASE_ST(test_latency_packet_forward, NULL, - test_latency_update), - /* Test Case 3: To check whether latency stats names + /* Test Case 2: To check whether latency stats names * are retrieved */ TEST_CASE_ST(NULL, NULL, test_latencystats_get_names), - /* Test Case 4: To check whether latency stats + /* Test Case 3: To check whether latency stats * values are retrieved */ TEST_CASE_ST(NULL, NULL, test_latencystats_get), + /* Test Case 4: Do packet forwarding for metrics + * calculation and check the latency metrics values + * are updated + */ + TEST_CASE_ST(test_latency_packet_forward, NULL, + test_latency_update), + /* Test Case 5: To check uninit of latency test */ TEST_CASE_ST(NULL, NULL, test_latency_uninit), -- 2.43.0