/*-
* BSD LICENSE
- *
+ *
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#include "test.h"
-#ifdef RTE_LIBRTE_IVSHMEM
-
#include <rte_common.h>
#include <rte_ivshmem.h>
#include <rte_string_fns.h>
char buf[PATH_MAX] = {0};
/* get file for config (fd is always 3) */
- rte_snprintf(path, sizeof(path), "/proc/self/fd/%d", 3);
+ snprintf(path, sizeof(path), "/proc/self/fd/%d", 3);
/* return NULL on error */
if (readlink(path, buf, sizeof(buf)) == -1)
return NULL;
/* get the basename */
- rte_snprintf(buf, sizeof(buf), "%s", basename(buf));
+ snprintf(buf, sizeof(buf), "%s", basename(buf));
/* copy string all the way from second char up to start of _config */
- rte_snprintf(prefix, size, "%.*s",
- strnlen(buf, sizeof(buf)) - sizeof("_config"), &buf[1]);
+ snprintf(prefix, size, "%.*s",
+ (int)(strnlen(buf, sizeof(buf)) - sizeof("_config")),
+ &buf[1]);
return prefix;
}
char pathname[PATH_MAX];
struct rte_ivshmem_metadata *metadata;
- rte_snprintf(pathname, sizeof(pathname),
+ snprintf(pathname, sizeof(pathname),
"/var/run/.dpdk_ivshmem_metadata_%s", name);
fd = open(pathname, O_RDWR, 0660);
"Failed to create metadata");
for (i = 0; i < RTE_LIBRTE_IVSHMEM_MAX_ENTRIES; i++) {
- rte_snprintf(name, sizeof(name), "mz_%i", i);
+ snprintf(name, sizeof(name), "mz_%i", i);
mz = rte_memzone_reserve(name, CACHE_LINE_SIZE, SOCKET_ID_ANY, 0);
ASSERT(mz != NULL, "Failed to reserve memzone");
struct rte_ivshmem_metadata *metadata;
for (i = 0; i < RTE_LIBRTE_IVSHMEM_MAX_METADATA_FILES / 2; i++) {
- rte_snprintf(name, sizeof(name), "test_%d", i);
+ snprintf(name, sizeof(name), "test_%d", i);
rte_ivshmem_metadata_create(name);
metadata = mmap_metadata(name);
char name[IVSHMEM_NAME_LEN];
for (i = 0; i < RTE_LIBRTE_IVSHMEM_MAX_METADATA_FILES; i++) {
- rte_snprintf(name, sizeof(name), "test_%d", i);
+ snprintf(name, sizeof(name), "test_%d", i);
ASSERT(rte_ivshmem_metadata_create(name) == 0,
"Create config file failed");
}
get_current_prefix(tmp, sizeof(tmp));
- rte_snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
+ snprintf(prefix, sizeof(prefix), "--file-prefix=%s", tmp);
const char *argv[] = { prgname, "-c", "1", "-n", "3",
"--proc-type=secondary", prefix };
return -1;
}
-#else /* RTE_LIBRTE_IVSHMEM */
-int
-test_ivshmem(void)
-{
- printf("This binary was not compiled with IVSHMEM support!\n");
- return 0;
-}
-#endif /* RTE_LIBRTE_IVSHMEM */
+static struct test_command ivshmem_cmd = {
+ .command = "ivshmem_autotest",
+ .callback = test_ivshmem,
+};
+REGISTER_TEST_COMMAND(ivshmem_cmd);