[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] Add a test which checks $CWD for find -execdir {} + and ...
From: |
James Youngman |
Subject: |
[PATCH 1/4] Add a test which checks $CWD for find -execdir {} + and ... {} ; |
Date: |
Sat, 10 Apr 2010 21:33:03 +0100 |
* find/testsuite/find.gnu/execdir-multiple.exp: New test; verifies
that for -execdir +, all the execs occur with the correct workikng
directory.
* find/testsuite/find.gnu/execdir-multiple.xo: Expected output for
this test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test.
(EXTRA_DIST_XO): Add the expected output file.
* find/testsuite/config/unix.exp (mkdir): Create proc "mkdir"
which creates a directory.
* find/testsuite/find.gnu/execdir-pwd1.exp: New test.
* find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add
execdir-pwd1.exp.
Signed-off-by: James Youngman <address@hidden>
---
ChangeLog | 17 ++++++++
find/testsuite/Makefile.am | 3 +
find/testsuite/config/unix.exp | 33 ++++++++++------
find/testsuite/find.gnu/execdir-multiple.exp | 55 ++++++++++++++++++++++++++
find/testsuite/find.gnu/execdir-multiple.xo | 24 +++++++++++
find/testsuite/find.gnu/execdir-pwd1.exp | 20 +++++++++
6 files changed, 140 insertions(+), 12 deletions(-)
create mode 100644 find/testsuite/find.gnu/execdir-multiple.exp
create mode 100644 find/testsuite/find.gnu/execdir-multiple.xo
create mode 100644 find/testsuite/find.gnu/execdir-pwd1.exp
diff --git a/ChangeLog b/ChangeLog
index 70a4614..0249307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2010-04-10 James Youngman <address@hidden>
+
+ Add a test which checks $CWD for find -execdir {} +/;
+ * find/testsuite/find.gnu/execdir-multiple.exp: New test; verifies
+ that for -execdir +, all the execs occur with the correct workikng
+ directory.
+ * find/testsuite/find.gnu/execdir-multiple.xo: Expected output for
+ this test.
+ * find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add the new test.
+ (EXTRA_DIST_XO): Add the expected output file.
+ * find/testsuite/config/unix.exp (mkdir): Create proc "mkdir"
+ which creates a directory.
+ * find/testsuite/find.gnu/execdir-pwd1.exp: New test.
+ * find/testsuite/Makefile.am (EXTRA_DIST_EXP): Add
+ execdir-pwd1.exp.
+
+
2010-04-09 James Youngman <address@hidden>
* find/parser.c (parse_samefile): Use open_cloexec to open the
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index 4ce87f6..f069727 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -14,6 +14,7 @@ find.gnu/depth.xo \
find.gnu/depth-d.xo \
find.gnu/empty.xo \
find.gnu/execdir-hier.xo \
+find.gnu/execdir-multiple.xo \
find.gnu/execdir-one.xo \
find.gnu/execdir-root-only.xo \
find.gnu/exec-many-rtn-failure.xo \
@@ -118,8 +119,10 @@ find.gnu/depth-d.exp \
find.gnu/empty.exp \
find.gnu/execdir-hier.exp \
find.gnu/execdir-in-unreadable.exp \
+find.gnu/execdir-multiple.exp \
find.gnu/execdir-one.exp \
find.gnu/execdir-pwd.exp \
+find.gnu/execdir-pwd1.exp \
find.gnu/execdir-root-only.exp \
find.gnu/exec-many-rtn-failure.exp \
find.gnu/exec-many-rtn-success.exp \
diff --git a/find/testsuite/config/unix.exp b/find/testsuite/config/unix.exp
index a898821..0c1baff 100644
--- a/find/testsuite/config/unix.exp
+++ b/find/testsuite/config/unix.exp
@@ -2,7 +2,7 @@
# Test-specific TCL procedures required by DejaGNU.
# Copyright (C) 2000, 2003, 2004, 2005, 2006,
# 2010 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
# the Free Software Foundation, either version 3 of the License, or
@@ -56,7 +56,7 @@ if { [ string equal $FTSFIND $OLDFIND ] } {
}
if [file exists $FTSFIND] then {
- if [file exists $OLDFIND] then {
+ if [file exists $OLDFIND] then {
verbose "FTSFIND=$FTSFIND and OLDFIND=$OLDFIND both exist." 2
} else {
error "OLDFIND=$OLDFIND, but that program does not exist"
@@ -64,7 +64,7 @@ if [file exists $FTSFIND] then {
} else {
error "FTSFIND=$FTSFIND, but that program does not exist (base_dir is
$base_dir)"
}
-
+
global FINDFLAGS
if ![info exists FINDFLAGS] then {
@@ -85,14 +85,14 @@ proc find_version {} {
}
}
-# Run find
+# Run find
# Called by individual test scripts.
proc do_find_start { suffix findprogram flags passfail options infile output }
{
global verbose
set scriptname [uplevel {info script}]
set testbase [file rootname $scriptname]
-
+
if { [string match "f*" $passfail] } {
set fail_good 1
@@ -116,7 +116,7 @@ proc do_find_start { suffix findprogram flags passfail
options infile output } {
}
}
- set test [file tail $testbase]
+ set test [file tail $testbase]
set testname "$test.$suffix"
# set compareprog "cmp"
@@ -145,7 +145,7 @@ proc do_find_start { suffix findprogram flags passfail
options infile output } {
} else {
send_log "Hoping for this command to return 0\n"
}
- set failed [ catch "exec $cmd" result ]
+ set failed [ catch "exec $cmd" result ]
send_log "return value is $failed, result is '$result'\n"
if $failed {
# The command failed.
@@ -172,9 +172,9 @@ proc do_find_start { suffix findprogram flags passfail
options infile output } {
# Because in the general case the person compiling and running
# "make check" will have a different collating order to the
# maintainer, we can't guarantee that our "correct" answer
- # is already sorted in the correct order. To avoid trying
- # to figure out how to select a POSIX environment on a
- # random system, we just sort the data again here, using
+ # is already sorted in the correct order. To avoid trying
+ # to figure out how to select a POSIX environment on a
+ # random system, we just sort the data again here, using
# the local user's environment.
exec sort < $outfile > cmp.out
set cmp_cmd "$compareprog find.out cmp.out"
@@ -272,11 +272,20 @@ proc touch args {
}
}
+proc mkdir { dirname } {
+ # Not all versions of Tcl offer 'file mkdir'.
+ set failed [ catch "file mkdir $dirname" result ]
+ if $failed {
+ # Fall back on the external command.
+ send_log "file mkdir does not work, falling back on exec mkdir\n"
+ exec mkdir "$dirname"
+ }
+}
proc safe_path [ ] {
if { [ path_setting_is_unsafe ] } {
- warning { Cannot perform test as your $PATH environment variable
includes a reference to the current directory or a directory name which is not
absolute }
+ warning { Cannot perform test as your $PATH environment variable
includes a reference to the current directory or a directory name which is not
absolute }
untested { skipping this test because your $PATH variable is wrongly
set }
return 0
} else {
@@ -293,7 +302,7 @@ proc fs_superuser [ ] {
set retval 0
if [ file readable $tmpfile ] {
- # On Cygwin, a user with admin rights can read all files, and
+ # On Cygwin, a user with admin rights can read all files, and
# access(foo,R_OK) correctly returns 1 for all files.
warning "You have superuser privileges, skipping this test."
untested {skipping this test because you have superuser privileges}
diff --git a/find/testsuite/find.gnu/execdir-multiple.exp
b/find/testsuite/find.gnu/execdir-multiple.exp
new file mode 100644
index 0000000..2ba10ad
--- /dev/null
+++ b/find/testsuite/find.gnu/execdir-multiple.exp
@@ -0,0 +1,55 @@
+# tests for -execdir ... \+
+
+# Create 4 empty files in each of 6 directories.
+# Also create a shell script in each of those 6 directories.
+# Run a find command which runs the shell script for each empty file.
+# Check to make sure that each file is mentioned exacly once, and that
+# the command was run with the correct working directory.
+#
+# The output is a sequence of lines of this form:
+#
+# cwd ./basename
+#
+# cmd is the basename of the current directory at the time the command
+# is run by -execidr. ./basename is the name of the file that was matched
+# (that is, it's the value passed in {}).
+
+# $body is the body of a shell script we use for testing.
+# It prints a series of lines of the form described above.
+# One line is printed for each command-line argument.
+set body {#! /bin/sh
+set -e
+here=`pwd`
+d=`basename $here`
+
+for arg;
+do
+ echo "$d" "$arg"
+done | LC_ALL=C sort
+}
+
+
+if { [ safe_path ] } {
+ global SKIP_OLD
+
+ exec rm -rf tmp
+ mkdir tmp
+
+ # Put a copy of our shell script in each
+ # directory, plus some files.
+ foreach dir { a b c d e f } {
+ mkdir "tmp/$dir"
+ set script_name "tmp/$dir/runme"
+ set f [open "$script_name" "w" 0700 ]
+ puts $f "$body"
+ close $f
+ foreach item { one two three four } {
+ touch "tmp/$dir/$item"
+ }
+ }
+
+ set SKIP_OLD 1
+ find_start p {tmp -type f -empty -execdir sh ./runme \{\} + } ""
+ set SKIP_OLD 0
+ exec rm -rf tmp
+}
diff --git a/find/testsuite/find.gnu/execdir-multiple.xo
b/find/testsuite/find.gnu/execdir-multiple.xo
new file mode 100644
index 0000000..a4f93d9
--- /dev/null
+++ b/find/testsuite/find.gnu/execdir-multiple.xo
@@ -0,0 +1,24 @@
+a ./one
+a ./two
+a ./three
+a ./four
+b ./one
+b ./two
+b ./three
+b ./four
+c ./one
+c ./two
+c ./three
+c ./four
+d ./one
+d ./two
+d ./three
+d ./four
+e ./one
+e ./two
+e ./three
+e ./four
+f ./one
+f ./two
+f ./three
+f ./four
diff --git a/find/testsuite/find.gnu/execdir-pwd1.exp
b/find/testsuite/find.gnu/execdir-pwd1.exp
new file mode 100644
index 0000000..e9863ac
--- /dev/null
+++ b/find/testsuite/find.gnu/execdir-pwd1.exp
@@ -0,0 +1,20 @@
+# tests for working directory of -execdir {} \;
+if { [ safe_path ] } {
+ global SKIP_OLD
+
+ exec rm -rf tmp
+ exec mkdir tmp
+
+ # Create an empty shell script.
+ exec touch tmp/foo
+ exec chmod +x tmp/foo
+
+ # The -execdir should find the "foo" in the current directory.
+ # If not, the find command is probably executing the command
+ # built up by -execdir in the wrong directory.
+
+ set SKIP_OLD 1
+ find_start p {tmp -name foo -execdir sh ./foo \{\} \; } ""
+ set SKIP_OLD 0
+ exec rm -rf tmp
+}
--
1.7.0
- [PATCH 1/4] Add a test which checks $CWD for find -execdir {} + and ... {} ;,
James Youngman <=