TestWriteFileRefusesNonRegular: write_file to an existing FIFO with no reader blocks identically in open(2) O_WRONLY; same guard, same contract.
(t *testing.T)
| 51 | // TestWriteFileRefusesNonRegular: write_file to an existing FIFO with no |
| 52 | // reader blocks identically in open(2) O_WRONLY; same guard, same contract. |
| 53 | func TestWriteFileRefusesNonRegular(t *testing.T) { |
| 54 | path := mkfifo(t) |
| 55 | done := make(chan string, 1) |
| 56 | go func() { done <- WriteFile(path, "data") }() |
| 57 | select { |
| 58 | case got := <-done: |
| 59 | if !strings.Contains(got, "not a regular file") { |
| 60 | t.Fatalf("want a not-a-regular-file refusal, got %q", got) |
| 61 | } |
| 62 | case <-timeoutC(t): |
| 63 | t.Fatal("WriteFile blocked on the FIFO instead of refusing") |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // TestEditFileRefusesNonRegular: edit_file reads the target first, so it needs |
| 68 | // the same guard as read_file. |