diff options
author | Jakob Unterwurzacher | 2015-12-11 19:54:53 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2015-12-11 20:02:12 +0100 |
commit | e99e8417137a713348d2797ba813bcefe0c3984d (patch) | |
tree | 1bd0f54313472a914ebb8f5370f4b97001f8b85c /integration_tests | |
parent | 78cd97c5e9de221a6cd2ddfcaaa2c1f1f430d264 (diff) |
Rmdir: handle creating and removing unreadable directories
This patch also splits off Mkdir and Rmdir into its own file.
Fixes issue #8, thanks to @diseq for the bug report.
Diffstat (limited to 'integration_tests')
-rw-r--r-- | integration_tests/helpers.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go index b269069..750283d 100644 --- a/integration_tests/helpers.go +++ b/integration_tests/helpers.go @@ -127,6 +127,38 @@ func testMkdirRmdir(t *testing.T, plainDir string) { if err != nil { t.Fatal(err) } + + // Removing a non-empty dir should fail with ENOTEMPTY + if os.Mkdir(dir, 0777) != nil { + t.Fatal(err) + } + f, err := os.Create(dir + "/file") + if err != nil { + t.Fatal(err) + } + f.Close() + err = syscall.Rmdir(dir) + errno := err.(syscall.Errno) + if errno != syscall.ENOTEMPTY { + t.Errorf("Should have gotten ENOTEMPTY, go %v", errno) + } + if syscall.Unlink(dir + "/file") != nil { + t.Fatal(err) + } + if syscall.Rmdir(dir) != nil { + t.Fatal(err) + } + + // We should also be able to remove a directory we do not have permissions to + // read or write + err = os.Mkdir(dir, 0000) + if err != nil { + t.Fatal(err) + } + err = syscall.Rmdir(dir) + if err != nil { + t.Fatal(err) + } } // Create and rename a file |