Commit 6b30e299 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

tests: fix data race in TestDeletedInodePath

Running `go test ./... -race` showed a data race
at `rootNode.deleted`. This race cannot really happen,
but the race detector does not know that as the calls
go through FUSE an appear to not be synchronized.

Use atomic loads and stores to make the race detector
happy.

Change-Id: I26bd3e7d8efdd5b967fdb360eb17d7f71a8005c8
parent 0e23766d
......@@ -9,6 +9,7 @@ import (
"log"
"os"
"strings"
"sync/atomic"
"syscall"
"testing"
"unsafe"
......@@ -155,7 +156,7 @@ func TestDeletedInodePath(t *testing.T) {
if err != nil {
t.Fatal(err)
}
rootNode.deleted = true
atomic.StoreInt32(&rootNode.deleted, 1)
// Our Getattr implementation `testDeletedIno.Getattr` should return
// ENFILE when everything looks ok, EILSEQ otherwise.
......@@ -169,11 +170,12 @@ func TestDeletedInodePath(t *testing.T) {
type testDeletedIno struct {
Inode
deleted bool
deleted int32
}
func (n *testDeletedIno) Lookup(ctx context.Context, name string, out *fuse.EntryOut) (*Inode, syscall.Errno) {
if n.Root().Operations().(*testDeletedIno).deleted {
ino := n.Root().Operations().(*testDeletedIno)
if atomic.LoadInt32(&ino.deleted) == 1 {
return nil, syscall.ENOENT
}
if name != "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