test

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

Testing

This directory contains misc testing scripts, tools, etc.

Running Caddy on development machine

This can be used to test TLS support for various things like wss:// upstream URIs, etc.

  • configure one SIOT instance (the upstream) to run on port 8081
  • cd <this directory>
  • install caddy and mkcert (Arch has packages for both)
  • mkcert -install
  • mkcert siottest.com
  • sudo vi /etc/hosts
    • 127.0.0.1 siottest.com
  • sudo caddy run -watch
  • start another SIOT instance (the downstream) and configure upstream with URL set to wss://siottest.com -- it will not connect to SIOT instance running on port 8081.

Documentation

Overview

Package test contains test utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HexDump added in v0.4.0

func HexDump(data []byte) string

HexDump provides a string of bytes in hex format

func NewIoSim added in v0.4.0

func NewIoSim() (*IoSim, *IoSim)

NewIoSim creates a new IO sim and returns the A and B side of an IO simulator that implements a io.ReadWriteCloser. Typically the A side would be used by your test code to read/write simulated data, and the B side would be passed to your code that uses an io.ReadWriter.

Types

type Fifo added in v0.4.0

type Fifo struct {
	// contains filtered or unexported fields
}

Fifo uses unix named pipes or fifos to emulate a UART type channel the A side manages the channel, creates the fifos, cleans up, etc. The B side only opens the fifos for read/write. Fifo implements the io.ReadWriteCloser interface. The Close() on the B side does not do anything.

func NewFifoA added in v0.4.0

func NewFifoA(name string) (*Fifo, error)

NewFifoA creates the A side interface. This must be called first to create the fifo files.

func NewFifoB added in v0.4.0

func NewFifoB(name string) (*Fifo, error)

NewFifoB creates the B side interface. This must be called after NewFifoB

func (*Fifo) Close added in v0.4.0

func (f *Fifo) Close() error

Close and delete fifos

func (*Fifo) Read added in v0.4.0

func (f *Fifo) Read(b []byte) (int, error)

func (*Fifo) Write added in v0.4.0

func (f *Fifo) Write(b []byte) (int, error)

type IoSim added in v0.4.0

type IoSim struct {
	// contains filtered or unexported fields
}

IoSim is used to simulate an io channel -- provides both sides so you can easily test code that uses an io.ReadWriter interface, etc

func (*IoSim) Close added in v0.4.0

func (ios *IoSim) Close() error

Close simulator

func (*IoSim) Read added in v0.4.0

func (ios *IoSim) Read(d []byte) (int, error)

Read blocks until there is some data in the out buffer or the ioSim is closed.

func (*IoSim) Write added in v0.4.0

func (ios *IoSim) Write(d []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL