From 5bf969e63bf8881e58faaff0f226e089d2c7cd0c Mon Sep 17 00:00:00 2001 From: Dave Goodell Date: Wed, 26 Feb 2014 07:48:05 +0000 Subject: [PATCH] usnic: unit test parse_ifex_str Reviewed-by: Jeff Squyres cmr=v1.7.5:ticket=trac:4253 This commit was SVN r30846. The following Trac tickets were found above: Ticket 4253 --> https://svn.open-mpi.org/trac/ompi/ticket/4253 --- ompi/mca/btl/usnic/Makefile.am | 6 ++- ompi/mca/btl/usnic/btl_usnic_component.c | 2 + .../btl/usnic/test/btl_usnic_component_test.h | 54 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 ompi/mca/btl/usnic/test/btl_usnic_component_test.h diff --git a/ompi/mca/btl/usnic/Makefile.am b/ompi/mca/btl/usnic/Makefile.am index dc847d76ec..3af24dd5e9 100644 --- a/ompi/mca/btl/usnic/Makefile.am +++ b/ompi/mca/btl/usnic/Makefile.am @@ -27,6 +27,9 @@ EXTRA_DIST = README.txt README.test dist_ompidata_DATA = \ help-mpi-btl-usnic.txt +test_sources = \ + test/btl_usnic_component_test.h + sources = \ btl_usnic_compat.h \ btl_usnic_module.c \ @@ -52,7 +55,8 @@ sources = \ btl_usnic_util.c \ btl_usnic_util.h \ btl_usnic_test.c \ - btl_usnic_test.h + btl_usnic_test.h \ + $(test_sources) if OPAL_HAVE_HWLOC sources += btl_usnic_hwloc.c diff --git a/ompi/mca/btl/usnic/btl_usnic_component.c b/ompi/mca/btl/usnic/btl_usnic_component.c index b55666f1f4..14400d36fe 100644 --- a/ompi/mca/btl/usnic/btl_usnic_component.c +++ b/ompi/mca/btl/usnic/btl_usnic_component.c @@ -1584,3 +1584,5 @@ void ompi_btl_usnic_component_debug(void) ompi_btl_usnic_print_stats(module, " manual", /*reset=*/false); } } + +#include "test/btl_usnic_component_test.h" diff --git a/ompi/mca/btl/usnic/test/btl_usnic_component_test.h b/ompi/mca/btl/usnic/test/btl_usnic_component_test.h new file mode 100644 index 0000000000..d5ba084553 --- /dev/null +++ b/ompi/mca/btl/usnic/test/btl_usnic_component_test.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "btl_usnic_test.h" + +/* see README.test for info about why/how this file is included into another + * source file */ +#if OMPI_BTL_USNIC_UNIT_TESTS + +static int test_parse_ifex_str(void *ctx) +{ + usnic_if_filter_t *f; + + f = parse_ifex_str(NULL, "include"); + check(f == NULL); + free_filter(f); + + f = parse_ifex_str("", "include"); + check(f == NULL); + free_filter(f); + + f = parse_ifex_str("usnic_1,usnic_0", "include"); + check(f != NULL); + check(f->n_elt == 2); + check(f->elts != NULL); + check(f->elts[0].is_netmask == false); + check_str_eq(f->elts[0].if_name, "usnic_1"); + check(f->elts[1].is_netmask == false); + check_str_eq(f->elts[1].if_name, "usnic_0"); + free_filter(f); + + f = parse_ifex_str("usnic_1,1.2.3.0/24", "exclude"); + check(f != NULL); + check(f->n_elt == 2); + check(f->elts != NULL); + check(f->elts[0].is_netmask == false); + check_str_eq(f->elts[0].if_name, "usnic_1"); + check(f->elts[1].is_netmask == true); + check(f->elts[1].addr == htonl(0x01020300)); + check(f->elts[1].prefixlen == 24); + free_filter(f); + + return 0; +} + +USNIC_REGISTER_TEST("test_parse_ifex_str", test_parse_ifex_str, NULL) + +#endif