The branch main has been updated by kevans:

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

commit 3c5c39c7ad8f010cfa5fc0db43d15d1964b4cf16
Author:     Kyle Evans <kev...@freebsd.org>
AuthorDate: 2021-01-05 21:49:46 +0000
Commit:     Kyle Evans <kev...@freebsd.org>
CommitDate: 2021-01-07 22:37:28 +0000

    du: tests: make H_flag tests more strict about output requirements
    
    The current version of this test will effectively pass as long as one of the
    specified paths is in the output, and it could even be a subset of one of
    the paths.
    
    Strengthen up the test a little bit:
      * Specify beginning/end anchors for each path
      * Add egrep -v checks to make sure we don't have any *additional* paths
      * Ratchet down paths2 to exactly the two paths we expect to appear
    
    Reviewed by:    ngie
    Differential Revision:  https://reviews.freebsd.org/D27984
---
 usr.bin/du/tests/du_test.sh | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/usr.bin/du/tests/du_test.sh b/usr.bin/du/tests/du_test.sh
index 4a8f11e83ff5..92a26deae02b 100755
--- a/usr.bin/du/tests/du_test.sh
+++ b/usr.bin/du/tests/du_test.sh
@@ -45,17 +45,25 @@ H_flag_head()
 H_flag_body()
 {
        local paths1='testdir/A/B testdir/A testdir/C testdir'
-       local paths2='testdir/A/B testdir/A testdir/C testdir'
+       local paths2='testdir/C/B testdir/C'
        local lineprefix="^[0-9]+$(printf "\t")"
-       local sep="\n${lineprefix}"
+       local sep="\$\n${lineprefix}"
 
        atf_check mkdir testdir
        atf_check -x "cd testdir && mkdir A && touch A/B && ln -s A C"
 
        atf_check -o save:du.out du -aAH testdir
-       atf_check egrep -q "${lineprefix}$(echo $paths1 | sed -e "s/ /$sep/g")" 
du.out
+       atf_check egrep -q "${lineprefix}$(echo $paths1 | sed -e "s/ 
/$sep/g")$" du.out
+       # Check that the output doesn't contain any lines (i.e. paths) that we
+       # did not expect it to contain from $paths1.
+       atf_check -s exit:1 egrep -vq "${lineprefix}$(echo $paths1 | sed -e "s/ 
/$sep/g")$" du.out
+
        atf_check -o save:du_C.out du -aAH testdir/C
-       atf_check egrep -q "${lineprefix}$(echo $paths2 | sed -e "s/ /$sep/g")" 
du_C.out
+       atf_check egrep -q "${lineprefix}$(echo $paths2 | sed -e "s/ 
/$sep/g")$" du_C.out
+
+       # Check that the output doesn't contain any lines (i.e. paths) that we
+       # did not expect it to contain from $paths2.
+       atf_check -s exit:1 egrep -vq "${lineprefix}$(echo $paths2 | sed -e "s/ 
/$sep/g")$" du_C.out
 }
 
 atf_test_case I_flag
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to