git: 136b8134a4b5 - main - if_ovpn tests: destroy an if_ovpn interface before it's been used

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Tue, 10 Sep 2024 18:34:38 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=136b8134a4b5a7efacf4109c2f89d6db94785774

commit 136b8134a4b5a7efacf4109c2f89d6db94785774
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-09-09 12:33:31 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-09-10 18:34:23 +0000

    if_ovpn tests: destroy an if_ovpn interface before it's been used
    
    Ensure that we correctly clean up even if the interface never gets a socket
    assigned.
    
    Reviewed by:    markj
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D46617
---
 tests/sys/net/if_ovpn/if_ovpn.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/sys/net/if_ovpn/if_ovpn.sh b/tests/sys/net/if_ovpn/if_ovpn.sh
index 77007c967333..ea1eed88de9e 100644
--- a/tests/sys/net/if_ovpn/if_ovpn.sh
+++ b/tests/sys/net/if_ovpn/if_ovpn.sh
@@ -1048,6 +1048,27 @@ gcm_128_cleanup()
 	ovpn_cleanup
 }
 
+atf_test_case "destroy_unused" "cleanup"
+destroy_unused_head()
+{
+	atf_set descr 'Destroy an if_ovpn interface before it is used'
+	atf_set require.user root
+}
+
+destroy_unused_body()
+{
+	ovpn_init
+
+	intf=$(ifconfig ovpn create)
+	atf_check -s exit:0 \
+	    ifconfig ${intf} destroy
+}
+
+destroy_unused_cleanup()
+{
+	ovpn_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "4in4"
@@ -1062,4 +1083,5 @@ atf_init_test_cases()
 	atf_add_test_case "ra"
 	atf_add_test_case "chacha"
 	atf_add_test_case "gcm_128"
+	atf_add_test_case "destroy_unused"
 }