Files
seaweedfs/weed/command/fuse_std_test.go
T
7y-9 3bf3d29058 fix(command): preserve fuse option after writers (#9972)
* fix(command): preserve fuse option after writers

Problem: FUSE mount option parsing skipped the option immediately following concurrentWriters, so values such as concurrentReaders could be silently ignored.

Root cause: runFuse incremented the options loop index inside the concurrentWriters case in addition to the loop increment.
Co-authored-by: Codex <noreply@openai.com>

* test: save and restore mountOptions pointers, not their values

The fields are reassigned to fresh heap variables during runFuse, so
dereferencing to back up/restore mutated throwaways instead of the
flag-bound originals and could nil-panic on unset fields.

---------

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Chris Lu <chris.lu@gmail.com>
2026-06-15 13:11:35 -07:00

39 lines
994 B
Go

//go:build darwin || freebsd || linux
package command
import (
"fmt"
"strings"
"testing"
)
func TestRunFuseDoesNotSkipOptionAfterConcurrentWriters(t *testing.T) {
oldUmask := mountOptions.umaskString
oldWriters := mountOptions.concurrentWriters
oldReaders := mountOptions.concurrentReaders
oldFuseCommandPid := mountOptions.fuseCommandPid
oldDir := mountOptions.dir
defer func() {
mountOptions.umaskString = oldUmask
mountOptions.concurrentWriters = oldWriters
mountOptions.concurrentReaders = oldReaders
mountOptions.fuseCommandPid = oldFuseCommandPid
mountOptions.dir = oldDir
recovered := recover()
if recovered == nil {
t.Fatal("expected invalid concurrentReaders option to be parsed")
}
if !strings.Contains(fmt.Sprint(recovered), "concurrentReaders") {
t.Fatalf("expected concurrentReaders parse error, got %v", recovered)
}
}()
runFuse(cmdMount, []string{
"/mnt",
"-o",
"child=1,concurrentWriters=2,concurrentReaders=bad,umask=bad",
})
}