From owner-dev-commits-src-branches@freebsd.org Sun Jan 24 04:05:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 763694EA964; Sun, 24 Jan 2021 04:05:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DNfXr0qVcz4Qx4; Sun, 24 Jan 2021 04:05:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EFD281CF77; Sun, 24 Jan 2021 04:05:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10O45FrM094094; Sun, 24 Jan 2021 04:05:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10O45FcX094093; Sun, 24 Jan 2021 04:05:15 GMT (envelope-from git) Date: Sun, 24 Jan 2021 04:05:15 GMT Message-Id: <202101240405.10O45FcX094093@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 4b74a4d4e267 - stable/12 - du: tests: fix the H_flag test (primarily grep usage) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 4b74a4d4e26788ae8e47ec10172ac80ce435dbb5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Jan 2021 04:05:16 -0000 The branch stable/12 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=4b74a4d4e26788ae8e47ec10172ac80ce435dbb5 commit 4b74a4d4e26788ae8e47ec10172ac80ce435dbb5 Author: Kyle Evans AuthorDate: 2021-01-05 21:33:06 +0000 Commit: Kyle Evans CommitDate: 2021-01-24 04:04:55 +0000 du: tests: fix the H_flag test (primarily grep usage) This test attempts to use \t (tab intended) in a grep expression. With the former /usr/bin/grep (i.e. gnugrep), this was interpreted as a literal 't'. The expression would work anyways because the tr(1) usage would ultimately replace all of the spaces with a single newline, and they would match the paths whether they were correctly fromatted or not. Current /usr/bin/grep (i.e. bsdgrep) is less-tolerant of ordinary-escapes, a property of the underlying regex(3) engine, to make it easier to identify when stuff like this happens. In-fact, this expression broke after the switch happened. This revision does the bare basics to fix the usage by using a printf to get a literal tab character to insert into the expression. It also swaps out the manual insertion of the line prefix into the grep expression by pulling that part out of $sep and reusing it for the leading path. The secondary issue was the tr(1) usage, since tr would only replace the first character of string1 with the first character of string2. This has instead been replaced by a sed expression, which similary understands \n to be a newline on all supported versions of FreeBSD. Each path now gets prefixed with the appropriate context that should be there (i.e. numeric sequence followed by a tab). PR: 252446 (cherry picked from commit 4832d2e8ae1df6f907ac00275764f8135722cb7e) --- usr.bin/du/tests/du_test.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr.bin/du/tests/du_test.sh b/usr.bin/du/tests/du_test.sh index 395051a0d781..4a8f11e83ff5 100755 --- a/usr.bin/du/tests/du_test.sh +++ b/usr.bin/du/tests/du_test.sh @@ -46,15 +46,16 @@ H_flag_body() { local paths1='testdir/A/B testdir/A testdir/C testdir' local paths2='testdir/A/B testdir/A testdir/C testdir' - local sep='\n[0-9]+\t' + local lineprefix="^[0-9]+$(printf "\t")" + 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 "[0-9]+\t$(echo $paths1 | tr ' ' "$sep")\n" du.out + atf_check egrep -q "${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 "[0-9]+\t$(echo $paths2 | tr ' ' "$sep")\n" du_C.out + atf_check egrep -q "${lineprefix}$(echo $paths2 | sed -e "s/ /$sep/g")" du_C.out } atf_test_case I_flag