get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1447/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1447,
    "url": "https://patches.dpdk.org/api/patches/1447/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1416591732-3735-11-git-send-email-pablo.de.lara.guarch@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1416591732-3735-11-git-send-email-pablo.de.lara.guarch@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1416591732-3735-11-git-send-email-pablo.de.lara.guarch@intel.com",
    "date": "2014-11-21T17:42:12",
    "name": "[dpdk-dev,v5,10/10] VM Power Management Unit Tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "20e16be2d53f616e72a156d81d51d0e44694a624",
    "submitter": {
        "id": 9,
        "url": "https://patches.dpdk.org/api/people/9/?format=api",
        "name": "De Lara Guarch, Pablo",
        "email": "pablo.de.lara.guarch@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1416591732-3735-11-git-send-email-pablo.de.lara.guarch@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/1447/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/1447/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id A21527FD5;\n\tFri, 21 Nov 2014 18:32:00 +0100 (CET)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id E2AE67F95\n\tfor <dev@dpdk.org>; Fri, 21 Nov 2014 18:31:47 +0100 (CET)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga101.jf.intel.com with ESMTP; 21 Nov 2014 09:42:21 -0800",
            "from irvmail001.ir.intel.com ([163.33.26.43])\n\tby orsmga002.jf.intel.com with ESMTP; 21 Nov 2014 09:42:18 -0800",
            "from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com\n\t[10.237.217.46])\n\tby irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id\n\tsALHgHHq001866; Fri, 21 Nov 2014 17:42:17 GMT",
            "from sivswdev02.ir.intel.com (localhost [127.0.0.1])\n\tby sivswdev02.ir.intel.com with ESMTP id sALHgHZb012260;\n\tFri, 21 Nov 2014 17:42:17 GMT",
            "(from pdelarax@localhost)\n\tby sivswdev02.ir.intel.com with  id sALHgHmR012256;\n\tFri, 21 Nov 2014 17:42:17 GMT"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.07,432,1413270000\"; d=\"scan'208\";a=\"641262985\"",
        "From": "Pablo de Lara <pablo.de.lara.guarch@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Fri, 21 Nov 2014 17:42:12 +0000",
        "Message-Id": "<1416591732-3735-11-git-send-email-pablo.de.lara.guarch@intel.com>",
        "X-Mailer": "git-send-email 1.7.4.1",
        "In-Reply-To": "<1416591732-3735-1-git-send-email-pablo.de.lara.guarch@intel.com>",
        "References": "<1413142571-23069-1-git-send-email-alan.carew@intel.com>\n\t<1416591732-3735-1-git-send-email-pablo.de.lara.guarch@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v5 10/10] VM Power Management Unit Tests",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Alan Carew <alan.carew@intel.com>\n\nUpdated the unit tests to cover both librte_power implementations as well as\nthe external API.\n\nSigned-off-by: Alan Carew <alan.carew@intel.com>\nSigned-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>\n---\n app/test/Makefile                  |    3 +-\n app/test/autotest_data.py          |   26 ++\n app/test/test_power.c              |  445 +++---------------------------\n app/test/test_power_acpi_cpufreq.c |  544 ++++++++++++++++++++++++++++++++++++\n app/test/test_power_kvm_vm.c       |  308 ++++++++++++++++++++\n 5 files changed, 917 insertions(+), 409 deletions(-)\n create mode 100644 app/test/test_power_acpi_cpufreq.c\n create mode 100644 app/test/test_power_kvm_vm.c",
    "diff": "diff --git a/app/test/Makefile b/app/test/Makefile\nindex ebfa0ba..4b03f00 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -120,7 +120,8 @@ endif\n \n SRCS-$(CONFIG_RTE_LIBRTE_METER) += test_meter.c\n SRCS-$(CONFIG_RTE_LIBRTE_KNI) += test_kni.c\n-SRCS-$(CONFIG_RTE_LIBRTE_POWER) += test_power.c\n+SRCS-$(CONFIG_RTE_LIBRTE_POWER) += test_power.c test_power_acpi_cpufreq.c\n+SRCS-$(CONFIG_RTE_LIBRTE_POWER) += test_power_kvm_vm.c\n SRCS-y += test_common.c\n SRCS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += test_ivshmem.c\n \ndiff --git a/app/test/autotest_data.py b/app/test/autotest_data.py\nindex 878c72e..618a946 100644\n--- a/app/test/autotest_data.py\n+++ b/app/test/autotest_data.py\n@@ -425,6 +425,32 @@ non_parallel_test_group_list = [\n \t]\n },\n {\n+\t\"Prefix\" :      \"power_acpi_cpufreq\",\n+\t\"Memory\" :      all_sockets(512),\n+\t\"Tests\" :\n+\t[\n+\t\t{\n+\t\t \"Name\" :       \"Power ACPI cpufreq autotest\",\n+\t\t \"Command\" :    \"power_acpi_cpufreq_autotest\",\n+\t\t \"Func\" :       default_autotest,\n+\t\t \"Report\" :     None,\n+\t\t},\n+\t]\n+},\n+{\n+\t\"Prefix\" :      \"power_kvm_vm\",\n+\t\"Memory\" :      \"512\",\n+\t\"Tests\" :\n+\t[\n+\t\t{\n+\t\t \"Name\" :       \"Power KVM VM  autotest\",\n+\t\t \"Command\" :    \"power_kvm_vm_autotest\",\n+\t\t \"Func\" :       default_autotest,\n+\t\t \"Report\" :     None,\n+\t\t},\n+\t]\n+},\n+{\n \t\"Prefix\" :\t\"lpm6\",\n \t\"Memory\" :\t\"512\",\n \t\"Tests\" :\ndiff --git a/app/test/test_power.c b/app/test/test_power.c\nindex d9eb420..64a2305 100644\n--- a/app/test/test_power.c\n+++ b/app/test/test_power.c\n@@ -41,437 +41,66 @@\n \n #include <rte_power.h>\n \n-#define TEST_POWER_LCORE_ID      2U\n-#define TEST_POWER_LCORE_INVALID ((unsigned)RTE_MAX_LCORE)\n-#define TEST_POWER_FREQS_NUM_MAX ((unsigned)RTE_MAX_LCORE_FREQS)\n-\n-#define TEST_POWER_SYSFILE_CUR_FREQ \\\n-\t\"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq\"\n-\n-static uint32_t total_freq_num;\n-static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];\n-\n-static int\n-check_cur_freq(unsigned lcore_id, uint32_t idx)\n-{\n-#define TEST_POWER_CONVERT_TO_DECIMAL 10\n-\tFILE *f;\n-\tchar fullpath[PATH_MAX];\n-\tchar buf[BUFSIZ];\n-\tuint32_t cur_freq;\n-\tint ret = -1;\n-\n-\tif (snprintf(fullpath, sizeof(fullpath),\n-\t\tTEST_POWER_SYSFILE_CUR_FREQ, lcore_id) < 0) {\n-\t\treturn 0;\n-\t}\n-\tf = fopen(fullpath, \"r\");\n-\tif (f == NULL) {\n-\t\treturn 0;\n-\t}\n-\tif (fgets(buf, sizeof(buf), f) == NULL) {\n-\t\tgoto fail_get_cur_freq;\n-\t}\n-\tcur_freq = strtoul(buf, NULL, TEST_POWER_CONVERT_TO_DECIMAL);\n-\tret = (freqs[idx] == cur_freq ? 0 : -1);\n-\n-fail_get_cur_freq:\n-\tfclose(f);\n-\n-\treturn ret;\n-}\n-\n-/* Check rte_power_freqs() */\n-static int\n-check_power_freqs(void)\n-{\n-\tuint32_t ret;\n-\n-\ttotal_freq_num = 0;\n-\tmemset(freqs, 0, sizeof(freqs));\n-\n-\t/* test with an invalid lcore id */\n-\tret = rte_power_freqs(TEST_POWER_LCORE_INVALID, freqs,\n-\t\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n-\tif (ret > 0) {\n-\t\tprintf(\"Unexpectedly get available freqs successfully on \"\n-\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* test with NULL buffer to save available freqs */\n-\tret = rte_power_freqs(TEST_POWER_LCORE_ID, NULL,\n-\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n-\tif (ret > 0) {\n-\t\tprintf(\"Unexpectedly get available freqs successfully with \"\n-\t\t\t\"NULL buffer on lcore %u\\n\", TEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* test of getting zero number of freqs */\n-\tret = rte_power_freqs(TEST_POWER_LCORE_ID, freqs, 0);\n-\tif (ret > 0) {\n-\t\tprintf(\"Unexpectedly get available freqs successfully with \"\n-\t\t\t\"zero buffer size on lcore %u\\n\", TEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* test with all valid input parameters */\n-\tret = rte_power_freqs(TEST_POWER_LCORE_ID, freqs,\n-\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n-\tif (ret == 0 || ret > TEST_POWER_FREQS_NUM_MAX) {\n-\t\tprintf(\"Fail to get available freqs on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Save the total number of available freqs */\n-\ttotal_freq_num = ret;\n-\n-\treturn 0;\n-}\n-\n-/* Check rte_power_get_freq() */\n-static int\n-check_power_get_freq(void)\n-{\n-\tint ret;\n-\tuint32_t count;\n-\n-\t/* test with an invalid lcore id */\n-\tcount = rte_power_get_freq(TEST_POWER_LCORE_INVALID);\n-\tif (count < TEST_POWER_FREQS_NUM_MAX) {\n-\t\tprintf(\"Unexpectedly get freq index successfully on \"\n-\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\n-\tcount = rte_power_get_freq(TEST_POWER_LCORE_ID);\n-\tif (count >= TEST_POWER_FREQS_NUM_MAX) {\n-\t\tprintf(\"Fail to get the freq index on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, count);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n-}\n-\n-/* Check rte_power_set_freq() */\n-static int\n-check_power_set_freq(void)\n-{\n-\tint ret;\n-\n-\t/* test with an invalid lcore id */\n-\tret = rte_power_set_freq(TEST_POWER_LCORE_INVALID, 0);\n-\tif (ret >= 0) {\n-\t\tprintf(\"Unexpectedly set freq index successfully on \"\n-\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* test with an invalid freq index */\n-\tret = rte_power_set_freq(TEST_POWER_LCORE_ID,\n-\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n-\tif (ret >= 0) {\n-\t\tprintf(\"Unexpectedly set an invalid freq index (%u)\"\n-\t\t\t\"successfully on lcore %u\\n\", TEST_POWER_FREQS_NUM_MAX,\n-\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/**\n-\t * test with an invalid freq index which is right one bigger than\n-\t * total number of freqs\n-\t */\n-\tret = rte_power_set_freq(TEST_POWER_LCORE_ID, total_freq_num);\n-\tif (ret >= 0) {\n-\t\tprintf(\"Unexpectedly set an invalid freq index (%u)\"\n-\t\t\t\"successfully on lcore %u\\n\", total_freq_num,\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\tret = rte_power_set_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to set freq index on lcore %u\\n\",\n-\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n-}\n-\n-/* Check rte_power_freq_down() */\n-static int\n-check_power_freq_down(void)\n-{\n-\tint ret;\n-\n-\t/* test with an invalid lcore id */\n-\tret = rte_power_freq_down(TEST_POWER_LCORE_INVALID);\n-\tif (ret >= 0) {\n-\t\tprintf(\"Unexpectedly scale down successfully the freq on \"\n-\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Scale down to min and then scale down one step */\n-\tret = rte_power_freq_min(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale down the freq to min on lcore %u\\n\",\n-\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\tret = rte_power_freq_down(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale down the freq on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\t/* Scale up to max and then scale down one step */\n-\tret = rte_power_freq_max(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale up the freq to max on lcore %u\\n\",\n-\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\tret = rte_power_freq_down(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf (\"Fail to scale down the freq on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, 1);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n-}\n-\n-/* Check rte_power_freq_up() */\n-static int\n-check_power_freq_up(void)\n-{\n-\tint ret;\n-\n-\t/* test with an invalid lcore id */\n-\tret = rte_power_freq_up(TEST_POWER_LCORE_INVALID);\n-\tif (ret >= 0) {\n-\t\tprintf(\"Unexpectedly scale up successfully the freq on %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Scale down to min and then scale up one step */\n-\tret = rte_power_freq_min(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale down the freq to min on lcore %u\\n\",\n-\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\tret = rte_power_freq_up(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale up the freq on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\t/* Scale up to max and then scale up one step */\n-\tret = rte_power_freq_max(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale up the freq to max on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\tret = rte_power_freq_up(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale up the freq on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, 0);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n-}\n-\n-/* Check rte_power_freq_max() */\n-static int\n-check_power_freq_max(void)\n-{\n-\tint ret;\n-\n-\t/* test with an invalid lcore id */\n-\tret = rte_power_freq_max(TEST_POWER_LCORE_INVALID);\n-\tif (ret >= 0) {\n-\t\tprintf(\"Unexpectedly scale up successfully the freq to max on \"\n-\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\tret = rte_power_freq_max(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale up the freq to max on lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, 0);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n-}\n-\n-/* Check rte_power_freq_min() */\n-static int\n-check_power_freq_min(void)\n-{\n-\tint ret;\n-\n-\t/* test with an invalid lcore id */\n-\tret = rte_power_freq_min(TEST_POWER_LCORE_INVALID);\n-\tif (ret >= 0) {\n-\t\tprintf(\"Unexpectedly scale down successfully the freq to min \"\n-\t\t\t\t\"on lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\tret = rte_power_freq_min(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Fail to scale down the freq to min on lcore %u\\n\",\n-\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n-\t}\n-\n-\t/* Check the current frequency */\n-\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n-\tif (ret < 0)\n-\t\treturn -1;\n-\n-\treturn 0;\n-}\n-\n static int\n test_power(void)\n {\n \tint ret = -1;\n+\tenum power_management_env env;\n \n-\t/* test of init power management for an invalid lcore */\n-\tret = rte_power_init(TEST_POWER_LCORE_INVALID);\n+\t/* Test setting an invalid environment */\n+\tret = rte_power_set_env(PM_ENV_NOT_SET);\n \tif (ret == 0) {\n-\t\tprintf(\"Unexpectedly initialise power management successfully \"\n-\t\t\t\t\"for lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n-\t}\n-\n-\tret = rte_power_init(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Cannot initialise power management for lcore %u\\n\",\n-\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\tprintf(\"Unexpectedly succeeded on setting an invalid environment\\n\");\n \t\treturn -1;\n \t}\n \n-\t/**\n-\t * test of initialising power management for the lcore which has\n-\t * been initialised\n-\t */\n-\tret = rte_power_init(TEST_POWER_LCORE_ID);\n-\tif (ret == 0) {\n-\t\tprintf(\"Unexpectedly init successfully power twice on \"\n-\t\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_ID);\n+\t/* Test that the environment has not been set */\n+\tenv = rte_power_get_env();\n+\tif (env != PM_ENV_NOT_SET) {\n+\t\tprintf(\"Unexpectedly got a valid environment configuration\\n\");\n \t\treturn -1;\n \t}\n \n-\tret = check_power_freqs();\n-\tif (ret < 0)\n+\t/* verify that function pointers are NULL */\n+\tif (rte_power_freqs != NULL) {\n+\t\tprintf(\"rte_power_freqs should be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n \t\tgoto fail_all;\n-\n-\tif (total_freq_num < 2) {\n-\t\trte_power_exit(TEST_POWER_LCORE_ID);\n-\t\tprintf(\"Frequency can not be changed due to CPU itself\\n\");\n-\t\treturn 0;\n \t}\n-\n-\tret = check_power_get_freq();\n-\tif (ret < 0)\n-\t\tgoto fail_all;\n-\n-\tret = check_power_set_freq();\n-\tif (ret < 0)\n+\tif (rte_power_get_freq != NULL) {\n+\t\tprintf(\"rte_power_get_freq should be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n \t\tgoto fail_all;\n-\n-\tret = check_power_freq_down();\n-\tif (ret < 0)\n-\t\tgoto fail_all;\n-\n-\tret = check_power_freq_up();\n-\tif (ret < 0)\n+\t}\n+\tif (rte_power_set_freq != NULL) {\n+\t\tprintf(\"rte_power_set_freq should be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n \t\tgoto fail_all;\n-\n-\tret = check_power_freq_max();\n-\tif (ret < 0)\n+\t}\n+\tif (rte_power_freq_up != NULL) {\n+\t\tprintf(\"rte_power_freq_up should be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n \t\tgoto fail_all;\n-\n-\tret = check_power_freq_min();\n-\tif (ret < 0)\n+\t}\n+\tif (rte_power_freq_down != NULL) {\n+\t\tprintf(\"rte_power_freq_down should be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n \t\tgoto fail_all;\n-\n-\tret = rte_power_exit(TEST_POWER_LCORE_ID);\n-\tif (ret < 0) {\n-\t\tprintf(\"Cannot exit power management for lcore %u\\n\",\n-\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n-\t\treturn -1;\n \t}\n-\n-\t/**\n-\t * test of exiting power management for the lcore which has been exited\n-\t */\n-\tret = rte_power_exit(TEST_POWER_LCORE_ID);\n-\tif (ret == 0) {\n-\t\tprintf(\"Unexpectedly exit successfully power management twice \"\n-\t\t\t\t\t\"on lcore %u\\n\", TEST_POWER_LCORE_ID);\n-\t\treturn -1;\n+\tif (rte_power_freq_max != NULL) {\n+\t\tprintf(\"rte_power_freq_max should be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n+\t\tgoto fail_all;\n \t}\n-\n-\t/* test of exit power management for an invalid lcore */\n-\tret = rte_power_exit(TEST_POWER_LCORE_INVALID);\n-\tif (ret == 0) {\n-\t\tprintf(\"Unpectedly exit power management successfully for \"\n-\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n-\t\treturn -1;\n+\tif (rte_power_freq_min != NULL) {\n+\t\tprintf(\"rte_power_freq_min should be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n+\t\tgoto fail_all;\n \t}\n-\n+\trte_power_unset_env();\n \treturn 0;\n-\n fail_all:\n-\trte_power_exit(TEST_POWER_LCORE_ID);\n-\n+\trte_power_unset_env();\n \treturn -1;\n }\n \ndiff --git a/app/test/test_power_acpi_cpufreq.c b/app/test/test_power_acpi_cpufreq.c\nnew file mode 100644\nindex 0000000..8848d75\n--- /dev/null\n+++ b/app/test/test_power_acpi_cpufreq.c\n@@ -0,0 +1,544 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <stdio.h>\n+#include <stdint.h>\n+#include <unistd.h>\n+#include <limits.h>\n+#include <string.h>\n+\n+#include \"test.h\"\n+\n+#include <rte_power.h>\n+\n+#define TEST_POWER_LCORE_ID      2U\n+#define TEST_POWER_LCORE_INVALID ((unsigned)RTE_MAX_LCORE)\n+#define TEST_POWER_FREQS_NUM_MAX ((unsigned)RTE_MAX_LCORE_FREQS)\n+\n+#define TEST_POWER_SYSFILE_CUR_FREQ \\\n+\t\"/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq\"\n+\n+static uint32_t total_freq_num;\n+static uint32_t freqs[TEST_POWER_FREQS_NUM_MAX];\n+\n+static int\n+check_cur_freq(unsigned lcore_id, uint32_t idx)\n+{\n+#define TEST_POWER_CONVERT_TO_DECIMAL 10\n+\tFILE *f;\n+\tchar fullpath[PATH_MAX];\n+\tchar buf[BUFSIZ];\n+\tuint32_t cur_freq;\n+\tint ret = -1;\n+\n+\tif (snprintf(fullpath, sizeof(fullpath),\n+\t\tTEST_POWER_SYSFILE_CUR_FREQ, lcore_id) < 0) {\n+\t\treturn 0;\n+\t}\n+\tf = fopen(fullpath, \"r\");\n+\tif (f == NULL) {\n+\t\treturn 0;\n+\t}\n+\tif (fgets(buf, sizeof(buf), f) == NULL) {\n+\t\tgoto fail_get_cur_freq;\n+\t}\n+\tcur_freq = strtoul(buf, NULL, TEST_POWER_CONVERT_TO_DECIMAL);\n+\tret = (freqs[idx] == cur_freq ? 0 : -1);\n+\n+fail_get_cur_freq:\n+\tfclose(f);\n+\n+\treturn ret;\n+}\n+\n+/* Check rte_power_freqs() */\n+static int\n+check_power_freqs(void)\n+{\n+\tuint32_t ret;\n+\n+\ttotal_freq_num = 0;\n+\tmemset(freqs, 0, sizeof(freqs));\n+\n+\t/* test with an invalid lcore id */\n+\tret = rte_power_freqs(TEST_POWER_LCORE_INVALID, freqs,\n+\t\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n+\tif (ret > 0) {\n+\t\tprintf(\"Unexpectedly get available freqs successfully on \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* test with NULL buffer to save available freqs */\n+\tret = rte_power_freqs(TEST_POWER_LCORE_ID, NULL,\n+\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n+\tif (ret > 0) {\n+\t\tprintf(\"Unexpectedly get available freqs successfully with \"\n+\t\t\t\"NULL buffer on lcore %u\\n\", TEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* test of getting zero number of freqs */\n+\tret = rte_power_freqs(TEST_POWER_LCORE_ID, freqs, 0);\n+\tif (ret > 0) {\n+\t\tprintf(\"Unexpectedly get available freqs successfully with \"\n+\t\t\t\"zero buffer size on lcore %u\\n\", TEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* test with all valid input parameters */\n+\tret = rte_power_freqs(TEST_POWER_LCORE_ID, freqs,\n+\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n+\tif (ret == 0 || ret > TEST_POWER_FREQS_NUM_MAX) {\n+\t\tprintf(\"Fail to get available freqs on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Save the total number of available freqs */\n+\ttotal_freq_num = ret;\n+\n+\treturn 0;\n+}\n+\n+/* Check rte_power_get_freq() */\n+static int\n+check_power_get_freq(void)\n+{\n+\tint ret;\n+\tuint32_t count;\n+\n+\t/* test with an invalid lcore id */\n+\tcount = rte_power_get_freq(TEST_POWER_LCORE_INVALID);\n+\tif (count < TEST_POWER_FREQS_NUM_MAX) {\n+\t\tprintf(\"Unexpectedly get freq index successfully on \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\treturn -1;\n+\t}\n+\n+\tcount = rte_power_get_freq(TEST_POWER_LCORE_ID);\n+\tif (count >= TEST_POWER_FREQS_NUM_MAX) {\n+\t\tprintf(\"Fail to get the freq index on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, count);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+/* Check rte_power_set_freq() */\n+static int\n+check_power_set_freq(void)\n+{\n+\tint ret;\n+\n+\t/* test with an invalid lcore id */\n+\tret = rte_power_set_freq(TEST_POWER_LCORE_INVALID, 0);\n+\tif (ret >= 0) {\n+\t\tprintf(\"Unexpectedly set freq index successfully on \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* test with an invalid freq index */\n+\tret = rte_power_set_freq(TEST_POWER_LCORE_ID,\n+\t\t\t\tTEST_POWER_FREQS_NUM_MAX);\n+\tif (ret >= 0) {\n+\t\tprintf(\"Unexpectedly set an invalid freq index (%u)\"\n+\t\t\t\"successfully on lcore %u\\n\", TEST_POWER_FREQS_NUM_MAX,\n+\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/**\n+\t * test with an invalid freq index which is right one bigger than\n+\t * total number of freqs\n+\t */\n+\tret = rte_power_set_freq(TEST_POWER_LCORE_ID, total_freq_num);\n+\tif (ret >= 0) {\n+\t\tprintf(\"Unexpectedly set an invalid freq index (%u)\"\n+\t\t\t\"successfully on lcore %u\\n\", total_freq_num,\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\tret = rte_power_set_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to set freq index on lcore %u\\n\",\n+\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+/* Check rte_power_freq_down() */\n+static int\n+check_power_freq_down(void)\n+{\n+\tint ret;\n+\n+\t/* test with an invalid lcore id */\n+\tret = rte_power_freq_down(TEST_POWER_LCORE_INVALID);\n+\tif (ret >= 0) {\n+\t\tprintf(\"Unexpectedly scale down successfully the freq on \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Scale down to min and then scale down one step */\n+\tret = rte_power_freq_min(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale down the freq to min on lcore %u\\n\",\n+\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\tret = rte_power_freq_down(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale down the freq on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\t/* Scale up to max and then scale down one step */\n+\tret = rte_power_freq_max(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale up the freq to max on lcore %u\\n\",\n+\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\tret = rte_power_freq_down(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf (\"Fail to scale down the freq on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, 1);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+/* Check rte_power_freq_up() */\n+static int\n+check_power_freq_up(void)\n+{\n+\tint ret;\n+\n+\t/* test with an invalid lcore id */\n+\tret = rte_power_freq_up(TEST_POWER_LCORE_INVALID);\n+\tif (ret >= 0) {\n+\t\tprintf(\"Unexpectedly scale up successfully the freq on %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_INVALID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Scale down to min and then scale up one step */\n+\tret = rte_power_freq_min(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale down the freq to min on lcore %u\\n\",\n+\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\tret = rte_power_freq_up(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale up the freq on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 2);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\t/* Scale up to max and then scale up one step */\n+\tret = rte_power_freq_max(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale up the freq to max on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\tret = rte_power_freq_up(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale up the freq on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, 0);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+/* Check rte_power_freq_max() */\n+static int\n+check_power_freq_max(void)\n+{\n+\tint ret;\n+\n+\t/* test with an invalid lcore id */\n+\tret = rte_power_freq_max(TEST_POWER_LCORE_INVALID);\n+\tif (ret >= 0) {\n+\t\tprintf(\"Unexpectedly scale up successfully the freq to max on \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\treturn -1;\n+\t}\n+\tret = rte_power_freq_max(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale up the freq to max on lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, 0);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+/* Check rte_power_freq_min() */\n+static int\n+check_power_freq_min(void)\n+{\n+\tint ret;\n+\n+\t/* test with an invalid lcore id */\n+\tret = rte_power_freq_min(TEST_POWER_LCORE_INVALID);\n+\tif (ret >= 0) {\n+\t\tprintf(\"Unexpectedly scale down successfully the freq to min \"\n+\t\t\t\t\"on lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\treturn -1;\n+\t}\n+\tret = rte_power_freq_min(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Fail to scale down the freq to min on lcore %u\\n\",\n+\t\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Check the current frequency */\n+\tret = check_cur_freq(TEST_POWER_LCORE_ID, total_freq_num - 1);\n+\tif (ret < 0)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static int\n+test_power_acpi_cpufreq(void)\n+{\n+\tint ret = -1;\n+\tenum power_management_env env;\n+\n+\tret = rte_power_set_env(PM_ENV_ACPI_CPUFREQ);\n+\tif (ret != 0) {\n+\t\tprintf(\"Failed on setting environment to PM_ENV_ACPI_CPUFREQ, this \"\n+\t\t\t\t\"may occur if environment is not configured correctly or \"\n+\t\t\t\t\" operating in another valid Power management environment\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test environment configuration */\n+\tenv = rte_power_get_env();\n+\tif (env != PM_ENV_ACPI_CPUFREQ) {\n+\t\tprintf(\"Unexpectedly got an environment other than ACPI cpufreq\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* verify that function pointers are not NULL */\n+\tif (rte_power_freqs == NULL) {\n+\t\tprintf(\"rte_power_freqs should not be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\tif (rte_power_get_freq == NULL) {\n+\t\tprintf(\"rte_power_get_freq should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\tif (rte_power_set_freq == NULL) {\n+\t\tprintf(\"rte_power_set_freq should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\tif (rte_power_freq_up == NULL) {\n+\t\tprintf(\"rte_power_freq_up should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\tif (rte_power_freq_down == NULL) {\n+\t\tprintf(\"rte_power_freq_down should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\tif (rte_power_freq_max == NULL) {\n+\t\tprintf(\"rte_power_freq_max should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\tif (rte_power_freq_min == NULL) {\n+\t\tprintf(\"rte_power_freq_min should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* test of init power management for an invalid lcore */\n+\tret = rte_power_init(TEST_POWER_LCORE_INVALID);\n+\tif (ret == 0) {\n+\t\tprintf(\"Unexpectedly initialise power management successfully \"\n+\t\t\t\t\"for lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test initialisation of a valid lcore */\n+\tret = rte_power_init(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Cannot initialise power management for lcore %u, this \"\n+\t\t\t\t\"may occur if environment is not configured \"\n+\t\t\t\t\"correctly(APCI cpufreq) or operating in another valid \"\n+\t\t\t\t\"Power management environment\\n\", TEST_POWER_LCORE_ID);\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\n+\t/**\n+\t * test of initialising power management for the lcore which has\n+\t * been initialised\n+\t */\n+\tret = rte_power_init(TEST_POWER_LCORE_ID);\n+\tif (ret == 0) {\n+\t\tprintf(\"Unexpectedly init successfully power twice on \"\n+\t\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\tret = check_power_freqs();\n+\tif (ret < 0)\n+\t\tgoto fail_all;\n+\n+\tif (total_freq_num < 2) {\n+\t\trte_power_exit(TEST_POWER_LCORE_ID);\n+\t\tprintf(\"Frequency can not be changed due to CPU itself\\n\");\n+\t\trte_power_unset_env();\n+\t\treturn 0;\n+\t}\n+\n+\tret = check_power_get_freq();\n+\tif (ret < 0)\n+\t\tgoto fail_all;\n+\n+\tret = check_power_set_freq();\n+\tif (ret < 0)\n+\t\tgoto fail_all;\n+\n+\tret = check_power_freq_down();\n+\tif (ret < 0)\n+\t\tgoto fail_all;\n+\n+\tret = check_power_freq_up();\n+\tif (ret < 0)\n+\t\tgoto fail_all;\n+\n+\tret = check_power_freq_max();\n+\tif (ret < 0)\n+\t\tgoto fail_all;\n+\n+\tret = check_power_freq_min();\n+\tif (ret < 0)\n+\t\tgoto fail_all;\n+\n+\tret = rte_power_exit(TEST_POWER_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Cannot exit power management for lcore %u\\n\",\n+\t\t\t\t\t\tTEST_POWER_LCORE_ID);\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\n+\t/**\n+\t * test of exiting power management for the lcore which has been exited\n+\t */\n+\tret = rte_power_exit(TEST_POWER_LCORE_ID);\n+\tif (ret == 0) {\n+\t\tprintf(\"Unexpectedly exit successfully power management twice \"\n+\t\t\t\t\t\"on lcore %u\\n\", TEST_POWER_LCORE_ID);\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\n+\t/* test of exit power management for an invalid lcore */\n+\tret = rte_power_exit(TEST_POWER_LCORE_INVALID);\n+\tif (ret == 0) {\n+\t\tprintf(\"Unpectedly exit power management successfully for \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_LCORE_INVALID);\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\trte_power_unset_env();\n+\treturn 0;\n+\n+fail_all:\n+\trte_power_exit(TEST_POWER_LCORE_ID);\n+\trte_power_unset_env();\n+\treturn -1;\n+}\n+\n+static struct test_command power_acpi_cpufreq_cmd = {\n+\t.command = \"power_acpi_cpufreq_autotest\",\n+\t.callback = test_power_acpi_cpufreq,\n+};\n+REGISTER_TEST_COMMAND(power_acpi_cpufreq_cmd);\ndiff --git a/app/test/test_power_kvm_vm.c b/app/test/test_power_kvm_vm.c\nnew file mode 100644\nindex 0000000..ac0fcb6\n--- /dev/null\n+++ b/app/test/test_power_kvm_vm.c\n@@ -0,0 +1,308 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <stdio.h>\n+#include <stdint.h>\n+#include <unistd.h>\n+#include <limits.h>\n+#include <string.h>\n+\n+#include \"test.h\"\n+\n+#include <rte_power.h>\n+#include <rte_config.h>\n+\n+#define TEST_POWER_VM_LCORE_ID            0U\n+#define TEST_POWER_VM_LCORE_OUT_OF_BOUNDS (RTE_MAX_LCORE+1)\n+#define TEST_POWER_VM_LCORE_INVALID       1U\n+\n+static int\n+test_power_kvm_vm(void)\n+{\n+\tint ret;\n+\tenum power_management_env env;\n+\n+\tret = rte_power_set_env(PM_ENV_KVM_VM);\n+\tif (ret != 0) {\n+\t\tprintf(\"Failed on setting environment to PM_ENV_KVM_VM\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test environment configuration */\n+\tenv = rte_power_get_env();\n+\tif (env != PM_ENV_KVM_VM) {\n+\t\tprintf(\"Unexpectedly got a Power Management environment other than \"\n+\t\t\t\t\"KVM VM\\n\");\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\n+\t/* verify that function pointers are not NULL */\n+\tif (rte_power_freqs == NULL) {\n+\t\tprintf(\"rte_power_freqs should not be NULL, environment has not been \"\n+\t\t\t\t\"initialised\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_power_get_freq == NULL) {\n+\t\tprintf(\"rte_power_get_freq should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_power_set_freq == NULL) {\n+\t\tprintf(\"rte_power_set_freq should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_power_freq_up == NULL) {\n+\t\tprintf(\"rte_power_freq_up should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_power_freq_down == NULL) {\n+\t\tprintf(\"rte_power_freq_down should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_power_freq_max == NULL) {\n+\t\tprintf(\"rte_power_freq_max should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_power_freq_min == NULL) {\n+\t\tprintf(\"rte_power_freq_min should not be NULL, environment has not \"\n+\t\t\t\t\"been initialised\\n\");\n+\t\treturn -1;\n+\t}\n+\t/* Test initialisation of an out of bounds lcore */\n+\tret = rte_power_init(TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\tif (ret != -1) {\n+\t\tprintf(\"rte_power_init unexpectedly succeeded on an invalid lcore %u\\n\",\n+\t\t\t\tTEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test initialisation of a valid lcore */\n+\tret = rte_power_init(TEST_POWER_VM_LCORE_ID);\n+\tif (ret < 0) {\n+\t\tprintf(\"Cannot initialise power management for lcore %u, this \"\n+\t\t\t\t\"may occur if environment is not configured \"\n+\t\t\t\t\"correctly(KVM VM) or operating in another valid \"\n+\t\t\t\t\"Power management environment\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\trte_power_unset_env();\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test initialisation of previously initialised lcore */\n+\tret = rte_power_init(TEST_POWER_VM_LCORE_ID);\n+\tif (ret == 0) {\n+\t\tprintf(\"rte_power_init unexpectedly succeeded on calling init twice on\"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency up of invalid lcore */\n+\tret = rte_power_freq_up(TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_up unexpectedly succeeded on invalid lcore %u\\n\",\n+\t\t\t\tTEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency down of invalid lcore */\n+\tret = rte_power_freq_down(TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_down unexpectedly succeeded on invalid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency min of invalid lcore */\n+\tret = rte_power_freq_min(TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_min unexpectedly succeeded on invalid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency max of invalid lcore */\n+\tret = rte_power_freq_max(TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_max unexpectedly succeeded on invalid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_OUT_OF_BOUNDS);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency up of valid but uninitialised lcore */\n+\tret = rte_power_freq_up(TEST_POWER_VM_LCORE_INVALID);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_up unexpectedly succeeded on invalid lcore %u\\n\",\n+\t\t\t\tTEST_POWER_VM_LCORE_INVALID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency down of valid but uninitialised lcore */\n+\tret = rte_power_freq_down(TEST_POWER_VM_LCORE_INVALID);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_down unexpectedly succeeded on invalid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_INVALID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency min of valid but uninitialised lcore */\n+\tret = rte_power_freq_min(TEST_POWER_VM_LCORE_INVALID);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_min unexpectedly succeeded on invalid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_INVALID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency max of valid but uninitialised lcore */\n+\tret = rte_power_freq_max(TEST_POWER_VM_LCORE_INVALID);\n+\tif (ret == 1) {\n+\t\tprintf(\"rte_power_freq_max unexpectedly succeeded on invalid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_INVALID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency up of valid lcore */\n+\tret = rte_power_freq_up(TEST_POWER_VM_LCORE_ID);\n+\tif (ret != 1) {\n+\t\tprintf(\"rte_power_freq_up unexpectedly failed on valid lcore %u\\n\",\n+\t\t\t\tTEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency down of valid lcore */\n+\tret = rte_power_freq_down(TEST_POWER_VM_LCORE_ID);\n+\tif (ret != 1) {\n+\t\tprintf(\"rte_power_freq_down unexpectedly failed on valid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency min of valid lcore */\n+\tret = rte_power_freq_min(TEST_POWER_VM_LCORE_ID);\n+\tif (ret != 1) {\n+\t\tprintf(\"rte_power_freq_min unexpectedly failed on valid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency max of valid lcore */\n+\tret = rte_power_freq_max(TEST_POWER_VM_LCORE_ID);\n+\tif (ret != 1) {\n+\t\tprintf(\"rte_power_freq_max unexpectedly failed on valid lcore \"\n+\t\t\t\t\"%u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test unsupported rte_power_freqs */\n+\tret = rte_power_freqs(TEST_POWER_VM_LCORE_ID, NULL, 0);\n+\tif (ret != -ENOTSUP) {\n+\t\tprintf(\"rte_power_freqs did not return the expected -ENOTSUP(%d) but \"\n+\t\t\t\t\"returned %d\\n\", -ENOTSUP, ret);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test unsupported rte_power_get_freq */\n+\tret = rte_power_get_freq(TEST_POWER_VM_LCORE_ID);\n+\tif (ret != -ENOTSUP) {\n+\t\tprintf(\"rte_power_get_freq did not return the expected -ENOTSUP(%d) but\"\n+\t\t\t\t\" returned %d for lcore %u\\n\",\n+\t\t\t\t-ENOTSUP, ret, TEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test unsupported rte_power_set_freq */\n+\tret = rte_power_set_freq(TEST_POWER_VM_LCORE_ID, 0);\n+\tif (ret != -ENOTSUP) {\n+\t\tprintf(\"rte_power_set_freq did not return the expected -ENOTSUP(%d) but\"\n+\t\t\t\t\" returned %d for lcore %u\\n\",\n+\t\t\t\t-ENOTSUP, ret, TEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test removing of an lcore */\n+\tret = rte_power_exit(TEST_POWER_VM_LCORE_ID);\n+\tif (ret != 0) {\n+\t\tprintf(\"rte_power_exit unexpectedly failed on valid lcore %u,\"\n+\t\t\t\t\"please ensure that the environment has been configured \"\n+\t\t\t\t\"correctly\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\tgoto fail_all;\n+\t}\n+\n+\t/* Test frequency up of previously removed lcore */\n+\tret = rte_power_freq_up(TEST_POWER_VM_LCORE_ID);\n+\tif (ret == 0) {\n+\t\tprintf(\"rte_power_freq_up unexpectedly succeeded on a removed \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test frequency down of previously removed lcore */\n+\tret = rte_power_freq_down(TEST_POWER_VM_LCORE_ID);\n+\tif (ret == 0) {\n+\t\tprintf(\"rte_power_freq_down unexpectedly succeeded on a removed \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test frequency min of previously removed lcore */\n+\tret = rte_power_freq_min(TEST_POWER_VM_LCORE_ID);\n+\tif (ret == 0) {\n+\t\tprintf(\"rte_power_freq_min unexpectedly succeeded on a removed \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test frequency max of previously removed lcore */\n+\tret = rte_power_freq_max(TEST_POWER_VM_LCORE_ID);\n+\tif (ret == 0) {\n+\t\tprintf(\"rte_power_freq_max unexpectedly succeeded on a removed \"\n+\t\t\t\t\"lcore %u\\n\", TEST_POWER_VM_LCORE_ID);\n+\t\treturn -1;\n+\t}\n+\trte_power_unset_env();\n+\treturn 0;\n+fail_all:\n+\trte_power_exit(TEST_POWER_VM_LCORE_ID);\n+\trte_power_unset_env();\n+\treturn -1;\n+}\n+\n+static struct test_command power_kvm_vm_cmd = {\n+    .command = \"power_kvm_vm_autotest\",\n+    .callback = test_power_kvm_vm,\n+};\n+REGISTER_TEST_COMMAND(power_kvm_vm_cmd);\n",
    "prefixes": [
        "dpdk-dev",
        "v5",
        "10/10"
    ]
}