power: add get capabilities API
[dpdk.git] / test / test / test_power_kvm_vm.c
index 97b8af9..bce706d 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2014 Intel Corporation
+ * Copyright(c) 2010-2018 Intel Corporation
  */
 
 #include <stdio.h>
 
 #include "test.h"
 
+#ifndef RTE_LIBRTE_POWER
+
+static int
+test_power_kvm_vm(void)
+{
+       printf("Power management library not supported, skipping test\n");
+       return TEST_SKIPPED;
+}
+
+#else
 #include <rte_power.h>
 
 #define TEST_POWER_VM_LCORE_ID            0U
@@ -88,7 +98,8 @@ test_power_kvm_vm(void)
                printf("Cannot initialise power management for lcore %u, this "
                                "may occur if environment is not configured "
                                "correctly(KVM VM) or operating in another valid "
-                               "Power management environment\n", TEST_POWER_VM_LCORE_ID);
+                               "Power management environment\n",
+                               TEST_POWER_VM_LCORE_ID);
                rte_power_unset_env();
                return -1;
        }
@@ -165,6 +176,22 @@ test_power_kvm_vm(void)
                goto fail_all;
        }
 
+       /* Test KVM_VM Enable Turbo of valid core */
+       ret = rte_power_freq_enable_turbo(TEST_POWER_VM_LCORE_ID);
+       if (ret == -1) {
+               printf("rte_power_freq_enable_turbo failed on valid lcore"
+                       "%u\n", TEST_POWER_VM_LCORE_ID);
+               goto fail_all;
+       }
+
+       /* Test KVM_VM Disable Turbo of valid core */
+       ret = rte_power_freq_disable_turbo(TEST_POWER_VM_LCORE_ID);
+       if (ret == -1) {
+               printf("rte_power_freq_disable_turbo failed on valid lcore"
+               "%u\n", TEST_POWER_VM_LCORE_ID);
+               goto fail_all;
+       }
+
        /* Test frequency up of valid lcore */
        ret = rte_power_freq_up(TEST_POWER_VM_LCORE_ID);
        if (ret != 1) {
@@ -270,5 +297,6 @@ fail_all:
        rte_power_unset_env();
        return -1;
 }
+#endif
 
 REGISTER_TEST_COMMAND(power_kvm_vm_autotest, test_power_kvm_vm);