Documentation
¶
Overview ¶
Package alloctest provides allocators that refuse on purpose, and the two loops SQLite runs against them.
It is an ordinary package rather than a set of _test.go helpers, for the same reason pkg/vfs/vfstest is: a test in any package installs one through the published API a production caller would use, so the code under test is the code that ships.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Sweep ¶
func Sweep(t *testing.T, mode Mode, maxAllocs int, run func() error, check func(t *testing.T, n int, runErr error))
Sweep runs one of SQLite's two out-of-memory loops.
Rig the allocator to fail once on the N-th allocation for N=1,2,3,.... Repeat until no memory allocations fail.
and the same walk for "fail all allocations beginning with the N-th". The termination condition is what makes it a proof rather than a sample: when a run completes with no allocation refused, N has passed the last allocation the scenario makes, and every allocation failure it can experience has been tried.
run performs the scenario and returns whatever error it produced; a refused allocation is an expected outcome. check runs after every step and holds the invariant — typically that the store is still usable, that nothing was silently dropped, and that nothing panicked.
Types ¶
type Failing ¶
type Failing struct {
// contains filtered or unexported fields
}
Failing refuses allocations according to a mode and a threshold.
type Mode ¶
type Mode int
Mode selects which of SQLite's two loops an allocator implements.
const ( // FailOnce refuses the N-th allocation and then behaves normally. It finds // handlers that cope with a single failure and then continue. FailOnce Mode = iota // FailAllFrom refuses the N-th allocation and every one after it. It finds // the handlers that only work when a later allocation succeeds — a cleanup // path that allocates in order to clean up, for instance. FailAllFrom )