Show a patch.

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

{
    "id": 165,
    "url": "https://patches.dpdk.org/api/patches/165/",
    "web_url": "https://patches.dpdk.org/patch/165/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<1408353973-16663-5-git-send-email-david.marchand@6wind.com>",
    "date": "2014-08-18T09:26:10",
    "name": "[dpdk-dev,4/7] app/test: introduce dynamic commands list",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "9943f76d57ce3bb89349b9ebe7e882a8594f77d4",
    "submitter": {
        "id": 3,
        "url": "https://patches.dpdk.org/api/people/3/",
        "name": "David Marchand",
        "email": "david.marchand@6wind.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/165/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/165/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/165/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<david.marchand@6wind.com>",
        "References": "<1408353973-16663-1-git-send-email-david.marchand@6wind.com>",
        "X-Mailman-Version": "2.1.15",
        "From": "David Marchand <david.marchand@6wind.com>",
        "X-List-Received-Date": "Mon, 18 Aug 2014 09:23:07 -0000",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<1408353973-16663-5-git-send-email-david.marchand@6wind.com>",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20130820;\n\th=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=JYZIpIypb7162QeeHIH77AeiOhK18B8xxA8c/Uzk758=;\n\tb=NKxsRzEfApG7Qx9Vex1iq63inas5fuj1tDp0UVizb3i1TrnxdKjBhB2wPbUQ9vz8Jk\n\t4o+ii4hhhaFWbarETamus11QN5jvC3RXrXLJXlZlUKkCmvhAAjBIcPjlwUn/0wvMQM+l\n\trITfUxONzl5o+INyQlllw9wDxnkHR6FcGwSU3p/SS4iE07f9NSjzIyz/MN2mJYrGX3fU\n\t/huYOwApZDtD3ZeMqbIucRagW4NDJl74xf1v/JjjuTvA3FfhoK9QlM9Umscb5Ti+JS5h\n\tjffUCZGE8DvNoJl2NCalWEianrF3SV5ZP7yB2cJJW0IVj+YhB0UXwiYDeFa+YdLPBWsa\n\tVyGw==",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "X-Received": "by 10.194.118.201 with SMTP id ko9mr39265220wjb.26.1408353988732;\n\tMon, 18 Aug 2014 02:26:28 -0700 (PDT)",
        "X-Mailer": "git-send-email 1.7.10.4",
        "Precedence": "list",
        "X-Gm-Message-State": "ALoCoQkVv8gTmJaXvyr0sA4z+9hxM4yqpkjFkR84px/yFu9ZFhRfDRCPRktZA39g3MMXSN2IfmcE",
        "Date": "Mon, 18 Aug 2014 11:26:10 +0200",
        "Subject": "[dpdk-dev] [PATCH 4/7] app/test: introduce dynamic commands list",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Received": [
            "from mail-wi0-f172.google.com (mail-wi0-f172.google.com\n\t[209.85.212.172]) by dpdk.org (Postfix) with ESMTP id 74F27B372\n\tfor <dev@dpdk.org>; Mon, 18 Aug 2014 11:23:06 +0200 (CEST)",
            "by mail-wi0-f172.google.com with SMTP id n3so3382533wiv.17\n\tfor <dev@dpdk.org>; Mon, 18 Aug 2014 02:26:28 -0700 (PDT)",
            "from alcyon.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net.\n\t[82.239.227.177]) by mx.google.com with ESMTPSA id\n\tza9sm25087627wjc.29.2014.08.18.02.26.27 for <dev@dpdk.org>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 18 Aug 2014 02:26:28 -0700 (PDT)"
        ],
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "In-Reply-To": "<1408353973-16663-1-git-send-email-david.marchand@6wind.com>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "To": "dev@dpdk.org"
    },
    "content": "This patch adds a way to dynamically add a test without modifying commands.c.\nMove all current tests in a builtin_commands[] list, next patch will convert\nthem to this new system.\n\nSigned-off-by: David Marchand <david.marchand@6wind.com>\n---\n app/test/commands.c |  118 ++++++++++++++++++++++++++++++++++-----------------\n app/test/test.c     |    3 ++\n app/test/test.h     |   21 +++++++++\n 3 files changed, 103 insertions(+), 39 deletions(-)",
    "diff": "diff --git a/app/test/commands.c b/app/test/commands.c\nindex 4a0cc05..a1ffd43 100644\n--- a/app/test/commands.c\n+++ b/app/test/commands.c\n@@ -78,6 +78,15 @@\n \n /****************/\n \n+static struct test_commands_list commands_list =\n+\tTAILQ_HEAD_INITIALIZER(commands_list);\n+\n+void\n+add_test_command(struct test_command *t)\n+{\n+\tTAILQ_INSERT_TAIL(&commands_list, t, next);\n+}\n+\n struct cmd_autotest_result {\n \tcmdline_fixed_string_t autotest;\n };\n@@ -86,9 +95,15 @@ static void cmd_autotest_parsed(void *parsed_result,\n \t\t\t\t__attribute__((unused)) struct cmdline *cl,\n \t\t\t\t__attribute__((unused)) void *data)\n {\n+\tstruct test_command *t;\n \tstruct cmd_autotest_result *res = parsed_result;\n \tint ret = 0;\n \n+\tTAILQ_FOREACH(t, &commands_list, next) {\n+\t\tif (!strcmp(res->autotest, t->command))\n+\t\t\tret = t->callback();\n+\t}\n+\n \tif (!strcmp(res->autotest, \"version_autotest\"))\n \t\tret = test_version();\n \tif (!strcmp(res->autotest, \"eal_fs_autotest\"))\n@@ -214,45 +229,7 @@ static void cmd_autotest_parsed(void *parsed_result,\n \n cmdline_parse_token_string_t cmd_autotest_autotest =\n \tTOKEN_STRING_INITIALIZER(struct cmd_autotest_result, autotest,\n-\t\t\t\"pci_autotest#memory_autotest#\"\n-\t\t\t\"per_lcore_autotest#spinlock_autotest#\"\n-\t\t\t\"rwlock_autotest#atomic_autotest#\"\n-\t\t\t\"byteorder_autotest#prefetch_autotest#\"\n-\t\t\t\"cycles_autotest#logs_autotest#\"\n-\t\t\t\"memzone_autotest#ring_autotest#\"\n-\t\t\t\"mempool_autotest#mbuf_autotest#\"\n-\t\t\t\"timer_autotest#malloc_autotest#\"\n-\t\t\t\"memcpy_autotest#hash_autotest#\"\n-\t\t\t\"lpm_autotest#debug_autotest#\"\n-\t\t\t\"lpm6_autotest#\"\n-\t\t\t\"errno_autotest#tailq_autotest#\"\n-\t\t\t\"string_autotest#multiprocess_autotest#\"\n-\t\t\t\"cpuflags_autotest#eal_flags_autotest#\"\n-\t\t\t\"alarm_autotest#interrupt_autotest#\"\n-\t\t\t\"version_autotest#eal_fs_autotest#\"\n-\t\t\t\"cmdline_autotest#func_reentrancy_autotest#\"\n-#ifdef RTE_LIBRTE_PMD_BOND\n-\t\t\t\"link_bonding_autotest#\"\n-#endif\n-\t\t\t\"mempool_perf_autotest#hash_perf_autotest#\"\n-\t\t\t\"memcpy_perf_autotest#ring_perf_autotest#\"\n-\t\t\t\"red_autotest#meter_autotest#sched_autotest#\"\n-\t\t\t\"memcpy_perf_autotest#kni_autotest#\"\n-\t\t\t\"ivshmem_autotest#\"\n-\t\t\t\"devargs_autotest#table_autotest#\"\n-#ifdef RTE_LIBRTE_ACL\n-\t\t\t\"acl_autotest#\"\n-#endif\n-\t\t\t\"power_autotest#\"\n-\t\t\t\"timer_perf_autotest#\"\n-#ifdef RTE_LIBRTE_PMD_RING\n-\t\t\t\"ring_pmd_autotest#\"\n-#endif\n-#ifdef RTE_LIBRTE_KVARGS\n-\t\t\t\"kvargs_autotest#\"\n-#endif\n-\t\t\t\"common_autotest#\"\n-\t\t\t\"distributor_autotest#distributor_perf_autotest\");\n+\t\t\t\t \"\");\n \n cmdline_parse_inst_t cmd_autotest = {\n \t.f = cmd_autotest_parsed,  /* function to call */\n@@ -460,3 +437,66 @@ cmdline_parse_ctx_t main_ctx[] = {\n \tNULL,\n };\n \n+int commands_init(void)\n+{\n+\tstruct test_command *t;\n+\tchar builtin_commands[] =\n+\t\t\t\"pci_autotest#memory_autotest#\"\n+\t\t\t\"per_lcore_autotest#spinlock_autotest#\"\n+\t\t\t\"rwlock_autotest#atomic_autotest#\"\n+\t\t\t\"byteorder_autotest#prefetch_autotest#\"\n+\t\t\t\"cycles_autotest#logs_autotest#\"\n+\t\t\t\"memzone_autotest#ring_autotest#\"\n+\t\t\t\"mempool_autotest#mbuf_autotest#\"\n+\t\t\t\"timer_autotest#malloc_autotest#\"\n+\t\t\t\"memcpy_autotest#hash_autotest#\"\n+\t\t\t\"lpm_autotest#debug_autotest#\"\n+\t\t\t\"lpm6_autotest#\"\n+\t\t\t\"errno_autotest#tailq_autotest#\"\n+\t\t\t\"string_autotest#multiprocess_autotest#\"\n+\t\t\t\"cpuflags_autotest#eal_flags_autotest#\"\n+\t\t\t\"alarm_autotest#interrupt_autotest#\"\n+\t\t\t\"version_autotest#eal_fs_autotest#\"\n+\t\t\t\"cmdline_autotest#func_reentrancy_autotest#\"\n+#ifdef RTE_LIBRTE_PMD_BOND\n+\t\t\t\"link_bonding_autotest#\"\n+#endif\n+\t\t\t\"mempool_perf_autotest#hash_perf_autotest#\"\n+\t\t\t\"memcpy_perf_autotest#ring_perf_autotest#\"\n+\t\t\t\"red_autotest#meter_autotest#sched_autotest#\"\n+\t\t\t\"memcpy_perf_autotest#kni_autotest#\"\n+\t\t\t\"ivshmem_autotest#\"\n+\t\t\t\"devargs_autotest#table_autotest#\"\n+#ifdef RTE_LIBRTE_ACL\n+\t\t\t\"acl_autotest#\"\n+#endif\n+\t\t\t\"power_autotest#\"\n+\t\t\t\"timer_perf_autotest#\"\n+#ifdef RTE_LIBRTE_PMD_RING\n+\t\t\t\"ring_pmd_autotest#\"\n+#endif\n+#ifdef RTE_LIBRTE_KVARGS\n+\t\t\t\"kvargs_autotest#\"\n+#endif\n+\t\t\t\"common_autotest#\"\n+\t\t\t\"distributor_autotest#distributor_perf_autotest\";\n+\tchar *commands, *ptr;\n+\tint commands_len = strlen(builtin_commands) + 1;\n+\n+\tTAILQ_FOREACH(t, &commands_list, next) {\n+\t\tcommands_len += strlen(t->command) + 1;\n+\t}\n+\n+\tcommands = malloc(commands_len);\n+\tif (!commands)\n+\t\treturn -1;\n+\n+\tptr = commands;\n+\tTAILQ_FOREACH(t, &commands_list, next) {\n+\t\tptr += sprintf(ptr, \"%s#\", t->command);\n+\t}\n+\tptr += sprintf(ptr, \"%s\", builtin_commands);\n+\n+\tcmd_autotest_autotest.string_data.str = commands;\n+\treturn 0;\n+}\ndiff --git a/app/test/test.c b/app/test/test.c\nindex 589a168..a33b2b5 100644\n--- a/app/test/test.c\n+++ b/app/test/test.c\n@@ -126,6 +126,9 @@ main(int argc, char **argv)\n \trte_timer_subsystem_init();\n #endif\n \n+\tif (commands_init() < 0)\n+\t\treturn -1;\n+\n \targv += ret;\n \n \tprgname = argv[0];\ndiff --git a/app/test/test.h b/app/test/test.h\nindex 181c38e..bba0ec5 100644\n--- a/app/test/test.h\n+++ b/app/test/test.h\n@@ -34,6 +34,8 @@\n #ifndef _TEST_H_\n #define _TEST_H_\n \n+#include <sys/queue.h>\n+\n #define TEST_ASSERT(cond, msg, ...) do {\t\t\t\t\t\t\\\n \t\tif (!(cond)) {\t\t\t\t\t\t\t\t\t\t\t\\\n \t\t\tprintf(\"TestCase %s() line %d failed: \"\t\t\t\\\n@@ -125,6 +127,8 @@ int unit_test_suite_runner(struct unit_test_suite *suite);\n \n extern const char *prgname;\n \n+int commands_init(void);\n+\n int main(int argc, char **argv);\n \n int test_pci(void);\n@@ -183,4 +187,21 @@ int test_link_bonding(void);\n \n int test_pci_run;\n \n+typedef int (test_callback)(void);\n+TAILQ_HEAD(test_commands_list, test_command);\n+struct test_command {\n+\tTAILQ_ENTRY(test_command) next;\n+\tconst char *command;\n+\ttest_callback *callback;\n+};\n+\n+void add_test_command(struct test_command *t);\n+\n+#define REGISTER_TEST_COMMAND(t) \\\n+static void testfn_##t(void);\\\n+void __attribute__((constructor, used)) testfn_##t(void)\\\n+{\\\n+\tadd_test_command(&t);\\\n+}\n+\n #endif\n",
    "prefixes": [
        "dpdk-dev",
        "4/7"
    ]
}