From: Reshma Pattan <reshma.pattan@intel.com>
To: david.hunt@intel.com, dev@dpdk.org
Cc: jananeex.m.parthasarathy@intel.com
Subject: [dpdk-dev] [PATCH v2] app/test: enhance power manager unit tests
Date: Wed, 11 Apr 2018 15:14:27 +0100 [thread overview]
Message-ID: <1523456067-14178-1-git-send-email-reshma.pattan@intel.com> (raw)
In-Reply-To: <1523022706-12231-1-git-send-email-reshma.pattan@intel.com>
Unit Testcases are added for power_acpi_cpu_freq,
power_kvm_vm_test to improve coverage
Signed-off-by: Jananee Parthasarathy <jananeex.m.parthasarathy@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>
---
V3: removed unnecessary extern funtion prototypes.
---
test/test/test_power_acpi_cpufreq.c | 2 +-
test/test/test_power_kvm_vm.c | 60 +++++++++++++++++++++++++++++++++----
2 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/test/test/test_power_acpi_cpufreq.c b/test/test/test_power_acpi_cpufreq.c
index 3bfd033..8da2dcc 100644
--- a/test/test/test_power_acpi_cpufreq.c
+++ b/test/test/test_power_acpi_cpufreq.c
@@ -27,7 +27,7 @@
#define TEST_POWER_FREQS_NUM_MAX ((unsigned)RTE_MAX_LCORE_FREQS)
#define TEST_POWER_SYSFILE_CUR_FREQ \
- "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq"
+ "/sys/devices/system/cpu/cpu%u/cpufreq/cpuinfo_cur_freq"
static uint32_t total_freq_num;
static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];
diff --git a/test/test/test_power_kvm_vm.c b/test/test/test_power_kvm_vm.c
index 91b31c4..2ac7491 100644
--- a/test/test/test_power_kvm_vm.c
+++ b/test/test/test_power_kvm_vm.c
@@ -25,12 +25,17 @@
#define TEST_POWER_VM_LCORE_ID 0U
#define TEST_POWER_VM_LCORE_OUT_OF_BOUNDS (RTE_MAX_LCORE+1)
#define TEST_POWER_VM_LCORE_INVALID 1U
+#define TEMP_POWER_MANAGER_FILE_PATH "/tmp/testpm"
+
+int guest_channel_host_connect(const char *path, unsigned int lcore_id);
static int
test_power_kvm_vm(void)
{
int ret;
enum power_management_env env;
+ char fPath[PATH_MAX];
+ FILE *fPtr = NULL;
ret = rte_power_set_env(PM_ENV_KVM_VM);
if (ret != 0) {
@@ -95,12 +100,31 @@
/* Test initialisation of a valid lcore */
ret = rte_power_init(TEST_POWER_VM_LCORE_ID);
if (ret < 0) {
- 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);
- rte_power_unset_env();
- return -1;
+ printf("rte_power_init failed as expected in host\n");
+ /* This test would be successful when run on VM,
+ * in order to run in Host itself, temporary file path
+ * is created and same is used for further communication
+ */
+
+ snprintf(fPath, PATH_MAX, "%s.%u",
+ TEMP_POWER_MANAGER_FILE_PATH, TEST_POWER_VM_LCORE_ID);
+ fPtr = fopen(fPath, "w");
+ if (fPtr == NULL) {
+ printf(" Unable to create file\n");
+ rte_power_unset_env();
+ return -1;
+ }
+ ret = guest_channel_host_connect(TEMP_POWER_MANAGER_FILE_PATH,
+ TEST_POWER_VM_LCORE_ID);
+ if (ret == 0)
+ printf("guest_channel_host_connect successful\n");
+ else {
+ printf("guest_channel_host_connect failed\n");
+ rte_power_unset_env();
+ fclose(fPtr);
+ remove(fPath);
+ return -1;
+ }
}
/* Test initialisation of previously initialised lcore */
@@ -175,6 +199,22 @@
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) {
@@ -274,10 +314,18 @@
return -1;
}
rte_power_unset_env();
+ if (fPtr != NULL) {
+ fclose(fPtr);
+ remove(fPath);
+ }
return 0;
fail_all:
rte_power_exit(TEST_POWER_VM_LCORE_ID);
rte_power_unset_env();
+ if (fPtr != NULL) {
+ fclose(fPtr);
+ remove(fPath);
+ }
return -1;
}
#endif
--
1.7.12.2
next prev parent reply other threads:[~2018-04-11 14:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-06 13:51 [dpdk-dev] [PATCH] " Reshma Pattan
2018-04-10 14:19 ` Hunt, David
2018-04-11 14:14 ` Reshma Pattan [this message]
2018-04-23 21:04 ` [dpdk-dev] [PATCH v2] " Thomas Monjalon
2018-04-24 10:58 ` Bruce Richardson
2018-04-24 11:23 ` Pattan, Reshma
2018-04-24 12:09 ` Hunt, David
2018-04-24 12:51 ` Pattan, Reshma
2018-04-24 22:34 ` Thomas Monjalon
2018-04-24 22:35 ` Pattan, Reshma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1523456067-14178-1-git-send-email-reshma.pattan@intel.com \
--to=reshma.pattan@intel.com \
--cc=david.hunt@intel.com \
--cc=dev@dpdk.org \
--cc=jananeex.m.parthasarathy@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).