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;
# 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.
{"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 */
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;
}
/* 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;
}
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) {
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;
}