#include <stdint.h>
#include <string.h>
#include <stdlib.h>
-#include <netinet/in.h>
-#include <termios.h>
-#ifndef __linux__
-#ifndef __FreeBSD__
-#include <net/socket.h>
-#endif
-#endif
#include <inttypes.h>
#include <errno.h>
#include <sys/queue.h>
#include <rte_eal.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
-#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_ring.h>
#include <rte_malloc.h>
#include <cmdline_parse_num.h>
#include <cmdline_parse_string.h>
#include <cmdline.h>
+#include <rte_string_fns.h>
#include "test.h"
};
static void cmd_autotest_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
{
struct test_command *t;
struct cmd_autotest_result *res = parsed_result;
}
static void cmd_dump_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- __attribute__((unused)) void *data)
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
{
struct cmd_dump_result *res = parsed_result;
};
static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
- __attribute__((unused)) void *data)
+ __rte_unused void *data)
{
struct cmd_dump_one_result *res = parsed_result;
};
static void
-cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
+cmd_quit_parsed(__rte_unused void *parsed_result,
struct cmdline *cl,
- __attribute__((unused)) void *data)
+ __rte_unused void *data)
{
cmdline_quit(cl);
}
};
static void cmd_set_rxtx_parsed(void *parsed_result, struct cmdline *cl,
- __attribute__((unused)) void *data)
+ __rte_unused void *data)
{
struct cmd_set_rxtx_result *res = parsed_result;
if (test_set_rxtx_conf(res->mode) < 0)
static void
cmd_set_rxtx_anchor_parsed(void *parsed_result,
struct cmdline *cl,
- __attribute__((unused)) void *data)
+ __rte_unused void *data)
{
struct cmd_set_rxtx_anchor *res = parsed_result;
if (test_set_rxtx_anchor(res->type) < 0)
static void
cmd_set_rxtx_sc_parsed(void *parsed_result,
struct cmdline *cl,
- __attribute__((unused)) void *data)
+ __rte_unused void *data)
{
struct cmd_set_rxtx_sc *res = parsed_result;
if (test_set_rxtx_sc(res->type) < 0)
int commands_init(void)
{
struct test_command *t;
- char *commands, *ptr;
+ char *commands;
int commands_len = 0;
TAILQ_FOREACH(t, &commands_list, next) {
commands_len += strlen(t->command) + 1;
}
- commands = malloc(commands_len + 1);
+ commands = (char *)calloc(commands_len, sizeof(char));
if (!commands)
return -1;
- ptr = commands;
TAILQ_FOREACH(t, &commands_list, next) {
- ptr += sprintf(ptr, "%s#", t->command);
+ strlcat(commands, t->command, commands_len);
+ if (TAILQ_NEXT(t, next) != NULL)
+ strlcat(commands, "#", commands_len);
}
- ptr--;
- ptr[0] = '\0';
cmd_autotest_autotest.string_data.str = commands;
return 0;
}
+
+int command_valid(const char *cmd)
+{
+ struct test_command *t;
+
+ TAILQ_FOREACH(t, &commands_list, next) {
+ if (strcmp(t->command, cmd) == 0)
+ return 1;
+ }
+ return 0;
+}