tests: detect and report chmod failures earlier
Instead of reporting the consequence: matrix_test.go:906: modeHave 0664 != modeWant 0777 Report it if chmod itself fails, and also report the old file mode: matrix_test.go:901: chmod 000 -> 777 failed: bad file descriptor
This commit is contained in:
parent
5ca6243eeb
commit
9e6ee47bc9
@ -896,11 +896,19 @@ func TestChmod(t *testing.T) {
|
||||
file.Close()
|
||||
modes := []os.FileMode{0777, 0707, 0606, 0666, 0444, 0000, 0111, 0123, 0321}
|
||||
for _, modeWant := range modes {
|
||||
os.Chmod(path, modeWant)
|
||||
fi, err := os.Stat(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = syscall.Chmod(path, uint32(modeWant))
|
||||
if err != nil {
|
||||
t.Errorf("chmod %03o -> %03o failed: %v", fi.Mode(), modeWant, err)
|
||||
continue
|
||||
}
|
||||
fi, err = os.Stat(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
modeHave := fi.Mode()
|
||||
if modeHave != modeWant {
|
||||
t.Errorf("modeHave %#o != modeWant %#o", modeHave, modeWant)
|
||||
|
Loading…
Reference in New Issue
Block a user