app/compress-perf: add parser
[dpdk.git] / app / test-compress-perf / main.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Intel Corporation
3  */
4
5 #include <rte_malloc.h>
6 #include <rte_eal.h>
7 #include <rte_log.h>
8 #include <rte_compressdev.h>
9
10 #include "comp_perf_options.h"
11
12 int
13 main(int argc, char **argv)
14 {
15         int ret;
16         struct comp_test_data *test_data;
17
18         /* Initialise DPDK EAL */
19         ret = rte_eal_init(argc, argv);
20         if (ret < 0)
21                 rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n");
22         argc -= ret;
23         argv += ret;
24
25         test_data = rte_zmalloc_socket(NULL, sizeof(struct comp_test_data),
26                                         0, rte_socket_id());
27
28         if (test_data == NULL)
29                 rte_exit(EXIT_FAILURE, "Cannot reserve memory in socket %d\n",
30                                 rte_socket_id());
31
32         comp_perf_options_default(test_data);
33
34         if (comp_perf_options_parse(test_data, argc, argv) < 0) {
35                 RTE_LOG(ERR, USER1,
36                         "Parsing one or more user options failed\n");
37                 ret = EXIT_FAILURE;
38                 goto err;
39         }
40
41         if (comp_perf_options_check(test_data) < 0) {
42                 ret = EXIT_FAILURE;
43                 goto err;
44         }
45
46         ret = EXIT_SUCCESS;
47
48 err:
49         rte_free(test_data);
50
51         return ret;
52 }