[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tests: correct print_ver_ arguments
From: |
Bernhard Voelker |
Subject: |
Re: [PATCH] tests: correct print_ver_ arguments |
Date: |
Wed, 22 Aug 2012 15:09:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 |
On 08/22/2012 12:41 PM, Jim Meyering wrote:
> Thanks!
> When there are two or more offending files, it would be nice
> to report all of them before failing. The above stops at the first.
Yes, alright. Here comes the amended version.
Have a nice day,
Berny
>From ee25eb729ce153fd64a09cfcff06b956e544d704 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
Date: Wed, 22 Aug 2012 15:04:04 +0200
Subject: [PATCH] tests: correct print_ver_ arguments and add a rule to
enforce this
Some tests have been derived from other tests while
the argument(s) to print_ver_ have not been adapted.
Add a new cfg.mk rule to prohibit this.
* cfg.mk (sc_prohibit_test_calls_print_ver_with_irrelevant_argument):
New rule, to prohit test scripts calling print_env_ for programs not
actually being used during the test.
* tests/chown/basic: s/\(print_ver_\) chgrp/\1 chown/
* tests/cp/acl: s/\(print_ver_\) mv/\1 cp/
* tests/cp/capability: s/\(print_ver_\) ls/\1 cp/
* tests/cp/cp-parents: s/(print_ver_\) mv/\1 cp/
* tests/du/bind-mount-dir-cycle: s/(print_ver_\) rm/\1 du/
* tests/misc/wc-parallel: s/(print_ver_\) md5sum/\1 wc/
---
cfg.mk | 18 ++++++++++++++++++
tests/chown/basic | 2 +-
tests/cp/acl | 2 +-
tests/cp/capability | 2 +-
tests/cp/cp-parents | 2 +-
tests/du/bind-mount-dir-cycle | 2 +-
tests/misc/wc-parallel | 2 +-
7 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 19a84fa..3c4ee61 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -329,6 +329,24 @@ sc_some_programs_must_avoid_exit_failure:
&& { echo '$(ME): do not use EXIT_FAILURE in the above' \
1>&2; exit 1; } || :
+# Ensure that tests call the print_ver_ function for programs which are
+# actually used in that test.
+sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
+ @git grep -w print_ver_ tests \
+ | sed 's#:print_ver_##' \
+ | { fail=0; \
+ while read file name; do \
+ for i in $$name; do \
+ case "$$i" in install) i=ginstall;; esac; \
+ grep -w "$$i" $$file|grep -vw print_ver_|grep -q . \
+ || { fail=1; \
+ echo "*** Test: $$file, offending: $$i." 1>&2; };\
+ done; \
+ done; \
+ test $$fail = 0 || exit 1; \
+ } || { echo "$(ME): the above test(s) call print_ver_ for" \
+ "program(s) they don't use" 1>&2; exit 1; }
+
# Exempt the contents of any usage function from the following.
_continued_string_col_1 = \
s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
diff --git a/tests/chown/basic b/tests/chown/basic
index 7c8951c..6225400 100755
--- a/tests/chown/basic
+++ b/tests/chown/basic
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-print_ver_ chgrp
+print_ver_ chown
require_root_
touch f || framework_failure_
diff --git a/tests/cp/acl b/tests/cp/acl
index 26a7f42..4520fc9 100755
--- a/tests/cp/acl
+++ b/tests/cp/acl
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-print_ver_ mv getfacl setfacl
+print_ver_ cp getfacl setfacl
require_acl_
diff --git a/tests/cp/capability b/tests/cp/capability
index 1338c94..94e5aea 100755
--- a/tests/cp/capability
+++ b/tests/cp/capability
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-print_ver_ ls
+print_ver_ cp
require_root_
working_umask_or_skip_
diff --git a/tests/cp/cp-parents b/tests/cp/cp-parents
index b325c72..506e708 100755
--- a/tests/cp/cp-parents
+++ b/tests/cp/cp-parents
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-print_ver_ mv
+print_ver_ cp
working_umask_or_skip_
diff --git a/tests/du/bind-mount-dir-cycle b/tests/du/bind-mount-dir-cycle
index 8f9e197..516ceae 100755
--- a/tests/du/bind-mount-dir-cycle
+++ b/tests/du/bind-mount-dir-cycle
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-print_ver_ rm
+print_ver_ du
require_root_
cleanup_()
diff --git a/tests/misc/wc-parallel b/tests/misc/wc-parallel
index 074160f..6611b47 100755
--- a/tests/misc/wc-parallel
+++ b/tests/misc/wc-parallel
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
-print_ver_ md5sum
+print_ver_ wc
(mkdir tmp && cd tmp && seq 2000 | xargs touch)
--
1.7.7