app: various changes
authorIntel <intel.com>
Tue, 12 Mar 2013 11:03:00 +0000 (12:03 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 25 Jul 2013 14:07:51 +0000 (16:07 +0200)
Signed-off-by: Intel
app/test-pmd/cmdline.c
app/test/autotest_data.py
app/test/test_cmdline_string.c
app/test/test_eal_flags.c
app/test/test_lpm.c
app/test/test_tailq.c

index 8eb15bd..880d4af 100644 (file)
@@ -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;
 
index 7c5b964..5270447 100644 (file)
@@ -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.
index 773d693..32cea79 100644 (file)
@@ -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 */
index c3754d9..cdbe87a 100644 (file)
@@ -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;
        }
index 158d8ac..ad71730 100644 (file)
@@ -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) {
index 24fbd29..b303033 100644 (file)
@@ -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;
 }