summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-11-13 11:34:33 -0800
committerRuss Cox <rsc@golang.org>2009-11-13 11:34:33 -0800
commit23abe19ca16ba0939ec537d950f2315a6122ad43 (patch)
tree97d306595c40f7767ac1577893b634a46a832fb0 /src
parent94b229c9b08b41907e3382f7112bea30574b197c (diff)
downloadgolang-23abe19ca16ba0939ec537d950f2315a6122ad43.tar.gz
path.TestWalk: disable error case if root
(chmod 0 doesn't cause errors for root) Fixes issue 22. R=gri http://codereview.appspot.com/152120
Diffstat (limited to 'src')
-rw-r--r--src/pkg/path/path_test.go48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/pkg/path/path_test.go b/src/pkg/path/path_test.go
index b5cc33f18..74520fa31 100644
--- a/src/pkg/path/path_test.go
+++ b/src/pkg/path/path_test.go
@@ -233,31 +233,33 @@ func TestWalk(t *testing.T) {
}
checkMarks(t);
- // introduce 2 errors: chmod top-level directories to 0
- os.Chmod(Join(tree.name, tree.entries[1].name), 0);
- os.Chmod(Join(tree.name, tree.entries[3].name), 0);
- // mark respective subtrees manually
- markTree(tree.entries[1]);
- markTree(tree.entries[3]);
- // correct double-marking of directory itself
- tree.entries[1].mark--;
- tree.entries[3].mark--;
-
- // 3) handle errors, expect two
- errors = make(chan os.Error, 64);
- os.Chmod(Join(tree.name, tree.entries[1].name), 0);
- Walk(tree.name, v, errors);
- for i := 1; i <= 2; i++ {
- if _, ok := <-errors; !ok {
- t.Errorf("%d. error expected, none found", i);
- break;
+ if os.Getuid() != 0 {
+ // introduce 2 errors: chmod top-level directories to 0
+ os.Chmod(Join(tree.name, tree.entries[1].name), 0);
+ os.Chmod(Join(tree.name, tree.entries[3].name), 0);
+ // mark respective subtrees manually
+ markTree(tree.entries[1]);
+ markTree(tree.entries[3]);
+ // correct double-marking of directory itself
+ tree.entries[1].mark--;
+ tree.entries[3].mark--;
+
+ // 3) handle errors, expect two
+ errors = make(chan os.Error, 64);
+ os.Chmod(Join(tree.name, tree.entries[1].name), 0);
+ Walk(tree.name, v, errors);
+ for i := 1; i <= 2; i++ {
+ if _, ok := <-errors; !ok {
+ t.Errorf("%d. error expected, none found", i);
+ break;
+ }
}
+ if err, ok := <-errors; ok {
+ t.Errorf("only two errors expected, found 3rd: %v", err)
+ }
+ // the inaccessible subtrees were marked manually
+ checkMarks(t);
}
- if err, ok := <-errors; ok {
- t.Errorf("only two errors expected, found 3rd: %v", err)
- }
- // the inaccessible subtrees were marked manually
- checkMarks(t);
// cleanup
os.Chmod(Join(tree.name, tree.entries[1].name), 0770);