36 lines
800 B
Go
36 lines
800 B
Go
//go:build unix
|
|
|
|
package store
|
|
|
|
import (
|
|
"os/signal"
|
|
"path/filepath"
|
|
"strings"
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
func TestWriteFailureIsReturned(t *testing.T) {
|
|
st, err := OpenSQLite(filepath.Join(t.TempDir(), "agent-system.db"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer st.Close()
|
|
signal.Ignore(syscall.SIGXFSZ)
|
|
t.Cleanup(func() { signal.Reset(syscall.SIGXFSZ) })
|
|
var lim syscall.Rlimit
|
|
if err := syscall.Getrlimit(syscall.RLIMIT_FSIZE, &lim); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
old := lim
|
|
lim.Cur = 4096
|
|
if err := syscall.Setrlimit(syscall.RLIMIT_FSIZE, &lim); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() { _ = syscall.Setrlimit(syscall.RLIMIT_FSIZE, &old) })
|
|
_, err = st.CreateProject("owner", strings.Repeat("x", 64*1024))
|
|
if err == nil {
|
|
t.Fatal("oversized write returned success")
|
|
}
|
|
}
|