Commit e7b8f5fa authored by Russ Cox's avatar Russ Cox

path.TestWalk: disable error case if root

(chmod 0 doesn't cause errors for root)

Fixes #22.

R=gri
https://golang.org/cl/152120
parent 87bc9b53
...@@ -233,31 +233,33 @@ func TestWalk(t *testing.T) { ...@@ -233,31 +233,33 @@ func TestWalk(t *testing.T) {
} }
checkMarks(t); checkMarks(t);
// introduce 2 errors: chmod top-level directories to 0 if os.Getuid() != 0 {
os.Chmod(Join(tree.name, tree.entries[1].name), 0); // introduce 2 errors: chmod top-level directories to 0
os.Chmod(Join(tree.name, tree.entries[3].name), 0); os.Chmod(Join(tree.name, tree.entries[1].name), 0);
// mark respective subtrees manually os.Chmod(Join(tree.name, tree.entries[3].name), 0);
markTree(tree.entries[1]); // mark respective subtrees manually
markTree(tree.entries[3]); markTree(tree.entries[1]);
// correct double-marking of directory itself markTree(tree.entries[3]);
tree.entries[1].mark--; // correct double-marking of directory itself
tree.entries[3].mark--; tree.entries[1].mark--;
tree.entries[3].mark--;
// 3) handle errors, expect two
errors = make(chan os.Error, 64); // 3) handle errors, expect two
os.Chmod(Join(tree.name, tree.entries[1].name), 0); errors = make(chan os.Error, 64);
Walk(tree.name, v, errors); os.Chmod(Join(tree.name, tree.entries[1].name), 0);
for i := 1; i <= 2; i++ { Walk(tree.name, v, errors);
if _, ok := <-errors; !ok { for i := 1; i <= 2; i++ {
t.Errorf("%d. error expected, none found", i); if _, ok := <-errors; !ok {
break; 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 // cleanup
os.Chmod(Join(tree.name, tree.entries[1].name), 0770); os.Chmod(Join(tree.name, tree.entries[1].name), 0770);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment