Documentation ¶
Overview ¶
Package concurrency implements a framework for systematic testing of concurrent vanadium Go programs. The framework implements the ideas described in "Systematic and Scalable Testing of Concurrent Programs":
http://repository.cmu.edu/cgi/viewcontent.cgi?article=1291&context=dissertations
Abstractly, the systematic testing framework divides execution of concurrent threads into coarse-grained transitions, by interposing on events of interest (e.g. thread creation, mutex acquisition, or channel communication).
The interposed events suspended and a centralized user-level scheduler is used to serialize the concurrent execution by advancing allowing only one concurrent transition to execute at any given time. In addition to controlling the scheduling, this centralized scheduler keeps track of the alternative scheduling choices. This information is then used to explore a different sequence of transitions next time the test body is executed.
The framework is initialized through the Init(setup, body, cleanup) function which specifies the test setup, body, and cleanup respectively. To start a systematic exploration, one invokes one of the following functions: Explore(), ExploreN(n), or ExploreFor(d). These functions repeatedly execute the test described through Init(), systematically enumerating the different ways in which different executions sequence concurrent transitions of the test. Finally, each systematic exploration should end by invoking the Finish() function.
See mutex_test.go for an example on how to use this framework to test concurrent access to mutexes.
Index ¶
- func Exit()
- func Finish()
- func Start(fn func())
- func TIDGenerator() func() TID
- type IncreasingDepth
- type IncreasingTID
- type TID
- type Tester
- func (t *Tester) Explore() (int, error)
- func (t *Tester) ExploreFor(d time.Duration) (int, error)
- func (t *Tester) ExploreN(n int) (int, error)
- func (t *Tester) MutexLock(m *sync.Mutex)
- func (t *Tester) MutexUnlock(m *sync.Mutex)
- func (t *Tester) RWMutexLock(rw *sync.RWMutex)
- func (t *Tester) RWMutexRLock(rw *sync.RWMutex)
- func (t *Tester) RWMutexRUnlock(rw *sync.RWMutex)
- func (t *Tester) RWMutexUnlock(rw *sync.RWMutex)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Exit ¶
func Exit()
Exit implements the logic related to modeling and scheduling thread termination.
func Start ¶
func Start(fn func())
Start implements the logic related to modeling and scheduling an execution of "go fn()".
func TIDGenerator ¶
func TIDGenerator() func() TID
TIDGenerator is used for generating unique thread identifiers.
Types ¶
type IncreasingDepth ¶
type IncreasingDepth []*state
IncreasingDepth is used to sort states in the increasing order of their depth.
func (IncreasingDepth) Len ¶
func (states IncreasingDepth) Len() int
func (IncreasingDepth) Less ¶
func (states IncreasingDepth) Less(i, j int) bool
func (IncreasingDepth) Swap ¶
func (states IncreasingDepth) Swap(i, j int)
type IncreasingTID ¶
type IncreasingTID []TID
Increasing is used to sort thread identifiers in an increasing order.
func (IncreasingTID) Len ¶
func (tids IncreasingTID) Len() int
func (IncreasingTID) Less ¶
func (tids IncreasingTID) Less(i, j int) bool
func (IncreasingTID) Swap ¶
func (tids IncreasingTID) Swap(i, j int)
type Tester ¶
type Tester struct {
// contains filtered or unexported fields
}
Tester represents an instance of the systematic test.
func Init ¶
func Init(setup, body, cleanup func()) *Tester
Setup sets up a new instance of the tester.
func (*Tester) Explore ¶
Explore explores the space of possible test schedules until the state space is fully exhausted.
func (*Tester) ExploreFor ¶
ExploreFor explores the space of possible test schedules until the state space is fully exhausted or the given duration elapses, whichever occurs first.
func (*Tester) ExploreN ¶
ExploreN explores the space of possible test schedules until the state space is fully exhausted or the given number of schedules is explored, whichever occurs first.
func (*Tester) MutexLock ¶
MutexLock implements the logic related to modeling and scheduling an execution of "m.Lock()".
func (*Tester) MutexUnlock ¶
MutexUnlock implements the logic related to modeling and scheduling an execution of "m.Unlock()".
func (*Tester) RWMutexLock ¶
RWMutexLock implements the logic related to modeling and scheduling an execution of "rw.Lock()".
func (*Tester) RWMutexRLock ¶
RWMutexRLock implements the logic related to modeling and scheduling an execution of "rw.RLock()".
func (*Tester) RWMutexRUnlock ¶
RWMutexRUnlock implements the logic related to modeling and scheduling an execution of "rw.RUnlock()".
func (*Tester) RWMutexUnlock ¶
RWMutexUnlock implements the logic related to modeling and scheduling an execution of "rw.Unlock()".