tests: add TestHaveDotdot
As discovered by xfstests generic/401 [1], during the move to
the v2 api we seem to have lost the "." and ".." directory
entries.
[1]: 4ef5b032bc/screenlog.0 (L520)
This commit is contained in:
parent
1d2ac1e589
commit
7d72baca69
@ -3,6 +3,7 @@ package matrix
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
@ -48,3 +49,24 @@ func TestRmdirPerms(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestHaveDotdot checks that we have "." and ".." in a directory.
|
||||
// (gocryptfs v2.0-beta1 did not!)
|
||||
func TestHaveDotdot(t *testing.T) {
|
||||
dir1 := test_helpers.DefaultPlainDir + "/TestHaveDotdot"
|
||||
err := os.Mkdir(dir1, 0700)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// All Go readdir functions filter out "." and "..".
|
||||
// Fall back to "ls -a" which does not.
|
||||
out, err := exec.Command("ls", "-a", dir1).CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
have := string(out)
|
||||
want := ".\n..\n"
|
||||
if have != want {
|
||||
t.Errorf("have=%q want=%q", have, want)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user