The branch main has been updated by des:

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

commit 89990e28e6e1cae1b3d74d5a06159c1f9e12abc5
Author:     Dag-Erling Smørgrav <d...@freebsd.org>
AuthorDate: 2025-07-09 17:10:59 +0000
Commit:     Dag-Erling Smørgrav <d...@freebsd.org>
CommitDate: 2025-07-09 17:10:59 +0000

    cp: Add descriptions to all test cases.
    
    While here, touch a few test cases up.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D51124
---
 bin/cp/tests/cp_test.sh | 175 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 164 insertions(+), 11 deletions(-)

diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh
index 3c3dd309b9e4..999993bfad67 100755
--- a/bin/cp/tests/cp_test.sh
+++ b/bin/cp/tests/cp_test.sh
@@ -34,6 +34,10 @@ check_size()
 }
 
 atf_test_case basic
+basic_head()
+{
+       atf_set "descr" "Copy a file"
+}
 basic_body()
 {
        echo "foo" > bar
@@ -43,18 +47,26 @@ basic_body()
 }
 
 atf_test_case basic_symlink
+basic_symlink_head()
+{
+       atf_set "descr" "Copy a symlink to a file"
+}
 basic_symlink_body()
 {
        echo "foo" > bar
        ln -s bar baz
 
        atf_check cp baz foo
-       atf_check test '!' -L foo
+       atf_check test ! -L foo
 
        atf_check cmp foo bar
 }
 
 atf_test_case chrdev
+chrdev_head()
+{
+       atf_set "descr" "Copy a character device"
+}
 chrdev_body()
 {
        echo "foo" > bar
@@ -69,6 +81,10 @@ chrdev_body()
 }
 
 atf_test_case hardlink
+hardlink_head()
+{
+       atf_set "descr" "Create a hard link to a file"
+}
 hardlink_body()
 {
        echo "foo" >foo
@@ -78,6 +94,11 @@ hardlink_body()
 }
 
 atf_test_case hardlink_exists
+hardlink_exists_head()
+{
+       atf_set "descr" "Attempt to create a hard link to a file, " \
+           "but the destination already exists"
+}
 hardlink_exists_body()
 {
        echo "foo" >foo
@@ -88,6 +109,11 @@ hardlink_exists_body()
 }
 
 atf_test_case hardlink_exists_force
+hardlink_exists_force_head()
+{
+       atf_set "descr" "Force creation of a hard link to a file " \
+           "when the destination already exists"
+}
 hardlink_exists_force_body()
 {
        echo "foo" >foo
@@ -98,9 +124,12 @@ hardlink_exists_force_body()
 }
 
 atf_test_case matching_srctgt
+matching_srctgt_head()
+{
+       atf_set "descr" "Avoid infinite loop when copying a directory to itself"
+}
 matching_srctgt_body()
 {
-
        # PR235438: `cp -R foo foo` would previously infinitely recurse and
        # eventually error out.
        mkdir foo
@@ -110,13 +139,17 @@ matching_srctgt_body()
        atf_check cp -R foo foo
        atf_check -o inline:"qux\n" cat foo/foo/bar
        atf_check -o inline:"qux\n" cat foo/foo/zoo
-       atf_check -e not-empty -s not-exit:0 stat foo/foo/foo
+       atf_check test ! -e foo/foo/foo
 }
 
 atf_test_case matching_srctgt_contained
+matching_srctgt_contained_head()
+{
+       atf_set "descr" "Avoid infinite loop when copying a directory " \
+           "into an existing subdirectory of itself"
+}
 matching_srctgt_contained_body()
 {
-
        # Let's do the same thing, except we'll try to recursively copy foo into
        # one of its subdirectories.
        mkdir foo
@@ -142,9 +175,13 @@ matching_srctgt_contained_body()
 }
 
 atf_test_case matching_srctgt_link
+matching_srctgt_link_head()
+{
+       atf_set "descr" "Avoid infinite loop when recursively copying a " \
+           "symlink to a directory into the directory it links to"
+}
 matching_srctgt_link_body()
 {
-
        mkdir foo
        echo "qux" > foo/bar
        cp foo/bar foo/zoo
@@ -156,9 +193,13 @@ matching_srctgt_link_body()
 }
 
 atf_test_case matching_srctgt_nonexistent
+matching_srctgt_nonexistent_head()
+{
+       atf_set "descr" "Avoid infinite loop when recursively copying a " \
+           "directory into a new subdirectory of itself"
+}
 matching_srctgt_nonexistent_body()
 {
-
        # We'll copy foo to a nonexistent subdirectory; ideally, we would
        # skip just the directory and end up with a layout like;
        #
@@ -180,6 +221,10 @@ matching_srctgt_nonexistent_body()
 }
 
 atf_test_case pflag_acls
