[v2,3/3] test: add UT for power turbo feature

Message ID 20190403103256.21856-4-lukaszx.krakowiak@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series test: improve test coverage for power library |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Lukasz Krakowiak April 3, 2019, 10:32 a.m. UTC
  Add UT check_power_turbo.

Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 app/test/test_power_cpufreq.c | 72 +++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
  

Comments

Hunt, David April 15, 2019, 3:22 p.m. UTC | #1
On 3/4/2019 11:32 AM, Lukasz Krakowiak wrote:
> Add UT check_power_turbo.
>
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
>   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..d203810da 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",


Acked-by: David Hunt <david.hunt@intel.com>
  
Marcin Hajkowski June 7, 2019, 8:45 a.m. UTC | #2
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Lukasz Krakowiak
> Sent: Wednesday, April 3, 2019 12:33 PM
> To: Hunt, David <david.hunt@intel.com>
> Cc: Burakov, Anatoly <anatoly.burakov@intel.com>; dev@dpdk.org;
> Krakowiak, LukaszX <lukaszx.krakowiak@intel.com>
> Subject: [dpdk-dev] [PATCH v2 3/3] test: add UT for power turbo feature
> 
> Add UT check_power_turbo.
> 
> Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
> ---
>  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..d203810da 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.19.2.windows.1

Tested-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
  

Patch

diff --git a/app/test/test_power_cpufreq.c b/app/test/test_power_cpufreq.c
index d099f2f47..d203810da 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",