From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EEFE8A00C5; Mon, 6 Jul 2020 13:06:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B1AB31DA00; Mon, 6 Jul 2020 13:06:16 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 228151D929 for ; Mon, 6 Jul 2020 13:06:12 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.61]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9DF96600B8; Mon, 6 Jul 2020 11:06:11 +0000 (UTC) Received: from us4-mdac16-54.ut7.mdlocal (unknown [10.7.66.25]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9DCA48009E; Mon, 6 Jul 2020 11:06:11 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.32]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 1A01980052; Mon, 6 Jul 2020 11:06:11 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id C4B9CB4006D; Mon, 6 Jul 2020 11:06:10 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 6 Jul 2020 12:06:06 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 6 Jul 2020 12:06:06 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 066B66t4008196; Mon, 6 Jul 2020 12:06:06 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id BB84F1616AE; Mon, 6 Jul 2020 12:06:06 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov , Harry van Haaren Date: Mon, 6 Jul 2020 12:06:00 +0100 Message-ID: <1594033561-24563-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594033561-24563-1-git-send-email-arybchenko@solarflare.com> References: <1593873347-13686-1-git-send-email-arybchenko@solarflare.com> <1594033561-24563-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.6.1012-25524.003 X-TM-AS-Result: No-7.148900-8.000000-10 X-TMASE-MatchedRID: RdgeCjOU6Zq09I1RF1swcOIfK/Jd5eHmjotcmj+7SkE4XREg9Ki10xd2 WyReW5ebcKLnwjXEZ1ayUescqeUMprYX2Zbb0Huyz5CYDcN91JtLXPA26IG0hJdCJPP1oyxLLJb swLUY6eGIi0Yt2qmJZUy4JXPiRR/8gNVHXM3C8e5uh7qwx+D6T1JAsn89ih94WfjPRPx8eiiwYD Wnvg3cdTozIrttdz6uSJvYlpSU4WjezO9WekFnOI4VSIjAMorOg+mueoS04+Ukt9BigJAcVsP32 38sD0q6u6PHiql9LhvDdbYg6L1jCz4Mxg/VjhfP5hMYPmU3XmB9LQinZ4QefPcjNeVeWlqY+gtH j7OwNO3Dfx1dF4y1d/5c9fmuZP5BXrRPJuzYxIeIOyDKWG23GV5cEoxgI4R7Vlxr1FJij9s= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.148900-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25524.003 X-MDID: 1594033571-JZWUrdTn5gAK Subject: [dpdk-dev] [PATCH v2 2/2] test/service: add test for service active on two lcores 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Igor Romanov The test checks that the service may be active API works when there are two cores: a non-service lcore and a service one. The API notes to take care when checking the status of a running service, but the test setup allows for a safe usage in that case. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- app/test/test_service_cores.c | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index 981e212130..80dc80ff9c 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -910,6 +910,55 @@ service_may_be_active(void) return unregister_all(); } +/* check service may be active when service is running on a second lcore */ +static int +service_active_two_cores(void) +{ + const uint32_t sid = 0; + int i; + + uint32_t lcore = rte_get_next_lcore(/* start core */ -1, + /* skip master */ 1, + /* wrap */ 0); + uint32_t slcore = rte_get_next_lcore(/* start core */ lcore, + /* skip master */ 1, + /* wrap */ 0); + + /* start the service on the second available lcore */ + TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1), + "Starting valid service failed"); + TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore), + "Add service core failed when not in use before"); + TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore, 1), + "Enabling valid service on valid core failed"); + TEST_ASSERT_EQUAL(0, rte_service_lcore_start(slcore), + "Service core start after add failed"); + + /* ensures core really is running the service function */ + TEST_ASSERT_EQUAL(1, service_lcore_running_check(), + "Service core expected to poll service but it didn't"); + + /* ensures that service may be active reports running state */ + TEST_ASSERT_EQUAL(1, rte_service_may_be_active(sid), + "Service may be active did not report running state"); + + /* stop the service */ + TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0), + "Error: Service stop returned non-zero"); + + /* give the service 100ms to stop running */ + for (i = 0; i < 100; i++) { + if (!rte_service_may_be_active(sid)) + break; + rte_delay_ms(SERVICE_DELAY); + } + + TEST_ASSERT_EQUAL(0, rte_service_may_be_active(sid), + "Error: Service not stopped after 100ms"); + + return unregister_all(); +} + static struct unit_test_suite service_tests = { .suite_name = "service core test suite", .setup = testsuite_setup, @@ -931,6 +980,7 @@ static struct unit_test_suite service_tests = { TEST_CASE_ST(dummy_register, NULL, service_app_lcore_mt_safe), TEST_CASE_ST(dummy_register, NULL, service_app_lcore_mt_unsafe), TEST_CASE_ST(dummy_register, NULL, service_may_be_active), + TEST_CASE_ST(dummy_register, NULL, service_active_two_cores), TEST_CASES_END() /**< NULL terminate unit test array */ } }; -- 2.17.1