Commit be93dbf7 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fs: don't enforce dirent ordering.

In TestBridgeReaddirPlusVirtualEntries we test that "." comes first,
and then "..". This ordering is not reliable. On
4.19.67-2rodete2-amd64, I see ".." before "."

Adapt the test to accept either ordering.

Change-Id: Ifc003dca6c2b19d9df3045ac30569ee27f78fc52
parent d4b28605
...@@ -55,27 +55,26 @@ func TestBridgeReaddirPlusVirtualEntries(t *testing.T) { ...@@ -55,27 +55,26 @@ func TestBridgeReaddirPlusVirtualEntries(t *testing.T) {
// Round up to 8. // Round up to 8.
const entry2off = (entryOutSize + direntSize + len(".\x00") + 7) / 8 * 8 const entry2off = (entryOutSize + direntSize + len(".\x00") + 7) / 8 * 8
names := map[string]*fuse.EntryOut{}
// 1st entry should be "." // 1st entry should be "."
entry1 := (*fuse.EntryOut)(unsafe.Pointer(&buf[0])) entry1 := (*fuse.EntryOut)(unsafe.Pointer(&buf[0]))
name1 := string(buf[entryOutSize+direntSize : entryOutSize+direntSize+2]) name1 := string(buf[entryOutSize+direntSize : entryOutSize+direntSize+2])
if name1 != ".\x00" { names[name1] = entry1
t.Errorf("Unexpected 1st entry %q", name1)
}
t.Logf("entry1 %q: %#v", name1, entry1)
// 2nd entry should be ".." // 2nd entry should be ".."
entry2 := (*fuse.EntryOut)(unsafe.Pointer(&buf[entry2off])) entry2 := (*fuse.EntryOut)(unsafe.Pointer(&buf[entry2off]))
name2 := string(buf[entry2off+entryOutSize+direntSize : entry2off+entryOutSize+direntSize+2]) name2 := string(buf[entry2off+entryOutSize+direntSize : entry2off+entryOutSize+direntSize+2])
if name2 != ".." {
t.Errorf("Unexpected 2nd entry %q", name2)
}
t.Logf("entry2 %q: %#v", name2, entry2)
if entry1.NodeId != 0 { names[name2] = entry2
t.Errorf("entry1 NodeId should be 0, but is %d", entry1.NodeId)
if len(names) != 2 || names[".\000"] == nil || names[".."] == nil {
t.Fatalf(`got %v, want {".\\0", ".."}`, names)
} }
if entry2.NodeId != 0 {
t.Errorf("entry2 NodeId should be 0, but is %d", entry2.NodeId) for k, v := range names {
if v.NodeId != 0 {
t.Errorf("entry %q NodeId should be 0, but is %d", k, v.NodeId)
}
} }
} }
......
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