aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bpf/t1.c14
-rw-r--r--test/bpf/t3.c13
-rw-r--r--test/test/test.c6
-rw-r--r--test/test/test_bpf.c108
-rw-r--r--test/test/test_common.c32
-rw-r--r--test/test/test_hash_readwrite.c20
-rw-r--r--test/test/test_kni.c2
-rw-r--r--test/test/test_power_acpi_cpufreq.c2
-rw-r--r--test/test/test_reorder.c2
9 files changed, 177 insertions, 22 deletions
diff --git a/test/bpf/t1.c b/test/bpf/t1.c
index 60f9434a..3364b4f1 100644
--- a/test/bpf/t1.c
+++ b/test/bpf/t1.c
@@ -20,32 +20,36 @@
* (011) ret #1
* (012) ret #0
*
- * To compile:
- * clang -O2 -target bpf -c t1.c
+ * To compile on x86:
+ * clang -O2 -U __GNUC__ -target bpf -c t1.c
+ *
+ * To compile on ARM:
+ * clang -O2 -I/usr/include/aarch64-linux-gnu/ -target bpf -c t1.c
*/
#include <stdint.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
#include <netinet/udp.h>
+#include <arpa/inet.h>
uint64_t
entry(void *pkt)
{
struct ether_header *ether_header = (void *)pkt;
- if (ether_header->ether_type != __builtin_bswap16(0x0800))
+ if (ether_header->ether_type != htons(0x0800))
return 0;
struct iphdr *iphdr = (void *)(ether_header + 1);
if (iphdr->protocol != 17 || (iphdr->frag_off & 0x1ffff) != 0 ||
- iphdr->daddr != __builtin_bswap32(0x1020304))
+ iphdr->daddr != htonl(0x1020304))
return 0;
int hlen = iphdr->ihl * 4;
struct udphdr *udphdr = (void *)iphdr + hlen;
- if (udphdr->dest != __builtin_bswap16(5000))
+ if (udphdr->dest != htons(5000))
return 0;
return 1;
diff --git a/test/bpf/t3.c b/test/bpf/t3.c
index 531b9cb8..9ba34638 100644
--- a/test/bpf/t3.c
+++ b/test/bpf/t3.c
@@ -6,9 +6,15 @@
* eBPF program sample.
* Accepts pointer to struct rte_mbuf as an input parameter.
* Dump the mbuf into stdout if it is an ARP packet (aka tcpdump 'arp').
- * To compile:
- * clang -O2 -I${RTE_SDK}/${RTE_TARGET}/include \
+ *
+ * To compile on x86:
+ * clang -O2 -U __GNUC__ -I${RTE_SDK}/${RTE_TARGET}/include \
* -target bpf -Wno-int-to-void-pointer-cast -c t3.c
+ *
+ * To compile on ARM:
+ * clang -O2 -I/usr/include/aarch64-linux-gnu \
+ * -I${RTE_SDK}/${RTE_TARGET}/include -target bpf \
+ * -Wno-int-to-void-pointer-cast -c t3.c
*/
#include <stdint.h>
@@ -17,6 +23,7 @@
#include <net/ethernet.h>
#include <rte_config.h>
#include "mbuf.h"
+#include <arpa/inet.h>
extern void rte_pktmbuf_dump(FILE *, const struct rte_mbuf *, unsigned int);
@@ -29,7 +36,7 @@ entry(const void *pkt)
mb = pkt;
eth = rte_pktmbuf_mtod(mb, const struct ether_header *);
- if (eth->ether_type == __builtin_bswap16(ETHERTYPE_ARP))
+ if (eth->ether_type == htons(ETHERTYPE_ARP))
rte_pktmbuf_dump(stdout, mb, 64);
return 1;
diff --git a/test/test/test.c b/test/test/test.c
index 24df6299..12fabd0b 100644
--- a/test/test/test.c
+++ b/test/test/test.c
@@ -102,8 +102,10 @@ main(int argc, char **argv)
/* merge argc/argv and the environment args */
all_argc = argc + eargc;
all_argv = malloc(sizeof(*all_argv) * (all_argc + 1));
- if (all_argv == NULL)
- return -1;
+ if (all_argv == NULL) {
+ ret = -1;
+ goto out;
+ }
for (i = 0; i < argc; i++)
all_argv[i] = argv[i];
diff --git a/test/test/test_bpf.c b/test/test/test_bpf.c
index fa17c4f7..1d50401a 100644
--- a/test/test/test_bpf.c
+++ b/test/test/test_bpf.c
@@ -48,6 +48,12 @@ struct dummy_vect8 {
#define TEST_JCC_3 5678
#define TEST_JCC_4 TEST_FILL_1
+#define TEST_IMM_1 UINT64_MAX
+#define TEST_IMM_2 ((uint64_t)INT64_MIN)
+#define TEST_IMM_3 ((uint64_t)INT64_MAX + INT32_MAX)
+#define TEST_IMM_4 ((uint64_t)UINT32_MAX)
+#define TEST_IMM_5 ((uint64_t)UINT32_MAX + 1)
+
struct bpf_test {
const char *name;
size_t arg_sz;
@@ -268,6 +274,94 @@ test_load1_check(uint64_t rc, const void *arg)
return cmp_res(__func__, v, rc, dft, dft, sizeof(*dft));
}
+/* load immediate test-cases */
+static const struct ebpf_insn test_ldimm1_prog[] = {
+
+ {
+ .code = (BPF_LD | BPF_IMM | EBPF_DW),
+ .dst_reg = EBPF_REG_0,
+ .imm = (uint32_t)TEST_IMM_1,
+ },
+ {
+ .imm = TEST_IMM_1 >> 32,
+ },
+ {
+ .code = (BPF_LD | BPF_IMM | EBPF_DW),
+ .dst_reg = EBPF_REG_3,
+ .imm = (uint32_t)TEST_IMM_2,
+ },
+ {
+ .imm = TEST_IMM_2 >> 32,
+ },
+ {
+ .code = (BPF_LD | BPF_IMM | EBPF_DW),
+ .dst_reg = EBPF_REG_5,
+ .imm = (uint32_t)TEST_IMM_3,
+ },
+ {
+ .imm = TEST_IMM_3 >> 32,
+ },
+ {
+ .code = (BPF_LD | BPF_IMM | EBPF_DW),
+ .dst_reg = EBPF_REG_7,
+ .imm = (uint32_t)TEST_IMM_4,
+ },
+ {
+ .imm = TEST_IMM_4 >> 32,
+ },
+ {
+ .code = (BPF_LD | BPF_IMM | EBPF_DW),
+ .dst_reg = EBPF_REG_9,
+ .imm = (uint32_t)TEST_IMM_5,
+ },
+ {
+ .imm = TEST_IMM_5 >> 32,
+ },
+ /* return sum */
+ {
+ .code = (EBPF_ALU64 | BPF_ADD | BPF_X),
+ .dst_reg = EBPF_REG_0,
+ .src_reg = EBPF_REG_3,
+ },
+ {
+ .code = (EBPF_ALU64 | BPF_ADD | BPF_X),
+ .dst_reg = EBPF_REG_0,
+ .src_reg = EBPF_REG_5,
+ },
+ {
+ .code = (EBPF_ALU64 | BPF_ADD | BPF_X),
+ .dst_reg = EBPF_REG_0,
+ .src_reg = EBPF_REG_7,
+ },
+ {
+ .code = (EBPF_ALU64 | BPF_ADD | BPF_X),
+ .dst_reg = EBPF_REG_0,
+ .src_reg = EBPF_REG_9,
+ },
+ {
+ .code = (BPF_JMP | EBPF_EXIT),
+ },
+};
+
+static int
+test_ldimm1_check(uint64_t rc, const void *arg)
+{
+ uint64_t v1, v2;
+
+ v1 = TEST_IMM_1;
+ v2 = TEST_IMM_2;
+ v1 += v2;
+ v2 = TEST_IMM_3;
+ v1 += v2;
+ v2 = TEST_IMM_4;
+ v1 += v2;
+ v2 = TEST_IMM_5;
+ v1 += v2;
+
+ return cmp_res(__func__, v1, rc, arg, arg, 0);
+}
+
+
/* alu mul test-cases */
static const struct ebpf_insn test_mul1_prog[] = {
@@ -1727,6 +1821,20 @@ static const struct bpf_test tests[] = {
.check_result = test_load1_check,
},
{
+ .name = "test_ldimm1",
+ .arg_sz = sizeof(struct dummy_offset),
+ .prm = {
+ .ins = test_ldimm1_prog,
+ .nb_ins = RTE_DIM(test_ldimm1_prog),
+ .prog_arg = {
+ .type = RTE_BPF_ARG_PTR,
+ .size = sizeof(struct dummy_offset),
+ },
+ },
+ .prepare = test_store1_prepare,
+ .check_result = test_ldimm1_check,
+ },
+ {
.name = "test_mul1",
.arg_sz = sizeof(struct dummy_vect8),
.prm = {
diff --git a/test/test/test_common.c b/test/test/test_common.c
index 7a67e458..c6d17baa 100644
--- a/test/test/test_common.c
+++ b/test/test/test_common.c
@@ -189,6 +189,37 @@ test_log2(void)
}
static int
+test_fls(void)
+{
+ struct fls_test_vector {
+ uint32_t arg;
+ int rc;
+ };
+ int expected, rc;
+ uint32_t i, arg;
+
+ const struct fls_test_vector test[] = {
+ {0x0, 0},
+ {0x1, 1},
+ {0x4000, 15},
+ {0x80000000, 32},
+ };
+
+ for (i = 0; i < RTE_DIM(test); i++) {
+ arg = test[i].arg;
+ rc = rte_fls_u32(arg);
+ expected = test[i].rc;
+ if (rc != expected) {
+ printf("Wrong rte_fls_u32(0x%x) rc=%d, expected=%d\n",
+ arg, rc, expected);
+ return TEST_FAILED;
+ }
+ }
+
+ return 0;
+}
+
+static int
test_common(void)
{
int ret = 0;
@@ -196,6 +227,7 @@ test_common(void)
ret |= test_macros(0);
ret |= test_misc();
ret |= test_log2();
+ ret |= test_fls();
return ret;
}
diff --git a/test/test/test_hash_readwrite.c b/test/test/test_hash_readwrite.c
index 01f986cf..6b695ce6 100644
--- a/test/test/test_hash_readwrite.c
+++ b/test/test/test_hash_readwrite.c
@@ -678,24 +678,26 @@ test_hash_readwrite_main(void)
reader_faster) < 0)
return -1;
+ printf("================\n");
printf("Results summary:\n");
+ printf("================\n");
printf("single read: %u\n", htm_results.single_read);
printf("single write: %u\n", htm_results.single_write);
for (i = 0; i < NUM_TEST; i++) {
- printf("core_cnt: %u\n", core_cnt[i]);
+ printf("+++ core_cnt: %u +++\n", core_cnt[i]);
printf("HTM:\n");
- printf("read only: %u\n", htm_results.read_only[i]);
- printf("write only: %u\n", htm_results.write_only[i]);
- printf("read-write read: %u\n", htm_results.read_write_r[i]);
- printf("read-write write: %u\n", htm_results.read_write_w[i]);
+ printf(" read only: %u\n", htm_results.read_only[i]);
+ printf(" write only: %u\n", htm_results.write_only[i]);
+ printf(" read-write read: %u\n", htm_results.read_write_r[i]);
+ printf(" read-write write: %u\n", htm_results.read_write_w[i]);
printf("non HTM:\n");
- printf("read only: %u\n", non_htm_results.read_only[i]);
- printf("write only: %u\n", non_htm_results.write_only[i]);
- printf("read-write read: %u\n",
+ printf(" read only: %u\n", non_htm_results.read_only[i]);
+ printf(" write only: %u\n", non_htm_results.write_only[i]);
+ printf(" read-write read: %u\n",
non_htm_results.read_write_r[i]);
- printf("read-write write: %u\n",
+ printf(" read-write write: %u\n",
non_htm_results.read_write_w[i]);
}
diff --git a/test/test/test_kni.c b/test/test/test_kni.c
index f3c19b5a..c92c0905 100644
--- a/test/test/test_kni.c
+++ b/test/test/test_kni.c
@@ -549,7 +549,7 @@ test_kni(void)
if (!dir) {
if (errno == ENOENT) {
printf("Cannot run UT due to missing rte_kni module\n");
- return -1;
+ return TEST_SKIPPED;
}
printf("opendir: %s", strerror(errno));
return -1;
diff --git a/test/test/test_power_acpi_cpufreq.c b/test/test/test_power_acpi_cpufreq.c
index 22e541d6..6d637cc7 100644
--- a/test/test/test_power_acpi_cpufreq.c
+++ b/test/test/test_power_acpi_cpufreq.c
@@ -441,7 +441,7 @@ test_power_acpi_cpufreq(void)
"correctly(APCI cpufreq) or operating in another valid "
"Power management environment\n", TEST_POWER_LCORE_ID);
rte_power_unset_env();
- return -1;
+ return TEST_SKIPPED;
}
/**
diff --git a/test/test/test_reorder.c b/test/test/test_reorder.c
index ccee4d08..58fa9c71 100644
--- a/test/test/test_reorder.c
+++ b/test/test/test_reorder.c
@@ -269,7 +269,7 @@ test_reorder_drain(void)
goto exit;
}
if (robufs[0] != NULL)
- rte_pktmbuf_free(robufs[i]);
+ rte_pktmbuf_free(robufs[0]);
/* Insert more packets
* RB[] = {NULL, NULL, NULL, NULL}