mirror of
https://github.com/samuelncui/acp.git
synced 2026-09-19 22:24:12 +00:00
fix: preserve linear target no-space failures
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
//go:build linux
|
||||
|
||||
package acp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRunStreamMapsDeviceFullToTargetNoSpace(t *testing.T) {
|
||||
// Route a disposable target symlink to Linux's deterministic ENOSPC device.
|
||||
root := t.TempDir()
|
||||
input := filepath.Join(root, "source")
|
||||
target := filepath.Join(root, "target")
|
||||
if err := os.WriteFile(input, []byte("fixture"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink("/dev/full", target); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source := &sliceStreamSource{requests: []*StreamRequest{{
|
||||
ID: 1, Source: input, Targets: []string{target},
|
||||
}}}
|
||||
|
||||
// The synchronous stream boundary must preserve the portable no-space sentinel.
|
||||
err := RunStream(
|
||||
context.Background(), source, new(collectingStreamSink),
|
||||
Overwrite(true), SetToDevice(LinearDevice(true)),
|
||||
)
|
||||
if !errors.Is(err, ErrTargetNoSpace) {
|
||||
t.Fatalf("RunStream() error = %v, want %v", err, ErrTargetNoSpace)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user