Documentation ¶
Overview ¶
Package spitest is meant to be used to test drivers over a fake SPI port.
Index ¶
- type Log
- type LogConn
- type Playback
- func (p *Playback) CLK() gpio.PinOut
- func (p *Playback) CS() gpio.PinOut
- func (p *Playback) Close() error
- func (p *Playback) Connect(maxHz int64, mode spi.Mode, bits int) (spi.Conn, error)
- func (p *Playback) LimitSpeed(maxHz int64) error
- func (p *Playback) MISO() gpio.PinIn
- func (p *Playback) MOSI() gpio.PinOut
- type Record
- func (r *Record) CLK() gpio.PinOut
- func (r *Record) CS() gpio.PinOut
- func (r *Record) Close() error
- func (r *Record) Connect(maxHz int64, mode spi.Mode, bits int) (spi.Conn, error)
- func (r *Record) LimitSpeed(maxHz int64) error
- func (r *Record) MISO() gpio.PinIn
- func (r *Record) MOSI() gpio.PinOut
- func (r *Record) String() string
- type RecordRaw
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
Port spi.PortCloser
}
Log logs all operations done on an spi.PortCloser.
func (*Log) LimitSpeed ¶
LimitSpeed implements spi.PortCloser.
type Playback ¶
type Playback struct { conntest.Playback CLKPin gpio.PinIO MOSIPin gpio.PinIO MISOPin gpio.PinIO CSPin gpio.PinIO Initialized bool }
Playback implements spi.PortCloser and plays back a recorded I/O flow.
While "replay" type of unit tests are of limited value, they still present an easy way to do basic code coverage.
func (*Playback) Close ¶
Close implements spi.PortCloser.
Close() verifies that all the expected Ops have been consumed.
func (*Playback) LimitSpeed ¶
LimitSpeed implements spi.PortCloser.
type Record ¶
type Record struct { sync.Mutex Port spi.PortCloser // Port can be nil if only writes are being recorded. Ops []conntest.IO Initialized bool }
Record implements spi.PortCloser that records everything written to it.
This can then be used to feed to Playback to do "replay" based unit tests.
func (*Record) LimitSpeed ¶
LimitSpeed implements spi.PortCloser.
type RecordRaw ¶
RecordRaw implements spi.PortCloser.
It sends everything written to it to W.
func NewRecordRaw ¶
NewRecordRaw is a shortcut to create a RecordRaw
func (*RecordRaw) LimitSpeed ¶
LimitSpeed is a no-op.