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 28BEAA00BE; Tue, 7 Jul 2020 12:45:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AE12A1DDD6; Tue, 7 Jul 2020 12:45:34 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 174011DDD5 for ; Tue, 7 Jul 2020 12:45:33 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.150]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 85A0220087; Tue, 7 Jul 2020 10:45:32 +0000 (UTC) Received: from us4-mdac16-44.at1.mdlocal (unknown [10.110.48.15]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 83983800A3; Tue, 7 Jul 2020 10:45:32 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.49.106]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 17BE3100052; Tue, 7 Jul 2020 10:45:32 +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 D414EB40066; Tue, 7 Jul 2020 10:45:31 +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; Tue, 7 Jul 2020 11:45:28 +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; Tue, 7 Jul 2020 11:45:28 +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 067AjSaH013633; Tue, 7 Jul 2020 11:45:28 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 67A7D1626E9; Tue, 7 Jul 2020 11:45:28 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov , Harry van Haaren Date: Tue, 7 Jul 2020 11:45:25 +0100 Message-ID: <1594118726-8421-2-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1594118726-8421-1-git-send-email-arybchenko@solarflare.com> References: <1593873347-13686-1-git-send-email-arybchenko@solarflare.com> <1594118726-8421-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-25526.003 X-TM-AS-Result: No-7.886200-8.000000-10 X-TMASE-MatchedRID: sgT35vMqibO09I1RF1swcOIfK/Jd5eHmjotcmj+7SkE4XREg9Ki10xd2 WyReW5ebcKLnwjXEZ1ayUescqeUMprYX2Zbb0Huy6fUfELqFUH9KRaXN2yYjHjsUTbqaO707QBz oPKhLasjFG6rPbKnpuvD8CGDYfAZ9FUPnz5fE4uPylEfNwb6iLVF5adRR2Ej1kaEC8FJraL/cru +PSMhej/bCvJzBrCnffuf8ioYS+7Gg2YoJMKNlEYNraaMEw/Vakos2tunL8DQrC/kbp8twD9IQa SugOFswNWlqv3euRjUYGmTiWQlQQpilmT/yOYwxlchF+IvkllOi8D/o42y/Sj1KWk8zZw5Fo8WM kQWv6iXBcIE78YqRWo6HM5rqDwqtHDoAauuBleM+fM8D35G8fb0MhOynrKQ48uLQ3wCtP7NiH+Z jIy/leEMMprcbiest X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--7.886200-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.6.1012-25526.003 X-MDID: 1594118732-xZXEK_HXckZ4 Subject: [dpdk-dev] [PATCH v3 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 --- v3: - skip the test if number of cores is insufficient app/test/test_service_cores.c | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/app/test/test_service_cores.c b/app/test/test_service_cores.c index 981e212130..4f003ed1af 100644 --- a/app/test/test_service_cores.c +++ b/app/test/test_service_cores.c @@ -910,6 +910,59 @@ 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) +{ + if (!rte_lcore_is_enabled(0) || !rte_lcore_is_enabled(1) || + !rte_lcore_is_enabled(2)) + return TEST_SKIPPED; + + 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 +984,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