From 674ea8b2dc17a017f2f5a7c67bc8cc90ca18ac53 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 2 Aug 2007 19:27:07 +0200 Subject: Adjust the other two "no-x" tests and unify all three. * tests/du/no-x: Factor out du-specific bits. * tests/chmod/no-x: Use the same code. * tests/chgrp/no-x: Use the same code. --- tests/chgrp/no-x | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'tests/chgrp') diff --git a/tests/chgrp/no-x b/tests/chgrp/no-x index 117ac5773..58ac089c7 100755 --- a/tests/chgrp/no-x +++ b/tests/chgrp/no-x @@ -2,7 +2,7 @@ # Make sure chgrp gives the right diagnostic for a readable, # but inaccessible directory. -# Copyright (C) 2003, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,25 +50,24 @@ fail=0 # This must exit nonzero. chgrp -R $g2 d >/dev/null 2>out && fail=1 -cat <<\EOF > exp -chgrp: `d/no-x': Permission denied -EOF -# With native fdopendir, du uses a different code path. -cat <<\EOF > exp-native-fdopendir -chgrp: cannot access `d/no-x/y': Permission denied +prog=chgrp +# NOTE: this code is the same for all tests/*/no-x tests. +# Depending on whether fts is using native fdopendir, we see one +# of the following diagnostics (note also the /y suffix in one case): +# prog: `d/no-x': Permission denied +# prog: cannot access `d/no-x/y': Permission denied +# prog: cannot read directory `d/no-x': Permission denied +# Convert either of the latter two to the first one. +sed "s/^$prog: cannot access /$prog: /" out > t && mv t out +sed "s/^$prog: cannot read directory /$prog: /" out > t && mv t out +sed 's,d/no-x/y,d/no-x,' out > t && mv t out + +cat < exp +$prog: \`d/no-x': Permission denied EOF -if cmp out exp >/dev/null 2>&1; then - : -else - if cmp out exp-native-fdopendir; then - : - else - fail=1 - fi -fi - +cmp out exp || fail=1 test $fail = 1 && diff out exp 2> /dev/null (exit $fail); exit $fail -- cgit v1.2.3-70-g09d2