From a051560e97738a16ae336d7d2d7b4954ca3e9c15 Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 12 Jun 2007 08:26:31 +0000 Subject: [PATCH] Avoid running find's fprint-unwritable.exp test if we are running the test suite as root --- ChangeLog | 9 +++++++++ find/testsuite/config/unix.exp | 18 ++++++++++++++++++ find/testsuite/find.gnu/access.exp | 9 +-------- find/testsuite/find.gnu/fprint-unwritable.exp | 14 ++++++++------ 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index de3e892..a602657 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-06-12 James Youngman + + Make the test suite work when run as root. + * find/testsuite/config/unix.exp (fs_superuser): Abstract out the + check which discovers if we have superuser privileges on the + filesystem (taken from access.exp). + * find/testsuite/find.gnu/access.exp: Call fs_superuser. + * find/testsuite/find.gnu/fprint-unwritable.exp: Use fs_superuser. + 2007-06-09 James Youngman Check that we can correctly read old-format databases which are diff --git a/find/testsuite/config/unix.exp b/find/testsuite/config/unix.exp index d49a000..4317e09 100644 --- a/find/testsuite/config/unix.exp +++ b/find/testsuite/config/unix.exp @@ -278,3 +278,21 @@ proc safe_path [ ] { } } + +proc fs_superuser [ ] { + set tmpfile "tmp000" + exec rm -f $tmpfile + touch $tmpfile + exec chmod 000 $tmpfile + set retval 0 + + if [ file readable $tmpfile ] { + # 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} + set retval 1 + } + exec rm -f $tmpfile + return $retval +} diff --git a/find/testsuite/find.gnu/access.exp b/find/testsuite/find.gnu/access.exp index ba5169b..18b7aab 100644 --- a/find/testsuite/find.gnu/access.exp +++ b/find/testsuite/find.gnu/access.exp @@ -1,14 +1,7 @@ # tests for -readable, -writable, -executable exec rm -rf tmp exec mkdir tmp -touch tmp/000 -exec chmod 000 tmp/000 -if [ file readable tmp/000 ] { - # 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} -} else { +if { ! [ fs_superuser ] } { touch tmp/x tmp/w tmp/r tmp/rw tmp/rwx tmp/0 exec chmod 400 tmp/r exec chmod 200 tmp/w diff --git a/find/testsuite/find.gnu/fprint-unwritable.exp b/find/testsuite/find.gnu/fprint-unwritable.exp index 1271bf4..905894d 100644 --- a/find/testsuite/find.gnu/fprint-unwritable.exp +++ b/find/testsuite/find.gnu/fprint-unwritable.exp @@ -1,7 +1,9 @@ # test for -fprint to unwritable dest (we expect this to fail) -exec rm -rf tmp -file mkdir tmp -exec touch tmp/unwritable -exec chmod 444 tmp/unwritable -find_start f { tmp -fprint tmp/unwritable } -exec rm -rf tmp +if { ! [ fs_superuser ] } { + exec rm -rf tmp + file mkdir tmp + exec touch tmp/unwritable + exec chmod 444 tmp/unwritable + find_start f { tmp -fprint tmp/unwritable } + exec rm -rf tmp +} -- 2.11.4.GIT