From: Intel Date: Tue, 12 Mar 2013 11:03:00 +0000 (+0100) Subject: app: various changes X-Git-Tag: spdx-start~11273 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ce8f00eaaac555aadea68294b716b57e7cb1b998;p=dpdk.git app: various changes Signed-off-by: Intel --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 8eb15bd1b2..880d4af70f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -1532,7 +1532,7 @@ cmd_vlan_offload_parsed(void *parsed_result, str[i]='\0'; tmp = strtoul(str, NULL, 0); /* If port_id greater that what portid_t can represent, return */ - if(tmp > 255) + if(tmp >= RTE_MAX_ETHPORTS) return; port_id = (portid_t)tmp; diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py index 7c5b96449d..527044767e 100644 --- a/app/test/autotest_data.py +++ b/app/test/autotest_data.py @@ -39,7 +39,10 @@ from autotest_test_funcs import * # quick and dirty function to find out number of sockets def num_sockets(): - return len(glob("/sys/devices/system/node/node*")) + result = len(glob("/sys/devices/system/node/node*")) + if result == 0: + return 1 + return result # multiply given number for all sockets # e.g. 32 becomes 32,32 or 32,32,32,32 etc. diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 773d69315b..32cea79a35 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -66,7 +66,10 @@ struct string_elt_str string_elt_strs[] = { {"one#two\nwith\nnewlines#three", "two\nwith\nnewlines", 1}, }; - +#if CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE +#undef CMDLINE_TEST_BUFSIZE +#define CMDLINE_TEST_BUFSIZE STR_TOKEN_SIZE +#endif struct string_nb_str { const char * str; /* parsed string */ diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c index c3754d9391..cdbe87a4b7 100644 --- a/app/test/test_eal_flags.c +++ b/app/test/test_eal_flags.c @@ -115,7 +115,8 @@ process_hugefiles(const char * prefix, enum hugepage_action action) const int prefix_len = rte_snprintf(hugefile_prefix, sizeof(hugefile_prefix), "%smap_", prefix); - if (prefix_len <= 0 || prefix_len >= (int)sizeof(hugefile_prefix)) { + if (prefix_len <= 0 || prefix_len >= (int)sizeof(hugefile_prefix) + || prefix_len >= (int)sizeof(dirent->d_name)) { printf("Error creating hugefile filename prefix\n"); return -1; } @@ -229,6 +230,11 @@ get_number_of_sockets(void) /* check if directory exists */ if ((dir = opendir(nodedir)) == NULL) { + /* if errno==ENOENT this means we don't have NUMA support */ + if (errno == ENOENT) { + printf("No NUMA nodes detected: assuming 1 available socket\n"); + return 1; + } printf("Error opening %s: %s\n", nodedir, strerror(errno)); return -1; } diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c index 158d8ace1f..ad71730fd6 100644 --- a/app/test/test_lpm.c +++ b/app/test/test_lpm.c @@ -938,9 +938,9 @@ test14(void) lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, 256 * 32, 0); TEST_LPM_ASSERT(lpm != NULL); - ip = IPv4(0, 0, 0, 0); depth = 32; next_hop_add = 100; + ip = IPv4(0, 0, 0, 0); /* Add 256 rules that require a tbl8 extension */ for (; ip <= IPv4(0, 0, 255, 0); ip += 256) { diff --git a/app/test/test_tailq.c b/app/test/test_tailq.c index 24fbd29cf4..b303033272 100644 --- a/app/test/test_tailq.c +++ b/app/test/test_tailq.c @@ -114,11 +114,53 @@ test_tailq_lookup(void) return 0; } +/* test for deprecated functions - mainly for coverage */ +static int +test_tailq_deprecated(void) +{ + struct rte_dummy_head *d_head; + + /* since TAILQ_RESERVE is not able to create new tailqs, + * we should find an existing one (IOW, RTE_TAILQ_RESERVE behaves identical + * to RTE_TAILQ_LOOKUP). + * + * PCI_RESOURCE_LIST tailq is guaranteed to + * be present in any DPDK app. */ + d_head = RTE_TAILQ_RESERVE("PCI_RESOURCE_LIST", rte_dummy_head); + if (d_head == NULL) + do_return("Error finding PCI_RESOURCE_LIST\n"); + + d_head = RTE_TAILQ_LOOKUP("PCI_RESOURCE_LIST", rte_dummy_head); + if (d_head == NULL) + do_return("Error finding PCI_RESOURCE_LIST\n"); + + /* try doing that with non-existent names */ + d_head = RTE_TAILQ_RESERVE("random name", rte_dummy_head); + if (d_head != NULL) + do_return("Non-existent tailq found!\n"); + + d_head = RTE_TAILQ_LOOKUP("random name", rte_dummy_head); + if (d_head != NULL) + do_return("Non-existent tailq found!\n"); + + /* try doing the same with NULL names */ + d_head = RTE_TAILQ_RESERVE(NULL, rte_dummy_head); + if (d_head != NULL) + do_return("NULL tailq found!\n"); + + d_head = RTE_TAILQ_LOOKUP(NULL, rte_dummy_head); + if (d_head != NULL) + do_return("NULL tailq found!\n"); + + return 0; +} + int test_tailq(void) { int ret = 0; ret |= test_tailq_create(); ret |= test_tailq_lookup(); + ret |= test_tailq_deprecated(); return ret; }