From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0084.outbound.protection.outlook.com [104.47.41.84]) by dpdk.org (Postfix) with ESMTP id E23437CB0 for ; Sun, 28 May 2017 22:00:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1pvsU8mzs4LQ+Im+GAcVvlDn2i3iP3NzzSg2L/8q1Ec=; b=QTQ0RM02mku8NJ+b+qice5x0U1cLfcc4I7WxV9/5GNTbu6THfqe2oC64V5eQ9yk2i6kofCudGSbnCL0qI9HIOsF+V6wQYor5a+ZVNkNd73gH32KGIiuYRAXxDzFnaJXQu+myh7/MKCR6zZolphfXZYw3Rl5qdBB/voFhdQ4e/F0= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from jerin.domain.name (111.93.218.67) by CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Sun, 28 May 2017 20:00:26 +0000 From: Jerin Jacob To: dev@dpdk.org Cc: bruce.richardson@intel.com, harry.van.haaren@intel.com, hemant.agrawal@nxp.com, gage.eads@intel.com, nipun.gupta@nxp.com, narender.vangati@intel.com, nikhil.rao@intel.com, gprathyusha@caviumnetworks.com, Jerin Jacob Date: Mon, 29 May 2017 01:28:30 +0530 Message-Id: <20170528195854.6064-10-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170528195854.6064-1-jerin.jacob@caviumnetworks.com> References: <20170528195854.6064-1-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BMXPR01CA0003.INDPRD01.PROD.OUTLOOK.COM (10.174.214.141) To CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY1PR0701MB1725: X-MS-Office365-Filtering-Correlation-Id: 056961e9-0edc-4fef-ecfa-08d4a604311a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 3:bA9kAi5MsSPjcyeIzcR7NxkCjM8RqXv35wIp7uUxgFvYx/vjf0gqI+8kZZM5+oy1ayLx3sJlC7YTF85dpp/Hy1eLobaJDNiJ/ojFtQ85+XPlte42qNYC9U5FA24zQlz9ACVdjNceg9kw8vbn6C5I0BktK/g0zdYP8gHKmajv1g8wwKaLpqp5edkGuoN4u6MpFjJqiaOdlS2RlAzOpytuuJL18bO5+XyqFY8I5Z+/zhSpuQv1MeGNo576c1nb25WNg1EX2A2VO129GYhVJOBJl4KwLAfytQRhCQVkUwCzJQYMiNublLbJnmVeKN84V45n50HI9AxuyMkk1u5ZlVfN9g==; 25:FZSnBeW0QI6KAi2QFzko3FjGfai19S6ZW4Tid5fwipfDzzn034R7UXFEkokp0nI9uhKQl4C+pxx4uT5Fy2wxs5i39NnloHLgFc1ICAappXBe7K00lf3YIRW0C1izg8GcECYl/jaaOHh6Et85clWjbLSeqYBtj0LZVLYNNP2ApA+d4iHRp7z2sp+ZsSDEw9nEwfGoGikkwE1my00hv/x3rtIX124O6B9c5p3xNIFsgilhY9FNReMbKJU8NlakE5JCw+y61gBXHrxPNQn2GsFqpjojvhO52ZYqFOKDAFFtosRokZVhX1eYStuHNsmxkJSDI16r8uA9Eg41EafY+5g+AFon0VQLh4um7SqwAn7nQcERIgUIbbIn6oMgZb19uIMOTmgRqlo8WjIBrSQpBV9ozjsfjE8cRLjEa5jGq80z1ey2Uzels5zitSoW8Gc9bVxyyNE5V/bbSIy7xEyxWfhxzbiykIsp/L1KEtW56D5s2tQ= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 31:hcgwXRkx4gD5Y3xMJwNTtjoucnmHFoXWXXkyGZoQgX6Zqf7tK40ETjyYQ179Ayz72Qtv6u9hMAHxCysUat7oA9aw9+H34Lln6uOqijREfvqaByGfAKyW09cLWK/ZiRArf5oZmpFoOeUNTS+T1HUmpMK7dPtybOsow7+Yi4yJKHqIm6sbOJai3Dns8zLT5K449/c2i/sJOvORrz6JMcq5tYJKblnPws+n8A3TbFIlwjA=; 20:qR693Trjna0JvsBuECiw4fJM28r5uDd2n46NREjtCvdAz7lKTJqZ0QdjNWbwJvIQYtMkq3cSAa5q30QssPH2iJ3IRpEqNMM9ITkDN5qSEgVZK6MQR5KXZkTjDG0BH69igGJc/9RCFOYhrOMQDcFZYIW/ZutFAr0EeySyx2w2Iyf1N6ssbTY9J+ZIuGsaos0IH5T323Hon6Cu4+k8IrYB+6hWUxoD7RpM+DhbXpOhcMBKwFr7d4p9OFON5us/w/JjsxVmdvpkRPqc20AnwoYWHfGztBIj0G8XQiOKIf+ZLVhAkEGzB7A5CfKGgASrM59aAA9Rz/7shlPtVOZ9WUVJWbYYuuD4qAioNsyCybtxidavg9RJb+joNVpgYoskKn/G5d+v9TUaV72vhm3+NW4YgCfA0Eh3ZRGPon3HTNV7K0KO6qJnz2mTh+y3oDOjlTymydZm4osFLr0ZByfK4E8359hHUMAKXgxKGKLg5lse3dVYqjSFoiA2IhimB4AgZZDUKHCZEB7lVCOcQS0Scempyd17zDdktFROjHXcxyGtDfq98WE/d0vEWm6SjNNUWD78AvHGx+OzSEnmy0wkx5VD1z4O68sTNgQ6oEQRTV5RwK8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700073)(100105000095)(100000701073)(100105300095)(100000702073)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(100000703073)(100105400095)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(100000704073)(100105200095)(100000705073)(100105500095); SRVR:CY1PR0701MB1725; BCL:0; PCL:0; RULEID:(100000800073)(100110000095)(100000801073)(100110300095)(100000802073)(100110100095)(100000803073)(100110400095)(100000804073)(100110200095)(100000805073)(100110500095); SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0701MB1725; 4:5JoGnlwnPwFsP3Ynqec+z6HgsGn3Ok3S+bNLz5ZE?= =?us-ascii?Q?YRiRhmWO45N2t3gFczrrsbdxC0y975Hdh9fF5PCKefaWxIwAxbQEDatuniiT?= =?us-ascii?Q?Hk2LbX26ftXDqZiss87wSy4TAWZtKQwIwhRU+EZHQY3dnN/l0p7f4UxRD0EX?= =?us-ascii?Q?LHLWtOHAZ+8yOoMMeoBTmui3mDrzNbzIXx+vNvEgD05qcNqmDjt+xGKNaTIM?= =?us-ascii?Q?wDDSEkKEmrXdZ5G/ThzG0Iw9ruqdB/qEPU+PVFvcXbz+N95ydrjyqt1OhExt?= =?us-ascii?Q?2ZZMZKn1vke95oNPFPA2mL69ss30xkZ/imPDzoTmfDeSDL2fnoTUO/nDsbND?= =?us-ascii?Q?sLpo0Wj8cMu88DmUmanBqjhihwgOYLQRFzHcE0ml4aMdV8C8d6EzDJj89Uq0?= =?us-ascii?Q?5JX6n8IPYJnnOkpLesHy/bE4l6IgPud/p+t/GdxdLlUDlUZqD1iVbRw1NBkT?= =?us-ascii?Q?DuVLP+ALZIB9wVlJHajeNpcElf1K3O4um+IOuu9Bn2YdB4cotRBuei93s2ph?= =?us-ascii?Q?IDOSrkdIb9ooJHV3zKVxeiA2FMj6cjBpVJ6osULFc2v8hzwDLGEKZbe6dL25?= =?us-ascii?Q?IoI7DgLaGKSo5mnuuN0V5gRm3jSTgA5jvalwDzuV+tNN/Ae8F6OFBAzQVsP7?= =?us-ascii?Q?R3R10a/wZJHXo06f08zpEOv1h4BnWCA03rchGx2OklZIXgymu2/0Rk5xVG4q?= =?us-ascii?Q?xn3HZzHU3uUVZWQuBW5e29+ln0KJwl3efFZN6FDO0GF6K53a3+GqqgP1D1ww?= =?us-ascii?Q?hFY2G9IwU3LJ/fMkaM/7mkgFHmPoHzHgr4+Y8/oGV41jstOcPm9n8BD8LOQJ?= =?us-ascii?Q?RqYGjOUzf5Ig0yfhAcilf0gzIWKarPLMZmxoircPu43UlBJorTPCzU9GTBkS?= =?us-ascii?Q?1w6GImb3JO9o0EqjkQNFppVhXEiAroGqc1H7zmZx1ypvnEzHUkp/0KFDkvjr?= =?us-ascii?Q?MY3RT7+6tTKS+7BcsfZQpThAvzc76G2Wg4KbxlytEZLYoQNss/xgfzk8dezz?= =?us-ascii?Q?Llyz+1VsccdgAveaqJ7664zrESwDS5GzOOUPFCkOSkzRSVHt7+PctWk/AfbW?= =?us-ascii?Q?mhJWun2Bzeeit4W79ICsc7zVxa0rZRqe4w16gfLubnBVuxoiEosa9YhkjNHX?= =?us-ascii?Q?6Njbp75KtmI=3D?= X-Forefront-PRVS: 03218BFD9F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39850400002)(39410400002)(39840400002)(39400400002)(81166006)(6486002)(66066001)(4326008)(50986999)(76176999)(50226002)(189998001)(72206003)(36756003)(6506006)(38730400002)(5003940100001)(5009440100003)(110136004)(107886003)(42186005)(53416004)(7736002)(8676002)(48376002)(50466002)(1076002)(3846002)(6116002)(6512007)(2361001)(305945005)(2906002)(6666003)(478600001)(25786009)(5660300001)(2351001)(6916009)(42882006)(2950100002)(33646002)(8656002)(47776003)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1725; H:jerin.domain.name; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?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cJLonwi5ZHIhWehkUdQhYvM7kJSPeT/gEt9Sl71ZInG0S2Hif1yTaV876Ku4lgZujKvsuAlLOGfO8KOCU77Tb+zdb6kbI4PfEKVeajJiX5/jOBUOysGxRcWGbXVZkd9Lg12rMuE233TBDRcOn34ODCRPXJtQ+cTt30EjG7Jjmh7VHjanay71wbSUXKkff5N95J4vvA2PVUHOVtyX9yjnA1N/EgutCBIFRrAL7Ug5BzPmCzNe++aemXXtJcI51hwKjhU0iF5ge9Le684AP2DReTLDie0fObySc0fUqPYanuDZcCVinZz5drEYsBGhXofaWLbYtm5hx++5yLi2HXI2rrdmGUVxKSh/m4IF9jv4EX0P8NyCvG4uY5C8JEiQ4XBJ7JrwJxQ+fg22Y65Q5U00WrkLzBZPeuU0mp/buIoe1YlIbYcid43oZ7SQdVes3fqQtkdMwVogTs5xCgw9QWgE2ZDlSgoQPQUCl9GCv0+a; 24:U7cUSp32H1IzXYXX3LB1p5Nun3js5gfcixYJPZ/mSdLJVqYThnFLFilF6h0VlwVtlj8F9jfmsjKhBEnXrk120MGKWVCH9sy5+uFFjKvdb+k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 7:DhwMPVtvskq96oo+kh0zl85NnASMOlpytTCljCA7bHHNO0O6VrJbICXYBE0O/X2Y8KE9KyMD4BXwbg+nbaY6Hy//m2bqEvUDqrtXIyZ8SycOTETRTo0uR+cusFoez/E6OHej4V327aB7Uox4ANIc1uIj8azmo1YDy0VLr5QR3vlW+CudZ7GWmQQWpTVPixLsquIdZixJjqTt0cgjKNLsidWq9+kaqGVvCzUoamFzLLtqfeYn98Lauf3JOwbBxpj9coAzqIj2CyObgPQkUPcC+P8kK1geilt+La+Ekt+NdQB7h57VenGbYcUhWIOexBwAdLR7o79PzGyCcPUaJYGlIA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2017 20:00:26.1970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1725 Subject: [dpdk-dev] [PATCH 09/33] app/testeventdev: update options through the command line X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 May 2017 20:00:32 -0000 From: Guduri Prathyusha Add an infrastructure for updating the options through application specific command line arguments. Signed-off-by: Guduri Prathyusha Signed-off-by: Jerin Jacob --- app/test-eventdev/evt_options.c | 258 ++++++++++++++++++++++++++++++++++++++++ app/test-eventdev/evt_options.h | 19 +++ 2 files changed, 277 insertions(+) diff --git a/app/test-eventdev/evt_options.c b/app/test-eventdev/evt_options.c index c657ec306..9f83e364f 100644 --- a/app/test-eventdev/evt_options.c +++ b/app/test-eventdev/evt_options.c @@ -57,6 +57,264 @@ evt_options_default(struct evt_options *opt) opt->nb_pkts = (1ULL << 22); } +typedef int (*option_parser_t)(struct evt_options *opt, + const char *arg); + +struct long_opt_parser { + const char *lgopt_name; + option_parser_t parser_fn; +}; + +static int +evt_parse_nb_flows(struct evt_options *opt, const char *arg) +{ + int ret; + + ret = parser_read_uint32(&(opt->nb_flows), arg); + + return ret; +} + +static int +evt_parse_dev_id(struct evt_options *opt, const char *arg) +{ + int ret; + + ret = parser_read_uint8(&(opt->dev_id), arg); + + return ret; +} + +static int +evt_parse_verbose(struct evt_options *opt, const char *arg __rte_unused) +{ + opt->verbose_level = atoi(arg); + return 0; +} + +static int +evt_parse_fwd_latency(struct evt_options *opt, const char *arg __rte_unused) +{ + opt->fwd_latency = 1; + return 0; +} + +static int +evt_parse_queue_priority(struct evt_options *opt, const char *arg __rte_unused) +{ + opt->q_priority = 1; + return 0; +} + +static int +evt_parse_test_name(struct evt_options *opt, const char *arg) +{ + strcpy(opt->test_name, arg); + return 0; +} + +static int +evt_parse_plcore(struct evt_options *opt, const char *arg) +{ + opt->plcore = atoi(arg); + return 0; +} + +static int +evt_parse_slcore(struct evt_options *opt, const char *arg) +{ + opt->slcore = atoi(arg); + return 0; +} + +static int +evt_parse_socket_id(struct evt_options *opt, const char *arg) +{ + opt->socket_id = atoi(arg); + return 0; +} + +static int +evt_parse_wkr_deq_dep(struct evt_options *opt, const char *arg) +{ + int ret; + + ret = parser_read_uint16(&(opt->wkr_deq_dep), arg); + return ret; +} + +static int +evt_parse_nb_pkts(struct evt_options *opt, const char *arg) +{ + int ret; + + ret = parser_read_uint64(&(opt->nb_pkts), arg); + + return ret; +} + +static int +evt_parse_pool_sz(struct evt_options *opt, const char *arg) +{ + opt->pool_sz = atoi(arg); + + return 0; +} + +static int +evt_parse_plcores(struct evt_options *opt, const char *corelist) +{ + return parse_lcores_list(opt->plcores, corelist); +} + +static int +evt_parse_work_lcores(struct evt_options *opt, const char *corelist) +{ + return parse_lcores_list(opt->wlcores, corelist); +} + +static void +usage(char *program) +{ + printf("usage : %s [EAL options] -- [application options]\n", program); + printf("application options:\n"); + printf("\t--verbose : verbose level\n" + "\t--dev : device id of the event device\n" + "\t--test : name of the test application to run\n" + "\t--socket_id : socket_id of application resources\n" + "\t--pool_sz : pool size of the mempool\n" + "\t--plcore : lcore id of the producer\n" + "\t--slcore : lcore id of the scheduler\n" + "\t--plcores : list of lcore ids for producers\n" + "\t--wlcores : list of lcore ids for workers\n" + "\t--stlist : list of scheduled types of the stages\n" + "\t--nb_flows : number of flows to produce\n" + "\t--nb_pkts : number of packets to produce\n" + "\t--worker_deq_depth : dequeue depth of the worker\n" + "\t--fwd_latency : perform fwd_latency measurement\n" + "\t--queue_priority : enable queue priority\n" + ); + printf("available tests:\n"); + evt_test_dump_names(); +} + +static int +evt_parse_sched_type_list(struct evt_options *opt, const char *arg) +{ + char c; + int i = 0, j = -1; + + for (i = 0; i < EVT_MAX_STAGES; i++) + opt->sched_type_list[i] = (uint8_t)-1; + + i = 0; + + do { + c = arg[++j]; + + switch (c) { + case 'o': + case 'O': + opt->sched_type_list[i++] = RTE_SCHED_TYPE_ORDERED; + break; + case 'a': + case 'A': + opt->sched_type_list[i++] = RTE_SCHED_TYPE_ATOMIC; + break; + case 'p': + case 'P': + opt->sched_type_list[i++] = RTE_SCHED_TYPE_PARALLEL; + break; + case ',': + break; + default: + if (c != '\0') { + evt_err("invalid sched_type %c", c); + return -EINVAL; + } + } + } while (c != '\0'); + + opt->nb_stages = i; + return 0; +} + +static struct option lgopts[] = { + { EVT_NB_FLOWS, 1, 0, 0 }, + { EVT_DEVICE, 1, 0, 0 }, + { EVT_VERBOSE, 1, 0, 0 }, + { EVT_TEST, 1, 0, 0 }, + { EVT_PROD_LCORES, 1, 0, 0 }, + { EVT_WORK_LCORES, 1, 0, 0 }, + { EVT_PROD_LCORE, 1, 0, 0 }, + { EVT_SOCKET_ID, 1, 0, 0 }, + { EVT_POOL_SZ, 1, 0, 0 }, + { EVT_NB_PKTS, 1, 0, 0 }, + { EVT_WKR_DEQ_DEP, 1, 0, 0 }, + { EVT_SCHED_LCORE, 1, 0, 0 }, + { EVT_SCHED_TYPE_LIST, 1, 0, 0 }, + { EVT_FWD_LATENCY, 0, 0, 0 }, + { EVT_QUEUE_PRIORITY, 0, 0, 0 }, + { EVT_HELP, 0, 0, 0 }, + { NULL, 0, 0, 0 } +}; + +static int +evt_opts_parse_long(int opt_idx, struct evt_options *opt) +{ + unsigned int i; + + struct long_opt_parser parsermap[] = { + { EVT_NB_FLOWS, evt_parse_nb_flows}, + { EVT_DEVICE, evt_parse_dev_id}, + { EVT_VERBOSE, evt_parse_verbose}, + { EVT_TEST, evt_parse_test_name}, + { EVT_PROD_LCORES, evt_parse_plcores}, + { EVT_WORK_LCORES, evt_parse_work_lcores}, + { EVT_PROD_LCORE, evt_parse_plcore}, + { EVT_SOCKET_ID, evt_parse_socket_id}, + { EVT_POOL_SZ, evt_parse_pool_sz}, + { EVT_NB_PKTS, evt_parse_nb_pkts}, + { EVT_WKR_DEQ_DEP, evt_parse_wkr_deq_dep}, + { EVT_SCHED_LCORE, evt_parse_slcore}, + { EVT_SCHED_TYPE_LIST, evt_parse_sched_type_list}, + { EVT_FWD_LATENCY, evt_parse_fwd_latency}, + { EVT_QUEUE_PRIORITY, evt_parse_queue_priority}, + }; + + for (i = 0; i < RTE_DIM(parsermap); i++) { + if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name, + strlen(parsermap[i].lgopt_name)) == 0) + return parsermap[i].parser_fn(opt, optarg); + } + + return -EINVAL; +} + +int +evt_options_parse(struct evt_options *opt, int argc, char **argv) +{ + int opts, retval, opt_idx; + + while ((opts = getopt_long(argc, argv, "", lgopts, &opt_idx)) != EOF) { + switch (opts) { + case 0: /* long options */ + if (!strcmp(lgopts[opt_idx].name, "help")) { + usage(argv[0]); + exit(EXIT_SUCCESS); + } + + retval = evt_opts_parse_long(opt_idx, opt); + if (retval != 0) + return retval; + break; + default: + return -EINVAL; + } + } + return 0; +} + void evt_options_dump(struct evt_options *opt) { diff --git a/app/test-eventdev/evt_options.h b/app/test-eventdev/evt_options.h index b01e8daeb..47e46bc06 100644 --- a/app/test-eventdev/evt_options.h +++ b/app/test-eventdev/evt_options.h @@ -44,6 +44,24 @@ #define EVT_BOOL_FMT(x) ((x) ? "true" : "false") +#define EVT_VERBOSE ("verbose") +#define EVT_DEVICE ("dev") +#define EVT_TEST ("test") +#define EVT_PROD_LCORE ("plcore") +#define EVT_SCHED_LCORE ("slcore") +#define EVT_PROD_LCORES ("plcores") +#define EVT_WORK_LCORES ("wlcores") +#define EVT_NB_FLOWS ("nb_flows") +#define EVT_SOCKET_ID ("socket_id") +#define EVT_POOL_SZ ("pool_sz") +#define EVT_WKR_DEQ_DEP ("worker_deq_depth") +#define EVT_NB_PKTS ("nb_pkts") +#define EVT_NB_STAGES ("nb_stages") +#define EVT_SCHED_TYPE_LIST ("stlist") +#define EVT_FWD_LATENCY ("fwd_latency") +#define EVT_QUEUE_PRIORITY ("queue_priority") +#define EVT_HELP ("help") + struct evt_options { #define EVT_TEST_NAME_MAX_LEN 32 char test_name[EVT_TEST_NAME_MAX_LEN]; @@ -65,6 +83,7 @@ struct evt_options { }; void evt_options_default(struct evt_options *opt); +int evt_options_parse(struct evt_options *opt, int argc, char **argv); void evt_options_dump(struct evt_options *opt); /* options check helpers */ -- 2.13.0