From bc14f8dcb65740dac792b50f2582372762e782b8 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 8 Sep 2018 17:00:23 +0200 Subject: tests: add chmod test Makes sure we don't add regressions when fixing https://github.com/rfjakob/gocryptfs/issues/259 --- tests/matrix/matrix_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/matrix') 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) + } + } +} -- cgit v1.2.3