aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-04-21 09:58:34 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-04-21 09:58:34 +0000
commit67f2f67fc8ce8484066e95dabac5af892888fca1 (patch)
tree80e7b86fccb86150b2bbd0273f3a15ca92992188
parentf8e57f89f3f550501c54ce839213a08981ff9250 (diff)
downloadsrc-67f2f67fc8ce8484066e95dabac5af892888fca1.tar.gz
src-67f2f67fc8ce8484066e95dabac5af892888fca1.zip
Update rtsock_l3 test after 2fe5a79425c79f7b828acd91da66d97230925fc8
Two of these tests now pass. Looking at Jenkins to find the first commit where this behaviour changed indicates that 2fe5a79425c79f7b828acd91da66d97230925fc8 is the most likely cause. Reviewed By: melifaro Differential Revision: https://reviews.freebsd.org/D28886
-rw-r--r--tests/sys/net/routing/rtsock_config.h9
-rw-r--r--tests/sys/net/routing/test_rtsock_l3.c38
2 files changed, 27 insertions, 20 deletions
diff --git a/tests/sys/net/routing/rtsock_config.h b/tests/sys/net/routing/rtsock_config.h
index 7d73f9e9a109..d9eccb6a19f6 100644
--- a/tests/sys/net/routing/rtsock_config.h
+++ b/tests/sys/net/routing/rtsock_config.h
@@ -126,8 +126,15 @@ config_setup(const atf_tc_t *tc, struct rtsock_config_options *co)
inet_ntop(AF_INET6, &c->net6.sin6_addr, c->net6_str, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &c->addr6.sin6_addr, c->addr6_str, INET6_ADDRSTRLEN);
+ ATF_CHECK_ERRNO(0, true);
+
if (co->num_interfaces > 0) {
- kldload("if_epair");
+ if (kldload("if_epair") == -1) {
+ /* Any errno other than EEXIST is fatal. */
+ ATF_REQUIRE_ERRNO(EEXIST, true);
+ /* Clear errno for the following tests. */
+ errno = 0;
+ }
ATF_REQUIRE_KERNEL_MODULE("if_epair");
c->ifnames = calloc(co->num_interfaces, sizeof(char *));
diff --git a/tests/sys/net/routing/test_rtsock_l3.c b/tests/sys/net/routing/test_rtsock_l3.c
index 91816679400f..b377b6c51ef2 100644
--- a/tests/sys/net/routing/test_rtsock_l3.c
+++ b/tests/sys/net/routing/test_rtsock_l3.c
@@ -64,6 +64,7 @@ presetup_ipv6_iface(const atf_tc_t *tc)
ret = iface_enable_ipv6(c->ifname);
ATF_REQUIRE_MSG(ret == 0, "Unable to enable IPv6 on %s", c->ifname);
+ ATF_REQUIRE_ERRNO(0, true);
return (c);
}
@@ -79,6 +80,7 @@ presetup_ipv6(const atf_tc_t *tc)
ret = iface_setup_addr(c->ifname, c->addr6_str, c->plen6);
c->rtsock_fd = rtsock_setup_socket();
+ ATF_REQUIRE_ERRNO(0, true);
return (c);
}
@@ -90,11 +92,13 @@ presetup_ipv4_iface(const atf_tc_t *tc)
int ret;
c = config_setup(tc, NULL);
+ ATF_REQUIRE(c != NULL);
jump_vnet(c, tc);
ret = iface_turn_up(c->ifname);
ATF_REQUIRE_MSG(ret == 0, "Unable to turn up %s", c->ifname);
+ ATF_REQUIRE_ERRNO(0, true);
return (c);
}
@@ -112,6 +116,7 @@ presetup_ipv4(const atf_tc_t *tc)
ATF_REQUIRE_MSG(ret == 0, "ifconfig failed");
c->rtsock_fd = rtsock_setup_socket();
+ ATF_REQUIRE_ERRNO(0, true);
return (c);
}
@@ -365,7 +370,7 @@ ATF_TC_BODY(rtm_get_v4_empty_dst_failure, tc)
(struct sockaddr *)&c->mask4, NULL);
rtsock_update_rtm_len(rtm);
- ATF_CHECK_ERRNO(EINVAL, write(c->rtsock_fd, rtm, rtm->rtm_msglen));
+ ATF_CHECK_ERRNO(EINVAL, write(c->rtsock_fd, rtm, rtm->rtm_msglen) == -1);
}
ATF_TC_CLEANUP(rtm_get_v4_empty_dst_failure, tc)
@@ -373,19 +378,16 @@ ATF_TC_CLEANUP(rtm_get_v4_empty_dst_failure, tc)
CLEANUP_AFTER_TEST;
}
-ATF_TC_WITH_CLEANUP(rtm_get_v4_hostbits_failure);
-ATF_TC_HEAD(rtm_get_v4_hostbits_failure, tc)
+ATF_TC_WITH_CLEANUP(rtm_get_v4_hostbits_success);
+ATF_TC_HEAD(rtm_get_v4_hostbits_success, tc)
{
DESCRIBE_ROOT_TEST("Tests RTM_GET with prefix with some hosts-bits set");
}
-ATF_TC_BODY(rtm_get_v4_hostbits_failure, tc)
+ATF_TC_BODY(rtm_get_v4_hostbits_success, tc)
{
DECLARE_TEST_VARS;
- if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
- atf_tc_expect_fail("Needs https://reviews.freebsd.org/D28886");
-
c = presetup_ipv4(tc);
/* Q the same prefix */
@@ -393,10 +395,11 @@ ATF_TC_BODY(rtm_get_v4_hostbits_failure, tc)
(struct sockaddr *)&c->mask4, NULL);
rtsock_update_rtm_len(rtm);
- ATF_CHECK_ERRNO(ESRCH, write(c->rtsock_fd, rtm, rtm->rtm_msglen));
+ ATF_REQUIRE_ERRNO(0, true);
+ ATF_CHECK_ERRNO(0, write(c->rtsock_fd, rtm, rtm->rtm_msglen) > 0);
}
-ATF_TC_CLEANUP(rtm_get_v4_hostbits_failure, tc)
+ATF_TC_CLEANUP(rtm_get_v4_hostbits_success, tc)
{
CLEANUP_AFTER_TEST;
}
@@ -443,16 +446,13 @@ ATF_TC_CLEANUP(rtm_add_v4_gw_direct_success, tc)
CLEANUP_AFTER_TEST;
}
-RTM_DECLARE_ROOT_TEST(rtm_add_v4_no_rtf_host_failure,
- "Tests failure with netmask sa and RTF_HOST inconsistency");
+RTM_DECLARE_ROOT_TEST(rtm_add_v4_no_rtf_host_success,
+ "Tests success with netmask sa and RTF_HOST inconsistency");
-ATF_TC_BODY(rtm_add_v4_no_rtf_host_failure, tc)
+ATF_TC_BODY(rtm_add_v4_no_rtf_host_success, tc)
{
DECLARE_TEST_VARS;
- if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
- atf_tc_expect_fail("Needs https://reviews.freebsd.org/D28886");
-
c = presetup_ipv4(tc);
/* Create IPv4 subnetwork with smaller prefix */
@@ -466,8 +466,8 @@ ATF_TC_BODY(rtm_add_v4_no_rtf_host_failure, tc)
rtsock_update_rtm_len(rtm);
/* RTF_HOST is NOT specified, while netmask is empty */
-
- ATF_CHECK_ERRNO(EINVAL, write(c->rtsock_fd, rtm, rtm->rtm_msglen));
+ ATF_REQUIRE_ERRNO(0, true);
+ ATF_CHECK_ERRNO(0, write(c->rtsock_fd, rtm, rtm->rtm_msglen) > 0);
}
ATF_TC_WITH_CLEANUP(rtm_del_v4_prefix_nogw_success);
@@ -1393,9 +1393,9 @@ ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, rtm_get_v4_exact_success);
ATF_TP_ADD_TC(tp, rtm_get_v4_lpm_success);
- ATF_TP_ADD_TC(tp, rtm_get_v4_hostbits_failure);
+ ATF_TP_ADD_TC(tp, rtm_get_v4_hostbits_success);
ATF_TP_ADD_TC(tp, rtm_get_v4_empty_dst_failure);
- ATF_TP_ADD_TC(tp, rtm_add_v4_no_rtf_host_failure);
+ ATF_TP_ADD_TC(tp, rtm_add_v4_no_rtf_host_success);
ATF_TP_ADD_TC(tp, rtm_add_v4_gw_direct_success);
ATF_TP_ADD_TC(tp, rtm_del_v4_prefix_nogw_success);
ATF_TP_ADD_TC(tp, rtm_add_v6_gu_gw_gu_direct_success);