summaryrefslogtreecommitdiff
path: root/internal/file/flags_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/file/flags_test.go')
-rw-r--r--internal/file/flags_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/file/flags_test.go b/internal/file/flags_test.go
new file mode 100644
index 0000000..120e432
--- /dev/null
+++ b/internal/file/flags_test.go
@@ -0,0 +1,40 @@
+package file
+
+import (
+ "strings"
+ "sync"
+ "syscall"
+ "testing"
+)
+
+func TestFlagsBuildStringConcurrent(t *testing.T) {
+ flagsToHumanCache = sync.Map{}
+
+ const workers = 32
+ const iterations = 500
+ const want = "O_WRONLY|O_APPEND"
+ flag := Flags(syscall.O_WRONLY | syscall.O_APPEND)
+
+ var wg sync.WaitGroup
+ errs := make(chan string, workers)
+ for i := 0; i < workers; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for j := 0; j < iterations; j++ {
+ var sb strings.Builder
+ flag.BuildString(&sb)
+ if got := sb.String(); got != want {
+ errs <- got
+ return
+ }
+ }
+ }()
+ }
+ wg.Wait()
+ close(errs)
+
+ for got := range errs {
+ t.Fatalf("unexpected BuildString output %q, want %q", got, want)
+ }
+}