[v2,2/3] test/power: add unit test for get capabilities API

Message ID 1528711403-29776-2-git-send-email-radu.nicolau@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2,1/3] power: add get capabilities API |

Checks

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

Commit Message

Radu Nicolau June 11, 2018, 10:03 a.m. UTC
  Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 test/test/test_power_acpi_cpufreq.c | 42 +++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
  

Comments

Hunt, David June 26, 2018, 9:43 a.m. UTC | #1
On 11/6/2018 11:03 AM, Radu Nicolau wrote:
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
>   test/test/test_power_acpi_cpufreq.c | 42 +++++++++++++++++++++++++++++++++++++
>   1 file changed, 42 insertions(+)
>
> diff --git a/test/test/test_power_acpi_cpufreq.c b/test/test/test_power_acpi_cpufreq.c
> index 8da2dcc..67d5ee0 100644
> --- a/test/test/test_power_acpi_cpufreq.c
> +++ b/test/test/test_power_acpi_cpufreq.c
> @@ -18,6 +18,12 @@ test_power_acpi_cpufreq(void)
>   	printf("Power management library not supported, skipping test\n");
>   	return TEST_SKIPPED;
>   }
> +static int
> +test_power_acpi_caps(void)
> +{
> +	printf("Power management library not supported, skipping test\n");
> +	return TEST_SKIPPED;
> +}
>   
>   #else
>   #include <rte_power.h>
> @@ -517,6 +523,42 @@ test_power_acpi_cpufreq(void)
>   	rte_power_unset_env();
>   	return -1;
>   }
> +
> +static int
> +test_power_acpi_caps(void)
> +{
> +	struct rte_power_core_capabilities caps;
> +	int ret;
> +
> +	ret = rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
> +	if (ret) {
> +		printf("Error setting ACPI environment\n");
> +		return -1;
> +	}
> +
> +	ret = rte_power_init(TEST_POWER_LCORE_ID);
> +	if (ret < 0) {
> +		printf("Cannot initialise power management for lcore %u, this "
> +			"may occur if environment is not configured "
> +			"correctly(APCI cpufreq) or operating in another valid "
> +			"Power management environment\n", TEST_POWER_LCORE_ID);
> +		rte_power_unset_env();
> +		return -1;
> +	}
> +
> +	ret = rte_power_get_capabilities(TEST_POWER_LCORE_ID, &caps);
> +	if (ret) {
> +		printf("ACPI: Error getting capabilities\n");
> +		return -1;
> +	}
> +
> +	printf("ACPI: Capabilities %lx\n", caps.capabilities);
> +
> +	rte_power_unset_env();
> +	return 0;
> +}
> +
>   #endif
>   
>   REGISTER_TEST_COMMAND(power_acpi_cpufreq_autotest, test_power_acpi_cpufreq);
> +REGISTER_TEST_COMMAND(power_acpi_caps_autotest, test_power_acpi_caps);

Acked-by: David Hunt<david.hunt@intel.com>
  

Patch

diff --git a/test/test/test_power_acpi_cpufreq.c b/test/test/test_power_acpi_cpufreq.c
index 8da2dcc..67d5ee0 100644
--- a/test/test/test_power_acpi_cpufreq.c
+++ b/test/test/test_power_acpi_cpufreq.c
@@ -18,6 +18,12 @@  test_power_acpi_cpufreq(void)
 	printf("Power management library not supported, skipping test\n");
 	return TEST_SKIPPED;
 }
+static int
+test_power_acpi_caps(void)
+{
+	printf("Power management library not supported, skipping test\n");
+	return TEST_SKIPPED;
+}
 
 #else
 #include <rte_power.h>
@@ -517,6 +523,42 @@  test_power_acpi_cpufreq(void)
 	rte_power_unset_env();
 	return -1;
 }
+
+static int
+test_power_acpi_caps(void)
+{
+	struct rte_power_core_capabilities caps;
+	int ret;
+
+	ret = rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
+	if (ret) {
+		printf("Error setting ACPI environment\n");
+		return -1;
+	}
+
+	ret = rte_power_init(TEST_POWER_LCORE_ID);
+	if (ret < 0) {
+		printf("Cannot initialise power management for lcore %u, this "
+			"may occur if environment is not configured "
+			"correctly(APCI cpufreq) or operating in another valid "
+			"Power management environment\n", TEST_POWER_LCORE_ID);
+		rte_power_unset_env();
+		return -1;
+	}
+
+	ret = rte_power_get_capabilities(TEST_POWER_LCORE_ID, &caps);
+	if (ret) {
+		printf("ACPI: Error getting capabilities\n");
+		return -1;
+	}
+
+	printf("ACPI: Capabilities %lx\n", caps.capabilities);
+
+	rte_power_unset_env();
+	return 0;
+}
+
 #endif
 
 REGISTER_TEST_COMMAND(power_acpi_cpufreq_autotest, test_power_acpi_cpufreq);
+REGISTER_TEST_COMMAND(power_acpi_caps_autotest, test_power_acpi_caps);