aboutsummaryrefslogtreecommitdiff
path: root/tests/matrix/matrix_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-09-22 13:34:03 +0200
committerJakob Unterwurzacher2018-09-22 13:39:17 +0200
commit9e6ee47bc97ec78807d1f7ea7d8e0c9ff6ed31fe (patch)
treeddea54e70d88ca1c849a26a52b74406fe0d8052d /tests/matrix/matrix_test.go
parent5ca6243eeb0df43ba0387029c2d8eceffa3172e2 (diff)
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
Diffstat (limited to 'tests/matrix/matrix_test.go')
-rw-r--r--tests/matrix/matrix_test.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index 4938ba9..6ec41bd 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -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)