+pflag_acls_head()
+{
+       atf_set "descr" "Verify that -p preserves access control lists"
+}
 pflag_acls_body()
 {
        mkdir dir
@@ -216,6 +261,10 @@ pflag_acls_body()
 }
 
 atf_test_case pflag_flags
+pflag_flags_head()
+{
+       atf_set "descr" "Verify that -p preserves file flags"
+}
 pflag_flags_body()
 {
        mkdir dir
@@ -263,6 +312,11 @@ recursive_link_setup()
 }
 
 atf_test_case recursive_link_dflt
+recursive_link_dflt_head()
+{
+       atf_set "descr" "Copy a directory containing a subdirectory and a " \
+           "symlink to that subdirectory"
+}
 recursive_link_dflt_body()
 {
        recursive_link_setup
@@ -270,9 +324,15 @@ recursive_link_dflt_body()
        # -P is the default, so this should work and preserve the link.
        atf_check cp -R foo foo-mirror
        atf_check test -L foo-mirror/foo/baz
+       atf_check test -d foo-mirror/foo/baz
 }
 
 atf_test_case recursive_link_Hflag
+recursive_link_Hflag_head()
+{
+       atf_set "descr" "Copy a directory containing a subdirectory and a " \
+           "symlink to that subdirectory"
+}
 recursive_link_Hflag_body()
 {
        recursive_link_setup
@@ -281,22 +341,32 @@ recursive_link_Hflag_body()
        # link.
        atf_check cp -RH foo foo-mirror
        atf_check test -L foo-mirror/foo/baz
+       atf_check test -d foo-mirror/foo/baz
 }
 
 atf_test_case recursive_link_Lflag
+recursive_link_Lflag_head()
+{
+       atf_set "descr" "Copy a directory containing a subdirectory and a " \
+           "symlink to that subdirectory"
+}
 recursive_link_Lflag_body()
 {
        recursive_link_setup -L
 
        # -L will work, but foo/baz ends up expanded to a directory.
-       atf_check test -d foo-mirror/foo/baz -a \
-           '(' ! -L foo-mirror/foo/baz ')'
+       atf_check test ! -L foo-mirror/foo/baz
+       atf_check test -d foo-mirror/foo/baz
        atf_check cp -RL foo foo-mirror
-       atf_check test -d foo-mirror/foo/baz -a \
-           '(' ! -L foo-mirror/foo/baz ')'
+       atf_check test ! -L foo-mirror/foo/baz
+       atf_check test -d foo-mirror/foo/baz
 }
 
 atf_test_case samefile
+samefile_head()
+{
+       atf_set "descr" "Copy a file to itself"
+}
 samefile_body()
 {
        echo "foo" >foo
@@ -324,6 +394,10 @@ files_are_equal()
 }
 
 atf_test_case sparse_leading_hole
+sparse_leading_hole_head()
+{
+       atf_set "descr" "Copy a sparse file stat starts with a hole"
+}
 sparse_leading_hole_body()
 {
        # A 16-megabyte hole followed by one megabyte of data
@@ -337,6 +411,10 @@ sparse_leading_hole_body()
 }
 
 atf_test_case sparse_multiple_holes
+sparse_multiple_hole_head()
+{
+       atf_set "descr" "Copy a sparse file with multiple holes"
+}
 sparse_multiple_holes_body()
 {
        # Three one-megabyte blocks of data preceded, separated, and
@@ -356,6 +434,10 @@ sparse_multiple_holes_body()
 }
 
 atf_test_case sparse_only_hole
+sparse_only_hole_head()
+{
+       atf_set "descr" "Copy a sparse file consisting entirely of a hole"
+}
 sparse_only_hole_body()
 {
        # A 16-megabyte hole
@@ -368,6 +450,10 @@ sparse_only_hole_body()
 }
 
 atf_test_case sparse_to_dev
+sparse_to_dev_head()
+{
+       atf_set "descr" "Copy a sparse file to a device"
+}
 sparse_to_dev_body()
 {
        # Three one-megabyte blocks of data preceded, separated, and
@@ -385,6 +471,10 @@ sparse_to_dev_body()
 }
 
 atf_test_case sparse_trailing_hole
+sparse_trailing_hole_head()
+{
+       atf_set "descr" "Copy a sparse file that ends with a hole"
+}
 sparse_trailing_hole_body()
 {
        # One megabyte of data followed by a 16-megabyte hole
@@ -398,16 +488,24 @@ sparse_trailing_hole_body()
 }
 
 atf_test_case standalone_Pflag
