Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Apr 2021 10:01:16 GMT
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 67f2f67fc8ce - main - Update rtsock_l3 test after 2fe5a79425c79f7b828acd91da66d97230925fc8
Message-ID:  <202104211001.13LA1G7a092327@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson:

URL: https://cgit.FreeBSD.org/src/commit/?id=67f2f67fc8ce8484066e95dabac5af892888fca1

commit 67f2f67fc8ce8484066e95dabac5af892888fca1
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2021-04-21 09:58:34 +0000
Commit:     Alex Richardson <arichardson@FreeBSD.org>
CommitDate: 2021-04-21 09:58:34 +0000

    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
---
 tests/sys/net/routing/rtsock_config.h  |  9 +++++++-
 tests/sys/net/routing/test_rtsock_l3.c | 38 +++++++++++++++++-----------------
 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104211001.13LA1G7a092327>