From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 7DEEA1B12B for ; Thu, 7 Mar 2019 15:04:18 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2019 06:04:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,451,1544515200"; d="scan'208";a="149487380" Received: from lkrakowx-mobl.ger.corp.intel.com (HELO lukas.isw.intel.com) ([10.103.104.102]) by fmsmga002.fm.intel.com with ESMTP; 07 Mar 2019 06:04:17 -0800 From: Lukasz Krakowiak To: david.hunt@intel.com Cc: dev@dpdk.org, Lukasz Krakowiak Date: Thu, 7 Mar 2019 07:59:50 -0600 Message-Id: <20190307135950.30738-4-lukaszx.krakowiak@intel.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190307135950.30738-1-lukaszx.krakowiak@intel.com> References: <20190307135950.30738-1-lukaszx.krakowiak@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 3/3] test: add UT for power turbo feature 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: Thu, 07 Mar 2019 14:04:18 -0000 Add UT check_power_turbo. Signed-off-by: Lukasz Krakowiak --- app/test/test_power_cpufreq.c | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c index d099f2f47..c75c9bf1c 100644 --- a/app/test/test_power_cpufreq.c +++ b/app/test/test_power_cpufreq.c @@ -366,6 +366,59 @@ check_power_freq_min(void) return 0; } +/* Check rte_power_turbo() */ +static int +check_power_turbo(void) +{ + int ret; + + if (rte_power_turbo_status(TEST_POWER_LCORE_ID) == 0) { + printf("Turbo not available on lcore %u, skipping test\n", + TEST_POWER_LCORE_ID); + return 0; + } + + /* test with an invalid lcore id */ + ret = rte_power_freq_enable_turbo(TEST_POWER_LCORE_INVALID); + if (ret >= 0) { + printf("Unexpectedly enable turbo successfully " + "on lcore %u\n", TEST_POWER_LCORE_INVALID); + return -1; + } + ret = rte_power_freq_enable_turbo(TEST_POWER_LCORE_ID); + if (ret < 0) { + printf("Fail to enable turbo on lcore %u\n", + TEST_POWER_LCORE_ID); + return -1; + } + + /* Check the current frequency */ + ret = check_cur_freq(TEST_POWER_LCORE_ID, 0); + if (ret < 0) + return -1; + + /* test with an invalid lcore id */ + ret = rte_power_freq_disable_turbo(TEST_POWER_LCORE_INVALID); + if (ret >= 0) { + printf("Unexpectedly disable turbo successfully " + "on lcore %u\n", TEST_POWER_LCORE_INVALID); + return -1; + } + ret = rte_power_freq_disable_turbo(TEST_POWER_LCORE_ID); + if (ret < 0) { + printf("Fail to disable turbo on lcore %u\n", + TEST_POWER_LCORE_ID); + return -1; + } + + /* Check the current frequency */ + ret = check_cur_freq(TEST_POWER_LCORE_ID, 1); + if (ret < 0) + return -1; + + return 0; +} + static int test_power_cpufreq(void) { @@ -427,6 +480,21 @@ test_power_cpufreq(void) "been initialised\n"); goto fail_all; } + if (rte_power_turbo_status == NULL) { + printf("rte_power_turbo_status should not be NULL, environment has not " + "been initialised\n"); + goto fail_all; + } + if (rte_power_freq_enable_turbo == NULL) { + printf("rte_power_freq_enable_turbo should not be NULL, environment has not " + "been initialised\n"); + goto fail_all; + } + if (rte_power_freq_disable_turbo == NULL) { + printf("rte_power_freq_disable_turbo should not be NULL, environment has not " + "been initialised\n"); + goto fail_all; + } ret = rte_power_exit(TEST_POWER_LCORE_ID); if (ret < 0) { @@ -502,6 +570,10 @@ test_power_cpufreq(void) if (ret < 0) goto fail_all; + ret = check_power_turbo(); + if (ret < 0) + goto fail_all; + ret = rte_power_exit(TEST_POWER_LCORE_ID); if (ret < 0) { printf("Cannot exit power management for lcore %u\n", -- 2.17.2