X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest%2Ftest_ivshmem.c;h=e759939cba6dbff2cd9c909f6ac3c2a8c4293832;hb=942405f9e2f2c22aa817be374ccfe939a72df2ce;hp=52f82779c3889bcac465851366a7729123ceb216;hpb=40b966a211ab71e96b8e155d9058f224e7b5bbf6;p=dpdk.git diff --git a/app/test/test_ivshmem.c b/app/test/test_ivshmem.c index 52f82779c3..e759939cba 100644 --- a/app/test/test_ivshmem.c +++ b/app/test/test_ivshmem.c @@ -1,13 +1,13 @@ /*- * 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 @@ -17,7 +17,7 @@ * * 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 @@ -73,18 +73,19 @@ get_current_prefix(char * prefix, int size) 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; } @@ -96,7 +97,7 @@ mmap_metadata(const char *name) 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); @@ -135,7 +136,7 @@ test_ivshmem_create_lots_of_memzones(void) "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"); @@ -263,10 +264,10 @@ test_ivshmem_api_test(void) ASSERT(strnlen(buf, sizeof(buf)) != 0, "Buffer is empty"); /* make sure we don't segfault */ - rte_ivshmem_metadata_dump(NULL); + rte_ivshmem_metadata_dump(stdout, NULL); /* dump our metadata */ - rte_ivshmem_metadata_dump(METADATA_NAME); + rte_ivshmem_metadata_dump(stdout, METADATA_NAME); return 0; } @@ -312,7 +313,7 @@ test_ivshmem_create_multiple_metadata_configs(void) 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); @@ -333,7 +334,7 @@ test_ivshmem_create_too_many_metadata_configs(void) 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"); } @@ -368,7 +369,7 @@ launch_all_tests_on_secondary_processes(void) 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 }; @@ -430,12 +431,10 @@ test_ivshmem(void) return -1; } -#else /* RTE_LIBRTE_IVSHMEM */ -int -test_ivshmem(void) -{ - printf("This binary was not compiled with IVSHMEM support!\n"); - return 0; -} +static struct test_command ivshmem_cmd = { + .command = "ivshmem_autotest", + .callback = test_ivshmem, +}; +REGISTER_TEST_COMMAND(ivshmem_cmd); #endif /* RTE_LIBRTE_IVSHMEM */