The branch main has been updated by des:

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

commit fc76ddee9be0d7f98c9f9a162627950f8102964e
Author:     Dag-Erling Smørgrav <d...@freebsd.org>
AuthorDate: 2023-03-13 16:16:10 +0000
Commit:     Dag-Erling Smørgrav <d...@freebsd.org>
CommitDate: 2023-03-13 16:16:26 +0000

    tftp: Add test cases for URL mode.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    asomers
    Differential Revision:  https://reviews.freebsd.org/D39014
---
 usr.bin/tftp/tests/tftp_test.sh | 59 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/usr.bin/tftp/tests/tftp_test.sh b/usr.bin/tftp/tests/tftp_test.sh
index 96e375f51aeb..a4c9f3b898e7 100644
--- a/usr.bin/tftp/tests/tftp_test.sh
+++ b/usr.bin/tftp/tests/tftp_test.sh
@@ -386,6 +386,62 @@ tftp_put_multi_host_cleanup() {
        stop_tftpd
 }
 
+atf_test_case tftp_url_host cleanup
+tftp_url_host_head() {
+       atf_set "descr" "URL with hostname"
+       atf_set "require.user" "root"
+}
+tftp_url_host_body() {
+       start_tftpd
+       local remote_file="${tftp_dir}/hello.txt"
+       echo "Hello, $$!" >"${remote_file}"
+       local local_file="${remote_file##*/}"
+       atf_check -o match:"Received [0-9]+ bytes" \
+           tftp tftp://localhost/"${remote_file##*/}";
+       atf_check cmp -s "${local_file}" "${remote_file}"
+}
+tftp_url_host_cleanup() {
+       stop_tftpd
+}
+
+atf_test_case tftp_url_ipv4 cleanup
+tftp_url_ipv4_head() {
+       atf_set "descr" "URL with IPv4 address"
+       atf_set "require.user" "root"
+}
+tftp_url_ipv4_body() {
+       start_tftpd
+       local remote_file="${tftp_dir}/hello.txt"
+       echo "Hello, $$!" >"${remote_file}"
+       local local_file="${remote_file##*/}"
+       atf_check -o match:"Received [0-9]+ bytes" \
+           tftp tftp://127.0.0.1/"${remote_file##*/}";
+       atf_check cmp -s "${local_file}" "${remote_file}"
+}
+tftp_url_ipv4_cleanup() {
+       stop_tftpd
+}
+
+atf_test_case tftp_url_ipv6 cleanup
+tftp_url_ipv6_head() {
+       atf_set "descr" "URL with IPv6 address"
+       atf_set "require.user" "root"
+}
+tftp_url_ipv6_body() {
+       sysctl -q kern.features.inet6 || atf_skip "This test requires IPv6 
support"
+       atf_expect_fail "tftp does not support bracketed IPv6 literals in URLs"
+       start_tftpd
+       local remote_file="${tftp_dir}/hello.txt"
+       echo "Hello, $$!" >"${remote_file}"
+       local local_file="${remote_file##*/}"
+       atf_check -o match:"Received [0-9]+ bytes" \
+           tftp tftp://"[::1]"/"${remote_file##*/}";
+       atf_check cmp -s "${local_file}" "${remote_file}"
+}
+tftp_url_ipv6_cleanup() {
+       stop_tftpd
+}
+
 atf_init_test_cases() {
        atf_add_test_case tftp_get_big
        atf_add_test_case tftp_get_host
@@ -403,4 +459,7 @@ atf_init_test_cases() {
        atf_add_test_case tftp_put_two
        atf_add_test_case tftp_put_more
        atf_add_test_case tftp_put_multi_host
+       atf_add_test_case tftp_url_host
+       atf_add_test_case tftp_url_ipv4
+       atf_add_test_case tftp_url_ipv6
 }

Reply via email to