mirror of https://gitee.com/openkylin/linux.git
selftests/bpf/test_progs: do not check errno == 0
The errno man page states: "The value in errno is significant only when the return value of the call indicated an error..." then it is not correct to check it, it could be different than zero even if the function succeeded. It causes some false positives if errno is set by a previous function. Signed-off-by: Mauricio Vasquez B <mauricio.vasquez@polito.it> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
ad1242d8a0
commit
f5bd3948eb
|
@ -112,13 +112,13 @@ static void test_pkt_access(void)
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, 100000, &pkt_v4, sizeof(pkt_v4),
|
err = bpf_prog_test_run(prog_fd, 100000, &pkt_v4, sizeof(pkt_v4),
|
||||||
NULL, NULL, &retval, &duration);
|
NULL, NULL, &retval, &duration);
|
||||||
CHECK(err || errno || retval, "ipv4",
|
CHECK(err || retval, "ipv4",
|
||||||
"err %d errno %d retval %d duration %d\n",
|
"err %d errno %d retval %d duration %d\n",
|
||||||
err, errno, retval, duration);
|
err, errno, retval, duration);
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, 100000, &pkt_v6, sizeof(pkt_v6),
|
err = bpf_prog_test_run(prog_fd, 100000, &pkt_v6, sizeof(pkt_v6),
|
||||||
NULL, NULL, &retval, &duration);
|
NULL, NULL, &retval, &duration);
|
||||||
CHECK(err || errno || retval, "ipv6",
|
CHECK(err || retval, "ipv6",
|
||||||
"err %d errno %d retval %d duration %d\n",
|
"err %d errno %d retval %d duration %d\n",
|
||||||
err, errno, retval, duration);
|
err, errno, retval, duration);
|
||||||
bpf_object__close(obj);
|
bpf_object__close(obj);
|
||||||
|
@ -153,14 +153,14 @@ static void test_xdp(void)
|
||||||
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
|
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
|
|
||||||
CHECK(err || errno || retval != XDP_TX || size != 74 ||
|
CHECK(err || retval != XDP_TX || size != 74 ||
|
||||||
iph->protocol != IPPROTO_IPIP, "ipv4",
|
iph->protocol != IPPROTO_IPIP, "ipv4",
|
||||||
"err %d errno %d retval %d size %d\n",
|
"err %d errno %d retval %d size %d\n",
|
||||||
err, errno, retval, size);
|
err, errno, retval, size);
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, 1, &pkt_v6, sizeof(pkt_v6),
|
err = bpf_prog_test_run(prog_fd, 1, &pkt_v6, sizeof(pkt_v6),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
CHECK(err || errno || retval != XDP_TX || size != 114 ||
|
CHECK(err || retval != XDP_TX || size != 114 ||
|
||||||
iph6->nexthdr != IPPROTO_IPV6, "ipv6",
|
iph6->nexthdr != IPPROTO_IPV6, "ipv6",
|
||||||
"err %d errno %d retval %d size %d\n",
|
"err %d errno %d retval %d size %d\n",
|
||||||
err, errno, retval, size);
|
err, errno, retval, size);
|
||||||
|
@ -185,13 +185,13 @@ static void test_xdp_adjust_tail(void)
|
||||||
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
|
err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
|
|
||||||
CHECK(err || errno || retval != XDP_DROP,
|
CHECK(err || retval != XDP_DROP,
|
||||||
"ipv4", "err %d errno %d retval %d size %d\n",
|
"ipv4", "err %d errno %d retval %d size %d\n",
|
||||||
err, errno, retval, size);
|
err, errno, retval, size);
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, 1, &pkt_v6, sizeof(pkt_v6),
|
err = bpf_prog_test_run(prog_fd, 1, &pkt_v6, sizeof(pkt_v6),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
CHECK(err || errno || retval != XDP_TX || size != 54,
|
CHECK(err || retval != XDP_TX || size != 54,
|
||||||
"ipv6", "err %d errno %d retval %d size %d\n",
|
"ipv6", "err %d errno %d retval %d size %d\n",
|
||||||
err, errno, retval, size);
|
err, errno, retval, size);
|
||||||
bpf_object__close(obj);
|
bpf_object__close(obj);
|
||||||
|
@ -254,14 +254,14 @@ static void test_l4lb(const char *file)
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v4, sizeof(pkt_v4),
|
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v4, sizeof(pkt_v4),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
CHECK(err || errno || retval != 7/*TC_ACT_REDIRECT*/ || size != 54 ||
|
CHECK(err || retval != 7/*TC_ACT_REDIRECT*/ || size != 54 ||
|
||||||
*magic != MAGIC_VAL, "ipv4",
|
*magic != MAGIC_VAL, "ipv4",
|
||||||
"err %d errno %d retval %d size %d magic %x\n",
|
"err %d errno %d retval %d size %d magic %x\n",
|
||||||
err, errno, retval, size, *magic);
|
err, errno, retval, size, *magic);
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v6, sizeof(pkt_v6),
|
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v6, sizeof(pkt_v6),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
CHECK(err || errno || retval != 7/*TC_ACT_REDIRECT*/ || size != 74 ||
|
CHECK(err || retval != 7/*TC_ACT_REDIRECT*/ || size != 74 ||
|
||||||
*magic != MAGIC_VAL, "ipv6",
|
*magic != MAGIC_VAL, "ipv6",
|
||||||
"err %d errno %d retval %d size %d magic %x\n",
|
"err %d errno %d retval %d size %d magic %x\n",
|
||||||
err, errno, retval, size, *magic);
|
err, errno, retval, size, *magic);
|
||||||
|
@ -343,14 +343,14 @@ static void test_xdp_noinline(void)
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v4, sizeof(pkt_v4),
|
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v4, sizeof(pkt_v4),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
CHECK(err || errno || retval != 1 || size != 54 ||
|
CHECK(err || retval != 1 || size != 54 ||
|
||||||
*magic != MAGIC_VAL, "ipv4",
|
*magic != MAGIC_VAL, "ipv4",
|
||||||
"err %d errno %d retval %d size %d magic %x\n",
|
"err %d errno %d retval %d size %d magic %x\n",
|
||||||
err, errno, retval, size, *magic);
|
err, errno, retval, size, *magic);
|
||||||
|
|
||||||
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v6, sizeof(pkt_v6),
|
err = bpf_prog_test_run(prog_fd, NUM_ITER, &pkt_v6, sizeof(pkt_v6),
|
||||||
buf, &size, &retval, &duration);
|
buf, &size, &retval, &duration);
|
||||||
CHECK(err || errno || retval != 1 || size != 74 ||
|
CHECK(err || retval != 1 || size != 74 ||
|
||||||
*magic != MAGIC_VAL, "ipv6",
|
*magic != MAGIC_VAL, "ipv6",
|
||||||
"err %d errno %d retval %d size %d magic %x\n",
|
"err %d errno %d retval %d size %d magic %x\n",
|
||||||
err, errno, retval, size, *magic);
|
err, errno, retval, size, *magic);
|
||||||
|
|
Loading…
Reference in New Issue