Commit ec4c9f2a authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher

tests: check that we can delete directories with all permission

Regression test for https://github.com/rfjakob/gocryptfs/issues/354
parent 962c5236
package matrix
import (
"fmt"
"os"
"syscall"
"testing"
......@@ -30,3 +31,20 @@ func TestDirOverwrite(t *testing.T) {
t.Fatal(err)
}
}
// Test that we can create and remove a directory regardless of the permission it has
// https://github.com/rfjakob/gocryptfs/issues/354
func TestRmdirPerms(t *testing.T) {
for _, perm := range []uint32{0000, 0100, 0200, 0300, 0400, 0500, 0600, 0700} {
dir := fmt.Sprintf("TestRmdir%#o", perm)
path := test_helpers.DefaultPlainDir + "/" + dir
err := syscall.Mkdir(path, perm)
if err != nil {
t.Fatalf("Mkdir %q: %v", dir, err)
}
err = syscall.Rmdir(path)
if err != nil {
t.Fatalf("Rmdir %q: %v", dir, err)
}
}
}
......@@ -227,7 +227,9 @@ func TestMkdirRmdir(t *testing.T, plainDir string) {
}
err = syscall.Unlink(dir + "/file")
if err != nil {
t.Error(err)
var st syscall.Stat_t
syscall.Stat(dir, &st)
t.Errorf("err=%v mode=%0o", err, st.Mode)
return
}
err = syscall.Rmdir(dir)
......
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