Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/172/?format=api
http://patches.dpdk.org/api/patches/172/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1408361365-12988-5-git-send-email-david.marchand@6wind.com/", "project": { "id": 1, "url": "http://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": "<1408361365-12988-5-git-send-email-david.marchand@6wind.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1408361365-12988-5-git-send-email-david.marchand@6wind.com", "date": "2014-08-18T11:29:22", "name": "[dpdk-dev,v2,4/7] app/test: introduce dynamic commands list", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "9943f76d57ce3bb89349b9ebe7e882a8594f77d4", "submitter": { "id": 3, "url": "http://patches.dpdk.org/api/people/3/?format=api", "name": "David Marchand", "email": "david.marchand@6wind.com" }, "delegate": null, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1408361365-12988-5-git-send-email-david.marchand@6wind.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/172/comments/", "check": "pending", "checks": "http://patches.dpdk.org/api/patches/172/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<david.marchand@6wind.com>", "Received": [ "from mail-wg0-f44.google.com (mail-wg0-f44.google.com\n\t[74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 9E508B362\n\tfor <dev@dpdk.org>; Mon, 18 Aug 2014 13:26:25 +0200 (CEST)", "by mail-wg0-f44.google.com with SMTP id m15so4784975wgh.15\n\tfor <dev@dpdk.org>; Mon, 18 Aug 2014 04:29:48 -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\tes9sm41617207wjd.1.2014.08.18.04.29.47 for <dev@dpdk.org>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 18 Aug 2014 04:29:47 -0700 (PDT)" ], "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=gT9sIRpa5EVaVVyP7HzzHyQY2cErveuA0+Si39NXPW85GpEIRW6R2ib57jmCE5CviS\n\tGrOfwsCYlsNkCFQ7bXLaWi89za8oSoCJh+qtsF8Ssxg1ZprbvNCT+5kwCDy+10aAYcQQ\n\tgq896BSJp9BwPcd8DpScksW5FA0hG93DoXEFdpZn6fjkYZ1pJkRESb9GuAM17K5N7wkj\n\tmuInLtplofMarUQ1K+kDi2IqQyKHn2bNiSO3QGVNBxh6Xs5woVmRpKfkMVJBxPORy4GU\n\tPCT6nZyaimAgpf3InEXuWDGX6vclReIQ0BNXbsrJ+Lgy88LfHEbX4GMtiA82aInhiNMw\n\tvG5g==", "X-Gm-Message-State": "ALoCoQmdeTa8DgwEdZb9Q8eTh9ICSyA6MrEHyVQc8Dhq4I9ct/jKMoyhKM3LK+WZybGmTua4MGHP", "X-Received": "by 10.180.75.49 with SMTP id z17mr39834494wiv.80.1408361388366; \n\tMon, 18 Aug 2014 04:29:48 -0700 (PDT)", "From": "David Marchand <david.marchand@6wind.com>", "To": "dev@dpdk.org", "Date": "Mon, 18 Aug 2014 13:29:22 +0200", "Message-Id": "<1408361365-12988-5-git-send-email-david.marchand@6wind.com>", "X-Mailer": "git-send-email 1.7.10.4", "In-Reply-To": "<1408361365-12988-1-git-send-email-david.marchand@6wind.com>", "References": "<1408361365-12988-1-git-send-email-david.marchand@6wind.com>", "Subject": "[dpdk-dev] [PATCH v2 4/7] app/test: introduce dynamic commands list", "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>", "X-List-Received-Date": "Mon, 18 Aug 2014 11:26:25 -0000" }, "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", "v2", "4/7" ] }{ "id": 172, "url": "