summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-09-08 17:00:23 +0200
committerJakob Unterwurzacher2018-09-08 17:00:23 +0200
commitbc14f8dcb65740dac792b50f2582372762e782b8 (patch)
treeb158669cf49e636ff0553aa5634d87f912d6bf9f
parent21b5fae0e606f14bba78abdbf36097ac447b68c4 (diff)
tests: add chmod test
Makes sure we don't add regressions when fixing https://github.com/rfjakob/gocryptfs/issues/259
-rw-r--r--tests/matrix/matrix_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go
index 642de01..19a6245 100644
--- a/tests/matrix/matrix_test.go
+++ b/tests/matrix/matrix_test.go
@@ -883,3 +883,25 @@ func TestMagicNames(t *testing.T) {
}
}
}
+
+// Test that chmod works correctly
+func TestChmod(t *testing.T) {
+ path := test_helpers.DefaultPlainDir + "/" + t.Name()
+ file, err := os.Create(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ 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)
+ }
+ modeHave := fi.Mode()
+ if modeHave != modeWant {
+ t.Errorf("modeHave %#o != modeWant %#o", modeHave, modeWant)
+ }
+ }
+}