+standalone_Pflag_head()
+{
+       atf_set "descr" "Test -P without -R"
+}
 standalone_Pflag_body()
 {
        echo "foo" > bar
        ln -s bar foo
 
        atf_check cp -P foo baz
-       atf_check -o inline:'Symbolic Link\n' stat -f %SHT baz
+       atf_check test -L baz
 }
 
 atf_test_case symlink
+symlink_head()
+{
+       atf_set "descr" "Create a symbolic link to a file"
+}
 symlink_body()
 {
        echo "foo" >foo
@@ -417,6 +515,11 @@ symlink_body()
 }
 
 atf_test_case symlink_exists
+symlink_exists_head()
+{
+       atf_set "descr" "Attempt to create a symbolic link to a file, " \
+           "but the destination already exists"
+}
 symlink_exists_body()
 {
        echo "foo" >foo
@@ -426,6 +529,11 @@ symlink_exists_body()
 }
 
 atf_test_case symlink_exists_force
+symlink_exists_force_head()
+{
+       atf_set "descr" "Force creation of a symbolic link to a file " \
+           "when the destination already exists"
+}
 symlink_exists_force_body()
 {
        echo "foo" >foo
@@ -436,6 +544,10 @@ symlink_exists_force_body()
 }
 
 atf_test_case directory_to_symlink
+directory_to_symlink_head()
+{
+       atf_set "descr" "Attempt to copy a directory to a symlink"
+}
 directory_to_symlink_body()
 {
        mkdir -p foo
@@ -449,6 +561,10 @@ directory_to_symlink_body()
 }
 
 atf_test_case overwrite_directory
+overwrite_directory_head()
+{
+       atf_set "descr" "Attempt to overwrite a directory with a file"
+}
 overwrite_directory_body()
 {
        mkdir -p foo/bar/baz
@@ -465,6 +581,10 @@ overwrite_directory_body()
 }
 
 atf_test_case to_dir_dne
+to_dir_dne_head()
+{
+       atf_set "descr" "Copy a directory to a nonexistent directory"
+}
 to_dir_dne_body()
 {
        mkdir dir
@@ -476,6 +596,10 @@ to_dir_dne_body()
 }
 
 atf_test_case to_nondir
+to_dir_dne_head()
+{
+       atf_set "descr" "Copy one or more files to a non-directory"
+}
 to_nondir_body()
 {
        echo "foo" >foo
@@ -490,6 +614,10 @@ to_nondir_body()
 }
 
 atf_test_case to_deadlink
+to_deadlink_head()
+{
+       atf_set "descr" "Copy a file to a dead symbolic link"
+}
 to_deadlink_body()
 {
        echo "foo" >foo
@@ -499,6 +627,10 @@ to_deadlink_body()
 }
 
 atf_test_case to_deadlink_append
+to_deadlink_append_head()
+{
+       atf_set "descr" "Copy multiple files to a dead symbolic link"
+}
 to_deadlink_append_body()
 {
        echo "foo" >foo
@@ -517,6 +649,10 @@ to_deadlink_append_body()
 }
 
 atf_test_case to_dirlink
+to_dirlink_head()
+{
+       atf_set "descr" "Copy things to a symbolic link to a directory"
+}
 to_dirlink_body()
 {
        mkdir src dir
@@ -542,6 +678,11 @@ to_dirlink_body()
 }
 
 atf_test_case to_deaddirlink
+to_deaddirlink_head()
+{
+       atf_set "descr" "Copy things to a symbolic link to a nonexistent " \
+           "directory"
+}
 to_deaddirlink_body()
 {
        mkdir src
@@ -572,6 +713,11 @@ to_deaddirlink_body()
 }
 
 atf_test_case to_link_outside
+to_link_outside_head()
+{
+       atf_set "descr" "Recursively copy a directory containing a symbolic " \
+           "link that points to somewhere outside the source directory"
+}
 to_link_outside_body()
 {
        mkdir dir dst dst/dir
@@ -584,6 +730,11 @@ to_link_outside_body()
 }
 
 atf_test_case dstmode
+dstmode_head()
+{
+       atf_set "descr" "Verify that directories are created with the " \
+           "correct permissions"
+}
 dstmode_body()
 {
        mkdir -m 0755 dir
@@ -646,6 +797,7 @@ atf_test_case unrdir
 unrdir_head()
 {
        atf_set "descr" "Test handling of unreadable directories"
+       atf_set "require.user" "unprivileged"
 }
 unrdir_body()
 {
@@ -670,6 +822,7 @@ atf_test_case unrfile
 unrfile_head()
 {
        atf_set "descr" "Test handling of unreadable files"
+       atf_set "require.user" "unprivileged"
 }
 unrfile_body()
 {

Reply via email to