mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
be99389d05
289 changed files with 58055 additions and 27748 deletions
|
|
@ -1,4 +1,7 @@
|
||||||
**/.git
|
**/.git
|
||||||
|
.git
|
||||||
|
!.git/HEAD
|
||||||
|
!.git/refs/heads
|
||||||
**/*_test.go
|
**/*_test.go
|
||||||
|
|
||||||
build/_workspace
|
build/_workspace
|
||||||
|
|
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -33,3 +33,8 @@ profile.cov
|
||||||
|
|
||||||
# IdeaIDE
|
# IdeaIDE
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
# dashboard
|
||||||
|
/dashboard/assets/node_modules
|
||||||
|
/dashboard/assets/stats.json
|
||||||
|
/dashboard/assets/public/bundle.js
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,5 @@ FROM alpine:latest
|
||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
|
||||||
|
|
||||||
EXPOSE 8545 8546 30303 30303/udp
|
EXPOSE 8545 8546 30303 30303/udp 30304/udp
|
||||||
ENTRYPOINT ["geth"]
|
ENTRYPOINT ["geth"]
|
||||||
|
|
|
||||||
15
Dockerfile.alltools
Normal file
15
Dockerfile.alltools
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Build Geth in a stock Go builder container
|
||||||
|
FROM golang:1.9-alpine as builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache make gcc musl-dev linux-headers
|
||||||
|
|
||||||
|
ADD . /go-ethereum
|
||||||
|
RUN cd /go-ethereum && make all
|
||||||
|
|
||||||
|
# Pull all binaries into a second stage deploy alpine container
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates
|
||||||
|
COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
|
||||||
|
|
||||||
|
EXPOSE 8545 8546 30303 30303/udp 30304/udp
|
||||||
|
|
@ -41,6 +41,7 @@ import (
|
||||||
var _ bind.ContractBackend = (*SimulatedBackend)(nil)
|
var _ bind.ContractBackend = (*SimulatedBackend)(nil)
|
||||||
|
|
||||||
var errBlockNumberUnsupported = errors.New("SimulatedBackend cannot access blocks other than the latest block")
|
var errBlockNumberUnsupported = errors.New("SimulatedBackend cannot access blocks other than the latest block")
|
||||||
|
var errGasEstimationFailed = errors.New("gas required exceeds allowance or always failing transaction")
|
||||||
|
|
||||||
// SimulatedBackend implements bind.ContractBackend, simulating a blockchain in
|
// SimulatedBackend implements bind.ContractBackend, simulating a blockchain in
|
||||||
// the background. Its main purpose is to allow easily testing contract bindings.
|
// the background. Its main purpose is to allow easily testing contract bindings.
|
||||||
|
|
@ -203,33 +204,47 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMs
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
// Binary search the gas requirement, as it may be higher than the amount used
|
// Determine the lowest and highest possible gas limits to binary search in between
|
||||||
var (
|
var (
|
||||||
lo uint64 = params.TxGas - 1
|
lo uint64 = params.TxGas - 1
|
||||||
hi uint64
|
hi uint64
|
||||||
|
cap uint64
|
||||||
)
|
)
|
||||||
if call.Gas != nil && call.Gas.Uint64() >= params.TxGas {
|
if call.Gas != nil && call.Gas.Uint64() >= params.TxGas {
|
||||||
hi = call.Gas.Uint64()
|
hi = call.Gas.Uint64()
|
||||||
} else {
|
} else {
|
||||||
hi = b.pendingBlock.GasLimit().Uint64()
|
hi = b.pendingBlock.GasLimit().Uint64()
|
||||||
}
|
}
|
||||||
for lo+1 < hi {
|
cap = hi
|
||||||
// Take a guess at the gas, and check transaction validity
|
|
||||||
mid := (hi + lo) / 2
|
// Create a helper to check if a gas allowance results in an executable transaction
|
||||||
call.Gas = new(big.Int).SetUint64(mid)
|
executable := func(gas uint64) bool {
|
||||||
|
call.Gas = new(big.Int).SetUint64(gas)
|
||||||
|
|
||||||
snapshot := b.pendingState.Snapshot()
|
snapshot := b.pendingState.Snapshot()
|
||||||
_, _, failed, err := b.callContract(ctx, call, b.pendingBlock, b.pendingState)
|
_, _, failed, err := b.callContract(ctx, call, b.pendingBlock, b.pendingState)
|
||||||
b.pendingState.RevertToSnapshot(snapshot)
|
b.pendingState.RevertToSnapshot(snapshot)
|
||||||
|
|
||||||
// If the transaction became invalid or execution failed, raise the gas limit
|
|
||||||
if err != nil || failed {
|
if err != nil || failed {
|
||||||
lo = mid
|
return false
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
// Otherwise assume the transaction succeeded, lower the gas limit
|
return true
|
||||||
|
}
|
||||||
|
// Execute the binary search and hone in on an executable gas limit
|
||||||
|
for lo+1 < hi {
|
||||||
|
mid := (hi + lo) / 2
|
||||||
|
if !executable(mid) {
|
||||||
|
lo = mid
|
||||||
|
} else {
|
||||||
hi = mid
|
hi = mid
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Reject the transaction as invalid if it still fails at the highest allowance
|
||||||
|
if hi == cap {
|
||||||
|
if !executable(hi) {
|
||||||
|
return nil, errGasEstimationFailed
|
||||||
|
}
|
||||||
|
}
|
||||||
return new(big.Int).SetUint64(hi), nil
|
return new(big.Int).SetUint64(hi), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/contracts/release"
|
"github.com/ethereum/go-ethereum/contracts/release"
|
||||||
|
"github.com/ethereum/go-ethereum/dashboard"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
|
@ -80,6 +81,7 @@ type gethConfig struct {
|
||||||
Shh whisper.Config
|
Shh whisper.Config
|
||||||
Node node.Config
|
Node node.Config
|
||||||
Ethstats ethstatsConfig
|
Ethstats ethstatsConfig
|
||||||
|
Dashboard dashboard.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(file string, cfg *gethConfig) error {
|
func loadConfig(file string, cfg *gethConfig) error {
|
||||||
|
|
@ -113,6 +115,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
|
||||||
Eth: eth.DefaultConfig,
|
Eth: eth.DefaultConfig,
|
||||||
Shh: whisper.DefaultConfig,
|
Shh: whisper.DefaultConfig,
|
||||||
Node: defaultNodeConfig(),
|
Node: defaultNodeConfig(),
|
||||||
|
Dashboard: dashboard.DefaultConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load config file.
|
// Load config file.
|
||||||
|
|
@ -134,6 +137,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.SetShhConfig(ctx, stack, &cfg.Shh)
|
utils.SetShhConfig(ctx, stack, &cfg.Shh)
|
||||||
|
utils.SetDashboardConfig(ctx, &cfg.Dashboard)
|
||||||
|
|
||||||
return stack, cfg
|
return stack, cfg
|
||||||
}
|
}
|
||||||
|
|
@ -153,6 +157,9 @@ func makeFullNode(ctx *cli.Context) *node.Node {
|
||||||
|
|
||||||
utils.RegisterEthService(stack, &cfg.Eth)
|
utils.RegisterEthService(stack, &cfg.Eth)
|
||||||
|
|
||||||
|
if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
|
||||||
|
utils.RegisterDashboardService(stack, &cfg.Dashboard)
|
||||||
|
}
|
||||||
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
|
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
|
||||||
shhEnabled := enableWhisper(ctx)
|
shhEnabled := enableWhisper(ctx)
|
||||||
shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DeveloperFlag.Name)
|
shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DeveloperFlag.Name)
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,11 @@ var (
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.KeyStoreDirFlag,
|
utils.KeyStoreDirFlag,
|
||||||
utils.NoUSBFlag,
|
utils.NoUSBFlag,
|
||||||
|
utils.DashboardEnabledFlag,
|
||||||
|
utils.DashboardAddrFlag,
|
||||||
|
utils.DashboardPortFlag,
|
||||||
|
utils.DashboardRefreshFlag,
|
||||||
|
utils.DashboardAssetsFlag,
|
||||||
utils.EthashCacheDirFlag,
|
utils.EthashCacheDirFlag,
|
||||||
utils.EthashCachesInMemoryFlag,
|
utils.EthashCachesInMemoryFlag,
|
||||||
utils.EthashCachesOnDiskFlag,
|
utils.EthashCachesOnDiskFlag,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/internal/debug"
|
"github.com/ethereum/go-ethereum/internal/debug"
|
||||||
"gopkg.in/urfave/cli.v1"
|
"gopkg.in/urfave/cli.v1"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppHelpTemplate is the test template for the default, global app help topic.
|
// AppHelpTemplate is the test template for the default, global app help topic.
|
||||||
|
|
@ -97,6 +98,16 @@ var AppHelpFlagGroups = []flagGroup{
|
||||||
utils.EthashDatasetsOnDiskFlag,
|
utils.EthashDatasetsOnDiskFlag,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
//{
|
||||||
|
// Name: "DASHBOARD",
|
||||||
|
// Flags: []cli.Flag{
|
||||||
|
// utils.DashboardEnabledFlag,
|
||||||
|
// utils.DashboardAddrFlag,
|
||||||
|
// utils.DashboardPortFlag,
|
||||||
|
// utils.DashboardRefreshFlag,
|
||||||
|
// utils.DashboardAssetsFlag,
|
||||||
|
// },
|
||||||
|
//},
|
||||||
{
|
{
|
||||||
Name: "TRANSACTION POOL",
|
Name: "TRANSACTION POOL",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
|
@ -268,6 +279,9 @@ func init() {
|
||||||
uncategorized := []cli.Flag{}
|
uncategorized := []cli.Flag{}
|
||||||
for _, flag := range data.(*cli.App).Flags {
|
for _, flag := range data.(*cli.App).Flags {
|
||||||
if _, ok := categorized[flag.String()]; !ok {
|
if _, ok := categorized[flag.String()]; !ok {
|
||||||
|
if strings.HasPrefix(flag.GetName(), "dashboard") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
uncategorized = append(uncategorized, flag)
|
uncategorized = append(uncategorized, flag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,18 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
|
||||||
} else {
|
} else {
|
||||||
key, err := ssh.ParsePrivateKey(buf)
|
key, err := ssh.ParsePrivateKey(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Bad SSH key, falling back to passwords", "path", path, "err", err)
|
fmt.Printf("What's the decryption password for %s? (won't be echoed)\n>", path)
|
||||||
|
blob, err := terminal.ReadPassword(int(os.Stdin.Fd()))
|
||||||
|
fmt.Println()
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("Couldn't read password", "err", err)
|
||||||
|
}
|
||||||
|
key, err := ssh.ParsePrivateKeyWithPassphrase(buf, blob)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("Failed to decrypt SSH key, falling back to passwords", "path", path, "err", err)
|
||||||
|
} else {
|
||||||
|
auths = append(auths, ssh.PublicKeys(key))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
auths = append(auths, ssh.PublicKeys(key))
|
auths = append(auths, ssh.PublicKeys(key))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ func (w *wizard) makeServer() string {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println("Please enter remote server's address:")
|
fmt.Println("Please enter remote server's address:")
|
||||||
|
|
||||||
// Read and fial the server to ensure docker is present
|
// Read and dial the server to ensure docker is present
|
||||||
input := w.readString()
|
input := w.readString()
|
||||||
|
|
||||||
client, err := dial(input, nil)
|
client, err := dial(input, nil)
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
"github.com/ethereum/go-ethereum/dashboard"
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
"github.com/ethereum/go-ethereum/eth/gasprice"
|
||||||
|
|
@ -183,6 +184,31 @@ var (
|
||||||
Name: "lightkdf",
|
Name: "lightkdf",
|
||||||
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
|
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
|
||||||
}
|
}
|
||||||
|
// Dashboard settings
|
||||||
|
DashboardEnabledFlag = cli.BoolFlag{
|
||||||
|
Name: "dashboard",
|
||||||
|
Usage: "Enable the dashboard",
|
||||||
|
}
|
||||||
|
DashboardAddrFlag = cli.StringFlag{
|
||||||
|
Name: "dashboard.addr",
|
||||||
|
Usage: "Dashboard listening interface",
|
||||||
|
Value: dashboard.DefaultConfig.Host,
|
||||||
|
}
|
||||||
|
DashboardPortFlag = cli.IntFlag{
|
||||||
|
Name: "dashboard.host",
|
||||||
|
Usage: "Dashboard listening port",
|
||||||
|
Value: dashboard.DefaultConfig.Port,
|
||||||
|
}
|
||||||
|
DashboardRefreshFlag = cli.DurationFlag{
|
||||||
|
Name: "dashboard.refresh",
|
||||||
|
Usage: "Dashboard metrics collection refresh rate",
|
||||||
|
Value: dashboard.DefaultConfig.Refresh,
|
||||||
|
}
|
||||||
|
DashboardAssetsFlag = cli.StringFlag{
|
||||||
|
Name: "dashboard.assets",
|
||||||
|
Usage: "Developer flag to serve the dashboard from the local file system",
|
||||||
|
Value: dashboard.DefaultConfig.Assets,
|
||||||
|
}
|
||||||
// Ethash settings
|
// Ethash settings
|
||||||
EthashCacheDirFlag = DirectoryFlag{
|
EthashCacheDirFlag = DirectoryFlag{
|
||||||
Name: "ethash.cachedir",
|
Name: "ethash.cachedir",
|
||||||
|
|
@ -1019,6 +1045,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetDashboardConfig applies dashboard related command line flags to the config.
|
||||||
|
func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) {
|
||||||
|
cfg.Host = ctx.GlobalString(DashboardAddrFlag.Name)
|
||||||
|
cfg.Port = ctx.GlobalInt(DashboardPortFlag.Name)
|
||||||
|
cfg.Refresh = ctx.GlobalDuration(DashboardRefreshFlag.Name)
|
||||||
|
cfg.Assets = ctx.GlobalString(DashboardAssetsFlag.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterEthService adds an Ethereum client to the stack.
|
// RegisterEthService adds an Ethereum client to the stack.
|
||||||
func RegisterEthService(stack *node.Node, cfg *eth.Config) {
|
func RegisterEthService(stack *node.Node, cfg *eth.Config) {
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -1041,6 +1075,13 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RegisterDashboardService adds a dashboard to the stack.
|
||||||
|
func RegisterDashboardService(stack *node.Node, cfg *dashboard.Config) {
|
||||||
|
stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
|
||||||
|
return dashboard.New(cfg)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterShhService configures Whisper and adds it to the given node.
|
// RegisterShhService configures Whisper and adds it to the given node.
|
||||||
func RegisterShhService(stack *node.Node, cfg *whisper.Config) {
|
func RegisterShhService(stack *node.Node, cfg *whisper.Config) {
|
||||||
if err := stack.Register(func(n *node.ServiceContext) (node.Service, error) {
|
if err := stack.Register(func(n *node.ServiceContext) (node.Service, error) {
|
||||||
|
|
|
||||||
|
|
@ -818,7 +818,12 @@ func (bc *BlockChain) WriteBlockAndState(block *types.Block, receipts []*types.R
|
||||||
// If the total difficulty is higher than our known, add it to the canonical chain
|
// If the total difficulty is higher than our known, add it to the canonical chain
|
||||||
// Second clause in the if statement reduces the vulnerability to selfish mining.
|
// Second clause in the if statement reduces the vulnerability to selfish mining.
|
||||||
// Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
|
// Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
|
||||||
if externTd.Cmp(localTd) > 0 || (externTd.Cmp(localTd) == 0 && mrand.Float64() < 0.5) {
|
reorg := externTd.Cmp(localTd) > 0
|
||||||
|
if !reorg && externTd.Cmp(localTd) == 0 {
|
||||||
|
// Split same-difficulty blocks by number, then at random
|
||||||
|
reorg = block.NumberU64() < bc.currentBlock.NumberU64() || (block.NumberU64() == bc.currentBlock.NumberU64() && mrand.Float64() < 0.5)
|
||||||
|
}
|
||||||
|
if reorg {
|
||||||
// Reorganise the chain if the parent is not the head block
|
// Reorganise the chain if the parent is not the head block
|
||||||
if block.ParentHash() != bc.currentBlock.Hash() {
|
if block.ParentHash() != bc.currentBlock.Hash() {
|
||||||
if err := bc.reorg(bc.currentBlock, block); err != nil {
|
if err := bc.reorg(bc.currentBlock, block); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
// destinations stores one map per contract (keyed by hash of code).
|
// destinations stores one map per contract (keyed by hash of code).
|
||||||
// The maps contain an entry for each location of a JUMPDEST
|
// The maps contain an entry for each location of a JUMPDEST
|
||||||
// instruction.
|
// instruction.
|
||||||
type destinations map[common.Hash][]byte
|
type destinations map[common.Hash]bitvec
|
||||||
|
|
||||||
// has checks whether code has a JUMPDEST at dest.
|
// has checks whether code has a JUMPDEST at dest.
|
||||||
func (d destinations) has(codehash common.Hash, code []byte, dest *big.Int) bool {
|
func (d destinations) has(codehash common.Hash, code []byte, dest *big.Int) bool {
|
||||||
|
|
@ -38,24 +38,53 @@ func (d destinations) has(codehash common.Hash, code []byte, dest *big.Int) bool
|
||||||
|
|
||||||
m, analysed := d[codehash]
|
m, analysed := d[codehash]
|
||||||
if !analysed {
|
if !analysed {
|
||||||
m = jumpdests(code)
|
m = codeBitmap(code)
|
||||||
d[codehash] = m
|
d[codehash] = m
|
||||||
}
|
}
|
||||||
return (m[udest/8] & (1 << (udest % 8))) != 0
|
return OpCode(code[udest]) == JUMPDEST && m.codeSegment(udest)
|
||||||
}
|
}
|
||||||
|
|
||||||
// jumpdests creates a map that contains an entry for each
|
// bitvec is a bit vector which maps bytes in a program.
|
||||||
// PC location that is a JUMPDEST instruction.
|
// An unset bit means the byte is an opcode, a set bit means
|
||||||
func jumpdests(code []byte) []byte {
|
// it's data (i.e. argument of PUSHxx).
|
||||||
m := make([]byte, len(code)/8+1)
|
type bitvec []byte
|
||||||
for pc := uint64(0); pc < uint64(len(code)); pc++ {
|
|
||||||
|
func (bits *bitvec) set(pos uint64) {
|
||||||
|
(*bits)[pos/8] |= 0x80 >> (pos % 8)
|
||||||
|
}
|
||||||
|
func (bits *bitvec) set8(pos uint64) {
|
||||||
|
(*bits)[pos/8] |= 0xFF >> (pos % 8)
|
||||||
|
(*bits)[pos/8+1] |= ^(0xFF >> (pos % 8))
|
||||||
|
}
|
||||||
|
|
||||||
|
// codeSegment checks if the position is in a code segment.
|
||||||
|
func (bits *bitvec) codeSegment(pos uint64) bool {
|
||||||
|
return ((*bits)[pos/8] & (0x80 >> (pos % 8))) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// codeBitmap collects data locations in code.
|
||||||
|
func codeBitmap(code []byte) bitvec {
|
||||||
|
// The bitmap is 4 bytes longer than necessary, in case the code
|
||||||
|
// ends with a PUSH32, the algorithm will push zeroes onto the
|
||||||
|
// bitvector outside the bounds of the actual code.
|
||||||
|
bits := make(bitvec, len(code)/8+1+4)
|
||||||
|
for pc := uint64(0); pc < uint64(len(code)); {
|
||||||
op := OpCode(code[pc])
|
op := OpCode(code[pc])
|
||||||
if op == JUMPDEST {
|
|
||||||
m[pc/8] |= 1 << (pc % 8)
|
if op >= PUSH1 && op <= PUSH32 {
|
||||||
} else if op >= PUSH1 && op <= PUSH32 {
|
numbits := op - PUSH1 + 1
|
||||||
a := uint64(op) - uint64(PUSH1) + 1
|
pc++
|
||||||
pc += a
|
for ; numbits >= 8; numbits -= 8 {
|
||||||
|
bits.set8(pc) // 8
|
||||||
|
pc += 8
|
||||||
|
}
|
||||||
|
for ; numbits > 0; numbits-- {
|
||||||
|
bits.set(pc)
|
||||||
|
pc++
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pc++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m
|
return bits
|
||||||
}
|
}
|
||||||
|
|
|
||||||
53
core/vm/analysis_test.go
Normal file
53
core/vm/analysis_test.go
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package vm
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestJumpDestAnalysis(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
code []byte
|
||||||
|
exp byte
|
||||||
|
which int
|
||||||
|
}{
|
||||||
|
{[]byte{byte(PUSH1), 0x01, 0x01, 0x01}, 0x40, 0},
|
||||||
|
{[]byte{byte(PUSH1), byte(PUSH1), byte(PUSH1), byte(PUSH1)}, 0x50, 0},
|
||||||
|
{[]byte{byte(PUSH8), byte(PUSH8), byte(PUSH8), byte(PUSH8), byte(PUSH8), byte(PUSH8), byte(PUSH8), byte(PUSH8), 0x01, 0x01, 0x01}, 0x7F, 0},
|
||||||
|
{[]byte{byte(PUSH8), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0x80, 1},
|
||||||
|
{[]byte{0x01, 0x01, 0x01, 0x01, 0x01, byte(PUSH2), byte(PUSH2), byte(PUSH2), 0x01, 0x01, 0x01}, 0x03, 0},
|
||||||
|
{[]byte{0x01, 0x01, 0x01, 0x01, 0x01, byte(PUSH2), 0x01, 0x01, 0x01, 0x01, 0x01}, 0x00, 1},
|
||||||
|
{[]byte{byte(PUSH3), 0x01, 0x01, 0x01, byte(PUSH1), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0x74, 0},
|
||||||
|
{[]byte{byte(PUSH3), 0x01, 0x01, 0x01, byte(PUSH1), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0x00, 1},
|
||||||
|
{[]byte{0x01, byte(PUSH8), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0x3F, 0},
|
||||||
|
{[]byte{0x01, byte(PUSH8), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0xC0, 1},
|
||||||
|
{[]byte{byte(PUSH16), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0x7F, 0},
|
||||||
|
{[]byte{byte(PUSH16), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0xFF, 1},
|
||||||
|
{[]byte{byte(PUSH16), 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, 0x80, 2},
|
||||||
|
{[]byte{byte(PUSH8), 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, byte(PUSH1), 0x01}, 0x7f, 0},
|
||||||
|
{[]byte{byte(PUSH8), 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, byte(PUSH1), 0x01}, 0xA0, 1},
|
||||||
|
{[]byte{byte(PUSH32)}, 0x7F, 0},
|
||||||
|
{[]byte{byte(PUSH32)}, 0xFF, 1},
|
||||||
|
{[]byte{byte(PUSH32)}, 0xFF, 2},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
ret := codeBitmap(test.code)
|
||||||
|
if ret[test.which] != test.exp {
|
||||||
|
t.Fatalf("expected %x, got %02x", test.exp, ret[test.which])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -42,12 +42,12 @@ type operation struct {
|
||||||
// memorySize returns the memory size required for the operation
|
// memorySize returns the memory size required for the operation
|
||||||
memorySize memorySizeFunc
|
memorySize memorySizeFunc
|
||||||
|
|
||||||
halts bool // indicates whether the operation shoult halt further execution
|
halts bool // indicates whether the operation should halt further execution
|
||||||
jumps bool // indicates whether the program counter should not increment
|
jumps bool // indicates whether the program counter should not increment
|
||||||
writes bool // determines whether this a state modifying operation
|
writes bool // determines whether this a state modifying operation
|
||||||
valid bool // indication whether the retrieved operation is valid and known
|
valid bool // indication whether the retrieved operation is valid and known
|
||||||
reverts bool // determines whether the operation reverts state (implicitly halts)
|
reverts bool // determines whether the operation reverts state (implicitly halts)
|
||||||
returns bool // determines whether the opertions sets the return data content
|
returns bool // determines whether the operations sets the return data content
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
46
dashboard/README.md
Normal file
46
dashboard/README.md
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
## Go Ethereum Dashboard
|
||||||
|
|
||||||
|
The dashboard is a data visualizer integrated into geth, intended to collect and visualize useful information of an Ethereum node. It consists of two parts:
|
||||||
|
|
||||||
|
* The client visualizes the collected data.
|
||||||
|
* The server collects the data, and updates the clients.
|
||||||
|
|
||||||
|
The client's UI uses [React][React] with JSX syntax, which is validated by the [ESLint][ESLint] linter mostly according to the [Airbnb React/JSX Style Guide][Airbnb]. The style is defined in the `.eslintrc` configuration file. The resources are bundled into a single `bundle.js` file using [Webpack][Webpack], which relies on the `webpack.config.js`. The bundled file is referenced from `dashboard.html` and takes part in the `assets.go` too. The necessary dependencies for the module bundler are gathered by [Node.js][Node.js].
|
||||||
|
|
||||||
|
### Development and bundling
|
||||||
|
|
||||||
|
As the dashboard depends on certain NPM packages (which are not included in the go-ethereum repo), these need to be installed first:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ (cd dashboard/assets && npm install)
|
||||||
|
```
|
||||||
|
|
||||||
|
Normally the dashboard assets are bundled into Geth via `go-bindata` to avoid external dependencies. Rebuilding Geth after each UI modification however is not feasible from a developer perspective. Instead, we can run `webpack` in watch mode to automatically rebundle the UI, and ask `geth` to use external assets to not rely on compiled resources:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ (cd dashboard/assets && ./node_modules/.bin/webpack --watch)
|
||||||
|
$ geth --dashboard --dashboard.assets=dashboard/assets/public --vmodule=dashboard=5
|
||||||
|
```
|
||||||
|
|
||||||
|
To bundle up the final UI into Geth, run `webpack` and `go generate`:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ (cd dashboard/assets && ./node_modules/.bin/webpack)
|
||||||
|
$ go generate ./dashboard
|
||||||
|
```
|
||||||
|
|
||||||
|
### Have fun
|
||||||
|
|
||||||
|
[Webpack][Webpack] offers handy tools for visualizing the bundle's dependency tree and space usage.
|
||||||
|
|
||||||
|
* Generate the bundle's profile running `webpack --profile --json > stats.json`
|
||||||
|
* For the _dependency tree_ go to [Webpack Analyze][WA], and import `stats.json`
|
||||||
|
* For the _space usage_ go to [Webpack Visualizer][WV], and import `stats.json`
|
||||||
|
|
||||||
|
[React]: https://reactjs.org/
|
||||||
|
[ESLint]: https://eslint.org/
|
||||||
|
[Airbnb]: https://github.com/airbnb/javascript/tree/master/react
|
||||||
|
[Webpack]: https://webpack.github.io/
|
||||||
|
[WA]: http://webpack.github.io/analyse/
|
||||||
|
[WV]: http://chrisbateman.github.io/webpack-visualizer/
|
||||||
|
[Node.js]: https://nodejs.org/en/
|
||||||
260
dashboard/assets.go
Normal file
260
dashboard/assets.go
Normal file
File diff suppressed because one or more lines are too long
52
dashboard/assets/.eslintrc
Normal file
52
dashboard/assets/.eslintrc
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// React syntax style mostly according to https://github.com/airbnb/javascript/tree/master/react
|
||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
"react"
|
||||||
|
],
|
||||||
|
"parser": "babel-eslint",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true,
|
||||||
|
"modules": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"react/prefer-es6-class": 2,
|
||||||
|
"react/prefer-stateless-function": 2,
|
||||||
|
"react/jsx-pascal-case": 2,
|
||||||
|
"react/jsx-closing-bracket-location": [1, {"selfClosing": "tag-aligned", "nonEmpty": "tag-aligned"}],
|
||||||
|
"react/jsx-closing-tag-location": 1,
|
||||||
|
"jsx-quotes": ["error", "prefer-double"],
|
||||||
|
"no-multi-spaces": "error",
|
||||||
|
"react/jsx-tag-spacing": 2,
|
||||||
|
"react/jsx-curly-spacing": [2, {"when": "never", "children": true}],
|
||||||
|
"react/jsx-boolean-value": 2,
|
||||||
|
"react/no-string-refs": 2,
|
||||||
|
"react/jsx-wrap-multilines": 2,
|
||||||
|
"react/self-closing-comp": 2,
|
||||||
|
"react/jsx-no-bind": 2,
|
||||||
|
"react/require-render-return": 2,
|
||||||
|
"react/no-is-mounted": 2,
|
||||||
|
"key-spacing": ["error", {"align": {
|
||||||
|
"beforeColon": false,
|
||||||
|
"afterColon": true,
|
||||||
|
"on": "value"
|
||||||
|
}}]
|
||||||
|
}
|
||||||
|
}
|
||||||
52
dashboard/assets/components/Common.jsx
Normal file
52
dashboard/assets/components/Common.jsx
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// isNullOrUndefined returns true if the given variable is null or undefined.
|
||||||
|
export const isNullOrUndefined = variable => variable === null || typeof variable === 'undefined';
|
||||||
|
|
||||||
|
export const LIMIT = {
|
||||||
|
memory: 200, // Maximum number of memory data samples.
|
||||||
|
traffic: 200, // Maximum number of traffic data samples.
|
||||||
|
log: 200, // Maximum number of logs.
|
||||||
|
};
|
||||||
|
// The sidebar menu and the main content are rendered based on these elements.
|
||||||
|
export const TAGS = (() => {
|
||||||
|
const T = {
|
||||||
|
home: { title: "Home", },
|
||||||
|
chain: { title: "Chain", },
|
||||||
|
transactions: { title: "Transactions", },
|
||||||
|
network: { title: "Network", },
|
||||||
|
system: { title: "System", },
|
||||||
|
logs: { title: "Logs", },
|
||||||
|
};
|
||||||
|
// Using the key is circumstantial in some cases, so it is better to insert it also as a value.
|
||||||
|
// This way the mistyping is prevented.
|
||||||
|
for(let key in T) {
|
||||||
|
T[key]['id'] = key;
|
||||||
|
}
|
||||||
|
return T;
|
||||||
|
})();
|
||||||
|
|
||||||
|
export const DATA_KEYS = (() => {
|
||||||
|
const DK = {};
|
||||||
|
["memory", "traffic", "logs"].map(key => {
|
||||||
|
DK[key] = key;
|
||||||
|
});
|
||||||
|
return DK;
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Temporary - taken from Material-UI
|
||||||
|
export const DRAWER_WIDTH = 240;
|
||||||
169
dashboard/assets/components/Dashboard.jsx
Normal file
169
dashboard/assets/components/Dashboard.jsx
Normal file
|
|
@ -0,0 +1,169 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import {withStyles} from 'material-ui/styles';
|
||||||
|
|
||||||
|
import SideBar from './SideBar.jsx';
|
||||||
|
import Header from './Header.jsx';
|
||||||
|
import Main from "./Main.jsx";
|
||||||
|
import {isNullOrUndefined, LIMIT, TAGS, DATA_KEYS,} from "./Common.jsx";
|
||||||
|
|
||||||
|
// Styles for the Dashboard component.
|
||||||
|
const styles = theme => ({
|
||||||
|
appFrame: {
|
||||||
|
position: 'relative',
|
||||||
|
display: 'flex',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
background: theme.palette.background.default,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Dashboard is the main component, which renders the whole page, makes connection with the server and listens for messages.
|
||||||
|
// When there is an incoming message, updates the page's content correspondingly.
|
||||||
|
class Dashboard extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
active: TAGS.home.id, // active menu
|
||||||
|
sideBar: true, // true if the sidebar is opened
|
||||||
|
memory: [],
|
||||||
|
traffic: [],
|
||||||
|
logs: [],
|
||||||
|
shouldUpdate: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// componentDidMount initiates the establishment of the first websocket connection after the component is rendered.
|
||||||
|
componentDidMount() {
|
||||||
|
this.reconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// reconnect establishes a websocket connection with the server, listens for incoming messages
|
||||||
|
// and tries to reconnect on connection loss.
|
||||||
|
reconnect = () => {
|
||||||
|
const server = new WebSocket(((window.location.protocol === "https:") ? "wss://" : "ws://") + window.location.host + "/api");
|
||||||
|
|
||||||
|
server.onmessage = event => {
|
||||||
|
const msg = JSON.parse(event.data);
|
||||||
|
if (isNullOrUndefined(msg)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.update(msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
server.onclose = () => {
|
||||||
|
setTimeout(this.reconnect, 3000);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// update analyzes the incoming message, and updates the charts' content correspondingly.
|
||||||
|
update = msg => {
|
||||||
|
console.log(msg);
|
||||||
|
this.setState(prevState => {
|
||||||
|
let newState = [];
|
||||||
|
newState.shouldUpdate = {};
|
||||||
|
const insert = (key, values, limit) => {
|
||||||
|
newState[key] = [...prevState[key], ...values];
|
||||||
|
while (newState[key].length > limit) {
|
||||||
|
newState[key].shift();
|
||||||
|
}
|
||||||
|
newState.shouldUpdate[key] = true;
|
||||||
|
};
|
||||||
|
// (Re)initialize the state with the past data.
|
||||||
|
if (!isNullOrUndefined(msg.history)) {
|
||||||
|
const memory = DATA_KEYS.memory;
|
||||||
|
const traffic = DATA_KEYS.traffic;
|
||||||
|
newState[memory] = [];
|
||||||
|
newState[traffic] = [];
|
||||||
|
if (!isNullOrUndefined(msg.history.memorySamples)) {
|
||||||
|
newState[memory] = msg.history.memorySamples.map(elem => isNullOrUndefined(elem.value) ? 0 : elem.value);
|
||||||
|
while (newState[memory].length > LIMIT.memory) {
|
||||||
|
newState[memory].shift();
|
||||||
|
}
|
||||||
|
newState.shouldUpdate[memory] = true;
|
||||||
|
}
|
||||||
|
if (!isNullOrUndefined(msg.history.trafficSamples)) {
|
||||||
|
newState[traffic] = msg.history.trafficSamples.map(elem => isNullOrUndefined(elem.value) ? 0 : elem.value);
|
||||||
|
while (newState[traffic].length > LIMIT.traffic) {
|
||||||
|
newState[traffic].shift();
|
||||||
|
}
|
||||||
|
newState.shouldUpdate[traffic] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Insert the new data samples.
|
||||||
|
if (!isNullOrUndefined(msg.memory)) {
|
||||||
|
insert(DATA_KEYS.memory, [isNullOrUndefined(msg.memory.value) ? 0 : msg.memory.value], LIMIT.memory);
|
||||||
|
}
|
||||||
|
if (!isNullOrUndefined(msg.traffic)) {
|
||||||
|
insert(DATA_KEYS.traffic, [isNullOrUndefined(msg.traffic.value) ? 0 : msg.traffic.value], LIMIT.traffic);
|
||||||
|
}
|
||||||
|
if (!isNullOrUndefined(msg.log)) {
|
||||||
|
insert(DATA_KEYS.logs, [msg.log], LIMIT.log);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newState;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// The change of the active label on the SideBar component will trigger a new render in the Main component.
|
||||||
|
changeContent = active => {
|
||||||
|
this.setState(prevState => prevState.active !== active ? {active: active} : {});
|
||||||
|
};
|
||||||
|
|
||||||
|
openSideBar = () => {
|
||||||
|
this.setState({sideBar: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
closeSideBar = () => {
|
||||||
|
this.setState({sideBar: false});
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
// The classes property is injected by withStyles().
|
||||||
|
const {classes} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={classes.appFrame}>
|
||||||
|
<Header
|
||||||
|
opened={this.state.sideBar}
|
||||||
|
open={this.openSideBar}
|
||||||
|
/>
|
||||||
|
<SideBar
|
||||||
|
opened={this.state.sideBar}
|
||||||
|
close={this.closeSideBar}
|
||||||
|
changeContent={this.changeContent}
|
||||||
|
/>
|
||||||
|
<Main
|
||||||
|
opened={this.state.sideBar}
|
||||||
|
active={this.state.active}
|
||||||
|
memory={this.state.memory}
|
||||||
|
traffic={this.state.traffic}
|
||||||
|
logs={this.state.logs}
|
||||||
|
shouldUpdate={this.state.shouldUpdate}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dashboard.propTypes = {
|
||||||
|
classes: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withStyles(styles)(Dashboard);
|
||||||
87
dashboard/assets/components/Header.jsx
Normal file
87
dashboard/assets/components/Header.jsx
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import {withStyles} from 'material-ui/styles';
|
||||||
|
import AppBar from 'material-ui/AppBar';
|
||||||
|
import Toolbar from 'material-ui/Toolbar';
|
||||||
|
import Typography from 'material-ui/Typography';
|
||||||
|
import IconButton from 'material-ui/IconButton';
|
||||||
|
import MenuIcon from 'material-ui-icons/Menu';
|
||||||
|
|
||||||
|
import {DRAWER_WIDTH} from './Common.jsx';
|
||||||
|
|
||||||
|
// Styles for the Header component.
|
||||||
|
const styles = theme => ({
|
||||||
|
appBar: {
|
||||||
|
position: 'absolute',
|
||||||
|
transition: theme.transitions.create(['margin', 'width'], {
|
||||||
|
easing: theme.transitions.easing.sharp,
|
||||||
|
duration: theme.transitions.duration.leavingScreen,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
appBarShift: {
|
||||||
|
marginLeft: DRAWER_WIDTH,
|
||||||
|
width: `calc(100% - ${DRAWER_WIDTH}px)`,
|
||||||
|
transition: theme.transitions.create(['margin', 'width'], {
|
||||||
|
easing: theme.transitions.easing.easeOut,
|
||||||
|
duration: theme.transitions.duration.enteringScreen,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
menuButton: {
|
||||||
|
marginLeft: 12,
|
||||||
|
marginRight: 20,
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Header renders a header, which contains a sidebar opener icon when that is closed.
|
||||||
|
class Header extends Component {
|
||||||
|
render() {
|
||||||
|
// The classes property is injected by withStyles().
|
||||||
|
const {classes} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppBar className={classNames(classes.appBar, this.props.opened && classes.appBarShift)}>
|
||||||
|
<Toolbar disableGutters={!this.props.opened}>
|
||||||
|
<IconButton
|
||||||
|
color="contrast"
|
||||||
|
aria-label="open drawer"
|
||||||
|
onClick={this.props.open}
|
||||||
|
className={classNames(classes.menuButton, this.props.opened && classes.hide)}
|
||||||
|
>
|
||||||
|
<MenuIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Typography type="title" color="inherit" noWrap>
|
||||||
|
Go Ethereum Dashboard
|
||||||
|
</Typography>
|
||||||
|
</Toolbar>
|
||||||
|
</AppBar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Header.propTypes = {
|
||||||
|
classes: PropTypes.object.isRequired,
|
||||||
|
opened: PropTypes.bool.isRequired,
|
||||||
|
open: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withStyles(styles)(Header);
|
||||||
89
dashboard/assets/components/Home.jsx
Normal file
89
dashboard/assets/components/Home.jsx
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import Grid from 'material-ui/Grid';
|
||||||
|
import {LineChart, AreaChart, Area, YAxis, CartesianGrid, Line, ResponsiveContainer} from 'recharts';
|
||||||
|
import {withTheme} from 'material-ui/styles';
|
||||||
|
|
||||||
|
import {isNullOrUndefined, DATA_KEYS} from "./Common.jsx";
|
||||||
|
|
||||||
|
// ChartGrid renders a grid container for responsive charts.
|
||||||
|
// The children are Recharts components extended with the Material-UI's xs property.
|
||||||
|
class ChartGrid extends Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Grid container spacing={this.props.spacing}>
|
||||||
|
{
|
||||||
|
React.Children.map(this.props.children, child => (
|
||||||
|
<Grid item xs={child.props.xs}>
|
||||||
|
<ResponsiveContainer width="100%" height={child.props.height}>
|
||||||
|
{React.cloneElement(child, {data: child.props.values.map(value => ({value: value}))})}
|
||||||
|
</ResponsiveContainer>
|
||||||
|
</Grid>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ChartGrid.propTypes = {
|
||||||
|
spacing: PropTypes.number.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Home renders the home component.
|
||||||
|
class Home extends Component {
|
||||||
|
shouldComponentUpdate(nextProps) {
|
||||||
|
return !isNullOrUndefined(nextProps.shouldUpdate[DATA_KEYS.memory]) ||
|
||||||
|
!isNullOrUndefined(nextProps.shouldUpdate[DATA_KEYS.traffic]);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const {theme} = this.props;
|
||||||
|
const memoryColor = theme.palette.primary[300];
|
||||||
|
const trafficColor = theme.palette.secondary[300];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ChartGrid spacing={24}>
|
||||||
|
<AreaChart xs={6} height={300} values={this.props.memory}>
|
||||||
|
<YAxis />
|
||||||
|
<Area type="monotone" dataKey="value" stroke={memoryColor} fill={memoryColor} />
|
||||||
|
</AreaChart>
|
||||||
|
<LineChart xs={6} height={300} values={this.props.traffic}>
|
||||||
|
<Line type="monotone" dataKey="value" stroke={trafficColor} dot={false} />
|
||||||
|
</LineChart>
|
||||||
|
<LineChart xs={6} height={300} values={this.props.memory}>
|
||||||
|
<YAxis />
|
||||||
|
<CartesianGrid stroke="#eee" strokeDasharray="5 5" />
|
||||||
|
<Line type="monotone" dataKey="value" stroke={memoryColor} dot={false} />
|
||||||
|
</LineChart>
|
||||||
|
<AreaChart xs={6} height={300} values={this.props.traffic}>
|
||||||
|
<CartesianGrid stroke="#eee" strokeDasharray="5 5" vertical={false} />
|
||||||
|
<Area type="monotone" dataKey="value" stroke={trafficColor} fill={trafficColor} />
|
||||||
|
</AreaChart>
|
||||||
|
</ChartGrid>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Home.propTypes = {
|
||||||
|
theme: PropTypes.object.isRequired,
|
||||||
|
shouldUpdate: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withTheme()(Home);
|
||||||
109
dashboard/assets/components/Main.jsx
Normal file
109
dashboard/assets/components/Main.jsx
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import {withStyles} from 'material-ui/styles';
|
||||||
|
|
||||||
|
import {TAGS, DRAWER_WIDTH} from "./Common.jsx";
|
||||||
|
import Home from './Home.jsx';
|
||||||
|
|
||||||
|
// ContentSwitch chooses and renders the proper page content.
|
||||||
|
class ContentSwitch extends Component {
|
||||||
|
render() {
|
||||||
|
switch(this.props.active) {
|
||||||
|
case TAGS.home.id:
|
||||||
|
return <Home memory={this.props.memory} traffic={this.props.traffic} shouldUpdate={this.props.shouldUpdate} />;
|
||||||
|
case TAGS.chain.id:
|
||||||
|
return null;
|
||||||
|
case TAGS.transactions.id:
|
||||||
|
return null;
|
||||||
|
case TAGS.network.id:
|
||||||
|
// Only for testing.
|
||||||
|
return null;
|
||||||
|
case TAGS.system.id:
|
||||||
|
return null;
|
||||||
|
case TAGS.logs.id:
|
||||||
|
return <div>{this.props.logs.map((log, index) => <div key={index}>{log}</div>)}</div>;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentSwitch.propTypes = {
|
||||||
|
active: PropTypes.string.isRequired,
|
||||||
|
shouldUpdate: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
// styles contains the styles for the Main component.
|
||||||
|
const styles = theme => ({
|
||||||
|
content: {
|
||||||
|
width: '100%',
|
||||||
|
marginLeft: -DRAWER_WIDTH,
|
||||||
|
flexGrow: 1,
|
||||||
|
backgroundColor: theme.palette.background.default,
|
||||||
|
padding: theme.spacing.unit * 3,
|
||||||
|
transition: theme.transitions.create('margin', {
|
||||||
|
easing: theme.transitions.easing.sharp,
|
||||||
|
duration: theme.transitions.duration.leavingScreen,
|
||||||
|
}),
|
||||||
|
marginTop: 56,
|
||||||
|
overflow: 'auto',
|
||||||
|
[theme.breakpoints.up('sm')]: {
|
||||||
|
content: {
|
||||||
|
height: 'calc(100% - 64px)',
|
||||||
|
marginTop: 64,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
contentShift: {
|
||||||
|
marginLeft: 0,
|
||||||
|
transition: theme.transitions.create('margin', {
|
||||||
|
easing: theme.transitions.easing.easeOut,
|
||||||
|
duration: theme.transitions.duration.enteringScreen,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Main renders a component for the page content.
|
||||||
|
class Main extends Component {
|
||||||
|
render() {
|
||||||
|
// The classes property is injected by withStyles().
|
||||||
|
const {classes} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className={classNames(classes.content, this.props.opened && classes.contentShift)}>
|
||||||
|
<ContentSwitch
|
||||||
|
active={this.props.active}
|
||||||
|
memory={this.props.memory}
|
||||||
|
traffic={this.props.traffic}
|
||||||
|
logs={this.props.logs}
|
||||||
|
shouldUpdate={this.props.shouldUpdate}
|
||||||
|
/>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Main.propTypes = {
|
||||||
|
classes: PropTypes.object.isRequired,
|
||||||
|
opened: PropTypes.bool.isRequired,
|
||||||
|
active: PropTypes.string.isRequired,
|
||||||
|
shouldUpdate: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withStyles(styles)(Main);
|
||||||
106
dashboard/assets/components/SideBar.jsx
Normal file
106
dashboard/assets/components/SideBar.jsx
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import {withStyles} from 'material-ui/styles';
|
||||||
|
import Drawer from 'material-ui/Drawer';
|
||||||
|
import {IconButton} from "material-ui";
|
||||||
|
import List, {ListItem, ListItemText} from 'material-ui/List';
|
||||||
|
import ChevronLeftIcon from 'material-ui-icons/ChevronLeft';
|
||||||
|
|
||||||
|
import {TAGS, DRAWER_WIDTH} from './Common.jsx';
|
||||||
|
|
||||||
|
// Styles for the SideBar component.
|
||||||
|
const styles = theme => ({
|
||||||
|
drawerPaper: {
|
||||||
|
position: 'relative',
|
||||||
|
height: '100%',
|
||||||
|
width: DRAWER_WIDTH,
|
||||||
|
},
|
||||||
|
drawerHeader: {
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'flex-end',
|
||||||
|
padding: '0 8px',
|
||||||
|
...theme.mixins.toolbar,
|
||||||
|
transitionDuration: {
|
||||||
|
enter: theme.transitions.duration.enteringScreen,
|
||||||
|
exit: theme.transitions.duration.leavingScreen,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// SideBar renders a sidebar component.
|
||||||
|
class SideBar extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
// clickOn contains onClick event functions for the menu items.
|
||||||
|
// Instantiate only once, and reuse the existing functions to prevent the creation of
|
||||||
|
// new function instances every time the render method is triggered.
|
||||||
|
this.clickOn = {};
|
||||||
|
for(let key in TAGS) {
|
||||||
|
const id = TAGS[key].id;
|
||||||
|
this.clickOn[id] = event => {
|
||||||
|
event.preventDefault();
|
||||||
|
console.log(event.target.key);
|
||||||
|
this.props.changeContent(id);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
// The classes property is injected by withStyles().
|
||||||
|
const {classes} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Drawer
|
||||||
|
type="persistent"
|
||||||
|
classes={{paper: classes.drawerPaper,}}
|
||||||
|
open={this.props.opened}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div className={classes.drawerHeader}>
|
||||||
|
<IconButton onClick={this.props.close}>
|
||||||
|
<ChevronLeftIcon />
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
|
<List>
|
||||||
|
{
|
||||||
|
Object.values(TAGS).map(tag => {
|
||||||
|
return (
|
||||||
|
<ListItem button key={tag.id} onClick={this.clickOn[tag.id]}>
|
||||||
|
<ListItemText primary={tag.title} />
|
||||||
|
</ListItem>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</List>
|
||||||
|
</div>
|
||||||
|
</Drawer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SideBar.propTypes = {
|
||||||
|
classes: PropTypes.object.isRequired,
|
||||||
|
opened: PropTypes.bool.isRequired,
|
||||||
|
close: PropTypes.func.isRequired,
|
||||||
|
changeContent: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withStyles(styles)(SideBar);
|
||||||
36
dashboard/assets/index.jsx
Normal file
36
dashboard/assets/index.jsx
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import {hydrate} from 'react-dom';
|
||||||
|
import {createMuiTheme, MuiThemeProvider} from 'material-ui/styles';
|
||||||
|
|
||||||
|
import Dashboard from './components/Dashboard.jsx';
|
||||||
|
|
||||||
|
// Theme for the dashboard.
|
||||||
|
const theme = createMuiTheme({
|
||||||
|
palette: {
|
||||||
|
type: 'dark',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Renders the whole dashboard.
|
||||||
|
hydrate(
|
||||||
|
<MuiThemeProvider theme={theme}>
|
||||||
|
<Dashboard />
|
||||||
|
</MuiThemeProvider>,
|
||||||
|
document.getElementById('dashboard')
|
||||||
|
);
|
||||||
22
dashboard/assets/package.json
Normal file
22
dashboard/assets/package.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"babel-core": "^6.26.0",
|
||||||
|
"babel-eslint": "^8.0.1",
|
||||||
|
"babel-loader": "^7.1.2",
|
||||||
|
"babel-preset-env": "^1.6.1",
|
||||||
|
"babel-preset-react": "^6.24.1",
|
||||||
|
"babel-preset-stage-0": "^6.24.1",
|
||||||
|
"classnames": "^2.2.5",
|
||||||
|
"eslint": "^4.5.0",
|
||||||
|
"eslint-plugin-react": "^7.4.0",
|
||||||
|
"material-ui": "^1.0.0-beta.18",
|
||||||
|
"material-ui-icons": "^1.0.0-beta.17",
|
||||||
|
"path": "^0.12.7",
|
||||||
|
"prop-types": "^15.6.0",
|
||||||
|
"recharts": "^1.0.0-beta.0",
|
||||||
|
"react": "^16.0.0",
|
||||||
|
"react-dom": "^16.0.0",
|
||||||
|
"url": "^0.11.0",
|
||||||
|
"webpack": "^3.5.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
17
dashboard/assets/public/dashboard.html
Normal file
17
dashboard/assets/public/dashboard.html
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" style="height: 100%">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<title>Go Ethereum Dashboard</title>
|
||||||
|
<link rel="shortcut icon" type="image/ico" href="https://ethereum.org/favicon.ico"/>
|
||||||
|
|
||||||
|
<!-- TODO (kurkomisi): Return to the external libraries to speed up the bundling during development -->
|
||||||
|
</head>
|
||||||
|
<body style="height: 100%; margin: 0">
|
||||||
|
<div id="dashboard" style="height: 100%"></div>
|
||||||
|
<script src="bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
36
dashboard/assets/webpack.config.js
Normal file
36
dashboard/assets/webpack.config.js
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: './index.jsx',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, 'public'),
|
||||||
|
filename: 'bundle.js',
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
test: /\.jsx$/, // regexp for JSX files
|
||||||
|
loader: 'babel-loader', // The babel configuration is in the package.json.
|
||||||
|
query: {
|
||||||
|
presets: ['env', 'react', 'stage-0']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
45
dashboard/config.go
Normal file
45
dashboard/config.go
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package dashboard
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
// DefaultConfig contains default settings for the dashboard.
|
||||||
|
var DefaultConfig = Config{
|
||||||
|
Host: "localhost",
|
||||||
|
Port: 8080,
|
||||||
|
Refresh: 3 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Config contains the configuration parameters of the dashboard.
|
||||||
|
type Config struct {
|
||||||
|
// Host is the host interface on which to start the dashboard server. If this
|
||||||
|
// field is empty, no dashboard will be started.
|
||||||
|
Host string `toml:",omitempty"`
|
||||||
|
|
||||||
|
// Port is the TCP port number on which to start the dashboard server. The
|
||||||
|
// default zero value is/ valid and will pick a port number randomly (useful
|
||||||
|
// for ephemeral nodes).
|
||||||
|
Port int `toml:",omitempty"`
|
||||||
|
|
||||||
|
// Refresh is the refresh rate of the data updates, the chartEntry will be collected this often.
|
||||||
|
Refresh time.Duration `toml:",omitempty"`
|
||||||
|
|
||||||
|
// Assets offers a possibility to manually set the dashboard website's location on the server side.
|
||||||
|
// It is useful for debugging, avoids the repeated generation of the binary.
|
||||||
|
Assets string `toml:",omitempty"`
|
||||||
|
}
|
||||||
305
dashboard/dashboard.go
Normal file
305
dashboard/dashboard.go
Normal file
|
|
@ -0,0 +1,305 @@
|
||||||
|
// Copyright 2017 The go-ethereum Authors
|
||||||
|
// This file is part of the go-ethereum library.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package dashboard
|
||||||
|
|
||||||
|
//go:generate go-bindata -nometadata -o assets.go -prefix assets -pkg dashboard assets/public/...
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/rcrowley/go-metrics"
|
||||||
|
"golang.org/x/net/websocket"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
memorySampleLimit = 200 // Maximum number of memory data samples
|
||||||
|
trafficSampleLimit = 200 // Maximum number of traffic data samples
|
||||||
|
)
|
||||||
|
|
||||||
|
var nextId uint32 // Next connection id
|
||||||
|
|
||||||
|
// Dashboard contains the dashboard internals.
|
||||||
|
type Dashboard struct {
|
||||||
|
config *Config
|
||||||
|
|
||||||
|
listener net.Listener
|
||||||
|
conns map[uint32]*client // Currently live websocket connections
|
||||||
|
charts charts // The collected data samples to plot
|
||||||
|
lock sync.RWMutex // Lock protecting the dashboard's internals
|
||||||
|
|
||||||
|
quit chan chan error // Channel used for graceful exit
|
||||||
|
wg sync.WaitGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
// message embraces the data samples of a client message.
|
||||||
|
type message struct {
|
||||||
|
History *charts `json:"history,omitempty"` // Past data samples
|
||||||
|
Memory *chartEntry `json:"memory,omitempty"` // One memory sample
|
||||||
|
Traffic *chartEntry `json:"traffic,omitempty"` // One traffic sample
|
||||||
|
Log string `json:"log,omitempty"` // One log
|
||||||
|
}
|
||||||
|
|
||||||
|
// client represents active websocket connection with a remote browser.
|
||||||
|
type client struct {
|
||||||
|
conn *websocket.Conn // Particular live websocket connection
|
||||||
|
msg chan message // Message queue for the update messages
|
||||||
|
logger log.Logger // Logger for the particular live websocket connection
|
||||||
|
}
|
||||||
|
|
||||||
|
// charts contains the collected data samples.
|
||||||
|
type charts struct {
|
||||||
|
Memory []*chartEntry `json:"memorySamples,omitempty"`
|
||||||
|
Traffic []*chartEntry `json:"trafficSamples,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// chartEntry represents one data sample
|
||||||
|
type chartEntry struct {
|
||||||
|
Time time.Time `json:"time,omitempty"`
|
||||||
|
Value float64 `json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new dashboard instance with the given configuration.
|
||||||
|
func New(config *Config) (*Dashboard, error) {
|
||||||
|
return &Dashboard{
|
||||||
|
conns: make(map[uint32]*client),
|
||||||
|
config: config,
|
||||||
|
quit: make(chan chan error),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Protocols is a meaningless implementation of node.Service.
|
||||||
|
func (db *Dashboard) Protocols() []p2p.Protocol { return nil }
|
||||||
|
|
||||||
|
// APIs is a meaningless implementation of node.Service.
|
||||||
|
func (db *Dashboard) APIs() []rpc.API { return nil }
|
||||||
|
|
||||||
|
// Start implements node.Service, starting the data collection thread and the listening server of the dashboard.
|
||||||
|
func (db *Dashboard) Start(server *p2p.Server) error {
|
||||||
|
db.wg.Add(2)
|
||||||
|
go db.collectData()
|
||||||
|
go db.collectLogs() // In case of removing this line change 2 back to 1 in wg.Add.
|
||||||
|
|
||||||
|
http.HandleFunc("/", db.webHandler)
|
||||||
|
http.Handle("/api", websocket.Handler(db.apiHandler))
|
||||||
|
|
||||||
|
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", db.config.Host, db.config.Port))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
db.listener = listener
|
||||||
|
|
||||||
|
go http.Serve(listener, nil)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop implements node.Service, stopping the data collection thread and the connection listener of the dashboard.
|
||||||
|
func (db *Dashboard) Stop() error {
|
||||||
|
// Close the connection listener.
|
||||||
|
var errs []error
|
||||||
|
if err := db.listener.Close(); err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
// Close the collectors.
|
||||||
|
errc := make(chan error, 1)
|
||||||
|
for i := 0; i < 2; i++ {
|
||||||
|
db.quit <- errc
|
||||||
|
if err := <-errc; err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Close the connections.
|
||||||
|
db.lock.Lock()
|
||||||
|
for _, c := range db.conns {
|
||||||
|
if err := c.conn.Close(); err != nil {
|
||||||
|
c.logger.Warn("Failed to close connection", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.lock.Unlock()
|
||||||
|
|
||||||
|
// Wait until every goroutine terminates.
|
||||||
|
db.wg.Wait()
|
||||||
|
log.Info("Dashboard stopped")
|
||||||
|
|
||||||
|
var err error
|
||||||
|
if len(errs) > 0 {
|
||||||
|
err = fmt.Errorf("%v", errs)
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// webHandler handles all non-api requests, simply flattening and returning the dashboard website.
|
||||||
|
func (db *Dashboard) webHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Debug("Request", "URL", r.URL)
|
||||||
|
|
||||||
|
path := r.URL.String()
|
||||||
|
if path == "/" {
|
||||||
|
path = "/dashboard.html"
|
||||||
|
}
|
||||||
|
// If the path of the assets is manually set
|
||||||
|
if db.config.Assets != "" {
|
||||||
|
blob, err := ioutil.ReadFile(filepath.Join(db.config.Assets, path))
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("Failed to read file", "path", path, "err", err)
|
||||||
|
http.Error(w, "not found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Write(blob)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
blob, err := Asset(filepath.Join("public", path))
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("Failed to load the asset", "path", path, "err", err)
|
||||||
|
http.Error(w, "not found", http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.Write(blob)
|
||||||
|
}
|
||||||
|
|
||||||
|
// apiHandler handles requests for the dashboard.
|
||||||
|
func (db *Dashboard) apiHandler(conn *websocket.Conn) {
|
||||||
|
id := atomic.AddUint32(&nextId, 1)
|
||||||
|
client := &client{
|
||||||
|
conn: conn,
|
||||||
|
msg: make(chan message, 128),
|
||||||
|
logger: log.New("id", id),
|
||||||
|
}
|
||||||
|
done := make(chan struct{}) // Buffered channel as sender may exit early
|
||||||
|
|
||||||
|
// Start listening for messages to send.
|
||||||
|
db.wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer db.wg.Done()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
case msg := <-client.msg:
|
||||||
|
if err := websocket.JSON.Send(client.conn, msg); err != nil {
|
||||||
|
client.logger.Warn("Failed to send the message", "msg", msg, "err", err)
|
||||||
|
client.conn.Close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// Send the past data.
|
||||||
|
client.msg <- message{
|
||||||
|
History: &db.charts,
|
||||||
|
}
|
||||||
|
// Start tracking the connection and drop at connection loss.
|
||||||
|
db.lock.Lock()
|
||||||
|
db.conns[id] = client
|
||||||
|
db.lock.Unlock()
|
||||||
|
defer func() {
|
||||||
|
db.lock.Lock()
|
||||||
|
delete(db.conns, id)
|
||||||
|
db.lock.Unlock()
|
||||||
|
}()
|
||||||
|
for {
|
||||||
|
fail := []byte{}
|
||||||
|
if _, err := conn.Read(fail); err != nil {
|
||||||
|
close(done)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Ignore all messages
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// collectData collects the required data to plot on the dashboard.
|
||||||
|
func (db *Dashboard) collectData() {
|
||||||
|
defer db.wg.Done()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case errc := <-db.quit:
|
||||||
|
errc <- nil
|
||||||
|
return
|
||||||
|
case <-time.After(db.config.Refresh):
|
||||||
|
inboundTraffic := metrics.DefaultRegistry.Get("p2p/InboundTraffic").(metrics.Meter).Rate1()
|
||||||
|
memoryInUse := metrics.DefaultRegistry.Get("system/memory/inuse").(metrics.Meter).Rate1()
|
||||||
|
now := time.Now()
|
||||||
|
memory := &chartEntry{
|
||||||
|
Time: now,
|
||||||
|
Value: memoryInUse,
|
||||||
|
}
|
||||||
|
traffic := &chartEntry{
|
||||||
|
Time: now,
|
||||||
|
Value: inboundTraffic,
|
||||||
|
}
|
||||||
|
// Remove the first elements in case the samples' amount exceeds the limit.
|
||||||
|
first := 0
|
||||||
|
if len(db.charts.Memory) == memorySampleLimit {
|
||||||
|
first = 1
|
||||||
|
}
|
||||||
|
db.charts.Memory = append(db.charts.Memory[first:], memory)
|
||||||
|
first = 0
|
||||||
|
if len(db.charts.Traffic) == trafficSampleLimit {
|
||||||
|
first = 1
|
||||||
|
}
|
||||||
|
db.charts.Traffic = append(db.charts.Traffic[first:], traffic)
|
||||||
|
|
||||||
|
db.sendToAll(&message{
|
||||||
|
Memory: memory,
|
||||||
|
Traffic: traffic,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// collectLogs collects and sends the logs to the active dashboards.
|
||||||
|
func (db *Dashboard) collectLogs() {
|
||||||
|
defer db.wg.Done()
|
||||||
|
|
||||||
|
// TODO (kurkomisi): log collection comes here.
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case errc := <-db.quit:
|
||||||
|
errc <- nil
|
||||||
|
return
|
||||||
|
case <-time.After(db.config.Refresh / 2):
|
||||||
|
db.sendToAll(&message{
|
||||||
|
Log: "This is a fake log.",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sendToAll sends the given message to the active dashboards.
|
||||||
|
func (db *Dashboard) sendToAll(msg *message) {
|
||||||
|
db.lock.Lock()
|
||||||
|
for _, c := range db.conns {
|
||||||
|
select {
|
||||||
|
case c.msg <- *msg:
|
||||||
|
default:
|
||||||
|
c.conn.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.lock.Unlock()
|
||||||
|
}
|
||||||
|
|
@ -82,18 +82,22 @@ func Env() Environment {
|
||||||
// LocalEnv returns build environment metadata gathered from git.
|
// LocalEnv returns build environment metadata gathered from git.
|
||||||
func LocalEnv() Environment {
|
func LocalEnv() Environment {
|
||||||
env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"})
|
env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"})
|
||||||
if _, err := os.Stat(".git"); err != nil {
|
|
||||||
|
head := readGitFile("HEAD")
|
||||||
|
if splits := strings.Split(head, " "); len(splits) == 2 {
|
||||||
|
head = splits[1]
|
||||||
|
} else {
|
||||||
return env
|
return env
|
||||||
}
|
}
|
||||||
if env.Commit == "" {
|
if env.Commit == "" {
|
||||||
env.Commit = RunGit("rev-parse", "HEAD")
|
env.Commit = readGitFile(head)
|
||||||
}
|
}
|
||||||
if env.Branch == "" {
|
if env.Branch == "" {
|
||||||
if b := RunGit("rev-parse", "--abbrev-ref", "HEAD"); b != "HEAD" {
|
if head != "HEAD" {
|
||||||
env.Branch = b
|
env.Branch = strings.TrimLeft(head, "refs/heads/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if env.Tag == "" {
|
if info, err := os.Stat(".git/objects"); err == nil && info.IsDir() && env.Tag == "" {
|
||||||
env.Tag = firstLine(RunGit("tag", "-l", "--points-at", "HEAD"))
|
env.Tag = firstLine(RunGit("tag", "-l", "--points-at", "HEAD"))
|
||||||
}
|
}
|
||||||
return env
|
return env
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -88,6 +89,15 @@ func RunGit(args ...string) string {
|
||||||
return strings.TrimSpace(stdout.String())
|
return strings.TrimSpace(stdout.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// readGitFile returns content of file in .git directory.
|
||||||
|
func readGitFile(file string) string {
|
||||||
|
content, err := ioutil.ReadFile(path.Join(".git", file))
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(content))
|
||||||
|
}
|
||||||
|
|
||||||
// Render renders the given template file into outputFile.
|
// Render renders the given template file into outputFile.
|
||||||
func Render(templateFile, outputFile string, outputPerm os.FileMode, x interface{}) {
|
func Render(templateFile, outputFile string, outputPerm os.FileMode, x interface{}) {
|
||||||
tpl := template.Must(template.ParseFiles(templateFile))
|
tpl := template.Must(template.ParseFiles(templateFile))
|
||||||
|
|
|
||||||
|
|
@ -649,12 +649,14 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNr r
|
||||||
return (hexutil.Bytes)(result), err
|
return (hexutil.Bytes)(result), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// EstimateGas returns an estimate of the amount of gas needed to execute the given transaction.
|
// EstimateGas returns an estimate of the amount of gas needed to execute the
|
||||||
|
// given transaction against the current pending block.
|
||||||
func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (*hexutil.Big, error) {
|
func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (*hexutil.Big, error) {
|
||||||
// Binary search the gas requirement, as it may be higher than the amount used
|
// Determine the lowest and highest possible gas limits to binary search in between
|
||||||
var (
|
var (
|
||||||
lo uint64 = params.TxGas - 1
|
lo uint64 = params.TxGas - 1
|
||||||
hi uint64
|
hi uint64
|
||||||
|
cap uint64
|
||||||
)
|
)
|
||||||
if (*big.Int)(&args.Gas).Uint64() >= params.TxGas {
|
if (*big.Int)(&args.Gas).Uint64() >= params.TxGas {
|
||||||
hi = (*big.Int)(&args.Gas).Uint64()
|
hi = (*big.Int)(&args.Gas).Uint64()
|
||||||
|
|
@ -666,21 +668,32 @@ func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs) (*
|
||||||
}
|
}
|
||||||
hi = block.GasLimit().Uint64()
|
hi = block.GasLimit().Uint64()
|
||||||
}
|
}
|
||||||
for lo+1 < hi {
|
cap = hi
|
||||||
// Take a guess at the gas, and check transaction validity
|
|
||||||
mid := (hi + lo) / 2
|
|
||||||
(*big.Int)(&args.Gas).SetUint64(mid)
|
|
||||||
|
|
||||||
|
// Create a helper to check if a gas allowance results in an executable transaction
|
||||||
|
executable := func(gas uint64) bool {
|
||||||
|
(*big.Int)(&args.Gas).SetUint64(gas)
|
||||||
_, _, failed, err := s.doCall(ctx, args, rpc.PendingBlockNumber, vm.Config{})
|
_, _, failed, err := s.doCall(ctx, args, rpc.PendingBlockNumber, vm.Config{})
|
||||||
|
|
||||||
// If the transaction became invalid or execution failed, raise the gas limit
|
|
||||||
if err != nil || failed {
|
if err != nil || failed {
|
||||||
lo = mid
|
return false
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
// Otherwise assume the transaction succeeded, lower the gas limit
|
return true
|
||||||
|
}
|
||||||
|
// Execute the binary search and hone in on an executable gas limit
|
||||||
|
for lo+1 < hi {
|
||||||
|
mid := (hi + lo) / 2
|
||||||
|
if !executable(mid) {
|
||||||
|
lo = mid
|
||||||
|
} else {
|
||||||
hi = mid
|
hi = mid
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Reject the transaction as invalid if it still fails at the highest allowance
|
||||||
|
if hi == cap {
|
||||||
|
if !executable(hi) {
|
||||||
|
return nil, fmt.Errorf("gas required exceeds allowance or always failing transaction")
|
||||||
|
}
|
||||||
|
}
|
||||||
return (*hexutil.Big)(new(big.Int).SetUint64(hi)), nil
|
return (*hexutil.Big)(new(big.Int).SetUint64(hi)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import (
|
||||||
|
|
||||||
// MetricsEnabledFlag is the CLI flag name to use to enable metrics collections.
|
// MetricsEnabledFlag is the CLI flag name to use to enable metrics collections.
|
||||||
const MetricsEnabledFlag = "metrics"
|
const MetricsEnabledFlag = "metrics"
|
||||||
|
const DashboardEnabledFlag = "dashboard"
|
||||||
|
|
||||||
// Enabled is the flag specifying if metrics are enable or not.
|
// Enabled is the flag specifying if metrics are enable or not.
|
||||||
var Enabled = false
|
var Enabled = false
|
||||||
|
|
@ -39,7 +40,7 @@ var Enabled = false
|
||||||
// and peek into the command line args for the metrics flag.
|
// and peek into the command line args for the metrics flag.
|
||||||
func init() {
|
func init() {
|
||||||
for _, arg := range os.Args {
|
for _, arg := range os.Args {
|
||||||
if strings.TrimLeft(arg, "-") == MetricsEnabledFlag {
|
if flag := strings.TrimLeft(arg, "-"); flag == MetricsEnabledFlag || flag == DashboardEnabledFlag {
|
||||||
log.Info("Enabling metrics collection")
|
log.Info("Enabling metrics collection")
|
||||||
Enabled = true
|
Enabled = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
vendor/github.com/pmezard/go-difflib/LICENSE
generated
vendored
Normal file
27
vendor/github.com/pmezard/go-difflib/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2013, Patrick Mezard
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
The names of its contributors may not be used to endorse or promote
|
||||||
|
products derived from this software without specific prior written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
772
vendor/github.com/pmezard/go-difflib/difflib/difflib.go
generated
vendored
Normal file
772
vendor/github.com/pmezard/go-difflib/difflib/difflib.go
generated
vendored
Normal file
|
|
@ -0,0 +1,772 @@
|
||||||
|
// Package difflib is a partial port of Python difflib module.
|
||||||
|
//
|
||||||
|
// It provides tools to compare sequences of strings and generate textual diffs.
|
||||||
|
//
|
||||||
|
// The following class and functions have been ported:
|
||||||
|
//
|
||||||
|
// - SequenceMatcher
|
||||||
|
//
|
||||||
|
// - unified_diff
|
||||||
|
//
|
||||||
|
// - context_diff
|
||||||
|
//
|
||||||
|
// Getting unified diffs was the main goal of the port. Keep in mind this code
|
||||||
|
// is mostly suitable to output text differences in a human friendly way, there
|
||||||
|
// are no guarantees generated diffs are consumable by patch(1).
|
||||||
|
package difflib
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func min(a, b int) int {
|
||||||
|
if a < b {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func max(a, b int) int {
|
||||||
|
if a > b {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func calculateRatio(matches, length int) float64 {
|
||||||
|
if length > 0 {
|
||||||
|
return 2.0 * float64(matches) / float64(length)
|
||||||
|
}
|
||||||
|
return 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
type Match struct {
|
||||||
|
A int
|
||||||
|
B int
|
||||||
|
Size int
|
||||||
|
}
|
||||||
|
|
||||||
|
type OpCode struct {
|
||||||
|
Tag byte
|
||||||
|
I1 int
|
||||||
|
I2 int
|
||||||
|
J1 int
|
||||||
|
J2 int
|
||||||
|
}
|
||||||
|
|
||||||
|
// SequenceMatcher compares sequence of strings. The basic
|
||||||
|
// algorithm predates, and is a little fancier than, an algorithm
|
||||||
|
// published in the late 1980's by Ratcliff and Obershelp under the
|
||||||
|
// hyperbolic name "gestalt pattern matching". The basic idea is to find
|
||||||
|
// the longest contiguous matching subsequence that contains no "junk"
|
||||||
|
// elements (R-O doesn't address junk). The same idea is then applied
|
||||||
|
// recursively to the pieces of the sequences to the left and to the right
|
||||||
|
// of the matching subsequence. This does not yield minimal edit
|
||||||
|
// sequences, but does tend to yield matches that "look right" to people.
|
||||||
|
//
|
||||||
|
// SequenceMatcher tries to compute a "human-friendly diff" between two
|
||||||
|
// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the
|
||||||
|
// longest *contiguous* & junk-free matching subsequence. That's what
|
||||||
|
// catches peoples' eyes. The Windows(tm) windiff has another interesting
|
||||||
|
// notion, pairing up elements that appear uniquely in each sequence.
|
||||||
|
// That, and the method here, appear to yield more intuitive difference
|
||||||
|
// reports than does diff. This method appears to be the least vulnerable
|
||||||
|
// to synching up on blocks of "junk lines", though (like blank lines in
|
||||||
|
// ordinary text files, or maybe "<P>" lines in HTML files). That may be
|
||||||
|
// because this is the only method of the 3 that has a *concept* of
|
||||||
|
// "junk" <wink>.
|
||||||
|
//
|
||||||
|
// Timing: Basic R-O is cubic time worst case and quadratic time expected
|
||||||
|
// case. SequenceMatcher is quadratic time for the worst case and has
|
||||||
|
// expected-case behavior dependent in a complicated way on how many
|
||||||
|
// elements the sequences have in common; best case time is linear.
|
||||||
|
type SequenceMatcher struct {
|
||||||
|
a []string
|
||||||
|
b []string
|
||||||
|
b2j map[string][]int
|
||||||
|
IsJunk func(string) bool
|
||||||
|
autoJunk bool
|
||||||
|
bJunk map[string]struct{}
|
||||||
|
matchingBlocks []Match
|
||||||
|
fullBCount map[string]int
|
||||||
|
bPopular map[string]struct{}
|
||||||
|
opCodes []OpCode
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMatcher(a, b []string) *SequenceMatcher {
|
||||||
|
m := SequenceMatcher{autoJunk: true}
|
||||||
|
m.SetSeqs(a, b)
|
||||||
|
return &m
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMatcherWithJunk(a, b []string, autoJunk bool,
|
||||||
|
isJunk func(string) bool) *SequenceMatcher {
|
||||||
|
|
||||||
|
m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk}
|
||||||
|
m.SetSeqs(a, b)
|
||||||
|
return &m
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set two sequences to be compared.
|
||||||
|
func (m *SequenceMatcher) SetSeqs(a, b []string) {
|
||||||
|
m.SetSeq1(a)
|
||||||
|
m.SetSeq2(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the first sequence to be compared. The second sequence to be compared is
|
||||||
|
// not changed.
|
||||||
|
//
|
||||||
|
// SequenceMatcher computes and caches detailed information about the second
|
||||||
|
// sequence, so if you want to compare one sequence S against many sequences,
|
||||||
|
// use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other
|
||||||
|
// sequences.
|
||||||
|
//
|
||||||
|
// See also SetSeqs() and SetSeq2().
|
||||||
|
func (m *SequenceMatcher) SetSeq1(a []string) {
|
||||||
|
if &a == &m.a {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.a = a
|
||||||
|
m.matchingBlocks = nil
|
||||||
|
m.opCodes = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the second sequence to be compared. The first sequence to be compared is
|
||||||
|
// not changed.
|
||||||
|
func (m *SequenceMatcher) SetSeq2(b []string) {
|
||||||
|
if &b == &m.b {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.b = b
|
||||||
|
m.matchingBlocks = nil
|
||||||
|
m.opCodes = nil
|
||||||
|
m.fullBCount = nil
|
||||||
|
m.chainB()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SequenceMatcher) chainB() {
|
||||||
|
// Populate line -> index mapping
|
||||||
|
b2j := map[string][]int{}
|
||||||
|
for i, s := range m.b {
|
||||||
|
indices := b2j[s]
|
||||||
|
indices = append(indices, i)
|
||||||
|
b2j[s] = indices
|
||||||
|
}
|
||||||
|
|
||||||
|
// Purge junk elements
|
||||||
|
m.bJunk = map[string]struct{}{}
|
||||||
|
if m.IsJunk != nil {
|
||||||
|
junk := m.bJunk
|
||||||
|
for s, _ := range b2j {
|
||||||
|
if m.IsJunk(s) {
|
||||||
|
junk[s] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for s, _ := range junk {
|
||||||
|
delete(b2j, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Purge remaining popular elements
|
||||||
|
popular := map[string]struct{}{}
|
||||||
|
n := len(m.b)
|
||||||
|
if m.autoJunk && n >= 200 {
|
||||||
|
ntest := n/100 + 1
|
||||||
|
for s, indices := range b2j {
|
||||||
|
if len(indices) > ntest {
|
||||||
|
popular[s] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for s, _ := range popular {
|
||||||
|
delete(b2j, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.bPopular = popular
|
||||||
|
m.b2j = b2j
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *SequenceMatcher) isBJunk(s string) bool {
|
||||||
|
_, ok := m.bJunk[s]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find longest matching block in a[alo:ahi] and b[blo:bhi].
|
||||||
|
//
|
||||||
|
// If IsJunk is not defined:
|
||||||
|
//
|
||||||
|
// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
|
||||||
|
// alo <= i <= i+k <= ahi
|
||||||
|
// blo <= j <= j+k <= bhi
|
||||||
|
// and for all (i',j',k') meeting those conditions,
|
||||||
|
// k >= k'
|
||||||
|
// i <= i'
|
||||||
|
// and if i == i', j <= j'
|
||||||
|
//
|
||||||
|
// In other words, of all maximal matching blocks, return one that
|
||||||
|
// starts earliest in a, and of all those maximal matching blocks that
|
||||||
|
// start earliest in a, return the one that starts earliest in b.
|
||||||
|
//
|
||||||
|
// If IsJunk is defined, first the longest matching block is
|
||||||
|
// determined as above, but with the additional restriction that no
|
||||||
|
// junk element appears in the block. Then that block is extended as
|
||||||
|
// far as possible by matching (only) junk elements on both sides. So
|
||||||
|
// the resulting block never matches on junk except as identical junk
|
||||||
|
// happens to be adjacent to an "interesting" match.
|
||||||
|
//
|
||||||
|
// If no blocks match, return (alo, blo, 0).
|
||||||
|
func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match {
|
||||||
|
// CAUTION: stripping common prefix or suffix would be incorrect.
|
||||||
|
// E.g.,
|
||||||
|
// ab
|
||||||
|
// acab
|
||||||
|
// Longest matching block is "ab", but if common prefix is
|
||||||
|
// stripped, it's "a" (tied with "b"). UNIX(tm) diff does so
|
||||||
|
// strip, so ends up claiming that ab is changed to acab by
|
||||||
|
// inserting "ca" in the middle. That's minimal but unintuitive:
|
||||||
|
// "it's obvious" that someone inserted "ac" at the front.
|
||||||
|
// Windiff ends up at the same place as diff, but by pairing up
|
||||||
|
// the unique 'b's and then matching the first two 'a's.
|
||||||
|
besti, bestj, bestsize := alo, blo, 0
|
||||||
|
|
||||||
|
// find longest junk-free match
|
||||||
|
// during an iteration of the loop, j2len[j] = length of longest
|
||||||
|
// junk-free match ending with a[i-1] and b[j]
|
||||||
|
j2len := map[int]int{}
|
||||||
|
for i := alo; i != ahi; i++ {
|
||||||
|
// look at all instances of a[i] in b; note that because
|
||||||
|
// b2j has no junk keys, the loop is skipped if a[i] is junk
|
||||||
|
newj2len := map[int]int{}
|
||||||
|
for _, j := range m.b2j[m.a[i]] {
|
||||||
|
// a[i] matches b[j]
|
||||||
|
if j < blo {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if j >= bhi {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
k := j2len[j-1] + 1
|
||||||
|
newj2len[j] = k
|
||||||
|
if k > bestsize {
|
||||||
|
besti, bestj, bestsize = i-k+1, j-k+1, k
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j2len = newj2len
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extend the best by non-junk elements on each end. In particular,
|
||||||
|
// "popular" non-junk elements aren't in b2j, which greatly speeds
|
||||||
|
// the inner loop above, but also means "the best" match so far
|
||||||
|
// doesn't contain any junk *or* popular non-junk elements.
|
||||||
|
for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) &&
|
||||||
|
m.a[besti-1] == m.b[bestj-1] {
|
||||||
|
besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
|
||||||
|
}
|
||||||
|
for besti+bestsize < ahi && bestj+bestsize < bhi &&
|
||||||
|
!m.isBJunk(m.b[bestj+bestsize]) &&
|
||||||
|
m.a[besti+bestsize] == m.b[bestj+bestsize] {
|
||||||
|
bestsize += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that we have a wholly interesting match (albeit possibly
|
||||||
|
// empty!), we may as well suck up the matching junk on each
|
||||||
|
// side of it too. Can't think of a good reason not to, and it
|
||||||
|
// saves post-processing the (possibly considerable) expense of
|
||||||
|
// figuring out what to do with it. In the case of an empty
|
||||||
|
// interesting match, this is clearly the right thing to do,
|
||||||
|
// because no other kind of match is possible in the regions.
|
||||||
|
for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) &&
|
||||||
|
m.a[besti-1] == m.b[bestj-1] {
|
||||||
|
besti, bestj, bestsize = besti-1, bestj-1, bestsize+1
|
||||||
|
}
|
||||||
|
for besti+bestsize < ahi && bestj+bestsize < bhi &&
|
||||||
|
m.isBJunk(m.b[bestj+bestsize]) &&
|
||||||
|
m.a[besti+bestsize] == m.b[bestj+bestsize] {
|
||||||
|
bestsize += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return Match{A: besti, B: bestj, Size: bestsize}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return list of triples describing matching subsequences.
|
||||||
|
//
|
||||||
|
// Each triple is of the form (i, j, n), and means that
|
||||||
|
// a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in
|
||||||
|
// i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are
|
||||||
|
// adjacent triples in the list, and the second is not the last triple in the
|
||||||
|
// list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe
|
||||||
|
// adjacent equal blocks.
|
||||||
|
//
|
||||||
|
// The last triple is a dummy, (len(a), len(b), 0), and is the only
|
||||||
|
// triple with n==0.
|
||||||
|
func (m *SequenceMatcher) GetMatchingBlocks() []Match {
|
||||||
|
if m.matchingBlocks != nil {
|
||||||
|
return m.matchingBlocks
|
||||||
|
}
|
||||||
|
|
||||||
|
var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match
|
||||||
|
matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match {
|
||||||
|
match := m.findLongestMatch(alo, ahi, blo, bhi)
|
||||||
|
i, j, k := match.A, match.B, match.Size
|
||||||
|
if match.Size > 0 {
|
||||||
|
if alo < i && blo < j {
|
||||||
|
matched = matchBlocks(alo, i, blo, j, matched)
|
||||||
|
}
|
||||||
|
matched = append(matched, match)
|
||||||
|
if i+k < ahi && j+k < bhi {
|
||||||
|
matched = matchBlocks(i+k, ahi, j+k, bhi, matched)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matched
|
||||||
|
}
|
||||||
|
matched := matchBlocks(0, len(m.a), 0, len(m.b), nil)
|
||||||
|
|
||||||
|
// It's possible that we have adjacent equal blocks in the
|
||||||
|
// matching_blocks list now.
|
||||||
|
nonAdjacent := []Match{}
|
||||||
|
i1, j1, k1 := 0, 0, 0
|
||||||
|
for _, b := range matched {
|
||||||
|
// Is this block adjacent to i1, j1, k1?
|
||||||
|
i2, j2, k2 := b.A, b.B, b.Size
|
||||||
|
if i1+k1 == i2 && j1+k1 == j2 {
|
||||||
|
// Yes, so collapse them -- this just increases the length of
|
||||||
|
// the first block by the length of the second, and the first
|
||||||
|
// block so lengthened remains the block to compare against.
|
||||||
|
k1 += k2
|
||||||
|
} else {
|
||||||
|
// Not adjacent. Remember the first block (k1==0 means it's
|
||||||
|
// the dummy we started with), and make the second block the
|
||||||
|
// new block to compare against.
|
||||||
|
if k1 > 0 {
|
||||||
|
nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
|
||||||
|
}
|
||||||
|
i1, j1, k1 = i2, j2, k2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if k1 > 0 {
|
||||||
|
nonAdjacent = append(nonAdjacent, Match{i1, j1, k1})
|
||||||
|
}
|
||||||
|
|
||||||
|
nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0})
|
||||||
|
m.matchingBlocks = nonAdjacent
|
||||||
|
return m.matchingBlocks
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return list of 5-tuples describing how to turn a into b.
|
||||||
|
//
|
||||||
|
// Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple
|
||||||
|
// has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the
|
||||||
|
// tuple preceding it, and likewise for j1 == the previous j2.
|
||||||
|
//
|
||||||
|
// The tags are characters, with these meanings:
|
||||||
|
//
|
||||||
|
// 'r' (replace): a[i1:i2] should be replaced by b[j1:j2]
|
||||||
|
//
|
||||||
|
// 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case.
|
||||||
|
//
|
||||||
|
// 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case.
|
||||||
|
//
|
||||||
|
// 'e' (equal): a[i1:i2] == b[j1:j2]
|
||||||
|
func (m *SequenceMatcher) GetOpCodes() []OpCode {
|
||||||
|
if m.opCodes != nil {
|
||||||
|
return m.opCodes
|
||||||
|
}
|
||||||
|
i, j := 0, 0
|
||||||
|
matching := m.GetMatchingBlocks()
|
||||||
|
opCodes := make([]OpCode, 0, len(matching))
|
||||||
|
for _, m := range matching {
|
||||||
|
// invariant: we've pumped out correct diffs to change
|
||||||
|
// a[:i] into b[:j], and the next matching block is
|
||||||
|
// a[ai:ai+size] == b[bj:bj+size]. So we need to pump
|
||||||
|
// out a diff to change a[i:ai] into b[j:bj], pump out
|
||||||
|
// the matching block, and move (i,j) beyond the match
|
||||||
|
ai, bj, size := m.A, m.B, m.Size
|
||||||
|
tag := byte(0)
|
||||||
|
if i < ai && j < bj {
|
||||||
|
tag = 'r'
|
||||||
|
} else if i < ai {
|
||||||
|
tag = 'd'
|
||||||
|
} else if j < bj {
|
||||||
|
tag = 'i'
|
||||||
|
}
|
||||||
|
if tag > 0 {
|
||||||
|
opCodes = append(opCodes, OpCode{tag, i, ai, j, bj})
|
||||||
|
}
|
||||||
|
i, j = ai+size, bj+size
|
||||||
|
// the list of matching blocks is terminated by a
|
||||||
|
// sentinel with size 0
|
||||||
|
if size > 0 {
|
||||||
|
opCodes = append(opCodes, OpCode{'e', ai, i, bj, j})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.opCodes = opCodes
|
||||||
|
return m.opCodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// Isolate change clusters by eliminating ranges with no changes.
|
||||||
|
//
|
||||||
|
// Return a generator of groups with up to n lines of context.
|
||||||
|
// Each group is in the same format as returned by GetOpCodes().
|
||||||
|
func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
|
||||||
|
if n < 0 {
|
||||||
|
n = 3
|
||||||
|
}
|
||||||
|
codes := m.GetOpCodes()
|
||||||
|
if len(codes) == 0 {
|
||||||
|
codes = []OpCode{OpCode{'e', 0, 1, 0, 1}}
|
||||||
|
}
|
||||||
|
// Fixup leading and trailing groups if they show no changes.
|
||||||
|
if codes[0].Tag == 'e' {
|
||||||
|
c := codes[0]
|
||||||
|
i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
|
||||||
|
codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2}
|
||||||
|
}
|
||||||
|
if codes[len(codes)-1].Tag == 'e' {
|
||||||
|
c := codes[len(codes)-1]
|
||||||
|
i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
|
||||||
|
codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)}
|
||||||
|
}
|
||||||
|
nn := n + n
|
||||||
|
groups := [][]OpCode{}
|
||||||
|
group := []OpCode{}
|
||||||
|
for _, c := range codes {
|
||||||
|
i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
|
||||||
|
// End the current group and start a new one whenever
|
||||||
|
// there is a large range with no changes.
|
||||||
|
if c.Tag == 'e' && i2-i1 > nn {
|
||||||
|
group = append(group, OpCode{c.Tag, i1, min(i2, i1+n),
|
||||||
|
j1, min(j2, j1+n)})
|
||||||
|
groups = append(groups, group)
|
||||||
|
group = []OpCode{}
|
||||||
|
i1, j1 = max(i1, i2-n), max(j1, j2-n)
|
||||||
|
}
|
||||||
|
group = append(group, OpCode{c.Tag, i1, i2, j1, j2})
|
||||||
|
}
|
||||||
|
if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') {
|
||||||
|
groups = append(groups, group)
|
||||||
|
}
|
||||||
|
return groups
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return a measure of the sequences' similarity (float in [0,1]).
|
||||||
|
//
|
||||||
|
// Where T is the total number of elements in both sequences, and
|
||||||
|
// M is the number of matches, this is 2.0*M / T.
|
||||||
|
// Note that this is 1 if the sequences are identical, and 0 if
|
||||||
|
// they have nothing in common.
|
||||||
|
//
|
||||||
|
// .Ratio() is expensive to compute if you haven't already computed
|
||||||
|
// .GetMatchingBlocks() or .GetOpCodes(), in which case you may
|
||||||
|
// want to try .QuickRatio() or .RealQuickRation() first to get an
|
||||||
|
// upper bound.
|
||||||
|
func (m *SequenceMatcher) Ratio() float64 {
|
||||||
|
matches := 0
|
||||||
|
for _, m := range m.GetMatchingBlocks() {
|
||||||
|
matches += m.Size
|
||||||
|
}
|
||||||
|
return calculateRatio(matches, len(m.a)+len(m.b))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return an upper bound on ratio() relatively quickly.
|
||||||
|
//
|
||||||
|
// This isn't defined beyond that it is an upper bound on .Ratio(), and
|
||||||
|
// is faster to compute.
|
||||||
|
func (m *SequenceMatcher) QuickRatio() float64 {
|
||||||
|
// viewing a and b as multisets, set matches to the cardinality
|
||||||
|
// of their intersection; this counts the number of matches
|
||||||
|
// without regard to order, so is clearly an upper bound
|
||||||
|
if m.fullBCount == nil {
|
||||||
|
m.fullBCount = map[string]int{}
|
||||||
|
for _, s := range m.b {
|
||||||
|
m.fullBCount[s] = m.fullBCount[s] + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// avail[x] is the number of times x appears in 'b' less the
|
||||||
|
// number of times we've seen it in 'a' so far ... kinda
|
||||||
|
avail := map[string]int{}
|
||||||
|
matches := 0
|
||||||
|
for _, s := range m.a {
|
||||||
|
n, ok := avail[s]
|
||||||
|
if !ok {
|
||||||
|
n = m.fullBCount[s]
|
||||||
|
}
|
||||||
|
avail[s] = n - 1
|
||||||
|
if n > 0 {
|
||||||
|
matches += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return calculateRatio(matches, len(m.a)+len(m.b))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return an upper bound on ratio() very quickly.
|
||||||
|
//
|
||||||
|
// This isn't defined beyond that it is an upper bound on .Ratio(), and
|
||||||
|
// is faster to compute than either .Ratio() or .QuickRatio().
|
||||||
|
func (m *SequenceMatcher) RealQuickRatio() float64 {
|
||||||
|
la, lb := len(m.a), len(m.b)
|
||||||
|
return calculateRatio(min(la, lb), la+lb)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert range to the "ed" format
|
||||||
|
func formatRangeUnified(start, stop int) string {
|
||||||
|
// Per the diff spec at http://www.unix.org/single_unix_specification/
|
||||||
|
beginning := start + 1 // lines start numbering with one
|
||||||
|
length := stop - start
|
||||||
|
if length == 1 {
|
||||||
|
return fmt.Sprintf("%d", beginning)
|
||||||
|
}
|
||||||
|
if length == 0 {
|
||||||
|
beginning -= 1 // empty ranges begin at line just before the range
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%d,%d", beginning, length)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unified diff parameters
|
||||||
|
type UnifiedDiff struct {
|
||||||
|
A []string // First sequence lines
|
||||||
|
FromFile string // First file name
|
||||||
|
FromDate string // First file time
|
||||||
|
B []string // Second sequence lines
|
||||||
|
ToFile string // Second file name
|
||||||
|
ToDate string // Second file time
|
||||||
|
Eol string // Headers end of line, defaults to LF
|
||||||
|
Context int // Number of context lines
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare two sequences of lines; generate the delta as a unified diff.
|
||||||
|
//
|
||||||
|
// Unified diffs are a compact way of showing line changes and a few
|
||||||
|
// lines of context. The number of context lines is set by 'n' which
|
||||||
|
// defaults to three.
|
||||||
|
//
|
||||||
|
// By default, the diff control lines (those with ---, +++, or @@) are
|
||||||
|
// created with a trailing newline. This is helpful so that inputs
|
||||||
|
// created from file.readlines() result in diffs that are suitable for
|
||||||
|
// file.writelines() since both the inputs and outputs have trailing
|
||||||
|
// newlines.
|
||||||
|
//
|
||||||
|
// For inputs that do not have trailing newlines, set the lineterm
|
||||||
|
// argument to "" so that the output will be uniformly newline free.
|
||||||
|
//
|
||||||
|
// The unidiff format normally has a header for filenames and modification
|
||||||
|
// times. Any or all of these may be specified using strings for
|
||||||
|
// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.
|
||||||
|
// The modification times are normally expressed in the ISO 8601 format.
|
||||||
|
func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error {
|
||||||
|
buf := bufio.NewWriter(writer)
|
||||||
|
defer buf.Flush()
|
||||||
|
wf := func(format string, args ...interface{}) error {
|
||||||
|
_, err := buf.WriteString(fmt.Sprintf(format, args...))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ws := func(s string) error {
|
||||||
|
_, err := buf.WriteString(s)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(diff.Eol) == 0 {
|
||||||
|
diff.Eol = "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
started := false
|
||||||
|
m := NewMatcher(diff.A, diff.B)
|
||||||
|
for _, g := range m.GetGroupedOpCodes(diff.Context) {
|
||||||
|
if !started {
|
||||||
|
started = true
|
||||||
|
fromDate := ""
|
||||||
|
if len(diff.FromDate) > 0 {
|
||||||
|
fromDate = "\t" + diff.FromDate
|
||||||
|
}
|
||||||
|
toDate := ""
|
||||||
|
if len(diff.ToDate) > 0 {
|
||||||
|
toDate = "\t" + diff.ToDate
|
||||||
|
}
|
||||||
|
if diff.FromFile != "" || diff.ToFile != "" {
|
||||||
|
err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
first, last := g[0], g[len(g)-1]
|
||||||
|
range1 := formatRangeUnified(first.I1, last.I2)
|
||||||
|
range2 := formatRangeUnified(first.J1, last.J2)
|
||||||
|
if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, c := range g {
|
||||||
|
i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2
|
||||||
|
if c.Tag == 'e' {
|
||||||
|
for _, line := range diff.A[i1:i2] {
|
||||||
|
if err := ws(" " + line); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if c.Tag == 'r' || c.Tag == 'd' {
|
||||||
|
for _, line := range diff.A[i1:i2] {
|
||||||
|
if err := ws("-" + line); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c.Tag == 'r' || c.Tag == 'i' {
|
||||||
|
for _, line := range diff.B[j1:j2] {
|
||||||
|
if err := ws("+" + line); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Like WriteUnifiedDiff but returns the diff a string.
|
||||||
|
func GetUnifiedDiffString(diff UnifiedDiff) (string, error) {
|
||||||
|
w := &bytes.Buffer{}
|
||||||
|
err := WriteUnifiedDiff(w, diff)
|
||||||
|
return string(w.Bytes()), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert range to the "ed" format.
|
||||||
|
func formatRangeContext(start, stop int) string {
|
||||||
|
// Per the diff spec at http://www.unix.org/single_unix_specification/
|
||||||
|
beginning := start + 1 // lines start numbering with one
|
||||||
|
length := stop - start
|
||||||
|
if length == 0 {
|
||||||
|
beginning -= 1 // empty ranges begin at line just before the range
|
||||||
|
}
|
||||||
|
if length <= 1 {
|
||||||
|
return fmt.Sprintf("%d", beginning)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%d,%d", beginning, beginning+length-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContextDiff UnifiedDiff
|
||||||
|
|
||||||
|
// Compare two sequences of lines; generate the delta as a context diff.
|
||||||
|
//
|
||||||
|
// Context diffs are a compact way of showing line changes and a few
|
||||||
|
// lines of context. The number of context lines is set by diff.Context
|
||||||
|
// which defaults to three.
|
||||||
|
//
|
||||||
|
// By default, the diff control lines (those with *** or ---) are
|
||||||
|
// created with a trailing newline.
|
||||||
|
//
|
||||||
|
// For inputs that do not have trailing newlines, set the diff.Eol
|
||||||
|
// argument to "" so that the output will be uniformly newline free.
|
||||||
|
//
|
||||||
|
// The context diff format normally has a header for filenames and
|
||||||
|
// modification times. Any or all of these may be specified using
|
||||||
|
// strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate.
|
||||||
|
// The modification times are normally expressed in the ISO 8601 format.
|
||||||
|
// If not specified, the strings default to blanks.
|
||||||
|
func WriteContextDiff(writer io.Writer, diff ContextDiff) error {
|
||||||
|
buf := bufio.NewWriter(writer)
|
||||||
|
defer buf.Flush()
|
||||||
|
var diffErr error
|
||||||
|
wf := func(format string, args ...interface{}) {
|
||||||
|
_, err := buf.WriteString(fmt.Sprintf(format, args...))
|
||||||
|
if diffErr == nil && err != nil {
|
||||||
|
diffErr = err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ws := func(s string) {
|
||||||
|
_, err := buf.WriteString(s)
|
||||||
|
if diffErr == nil && err != nil {
|
||||||
|
diffErr = err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(diff.Eol) == 0 {
|
||||||
|
diff.Eol = "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
prefix := map[byte]string{
|
||||||
|
'i': "+ ",
|
||||||
|
'd': "- ",
|
||||||
|
'r': "! ",
|
||||||
|
'e': " ",
|
||||||
|
}
|
||||||
|
|
||||||
|
started := false
|
||||||
|
m := NewMatcher(diff.A, diff.B)
|
||||||
|
for _, g := range m.GetGroupedOpCodes(diff.Context) {
|
||||||
|
if !started {
|
||||||
|
started = true
|
||||||
|
fromDate := ""
|
||||||
|
if len(diff.FromDate) > 0 {
|
||||||
|
fromDate = "\t" + diff.FromDate
|
||||||
|
}
|
||||||
|
toDate := ""
|
||||||
|
if len(diff.ToDate) > 0 {
|
||||||
|
toDate = "\t" + diff.ToDate
|
||||||
|
}
|
||||||
|
if diff.FromFile != "" || diff.ToFile != "" {
|
||||||
|
wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol)
|
||||||
|
wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
first, last := g[0], g[len(g)-1]
|
||||||
|
ws("***************" + diff.Eol)
|
||||||
|
|
||||||
|
range1 := formatRangeContext(first.I1, last.I2)
|
||||||
|
wf("*** %s ****%s", range1, diff.Eol)
|
||||||
|
for _, c := range g {
|
||||||
|
if c.Tag == 'r' || c.Tag == 'd' {
|
||||||
|
for _, cc := range g {
|
||||||
|
if cc.Tag == 'i' {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, line := range diff.A[cc.I1:cc.I2] {
|
||||||
|
ws(prefix[cc.Tag] + line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
range2 := formatRangeContext(first.J1, last.J2)
|
||||||
|
wf("--- %s ----%s", range2, diff.Eol)
|
||||||
|
for _, c := range g {
|
||||||
|
if c.Tag == 'r' || c.Tag == 'i' {
|
||||||
|
for _, cc := range g {
|
||||||
|
if cc.Tag == 'd' {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, line := range diff.B[cc.J1:cc.J2] {
|
||||||
|
ws(prefix[cc.Tag] + line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return diffErr
|
||||||
|
}
|
||||||
|
|
||||||
|
// Like WriteContextDiff but returns the diff a string.
|
||||||
|
func GetContextDiffString(diff ContextDiff) (string, error) {
|
||||||
|
w := &bytes.Buffer{}
|
||||||
|
err := WriteContextDiff(w, diff)
|
||||||
|
return string(w.Bytes()), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split a string on "\n" while preserving them. The output can be used
|
||||||
|
// as input for UnifiedDiff and ContextDiff structures.
|
||||||
|
func SplitLines(s string) []string {
|
||||||
|
lines := strings.SplitAfter(s, "\n")
|
||||||
|
lines[len(lines)-1] += "\n"
|
||||||
|
return lines
|
||||||
|
}
|
||||||
22
vendor/github.com/stretchr/testify/LICENSE
generated
vendored
Normal file
22
vendor/github.com/stretchr/testify/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell
|
||||||
|
|
||||||
|
Please consider promoting this project if you find it useful.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge,
|
||||||
|
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
||||||
|
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||||
|
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
379
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
Normal file
379
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
Normal file
|
|
@ -0,0 +1,379 @@
|
||||||
|
/*
|
||||||
|
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
|
||||||
|
* THIS FILE MUST NOT BE EDITED BY HAND
|
||||||
|
*/
|
||||||
|
|
||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
http "net/http"
|
||||||
|
url "net/url"
|
||||||
|
time "time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Conditionf uses a Comparison to assert a complex condition.
|
||||||
|
func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool {
|
||||||
|
return Condition(t, comp, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Containsf asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Contains(t, s, contains, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// assert.Emptyf(t, obj, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Empty(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// assert.Equalf(t, 123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses). Function equality
|
||||||
|
// cannot be determined and will always fail.
|
||||||
|
func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool {
|
||||||
|
return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errorf asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.Errorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedErrorf, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Errorf(t TestingT, err error, msg string, args ...interface{}) bool {
|
||||||
|
return Error(t, err, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return Fail(t, failureMessage, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// assert.Falsef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool {
|
||||||
|
return False(t, value, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyContains(t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyNotContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyNotContains(t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPErrorf asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPError(t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPRedirect(t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccessf asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPSuccess(t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool {
|
||||||
|
return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool {
|
||||||
|
return Len(t, object, length, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// assert.Nilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Nil(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.NoErrorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool {
|
||||||
|
return NoError(t, err, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEmpty(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// assert.NotNilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotNil(t, object, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return NotPanics(t, f, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotZero(t, i, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return Panics(t, f, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
|
||||||
|
// the recovered panic value equals the expected panic value.
|
||||||
|
//
|
||||||
|
// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Regexp(t, rx, str, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Subset(t, list, subset, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// assert.Truef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Truef(t TestingT, value bool, msg string, args ...interface{}) bool {
|
||||||
|
return True(t, value, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
|
||||||
|
return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Zero(t, i, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
4
vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl
generated
vendored
Normal file
4
vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{.CommentFormat}}
|
||||||
|
func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool {
|
||||||
|
return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}})
|
||||||
|
}
|
||||||
746
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
Normal file
746
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
Normal file
|
|
@ -0,0 +1,746 @@
|
||||||
|
/*
|
||||||
|
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
|
||||||
|
* THIS FILE MUST NOT BE EDITED BY HAND
|
||||||
|
*/
|
||||||
|
|
||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
http "net/http"
|
||||||
|
url "net/url"
|
||||||
|
time "time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Condition uses a Comparison to assert a complex condition.
|
||||||
|
func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool {
|
||||||
|
return Condition(a.t, comp, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conditionf uses a Comparison to assert a complex condition.
|
||||||
|
func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool {
|
||||||
|
return Conditionf(a.t, comp, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.Contains("Hello World", "World")
|
||||||
|
// a.Contains(["Hello", "World"], "World")
|
||||||
|
// a.Contains({"Hello": "World"}, "Hello")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Contains(a.t, s, contains, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Containsf asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.Containsf("Hello World", "World", "error message %s", "formatted")
|
||||||
|
// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
|
||||||
|
// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Containsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// a.Empty(obj)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Empty(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// a.Emptyf(obj, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Emptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// a.Equal(123, 123)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses). Function equality
|
||||||
|
// cannot be determined and will always fail.
|
||||||
|
func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Equal(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualError asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// a.EqualError(err, expectedErrorString)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool {
|
||||||
|
return EqualError(a.t, theError, errString, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool {
|
||||||
|
return EqualErrorf(a.t, theError, errString, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// a.EqualValues(uint32(123), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return EqualValues(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return EqualValuesf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// a.Equalf(123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses). Function equality
|
||||||
|
// cannot be determined and will always fail.
|
||||||
|
func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Equalf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.Error(err) {
|
||||||
|
// assert.Equal(t, expectedError, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool {
|
||||||
|
return Error(a.t, err, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errorf asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.Errorf(err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedErrorf, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool {
|
||||||
|
return Errorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// a.Exactly(int32(123), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Exactly(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Exactlyf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail reports a failure through
|
||||||
|
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool {
|
||||||
|
return Fail(a.t, failureMessage, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNow fails test
|
||||||
|
func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool {
|
||||||
|
return FailNow(a.t, failureMessage, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return FailNowf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool {
|
||||||
|
return Failf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// False asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// a.False(myBool)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
return False(a.t, value, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// a.Falsef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool {
|
||||||
|
return Falsef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContains asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyContains(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyNotContains(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyNotContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool {
|
||||||
|
return HTTPBodyNotContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPError asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPError(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPErrorf asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPErrorf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPRedirect(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPRedirectf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPSuccess(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccessf asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values) bool {
|
||||||
|
return HTTPSuccessf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// a.Implements((*MyInterface)(nil), new(MyObject))
|
||||||
|
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Implements(a.t, interfaceObject, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Implementsf(a.t, interfaceObject, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDelta asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// a.InDelta(math.Pi, (22 / 7.0), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
||||||
|
return InDelta(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlice is the same as InDelta, except it compares two slices.
|
||||||
|
func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool {
|
||||||
|
return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool {
|
||||||
|
return InDeltaf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
|
||||||
|
return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool {
|
||||||
|
return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool {
|
||||||
|
return InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsType asserts that the specified objects are of the same type.
|
||||||
|
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return IsType(a.t, expectedType, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return IsTypef(a.t, expectedType, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEq asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool {
|
||||||
|
return JSONEq(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool {
|
||||||
|
return JSONEqf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Len asserts that the specified object has specific length.
|
||||||
|
// Len also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// a.Len(mySlice, 3)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool {
|
||||||
|
return Len(a.t, object, length, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// a.Lenf(mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool {
|
||||||
|
return Lenf(a.t, object, length, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nil asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// a.Nil(err)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Nil(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// a.Nilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Nilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.NoError(err) {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool {
|
||||||
|
return NoError(a.t, err, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.NoErrorf(err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool {
|
||||||
|
return NoErrorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.NotContains("Hello World", "Earth")
|
||||||
|
// a.NotContains(["Hello", "World"], "Earth")
|
||||||
|
// a.NotContains({"Hello": "World"}, "Earth")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotContains(a.t, s, contains, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotContainsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if a.NotEmpty(obj) {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotEmpty(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if a.NotEmptyf(obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEmptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// a.NotEqual(obj1, obj2)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotEqual(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotEqualf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNil asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// a.NotNil(err)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotNil(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// a.NotNilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotNilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// a.NotPanics(func(){ RemainCalm() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotPanics(a.t, f, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return NotPanicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexp asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
|
||||||
|
// a.NotRegexp("^start", "it's not starting")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotRegexp(a.t, rx, str, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotRegexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubset asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotSubset(a.t, list, subset, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotSubsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return NotZero(a.t, i, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return NotZerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// a.Panics(func(){ GoCrazy() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
return Panics(a.t, f, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
|
||||||
|
// the recovered panic value equals the expected panic value.
|
||||||
|
//
|
||||||
|
// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
|
||||||
|
return PanicsWithValue(a.t, expected, f, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
|
||||||
|
// the recovered panic value equals the expected panic value.
|
||||||
|
//
|
||||||
|
// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return PanicsWithValuef(a.t, expected, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool {
|
||||||
|
return Panicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexp asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// a.Regexp(regexp.MustCompile("start"), "it's starting")
|
||||||
|
// a.Regexp("start...$", "it's not starting")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Regexp(a.t, rx, str, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Regexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subset asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Subset(a.t, list, subset, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Subsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// True asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// a.True(myBool)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool {
|
||||||
|
return True(a.t, value, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// a.Truef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool {
|
||||||
|
return Truef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
|
return WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool {
|
||||||
|
return WithinDurationf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zero asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
return Zero(a.t, i, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool {
|
||||||
|
return Zerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
4
vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl
generated
vendored
Normal file
4
vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{.CommentWithoutT "a"}}
|
||||||
|
func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool {
|
||||||
|
return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
|
||||||
|
}
|
||||||
1208
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
Normal file
1208
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
45
vendor/github.com/stretchr/testify/assert/doc.go
generated
vendored
Normal file
45
vendor/github.com/stretchr/testify/assert/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
|
||||||
|
//
|
||||||
|
// Example Usage
|
||||||
|
//
|
||||||
|
// The following is a complete example using assert in a standard test function:
|
||||||
|
// import (
|
||||||
|
// "testing"
|
||||||
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// func TestSomething(t *testing.T) {
|
||||||
|
//
|
||||||
|
// var a string = "Hello"
|
||||||
|
// var b string = "Hello"
|
||||||
|
//
|
||||||
|
// assert.Equal(t, a, b, "The two words should be the same.")
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if you assert many times, use the format below:
|
||||||
|
//
|
||||||
|
// import (
|
||||||
|
// "testing"
|
||||||
|
// "github.com/stretchr/testify/assert"
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// func TestSomething(t *testing.T) {
|
||||||
|
// assert := assert.New(t)
|
||||||
|
//
|
||||||
|
// var a string = "Hello"
|
||||||
|
// var b string = "Hello"
|
||||||
|
//
|
||||||
|
// assert.Equal(a, b, "The two words should be the same.")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Assertions
|
||||||
|
//
|
||||||
|
// Assertions allow you to easily write test code, and are global funcs in the `assert` package.
|
||||||
|
// All assertion functions take, as the first argument, the `*testing.T` object provided by the
|
||||||
|
// testing framework. This allows the assertion funcs to write the failings and other details to
|
||||||
|
// the correct place.
|
||||||
|
//
|
||||||
|
// Every assertion function also takes an optional string message as the final argument,
|
||||||
|
// allowing custom error messages to be appended to the message the assertion method outputs.
|
||||||
|
package assert
|
||||||
10
vendor/github.com/stretchr/testify/assert/errors.go
generated
vendored
Normal file
10
vendor/github.com/stretchr/testify/assert/errors.go
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AnError is an error instance useful for testing. If the code does not care
|
||||||
|
// about error specifics, and only needs to return the error for example, this
|
||||||
|
// error should be used to make the test code more readable.
|
||||||
|
var AnError = errors.New("assert.AnError general error for testing")
|
||||||
16
vendor/github.com/stretchr/testify/assert/forward_assertions.go
generated
vendored
Normal file
16
vendor/github.com/stretchr/testify/assert/forward_assertions.go
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package assert
|
||||||
|
|
||||||
|
// Assertions provides assertion methods around the
|
||||||
|
// TestingT interface.
|
||||||
|
type Assertions struct {
|
||||||
|
t TestingT
|
||||||
|
}
|
||||||
|
|
||||||
|
// New makes a new Assertions object for the specified TestingT.
|
||||||
|
func New(t TestingT) *Assertions {
|
||||||
|
return &Assertions{
|
||||||
|
t: t,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs
|
||||||
127
vendor/github.com/stretchr/testify/assert/http_assertions.go
generated
vendored
Normal file
127
vendor/github.com/stretchr/testify/assert/http_assertions.go
generated
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
package assert
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// httpCode is a helper that returns HTTP code of the response. It returns -1 and
|
||||||
|
// an error if building a new request fails.
|
||||||
|
func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) {
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
handler(w, req)
|
||||||
|
return w.Code, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool {
|
||||||
|
code, err := httpCode(handler, method, url, values)
|
||||||
|
if err != nil {
|
||||||
|
Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent
|
||||||
|
if !isSuccessCode {
|
||||||
|
Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code))
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSuccessCode
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool {
|
||||||
|
code, err := httpCode(handler, method, url, values)
|
||||||
|
if err != nil {
|
||||||
|
Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect
|
||||||
|
if !isRedirectCode {
|
||||||
|
Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code))
|
||||||
|
}
|
||||||
|
|
||||||
|
return isRedirectCode
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPError asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool {
|
||||||
|
code, err := httpCode(handler, method, url, values)
|
||||||
|
if err != nil {
|
||||||
|
Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
isErrorCode := code >= http.StatusBadRequest
|
||||||
|
if !isErrorCode {
|
||||||
|
Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code))
|
||||||
|
}
|
||||||
|
|
||||||
|
return isErrorCode
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBody is a helper that returns HTTP body of the response. It returns
|
||||||
|
// empty string if building a new request fails.
|
||||||
|
func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string {
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
handler(w, req)
|
||||||
|
return w.Body.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContains asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool {
|
||||||
|
body := HTTPBody(handler, method, url, values)
|
||||||
|
|
||||||
|
contains := strings.Contains(body, fmt.Sprint(str))
|
||||||
|
if !contains {
|
||||||
|
Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
|
||||||
|
}
|
||||||
|
|
||||||
|
return contains
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool {
|
||||||
|
body := HTTPBody(handler, method, url, values)
|
||||||
|
|
||||||
|
contains := strings.Contains(body, fmt.Sprint(str))
|
||||||
|
if contains {
|
||||||
|
Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
|
||||||
|
}
|
||||||
|
|
||||||
|
return !contains
|
||||||
|
}
|
||||||
28
vendor/github.com/stretchr/testify/require/doc.go
generated
vendored
Normal file
28
vendor/github.com/stretchr/testify/require/doc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Package require implements the same assertions as the `assert` package but
|
||||||
|
// stops test execution when a test fails.
|
||||||
|
//
|
||||||
|
// Example Usage
|
||||||
|
//
|
||||||
|
// The following is a complete example using require in a standard test function:
|
||||||
|
// import (
|
||||||
|
// "testing"
|
||||||
|
// "github.com/stretchr/testify/require"
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// func TestSomething(t *testing.T) {
|
||||||
|
//
|
||||||
|
// var a string = "Hello"
|
||||||
|
// var b string = "Hello"
|
||||||
|
//
|
||||||
|
// require.Equal(t, a, b, "The two words should be the same.")
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Assertions
|
||||||
|
//
|
||||||
|
// The `require` package have same global functions as in the `assert` package,
|
||||||
|
// but instead of returning a boolean result they call `t.FailNow()`.
|
||||||
|
//
|
||||||
|
// Every assertion function also takes an optional string message as the final argument,
|
||||||
|
// allowing custom error messages to be appended to the message the assertion method outputs.
|
||||||
|
package require
|
||||||
16
vendor/github.com/stretchr/testify/require/forward_requirements.go
generated
vendored
Normal file
16
vendor/github.com/stretchr/testify/require/forward_requirements.go
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
package require
|
||||||
|
|
||||||
|
// Assertions provides assertion methods around the
|
||||||
|
// TestingT interface.
|
||||||
|
type Assertions struct {
|
||||||
|
t TestingT
|
||||||
|
}
|
||||||
|
|
||||||
|
// New makes a new Assertions object for the specified TestingT.
|
||||||
|
func New(t TestingT) *Assertions {
|
||||||
|
return &Assertions{
|
||||||
|
t: t,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl -include-format-funcs
|
||||||
911
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
Normal file
911
vendor/github.com/stretchr/testify/require/require.go
generated
vendored
Normal file
|
|
@ -0,0 +1,911 @@
|
||||||
|
/*
|
||||||
|
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
|
||||||
|
* THIS FILE MUST NOT BE EDITED BY HAND
|
||||||
|
*/
|
||||||
|
|
||||||
|
package require
|
||||||
|
|
||||||
|
import (
|
||||||
|
assert "github.com/stretchr/testify/assert"
|
||||||
|
http "net/http"
|
||||||
|
url "net/url"
|
||||||
|
time "time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Condition uses a Comparison to assert a complex condition.
|
||||||
|
func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Condition(t, comp, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conditionf uses a Comparison to assert a complex condition.
|
||||||
|
func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) {
|
||||||
|
if !assert.Conditionf(t, comp, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.Contains(t, "Hello World", "World")
|
||||||
|
// assert.Contains(t, ["Hello", "World"], "World")
|
||||||
|
// assert.Contains(t, {"Hello": "World"}, "Hello")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Contains(t, s, contains, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Containsf asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted")
|
||||||
|
// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Containsf(t, s, contains, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// assert.Empty(t, obj)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Empty(t, object, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// assert.Emptyf(t, obj, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Emptyf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// assert.Equal(t, 123, 123)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses). Function equality
|
||||||
|
// cannot be determined and will always fail.
|
||||||
|
func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Equal(t, expected, actual, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualError asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// assert.EqualError(t, err, expectedErrorString)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.EqualError(t, theError, errString, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) {
|
||||||
|
if !assert.EqualErrorf(t, theError, errString, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// assert.EqualValues(t, uint32(123), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.EqualValues(t, expected, actual, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.EqualValuesf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// assert.Equalf(t, 123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses). Function equality
|
||||||
|
// cannot be determined and will always fail.
|
||||||
|
func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Equalf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.Error(t, err) {
|
||||||
|
// assert.Equal(t, expectedError, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Error(t TestingT, err error, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Error(t, err, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errorf asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.Errorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedErrorf, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Errorf(t TestingT, err error, msg string, args ...interface{}) {
|
||||||
|
if !assert.Errorf(t, err, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// assert.Exactly(t, int32(123), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Exactly(t, expected, actual, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Exactlyf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail reports a failure through
|
||||||
|
func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Fail(t, failureMessage, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNow fails test
|
||||||
|
func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.FailNow(t, failureMessage, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) {
|
||||||
|
if !assert.FailNowf(t, failureMessage, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) {
|
||||||
|
if !assert.Failf(t, failureMessage, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// False asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// assert.False(t, myBool)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func False(t TestingT, value bool, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.False(t, value, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// assert.Falsef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Falsef(t TestingT, value bool, msg string, args ...interface{}) {
|
||||||
|
if !assert.Falsef(t, value, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContains asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
if !assert.HTTPBodyContains(t, handler, method, url, values, str) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
if !assert.HTTPBodyContainsf(t, handler, method, url, values, str) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
if !assert.HTTPBodyNotContains(t, handler, method, url, values, str) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// assert.HTTPBodyNotContainsf(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
if !assert.HTTPBodyNotContainsf(t, handler, method, url, values, str) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPError asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPError(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPErrorf asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPErrorf(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPRedirect(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPRedirectf(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPSuccess(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccessf asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
if !assert.HTTPSuccessf(t, handler, method, url, values) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// assert.Implements(t, (*MyInterface)(nil), new(MyObject))
|
||||||
|
func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Implements(t, interfaceObject, object, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Implementsf(t, interfaceObject, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDelta asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.InDelta(t, expected, actual, delta, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlice is the same as InDelta, except it compares two slices.
|
||||||
|
func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InDeltaf(t, expected, actual, delta, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
if !assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsType asserts that the specified objects are of the same type.
|
||||||
|
func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.IsType(t, expectedType, object, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.IsTypef(t, expectedType, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEq asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.JSONEq(t, expected, actual, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) {
|
||||||
|
if !assert.JSONEqf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Len asserts that the specified object has specific length.
|
||||||
|
// Len also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// assert.Len(t, mySlice, 3)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Len(t, object, length, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// assert.Lenf(t, mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) {
|
||||||
|
if !assert.Lenf(t, object, length, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nil asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// assert.Nil(t, err)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Nil(t, object, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// assert.Nilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Nilf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.NoError(t, err) {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NoError(t TestingT, err error, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NoError(t, err, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if assert.NoErrorf(t, err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NoErrorf(t TestingT, err error, msg string, args ...interface{}) {
|
||||||
|
if !assert.NoErrorf(t, err, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.NotContains(t, "Hello World", "Earth")
|
||||||
|
// assert.NotContains(t, ["Hello", "World"], "Earth")
|
||||||
|
// assert.NotContains(t, {"Hello": "World"}, "Earth")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotContains(t, s, contains, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotContainsf(t, s, contains, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if assert.NotEmpty(t, obj) {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotEmpty(t, object, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if assert.NotEmptyf(t, obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotEmptyf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// assert.NotEqual(t, obj1, obj2)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotEqual(t, expected, actual, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotEqualf(t, expected, actual, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNil asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// assert.NotNil(t, err)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotNil(t, object, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// assert.NotNilf(t, err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotNilf(t, object, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// assert.NotPanics(t, func(){ RemainCalm() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotPanics(t, f, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotPanicsf(t, f, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexp asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
|
||||||
|
// assert.NotRegexp(t, "^start", "it's not starting")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotRegexp(t, rx, str, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotRegexpf(t, rx, str, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubset asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotSubset(t, list, subset, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotSubsetf(t, list, subset, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.NotZero(t, i, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.NotZerof(t, i, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// assert.Panics(t, func(){ GoCrazy() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Panics(t, f, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
|
||||||
|
// the recovered panic value equals the expected panic value.
|
||||||
|
//
|
||||||
|
// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.PanicsWithValue(t, expected, f, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
|
||||||
|
// the recovered panic value equals the expected panic value.
|
||||||
|
//
|
||||||
|
// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
if !assert.PanicsWithValuef(t, expected, f, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
if !assert.Panicsf(t, f, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexp asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// assert.Regexp(t, regexp.MustCompile("start"), "it's starting")
|
||||||
|
// assert.Regexp(t, "start...$", "it's not starting")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Regexp(t, rx, str, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Regexpf(t, rx, str, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subset asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Subset(t, list, subset, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Subsetf(t, list, subset, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// True asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// assert.True(t, myBool)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func True(t TestingT, value bool, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.True(t, value, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// assert.Truef(t, myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func Truef(t TestingT, value bool, msg string, args ...interface{}) {
|
||||||
|
if !assert.Truef(t, value, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
|
||||||
|
if !assert.WithinDurationf(t, expected, actual, delta, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zero asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) {
|
||||||
|
if !assert.Zero(t, i, msgAndArgs...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) {
|
||||||
|
if !assert.Zerof(t, i, msg, args...) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
6
vendor/github.com/stretchr/testify/require/require.go.tmpl
generated
vendored
Normal file
6
vendor/github.com/stretchr/testify/require/require.go.tmpl
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{{.Comment}}
|
||||||
|
func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
|
||||||
|
if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) {
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
747
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
Normal file
747
vendor/github.com/stretchr/testify/require/require_forward.go
generated
vendored
Normal file
|
|
@ -0,0 +1,747 @@
|
||||||
|
/*
|
||||||
|
* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen
|
||||||
|
* THIS FILE MUST NOT BE EDITED BY HAND
|
||||||
|
*/
|
||||||
|
|
||||||
|
package require
|
||||||
|
|
||||||
|
import (
|
||||||
|
assert "github.com/stretchr/testify/assert"
|
||||||
|
http "net/http"
|
||||||
|
url "net/url"
|
||||||
|
time "time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Condition uses a Comparison to assert a complex condition.
|
||||||
|
func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) {
|
||||||
|
Condition(a.t, comp, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Conditionf uses a Comparison to assert a complex condition.
|
||||||
|
func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) {
|
||||||
|
Conditionf(a.t, comp, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contains asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.Contains("Hello World", "World")
|
||||||
|
// a.Contains(["Hello", "World"], "World")
|
||||||
|
// a.Contains({"Hello": "World"}, "Hello")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Contains(a.t, s, contains, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Containsf asserts that the specified string, list(array, slice...) or map contains the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.Containsf("Hello World", "World", "error message %s", "formatted")
|
||||||
|
// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted")
|
||||||
|
// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
Containsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// a.Empty(obj)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Empty(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// a.Emptyf(obj, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
Emptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// a.Equal(123, 123)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses). Function equality
|
||||||
|
// cannot be determined and will always fail.
|
||||||
|
func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Equal(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualError asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// a.EqualError(err, expectedErrorString)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) {
|
||||||
|
EqualError(a.t, theError, errString, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualErrorf asserts that a function returned an error (i.e. not `nil`)
|
||||||
|
// and that it is equal to the provided error.
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) {
|
||||||
|
EqualErrorf(a.t, theError, errString, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValues asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// a.EqualValues(uint32(123), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
EqualValues(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EqualValuesf asserts that two objects are equal or convertable to the same types
|
||||||
|
// and equal.
|
||||||
|
//
|
||||||
|
// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
EqualValuesf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equalf asserts that two objects are equal.
|
||||||
|
//
|
||||||
|
// a.Equalf(123, 123, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses). Function equality
|
||||||
|
// cannot be determined and will always fail.
|
||||||
|
func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
Equalf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.Error(err) {
|
||||||
|
// assert.Equal(t, expectedError, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Error(err error, msgAndArgs ...interface{}) {
|
||||||
|
Error(a.t, err, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errorf asserts that a function returned an error (i.e. not `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.Errorf(err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedErrorf, err)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Errorf(err error, msg string, args ...interface{}) {
|
||||||
|
Errorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactly asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// a.Exactly(int32(123), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Exactly(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exactlyf asserts that two objects are equal is value and type.
|
||||||
|
//
|
||||||
|
// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123))
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
Exactlyf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail reports a failure through
|
||||||
|
func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) {
|
||||||
|
Fail(a.t, failureMessage, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNow fails test
|
||||||
|
func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) {
|
||||||
|
FailNow(a.t, failureMessage, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FailNowf fails test
|
||||||
|
func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) {
|
||||||
|
FailNowf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Failf reports a failure through
|
||||||
|
func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) {
|
||||||
|
Failf(a.t, failureMessage, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// False asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// a.False(myBool)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) False(value bool, msgAndArgs ...interface{}) {
|
||||||
|
False(a.t, value, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Falsef asserts that the specified value is false.
|
||||||
|
//
|
||||||
|
// a.Falsef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) {
|
||||||
|
Falsef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContains asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
HTTPBodyContains(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyContainsf asserts that a specified handler returns a
|
||||||
|
// body that contains a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
HTTPBodyContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContains asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
HTTPBodyNotContains(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPBodyNotContainsf asserts that a specified handler returns a
|
||||||
|
// body that does not contain a string.
|
||||||
|
//
|
||||||
|
// a.HTTPBodyNotContainsf(myHandler, "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) {
|
||||||
|
HTTPBodyNotContainsf(a.t, handler, method, url, values, str)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPError asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
HTTPError(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPErrorf asserts that a specified handler returns an error status code.
|
||||||
|
//
|
||||||
|
// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
HTTPErrorf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirect asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
HTTPRedirect(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPRedirectf asserts that a specified handler returns a redirect status code.
|
||||||
|
//
|
||||||
|
// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}}
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false).
|
||||||
|
func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
HTTPRedirectf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccess asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
HTTPSuccess(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPSuccessf asserts that a specified handler returns a success status code.
|
||||||
|
//
|
||||||
|
// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values) {
|
||||||
|
HTTPSuccessf(a.t, handler, method, url, values)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implements asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// a.Implements((*MyInterface)(nil), new(MyObject))
|
||||||
|
func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Implements(a.t, interfaceObject, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implementsf asserts that an object is implemented by the specified interface.
|
||||||
|
//
|
||||||
|
// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject))
|
||||||
|
func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
Implementsf(a.t, interfaceObject, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDelta asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// a.InDelta(math.Pi, (22 / 7.0), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
||||||
|
InDelta(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlice is the same as InDelta, except it compares two slices.
|
||||||
|
func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) {
|
||||||
|
InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaSlicef is the same as InDelta, except it compares two slices.
|
||||||
|
func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
InDeltaSlicef(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InDeltaf asserts that the two numerals are within delta of each other.
|
||||||
|
//
|
||||||
|
// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) {
|
||||||
|
InDeltaf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilon asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
||||||
|
InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) {
|
||||||
|
InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices.
|
||||||
|
func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InEpsilonf asserts that expected and actual have a relative error less than epsilon
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) {
|
||||||
|
InEpsilonf(a.t, expected, actual, epsilon, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsType asserts that the specified objects are of the same type.
|
||||||
|
func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
IsType(a.t, expectedType, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTypef asserts that the specified objects are of the same type.
|
||||||
|
func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) {
|
||||||
|
IsTypef(a.t, expectedType, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEq asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) {
|
||||||
|
JSONEq(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONEqf asserts that two JSON strings are equivalent.
|
||||||
|
//
|
||||||
|
// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) {
|
||||||
|
JSONEqf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Len asserts that the specified object has specific length.
|
||||||
|
// Len also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// a.Len(mySlice, 3)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) {
|
||||||
|
Len(a.t, object, length, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lenf asserts that the specified object has specific length.
|
||||||
|
// Lenf also fails if the object has a type that len() not accept.
|
||||||
|
//
|
||||||
|
// a.Lenf(mySlice, 3, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) {
|
||||||
|
Lenf(a.t, object, length, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nil asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// a.Nil(err)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Nil(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nilf asserts that the specified object is nil.
|
||||||
|
//
|
||||||
|
// a.Nilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
Nilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoError asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.NoError(err) {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) {
|
||||||
|
NoError(a.t, err, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoErrorf asserts that a function returned no error (i.e. `nil`).
|
||||||
|
//
|
||||||
|
// actualObj, err := SomeFunction()
|
||||||
|
// if a.NoErrorf(err, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, expectedObj, actualObj)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) {
|
||||||
|
NoErrorf(a.t, err, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.NotContains("Hello World", "Earth")
|
||||||
|
// a.NotContains(["Hello", "World"], "Earth")
|
||||||
|
// a.NotContains({"Hello": "World"}, "Earth")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) {
|
||||||
|
NotContains(a.t, s, contains, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the
|
||||||
|
// specified substring or element.
|
||||||
|
//
|
||||||
|
// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted")
|
||||||
|
// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) {
|
||||||
|
NotContainsf(a.t, s, contains, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if a.NotEmpty(obj) {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
NotEmpty(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
|
// a slice or a channel with len == 0.
|
||||||
|
//
|
||||||
|
// if a.NotEmptyf(obj, "error message %s", "formatted") {
|
||||||
|
// assert.Equal(t, "two", obj[1])
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
NotEmptyf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqual asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// a.NotEqual(obj1, obj2)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) {
|
||||||
|
NotEqual(a.t, expected, actual, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotEqualf asserts that the specified values are NOT equal.
|
||||||
|
//
|
||||||
|
// a.NotEqualf(obj1, obj2, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
//
|
||||||
|
// Pointer variable equality is determined based on the equality of the
|
||||||
|
// referenced values (as opposed to the memory addresses).
|
||||||
|
func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) {
|
||||||
|
NotEqualf(a.t, expected, actual, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNil asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// a.NotNil(err)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) {
|
||||||
|
NotNil(a.t, object, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotNilf asserts that the specified object is not nil.
|
||||||
|
//
|
||||||
|
// a.NotNilf(err, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) {
|
||||||
|
NotNilf(a.t, object, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// a.NotPanics(func(){ RemainCalm() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
NotPanics(a.t, f, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic.
|
||||||
|
//
|
||||||
|
// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
NotPanicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexp asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// a.NotRegexp(regexp.MustCompile("starts"), "it's starting")
|
||||||
|
// a.NotRegexp("^start", "it's not starting")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
||||||
|
NotRegexp(a.t, rx, str, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotRegexpf asserts that a specified regexp does not match a string.
|
||||||
|
//
|
||||||
|
// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
NotRegexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubset asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
|
||||||
|
NotSubset(a.t, list, subset, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotSubsetf asserts that the specified list(array, slice...) contains not all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
NotSubsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZero asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) {
|
||||||
|
NotZero(a.t, i, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotZerof asserts that i is not the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) {
|
||||||
|
NotZerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panics asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// a.Panics(func(){ GoCrazy() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
Panics(a.t, f, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that
|
||||||
|
// the recovered panic value equals the expected panic value.
|
||||||
|
//
|
||||||
|
// a.PanicsWithValue("crazy error", func(){ GoCrazy() })
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
|
||||||
|
PanicsWithValue(a.t, expected, f, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that
|
||||||
|
// the recovered panic value equals the expected panic value.
|
||||||
|
//
|
||||||
|
// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
PanicsWithValuef(a.t, expected, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Panicsf asserts that the code inside the specified PanicTestFunc panics.
|
||||||
|
//
|
||||||
|
// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) {
|
||||||
|
Panicsf(a.t, f, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexp asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// a.Regexp(regexp.MustCompile("start"), "it's starting")
|
||||||
|
// a.Regexp("start...$", "it's not starting")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Regexp(a.t, rx, str, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regexpf asserts that a specified regexp matches a string.
|
||||||
|
//
|
||||||
|
// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting")
|
||||||
|
// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) {
|
||||||
|
Regexpf(a.t, rx, str, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subset asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Subset(a.t, list, subset, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subsetf asserts that the specified list(array, slice...) contains all
|
||||||
|
// elements given in the specified subset(array, slice...).
|
||||||
|
//
|
||||||
|
// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) {
|
||||||
|
Subsetf(a.t, list, subset, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// True asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// a.True(myBool)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) True(value bool, msgAndArgs ...interface{}) {
|
||||||
|
True(a.t, value, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truef asserts that the specified value is true.
|
||||||
|
//
|
||||||
|
// a.Truef(myBool, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) Truef(value bool, msg string, args ...interface{}) {
|
||||||
|
Truef(a.t, value, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDuration asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// a.WithinDuration(time.Now(), time.Now(), 10*time.Second)
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) {
|
||||||
|
WithinDuration(a.t, expected, actual, delta, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithinDurationf asserts that the two times are within duration delta of each other.
|
||||||
|
//
|
||||||
|
// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted")
|
||||||
|
//
|
||||||
|
// Returns whether the assertion was successful (true) or not (false).
|
||||||
|
func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) {
|
||||||
|
WithinDurationf(a.t, expected, actual, delta, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zero asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) {
|
||||||
|
Zero(a.t, i, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zerof asserts that i is the zero value for its type and returns the truth.
|
||||||
|
func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) {
|
||||||
|
Zerof(a.t, i, msg, args...)
|
||||||
|
}
|
||||||
4
vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
generated
vendored
Normal file
4
vendor/github.com/stretchr/testify/require/require_forward.go.tmpl
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{.CommentWithoutT "a"}}
|
||||||
|
func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {
|
||||||
|
{{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
|
||||||
|
}
|
||||||
9
vendor/github.com/stretchr/testify/require/requirements.go
generated
vendored
Normal file
9
vendor/github.com/stretchr/testify/require/requirements.go
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package require
|
||||||
|
|
||||||
|
// TestingT is an interface wrapper around *testing.T
|
||||||
|
type TestingT interface {
|
||||||
|
Errorf(format string, args ...interface{})
|
||||||
|
FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl -include-format-funcs
|
||||||
2
vendor/golang.org/x/crypto/curve25519/const_amd64.h
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/const_amd64.h
generated
vendored
|
|
@ -3,6 +3,6 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This code was translated into a form compatible with 6a from the public
|
// This code was translated into a form compatible with 6a from the public
|
||||||
// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
|
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
|
||||||
|
|
||||||
#define REDMASK51 0x0007FFFFFFFFFFFF
|
#define REDMASK51 0x0007FFFFFFFFFFFF
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/curve25519/const_amd64.s
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/const_amd64.s
generated
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This code was translated into a form compatible with 6a from the public
|
// This code was translated into a form compatible with 6a from the public
|
||||||
// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
|
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
|
||||||
|
|
||||||
// +build amd64,!gccgo,!appengine
|
// +build amd64,!gccgo,!appengine
|
||||||
|
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/curve25519.go
generated
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// We have a implementation in amd64 assembly so this code is only run on
|
// We have an implementation in amd64 assembly so this code is only run on
|
||||||
// non-amd64 platforms. The amd64 assembly does not support gccgo.
|
// non-amd64 platforms. The amd64 assembly does not support gccgo.
|
||||||
// +build !amd64 gccgo appengine
|
// +build !amd64 gccgo appengine
|
||||||
|
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/curve25519/doc.go
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/doc.go
generated
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package curve25519 provides an implementation of scalar multiplication on
|
// Package curve25519 provides an implementation of scalar multiplication on
|
||||||
// the elliptic curve known as curve25519. See http://cr.yp.to/ecdh.html
|
// the elliptic curve known as curve25519. See https://cr.yp.to/ecdh.html
|
||||||
package curve25519 // import "golang.org/x/crypto/curve25519"
|
package curve25519 // import "golang.org/x/crypto/curve25519"
|
||||||
|
|
||||||
// basePoint is the x coordinate of the generator of the curve.
|
// basePoint is the x coordinate of the generator of the curve.
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/curve25519/freeze_amd64.s
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/freeze_amd64.s
generated
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This code was translated into a form compatible with 6a from the public
|
// This code was translated into a form compatible with 6a from the public
|
||||||
// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
|
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
|
||||||
|
|
||||||
// +build amd64,!gccgo,!appengine
|
// +build amd64,!gccgo,!appengine
|
||||||
|
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s
generated
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This code was translated into a form compatible with 6a from the public
|
// This code was translated into a form compatible with 6a from the public
|
||||||
// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
|
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
|
||||||
|
|
||||||
// +build amd64,!gccgo,!appengine
|
// +build amd64,!gccgo,!appengine
|
||||||
|
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/curve25519/mul_amd64.s
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/mul_amd64.s
generated
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This code was translated into a form compatible with 6a from the public
|
// This code was translated into a form compatible with 6a from the public
|
||||||
// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
|
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
|
||||||
|
|
||||||
// +build amd64,!gccgo,!appengine
|
// +build amd64,!gccgo,!appengine
|
||||||
|
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/curve25519/square_amd64.s
generated
vendored
2
vendor/golang.org/x/crypto/curve25519/square_amd64.s
generated
vendored
|
|
@ -3,7 +3,7 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// This code was translated into a form compatible with 6a from the public
|
// This code was translated into a form compatible with 6a from the public
|
||||||
// domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
|
// domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html
|
||||||
|
|
||||||
// +build amd64,!gccgo,!appengine
|
// +build amd64,!gccgo,!appengine
|
||||||
|
|
||||||
|
|
|
||||||
8
vendor/golang.org/x/crypto/ed25519/ed25519.go
generated
vendored
8
vendor/golang.org/x/crypto/ed25519/ed25519.go
generated
vendored
|
|
@ -3,20 +3,20 @@
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package ed25519 implements the Ed25519 signature algorithm. See
|
// Package ed25519 implements the Ed25519 signature algorithm. See
|
||||||
// http://ed25519.cr.yp.to/.
|
// https://ed25519.cr.yp.to/.
|
||||||
//
|
//
|
||||||
// These functions are also compatible with the “Ed25519” function defined in
|
// These functions are also compatible with the “Ed25519” function defined in
|
||||||
// https://tools.ietf.org/html/draft-irtf-cfrg-eddsa-05.
|
// RFC 8032.
|
||||||
package ed25519
|
package ed25519
|
||||||
|
|
||||||
// This code is a port of the public domain, “ref10” implementation of ed25519
|
// This code is a port of the public domain, “ref10” implementation of ed25519
|
||||||
// from SUPERCOP.
|
// from SUPERCOP.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto"
|
"crypto"
|
||||||
cryptorand "crypto/rand"
|
cryptorand "crypto/rand"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"crypto/subtle"
|
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -177,5 +177,5 @@ func Verify(publicKey PublicKey, message, sig []byte) bool {
|
||||||
|
|
||||||
var checkR [32]byte
|
var checkR [32]byte
|
||||||
R.ToBytes(&checkR)
|
R.ToBytes(&checkR)
|
||||||
return subtle.ConstantTimeCompare(sig[:32], checkR[:]) == 1
|
return bytes.Equal(sig[:32], checkR[:])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
vendor/golang.org/x/crypto/openpgp/packet/symmetric_key_encrypted.go
generated
vendored
6
vendor/golang.org/x/crypto/openpgp/packet/symmetric_key_encrypted.go
generated
vendored
|
|
@ -88,10 +88,10 @@ func (ske *SymmetricKeyEncrypted) Decrypt(passphrase []byte) ([]byte, CipherFunc
|
||||||
return nil, ske.CipherFunc, errors.UnsupportedError("unknown cipher: " + strconv.Itoa(int(cipherFunc)))
|
return nil, ske.CipherFunc, errors.UnsupportedError("unknown cipher: " + strconv.Itoa(int(cipherFunc)))
|
||||||
}
|
}
|
||||||
plaintextKey = plaintextKey[1:]
|
plaintextKey = plaintextKey[1:]
|
||||||
if l := len(plaintextKey); l == 0 || l%cipherFunc.blockSize() != 0 {
|
if l, cipherKeySize := len(plaintextKey), cipherFunc.KeySize(); l != cipherFunc.KeySize() {
|
||||||
return nil, cipherFunc, errors.StructuralError("length of decrypted key not a multiple of block size")
|
return nil, cipherFunc, errors.StructuralError("length of decrypted key (" + strconv.Itoa(l) + ") " +
|
||||||
|
"not equal to cipher keysize (" + strconv.Itoa(cipherKeySize) + ")")
|
||||||
}
|
}
|
||||||
|
|
||||||
return plaintextKey, cipherFunc, nil
|
return plaintextKey, cipherFunc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
9
vendor/golang.org/x/crypto/scrypt/scrypt.go
generated
vendored
9
vendor/golang.org/x/crypto/scrypt/scrypt.go
generated
vendored
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
// Package scrypt implements the scrypt key derivation function as defined in
|
// Package scrypt implements the scrypt key derivation function as defined in
|
||||||
// Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard
|
// Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard
|
||||||
// Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf).
|
// Functions" (https://www.tarsnap.com/scrypt/scrypt.pdf).
|
||||||
package scrypt // import "golang.org/x/crypto/scrypt"
|
package scrypt // import "golang.org/x/crypto/scrypt"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
@ -220,9 +220,10 @@ func smix(b []byte, r, N int, v, xy []uint32) {
|
||||||
//
|
//
|
||||||
// dk, err := scrypt.Key([]byte("some password"), salt, 16384, 8, 1, 32)
|
// dk, err := scrypt.Key([]byte("some password"), salt, 16384, 8, 1, 32)
|
||||||
//
|
//
|
||||||
// The recommended parameters for interactive logins as of 2009 are N=16384,
|
// The recommended parameters for interactive logins as of 2017 are N=32768, r=8
|
||||||
// r=8, p=1. They should be increased as memory latency and CPU parallelism
|
// and p=1. The parameters N, r, and p should be increased as memory latency and
|
||||||
// increases. Remember to get a good random salt.
|
// CPU parallelism increases; consider setting N to the highest power of 2 you
|
||||||
|
// can derive within 100 milliseconds. Remember to get a good random salt.
|
||||||
func Key(password, salt []byte, N, r, p, keyLen int) ([]byte, error) {
|
func Key(password, salt []byte, N, r, p, keyLen int) ([]byte, error) {
|
||||||
if N <= 1 || N&(N-1) != 0 {
|
if N <= 1 || N&(N-1) != 0 {
|
||||||
return nil, errors.New("scrypt: N must be > 1 and a power of 2")
|
return nil, errors.New("scrypt: N must be > 1 and a power of 2")
|
||||||
|
|
|
||||||
5
vendor/golang.org/x/crypto/ssh/buffer.go
generated
vendored
5
vendor/golang.org/x/crypto/ssh/buffer.go
generated
vendored
|
|
@ -51,13 +51,12 @@ func (b *buffer) write(buf []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eof closes the buffer. Reads from the buffer once all
|
// eof closes the buffer. Reads from the buffer once all
|
||||||
// the data has been consumed will receive os.EOF.
|
// the data has been consumed will receive io.EOF.
|
||||||
func (b *buffer) eof() error {
|
func (b *buffer) eof() {
|
||||||
b.Cond.L.Lock()
|
b.Cond.L.Lock()
|
||||||
b.closed = true
|
b.closed = true
|
||||||
b.Cond.Signal()
|
b.Cond.Signal()
|
||||||
b.Cond.L.Unlock()
|
b.Cond.L.Unlock()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read reads data from the internal buffer in buf. Reads will block
|
// Read reads data from the internal buffer in buf. Reads will block
|
||||||
|
|
|
||||||
34
vendor/golang.org/x/crypto/ssh/certs.go
generated
vendored
34
vendor/golang.org/x/crypto/ssh/certs.go
generated
vendored
|
|
@ -251,10 +251,18 @@ type CertChecker struct {
|
||||||
// for user certificates.
|
// for user certificates.
|
||||||
SupportedCriticalOptions []string
|
SupportedCriticalOptions []string
|
||||||
|
|
||||||
// IsAuthority should return true if the key is recognized as
|
// IsUserAuthority should return true if the key is recognized as an
|
||||||
// an authority. This allows for certificates to be signed by other
|
// authority for the given user certificate. This allows for
|
||||||
// certificates.
|
// certificates to be signed by other certificates. This must be set
|
||||||
IsAuthority func(auth PublicKey) bool
|
// if this CertChecker will be checking user certificates.
|
||||||
|
IsUserAuthority func(auth PublicKey) bool
|
||||||
|
|
||||||
|
// IsHostAuthority should report whether the key is recognized as
|
||||||
|
// an authority for this host. This allows for certificates to be
|
||||||
|
// signed by other keys, and for those other keys to only be valid
|
||||||
|
// signers for particular hostnames. This must be set if this
|
||||||
|
// CertChecker will be checking host certificates.
|
||||||
|
IsHostAuthority func(auth PublicKey, address string) bool
|
||||||
|
|
||||||
// Clock is used for verifying time stamps. If nil, time.Now
|
// Clock is used for verifying time stamps. If nil, time.Now
|
||||||
// is used.
|
// is used.
|
||||||
|
|
@ -290,8 +298,17 @@ func (c *CertChecker) CheckHostKey(addr string, remote net.Addr, key PublicKey)
|
||||||
if cert.CertType != HostCert {
|
if cert.CertType != HostCert {
|
||||||
return fmt.Errorf("ssh: certificate presented as a host key has type %d", cert.CertType)
|
return fmt.Errorf("ssh: certificate presented as a host key has type %d", cert.CertType)
|
||||||
}
|
}
|
||||||
|
if !c.IsHostAuthority(cert.SignatureKey, addr) {
|
||||||
|
return fmt.Errorf("ssh: no authorities for hostname: %v", addr)
|
||||||
|
}
|
||||||
|
|
||||||
return c.CheckCert(addr, cert)
|
hostname, _, err := net.SplitHostPort(addr)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pass hostname only as principal for host certificates (consistent with OpenSSH)
|
||||||
|
return c.CheckCert(hostname, cert)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Authenticate checks a user certificate. Authenticate can be used as
|
// Authenticate checks a user certificate. Authenticate can be used as
|
||||||
|
|
@ -308,6 +325,9 @@ func (c *CertChecker) Authenticate(conn ConnMetadata, pubKey PublicKey) (*Permis
|
||||||
if cert.CertType != UserCert {
|
if cert.CertType != UserCert {
|
||||||
return nil, fmt.Errorf("ssh: cert has type %d", cert.CertType)
|
return nil, fmt.Errorf("ssh: cert has type %d", cert.CertType)
|
||||||
}
|
}
|
||||||
|
if !c.IsUserAuthority(cert.SignatureKey) {
|
||||||
|
return nil, fmt.Errorf("ssh: certificate signed by unrecognized authority")
|
||||||
|
}
|
||||||
|
|
||||||
if err := c.CheckCert(conn.User(), cert); err != nil {
|
if err := c.CheckCert(conn.User(), cert); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -356,10 +376,6 @@ func (c *CertChecker) CheckCert(principal string, cert *Certificate) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.IsAuthority(cert.SignatureKey) {
|
|
||||||
return fmt.Errorf("ssh: certificate signed by unrecognized authority")
|
|
||||||
}
|
|
||||||
|
|
||||||
clock := c.Clock
|
clock := c.Clock
|
||||||
if clock == nil {
|
if clock == nil {
|
||||||
clock = time.Now
|
clock = time.Now
|
||||||
|
|
|
||||||
6
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
6
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
|
|
@ -304,7 +304,7 @@ type gcmCipher struct {
|
||||||
buf []byte
|
buf []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGCMCipher(iv, key, macKey []byte) (packetCipher, error) {
|
func newGCMCipher(iv, key []byte) (packetCipher, error) {
|
||||||
c, err := aes.NewCipher(key)
|
c, err := aes.NewCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -392,7 +392,9 @@ func (c *gcmCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
|
||||||
c.incIV()
|
c.incIV()
|
||||||
|
|
||||||
padding := plain[0]
|
padding := plain[0]
|
||||||
if padding < 4 || padding >= 20 {
|
if padding < 4 {
|
||||||
|
// padding is a byte, so it automatically satisfies
|
||||||
|
// the maximum size, which is 255.
|
||||||
return nil, fmt.Errorf("ssh: illegal padding %d", padding)
|
return nil, fmt.Errorf("ssh: illegal padding %d", padding)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
|
|
@ -349,7 +349,7 @@ func handleAuthResponse(c packetConn) (bool, []string, error) {
|
||||||
// both CLI and GUI environments.
|
// both CLI and GUI environments.
|
||||||
type KeyboardInteractiveChallenge func(user, instruction string, questions []string, echos []bool) (answers []string, err error)
|
type KeyboardInteractiveChallenge func(user, instruction string, questions []string, echos []bool) (answers []string, err error)
|
||||||
|
|
||||||
// KeyboardInteractive returns a AuthMethod using a prompt/response
|
// KeyboardInteractive returns an AuthMethod using a prompt/response
|
||||||
// sequence controlled by the server.
|
// sequence controlled by the server.
|
||||||
func KeyboardInteractive(challenge KeyboardInteractiveChallenge) AuthMethod {
|
func KeyboardInteractive(challenge KeyboardInteractiveChallenge) AuthMethod {
|
||||||
return challenge
|
return challenge
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/ssh/connection.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/connection.go
generated
vendored
|
|
@ -25,7 +25,7 @@ type ConnMetadata interface {
|
||||||
// User returns the user ID for this connection.
|
// User returns the user ID for this connection.
|
||||||
User() string
|
User() string
|
||||||
|
|
||||||
// SessionID returns the sesson hash, also denoted by H.
|
// SessionID returns the session hash, also denoted by H.
|
||||||
SessionID() []byte
|
SessionID() []byte
|
||||||
|
|
||||||
// ClientVersion returns the client's version string as hashed
|
// ClientVersion returns the client's version string as hashed
|
||||||
|
|
|
||||||
86
vendor/golang.org/x/crypto/ssh/keys.go
generated
vendored
86
vendor/golang.org/x/crypto/ssh/keys.go
generated
vendored
|
|
@ -367,6 +367,17 @@ func (r *dsaPublicKey) Type() string {
|
||||||
return "ssh-dss"
|
return "ssh-dss"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkDSAParams(param *dsa.Parameters) error {
|
||||||
|
// SSH specifies FIPS 186-2, which only provided a single size
|
||||||
|
// (1024 bits) DSA key. FIPS 186-3 allows for larger key
|
||||||
|
// sizes, which would confuse SSH.
|
||||||
|
if l := param.P.BitLen(); l != 1024 {
|
||||||
|
return fmt.Errorf("ssh: unsupported DSA key size %d", l)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// parseDSA parses an DSA key according to RFC 4253, section 6.6.
|
// parseDSA parses an DSA key according to RFC 4253, section 6.6.
|
||||||
func parseDSA(in []byte) (out PublicKey, rest []byte, err error) {
|
func parseDSA(in []byte) (out PublicKey, rest []byte, err error) {
|
||||||
var w struct {
|
var w struct {
|
||||||
|
|
@ -377,12 +388,17 @@ func parseDSA(in []byte) (out PublicKey, rest []byte, err error) {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
key := &dsaPublicKey{
|
param := dsa.Parameters{
|
||||||
Parameters: dsa.Parameters{
|
|
||||||
P: w.P,
|
P: w.P,
|
||||||
Q: w.Q,
|
Q: w.Q,
|
||||||
G: w.G,
|
G: w.G,
|
||||||
},
|
}
|
||||||
|
if err := checkDSAParams(¶m); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
key := &dsaPublicKey{
|
||||||
|
Parameters: param,
|
||||||
Y: w.Y,
|
Y: w.Y,
|
||||||
}
|
}
|
||||||
return key, w.Rest, nil
|
return key, w.Rest, nil
|
||||||
|
|
@ -630,19 +646,28 @@ func (k *ecdsaPublicKey) CryptoPublicKey() crypto.PublicKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSignerFromKey takes an *rsa.PrivateKey, *dsa.PrivateKey,
|
// NewSignerFromKey takes an *rsa.PrivateKey, *dsa.PrivateKey,
|
||||||
// *ecdsa.PrivateKey or any other crypto.Signer and returns a corresponding
|
// *ecdsa.PrivateKey or any other crypto.Signer and returns a
|
||||||
// Signer instance. ECDSA keys must use P-256, P-384 or P-521.
|
// corresponding Signer instance. ECDSA keys must use P-256, P-384 or
|
||||||
|
// P-521. DSA keys must use parameter size L1024N160.
|
||||||
func NewSignerFromKey(key interface{}) (Signer, error) {
|
func NewSignerFromKey(key interface{}) (Signer, error) {
|
||||||
switch key := key.(type) {
|
switch key := key.(type) {
|
||||||
case crypto.Signer:
|
case crypto.Signer:
|
||||||
return NewSignerFromSigner(key)
|
return NewSignerFromSigner(key)
|
||||||
case *dsa.PrivateKey:
|
case *dsa.PrivateKey:
|
||||||
return &dsaPrivateKey{key}, nil
|
return newDSAPrivateKey(key)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("ssh: unsupported key type %T", key)
|
return nil, fmt.Errorf("ssh: unsupported key type %T", key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newDSAPrivateKey(key *dsa.PrivateKey) (Signer, error) {
|
||||||
|
if err := checkDSAParams(&key.PublicKey.Parameters); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &dsaPrivateKey{key}, nil
|
||||||
|
}
|
||||||
|
|
||||||
type wrappedSigner struct {
|
type wrappedSigner struct {
|
||||||
signer crypto.Signer
|
signer crypto.Signer
|
||||||
pubKey PublicKey
|
pubKey PublicKey
|
||||||
|
|
@ -756,6 +781,18 @@ func ParsePrivateKey(pemBytes []byte) (Signer, error) {
|
||||||
return NewSignerFromKey(key)
|
return NewSignerFromKey(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParsePrivateKeyWithPassphrase returns a Signer from a PEM encoded private
|
||||||
|
// key and passphrase. It supports the same keys as
|
||||||
|
// ParseRawPrivateKeyWithPassphrase.
|
||||||
|
func ParsePrivateKeyWithPassphrase(pemBytes, passPhrase []byte) (Signer, error) {
|
||||||
|
key, err := ParseRawPrivateKeyWithPassphrase(pemBytes, passPhrase)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewSignerFromKey(key)
|
||||||
|
}
|
||||||
|
|
||||||
// encryptedBlock tells whether a private key is
|
// encryptedBlock tells whether a private key is
|
||||||
// encrypted by examining its Proc-Type header
|
// encrypted by examining its Proc-Type header
|
||||||
// for a mention of ENCRYPTED
|
// for a mention of ENCRYPTED
|
||||||
|
|
@ -790,6 +827,43 @@ func ParseRawPrivateKey(pemBytes []byte) (interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParseRawPrivateKeyWithPassphrase returns a private key decrypted with
|
||||||
|
// passphrase from a PEM encoded private key. If wrong passphrase, return
|
||||||
|
// x509.IncorrectPasswordError.
|
||||||
|
func ParseRawPrivateKeyWithPassphrase(pemBytes, passPhrase []byte) (interface{}, error) {
|
||||||
|
block, _ := pem.Decode(pemBytes)
|
||||||
|
if block == nil {
|
||||||
|
return nil, errors.New("ssh: no key found")
|
||||||
|
}
|
||||||
|
buf := block.Bytes
|
||||||
|
|
||||||
|
if encryptedBlock(block) {
|
||||||
|
if x509.IsEncryptedPEMBlock(block) {
|
||||||
|
var err error
|
||||||
|
buf, err = x509.DecryptPEMBlock(block, passPhrase)
|
||||||
|
if err != nil {
|
||||||
|
if err == x509.IncorrectPasswordError {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("ssh: cannot decode encrypted private keys: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch block.Type {
|
||||||
|
case "RSA PRIVATE KEY":
|
||||||
|
return x509.ParsePKCS1PrivateKey(buf)
|
||||||
|
case "EC PRIVATE KEY":
|
||||||
|
return x509.ParseECPrivateKey(buf)
|
||||||
|
case "DSA PRIVATE KEY":
|
||||||
|
return ParseDSAPrivateKey(buf)
|
||||||
|
case "OPENSSH PRIVATE KEY":
|
||||||
|
return parseOpenSSHPrivateKey(buf)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ssh: unsupported key type %q", block.Type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ParseDSAPrivateKey returns a DSA private key from its ASN.1 DER encoding, as
|
// ParseDSAPrivateKey returns a DSA private key from its ASN.1 DER encoding, as
|
||||||
// specified by the OpenSSL DSA man page.
|
// specified by the OpenSSL DSA man page.
|
||||||
func ParseDSAPrivateKey(der []byte) (*dsa.PrivateKey, error) {
|
func ParseDSAPrivateKey(der []byte) (*dsa.PrivateKey, error) {
|
||||||
|
|
|
||||||
79
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
79
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
|
|
@ -14,23 +14,34 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// The Permissions type holds fine-grained permissions that are
|
// The Permissions type holds fine-grained permissions that are
|
||||||
// specific to a user or a specific authentication method for a
|
// specific to a user or a specific authentication method for a user.
|
||||||
// user. Permissions, except for "source-address", must be enforced in
|
// The Permissions value for a successful authentication attempt is
|
||||||
// the server application layer, after successful authentication. The
|
// available in ServerConn, so it can be used to pass information from
|
||||||
// Permissions are passed on in ServerConn so a server implementation
|
// the user-authentication phase to the application layer.
|
||||||
// can honor them.
|
|
||||||
type Permissions struct {
|
type Permissions struct {
|
||||||
// Critical options restrict default permissions. Common
|
// CriticalOptions indicate restrictions to the default
|
||||||
// restrictions are "source-address" and "force-command". If
|
// permissions, and are typically used in conjunction with
|
||||||
// the server cannot enforce the restriction, or does not
|
// user certificates. The standard for SSH certificates
|
||||||
// recognize it, the user should not authenticate.
|
// defines "force-command" (only allow the given command to
|
||||||
|
// execute) and "source-address" (only allow connections from
|
||||||
|
// the given address). The SSH package currently only enforces
|
||||||
|
// the "source-address" critical option. It is up to server
|
||||||
|
// implementations to enforce other critical options, such as
|
||||||
|
// "force-command", by checking them after the SSH handshake
|
||||||
|
// is successful. In general, SSH servers should reject
|
||||||
|
// connections that specify critical options that are unknown
|
||||||
|
// or not supported.
|
||||||
CriticalOptions map[string]string
|
CriticalOptions map[string]string
|
||||||
|
|
||||||
// Extensions are extra functionality that the server may
|
// Extensions are extra functionality that the server may
|
||||||
// offer on authenticated connections. Common extensions are
|
// offer on authenticated connections. Lack of support for an
|
||||||
// "permit-agent-forwarding", "permit-X11-forwarding". Lack of
|
// extension does not preclude authenticating a user. Common
|
||||||
// support for an extension does not preclude authenticating a
|
// extensions are "permit-agent-forwarding",
|
||||||
// user.
|
// "permit-X11-forwarding". The Go SSH library currently does
|
||||||
|
// not act on any extension, and it is up to server
|
||||||
|
// implementations to honor them. Extensions can be used to
|
||||||
|
// pass data from the authentication callbacks to the server
|
||||||
|
// application layer.
|
||||||
Extensions map[string]string
|
Extensions map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,9 +66,14 @@ type ServerConfig struct {
|
||||||
// attempts to authenticate using a password.
|
// attempts to authenticate using a password.
|
||||||
PasswordCallback func(conn ConnMetadata, password []byte) (*Permissions, error)
|
PasswordCallback func(conn ConnMetadata, password []byte) (*Permissions, error)
|
||||||
|
|
||||||
// PublicKeyCallback, if non-nil, is called when a client attempts public
|
// PublicKeyCallback, if non-nil, is called when a client
|
||||||
// key authentication. It must return true if the given public key is
|
// offers a public key for authentication. It must return a nil error
|
||||||
// valid for the given user. For example, see CertChecker.Authenticate.
|
// if the given public key can be used to authenticate the
|
||||||
|
// given user. For example, see CertChecker.Authenticate. A
|
||||||
|
// call to this function does not guarantee that the key
|
||||||
|
// offered is in fact used to authenticate. To record any data
|
||||||
|
// depending on the public key, store it inside a
|
||||||
|
// Permissions.Extensions entry.
|
||||||
PublicKeyCallback func(conn ConnMetadata, key PublicKey) (*Permissions, error)
|
PublicKeyCallback func(conn ConnMetadata, key PublicKey) (*Permissions, error)
|
||||||
|
|
||||||
// KeyboardInteractiveCallback, if non-nil, is called when
|
// KeyboardInteractiveCallback, if non-nil, is called when
|
||||||
|
|
@ -147,12 +163,12 @@ type ServerConn struct {
|
||||||
// Request and NewChannel channels must be serviced, or the connection
|
// Request and NewChannel channels must be serviced, or the connection
|
||||||
// will hang.
|
// will hang.
|
||||||
func NewServerConn(c net.Conn, config *ServerConfig) (*ServerConn, <-chan NewChannel, <-chan *Request, error) {
|
func NewServerConn(c net.Conn, config *ServerConfig) (*ServerConn, <-chan NewChannel, <-chan *Request, error) {
|
||||||
if config.MaxAuthTries == 0 {
|
|
||||||
config.MaxAuthTries = 6
|
|
||||||
}
|
|
||||||
|
|
||||||
fullConf := *config
|
fullConf := *config
|
||||||
fullConf.SetDefaults()
|
fullConf.SetDefaults()
|
||||||
|
if fullConf.MaxAuthTries == 0 {
|
||||||
|
fullConf.MaxAuthTries = 6
|
||||||
|
}
|
||||||
|
|
||||||
s := &connection{
|
s := &connection{
|
||||||
sshConn: sshConn{conn: c},
|
sshConn: sshConn{conn: c},
|
||||||
}
|
}
|
||||||
|
|
@ -272,12 +288,30 @@ func checkSourceAddress(addr net.Addr, sourceAddrs string) error {
|
||||||
return fmt.Errorf("ssh: remote address %v is not allowed because of source-address restriction", addr)
|
return fmt.Errorf("ssh: remote address %v is not allowed because of source-address restriction", addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServerAuthError implements the error interface. It appends any authentication
|
||||||
|
// errors that may occur, and is returned if all of the authentication methods
|
||||||
|
// provided by the user failed to authenticate.
|
||||||
|
type ServerAuthError struct {
|
||||||
|
// Errors contains authentication errors returned by the authentication
|
||||||
|
// callback methods.
|
||||||
|
Errors []error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l ServerAuthError) Error() string {
|
||||||
|
var errs []string
|
||||||
|
for _, err := range l.Errors {
|
||||||
|
errs = append(errs, err.Error())
|
||||||
|
}
|
||||||
|
return "[" + strings.Join(errs, ", ") + "]"
|
||||||
|
}
|
||||||
|
|
||||||
func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, error) {
|
func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, error) {
|
||||||
sessionID := s.transport.getSessionID()
|
sessionID := s.transport.getSessionID()
|
||||||
var cache pubKeyCache
|
var cache pubKeyCache
|
||||||
var perms *Permissions
|
var perms *Permissions
|
||||||
|
|
||||||
authFailures := 0
|
authFailures := 0
|
||||||
|
var authErrs []error
|
||||||
|
|
||||||
userAuthLoop:
|
userAuthLoop:
|
||||||
for {
|
for {
|
||||||
|
|
@ -296,6 +330,9 @@ userAuthLoop:
|
||||||
|
|
||||||
var userAuthReq userAuthRequestMsg
|
var userAuthReq userAuthRequestMsg
|
||||||
if packet, err := s.transport.readPacket(); err != nil {
|
if packet, err := s.transport.readPacket(); err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
return nil, &ServerAuthError{Errors: authErrs}
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if err = Unmarshal(packet, &userAuthReq); err != nil {
|
} else if err = Unmarshal(packet, &userAuthReq); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -432,6 +469,8 @@ userAuthLoop:
|
||||||
authErr = fmt.Errorf("ssh: unknown method %q", userAuthReq.Method)
|
authErr = fmt.Errorf("ssh: unknown method %q", userAuthReq.Method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authErrs = append(authErrs, authErr)
|
||||||
|
|
||||||
if config.AuthLogCallback != nil {
|
if config.AuthLogCallback != nil {
|
||||||
config.AuthLogCallback(s, userAuthReq.Method, authErr)
|
config.AuthLogCallback(s, userAuthReq.Method, authErr)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
vendor/golang.org/x/crypto/ssh/session.go
generated
vendored
20
vendor/golang.org/x/crypto/ssh/session.go
generated
vendored
|
|
@ -231,6 +231,26 @@ func (s *Session) RequestSubsystem(subsystem string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RFC 4254 Section 6.7.
|
||||||
|
type ptyWindowChangeMsg struct {
|
||||||
|
Columns uint32
|
||||||
|
Rows uint32
|
||||||
|
Width uint32
|
||||||
|
Height uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
// WindowChange informs the remote host about a terminal window dimension change to h rows and w columns.
|
||||||
|
func (s *Session) WindowChange(h, w int) error {
|
||||||
|
req := ptyWindowChangeMsg{
|
||||||
|
Columns: uint32(w),
|
||||||
|
Rows: uint32(h),
|
||||||
|
Width: uint32(w * 8),
|
||||||
|
Height: uint32(h * 8),
|
||||||
|
}
|
||||||
|
_, err := s.ch.SendRequest("window-change", false, Marshal(&req))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// RFC 4254 Section 6.9.
|
// RFC 4254 Section 6.9.
|
||||||
type signalMsg struct {
|
type signalMsg struct {
|
||||||
Signal string
|
Signal string
|
||||||
|
|
|
||||||
67
vendor/golang.org/x/crypto/ssh/terminal/util.go
generated
vendored
67
vendor/golang.org/x/crypto/ssh/terminal/util.go
generated
vendored
|
|
@ -17,40 +17,41 @@
|
||||||
package terminal // import "golang.org/x/crypto/ssh/terminal"
|
package terminal // import "golang.org/x/crypto/ssh/terminal"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"golang.org/x/sys/unix"
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// State contains the state of a terminal.
|
// State contains the state of a terminal.
|
||||||
type State struct {
|
type State struct {
|
||||||
termios syscall.Termios
|
termios unix.Termios
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||||
func IsTerminal(fd int) bool {
|
func IsTerminal(fd int) bool {
|
||||||
var termios syscall.Termios
|
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
return err == nil
|
||||||
return err == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeRaw put the terminal connected to the given file descriptor into raw
|
// MakeRaw put the terminal connected to the given file descriptor into raw
|
||||||
// mode and returns the previous state of the terminal so that it can be
|
// mode and returns the previous state of the terminal so that it can be
|
||||||
// restored.
|
// restored.
|
||||||
func MakeRaw(fd int) (*State, error) {
|
func MakeRaw(fd int) (*State, error) {
|
||||||
var oldState State
|
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newState := oldState.termios
|
oldState := State{termios: *termios}
|
||||||
|
|
||||||
// This attempts to replicate the behaviour documented for cfmakeraw in
|
// This attempts to replicate the behaviour documented for cfmakeraw in
|
||||||
// the termios(3) manpage.
|
// the termios(3) manpage.
|
||||||
newState.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON
|
termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
|
||||||
newState.Oflag &^= syscall.OPOST
|
termios.Oflag &^= unix.OPOST
|
||||||
newState.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
|
termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
|
||||||
newState.Cflag &^= syscall.CSIZE | syscall.PARENB
|
termios.Cflag &^= unix.CSIZE | unix.PARENB
|
||||||
newState.Cflag |= syscall.CS8
|
termios.Cflag |= unix.CS8
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 {
|
termios.Cc[unix.VMIN] = 1
|
||||||
|
termios.Cc[unix.VTIME] = 0
|
||||||
|
if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, termios); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,59 +61,55 @@ func MakeRaw(fd int) (*State, error) {
|
||||||
// GetState returns the current state of a terminal which may be useful to
|
// GetState returns the current state of a terminal which may be useful to
|
||||||
// restore the terminal after a signal.
|
// restore the terminal after a signal.
|
||||||
func GetState(fd int) (*State, error) {
|
func GetState(fd int) (*State, error) {
|
||||||
var oldState State
|
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &oldState, nil
|
return &State{termios: *termios}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore restores the terminal connected to the given file descriptor to a
|
// Restore restores the terminal connected to the given file descriptor to a
|
||||||
// previous state.
|
// previous state.
|
||||||
func Restore(fd int, state *State) error {
|
func Restore(fd int, state *State) error {
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0); err != 0 {
|
return unix.IoctlSetTermios(fd, ioctlWriteTermios, &state.termios)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSize returns the dimensions of the given terminal.
|
// GetSize returns the dimensions of the given terminal.
|
||||||
func GetSize(fd int) (width, height int, err error) {
|
func GetSize(fd int) (width, height int, err error) {
|
||||||
var dimensions [4]uint16
|
ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
|
||||||
|
if err != nil {
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 {
|
|
||||||
return -1, -1, err
|
return -1, -1, err
|
||||||
}
|
}
|
||||||
return int(dimensions[1]), int(dimensions[0]), nil
|
return int(ws.Col), int(ws.Row), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// passwordReader is an io.Reader that reads from a specific file descriptor.
|
// passwordReader is an io.Reader that reads from a specific file descriptor.
|
||||||
type passwordReader int
|
type passwordReader int
|
||||||
|
|
||||||
func (r passwordReader) Read(buf []byte) (int, error) {
|
func (r passwordReader) Read(buf []byte) (int, error) {
|
||||||
return syscall.Read(int(r), buf)
|
return unix.Read(int(r), buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadPassword reads a line of input from a terminal without local echo. This
|
// ReadPassword reads a line of input from a terminal without local echo. This
|
||||||
// is commonly used for inputting passwords and other sensitive data. The slice
|
// is commonly used for inputting passwords and other sensitive data. The slice
|
||||||
// returned does not include the \n.
|
// returned does not include the \n.
|
||||||
func ReadPassword(fd int) ([]byte, error) {
|
func ReadPassword(fd int) ([]byte, error) {
|
||||||
var oldState syscall.Termios
|
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); err != 0 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
newState := oldState
|
newState := *termios
|
||||||
newState.Lflag &^= syscall.ECHO
|
newState.Lflag &^= unix.ECHO
|
||||||
newState.Lflag |= syscall.ICANON | syscall.ISIG
|
newState.Lflag |= unix.ICANON | unix.ISIG
|
||||||
newState.Iflag |= syscall.ICRNL
|
newState.Iflag |= unix.ICRNL
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 {
|
if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, &newState); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0)
|
unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return readPasswordLine(passwordReader(fd))
|
return readPasswordLine(passwordReader(fd))
|
||||||
|
|
|
||||||
6
vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go
generated
vendored
6
vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go
generated
vendored
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
package terminal
|
package terminal
|
||||||
|
|
||||||
import "syscall"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
const ioctlReadTermios = syscall.TIOCGETA
|
const ioctlReadTermios = unix.TIOCGETA
|
||||||
const ioctlWriteTermios = syscall.TIOCSETA
|
const ioctlWriteTermios = unix.TIOCSETA
|
||||||
|
|
|
||||||
9
vendor/golang.org/x/crypto/ssh/terminal/util_linux.go
generated
vendored
9
vendor/golang.org/x/crypto/ssh/terminal/util_linux.go
generated
vendored
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
package terminal
|
package terminal
|
||||||
|
|
||||||
// These constants are declared here, rather than importing
|
import "golang.org/x/sys/unix"
|
||||||
// them from the syscall package as some syscall packages, even
|
|
||||||
// on linux, for example gccgo, do not declare them.
|
const ioctlReadTermios = unix.TCGETS
|
||||||
const ioctlReadTermios = 0x5401 // syscall.TCGETS
|
const ioctlWriteTermios = unix.TCSETS
|
||||||
const ioctlWriteTermios = 0x5402 // syscall.TCSETS
|
|
||||||
|
|
|
||||||
99
vendor/golang.org/x/crypto/ssh/terminal/util_windows.go
generated
vendored
99
vendor/golang.org/x/crypto/ssh/terminal/util_windows.go
generated
vendored
|
|
@ -17,53 +17,7 @@
|
||||||
package terminal
|
package terminal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"golang.org/x/sys/windows"
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
enableLineInput = 2
|
|
||||||
enableEchoInput = 4
|
|
||||||
enableProcessedInput = 1
|
|
||||||
enableWindowInput = 8
|
|
||||||
enableMouseInput = 16
|
|
||||||
enableInsertMode = 32
|
|
||||||
enableQuickEditMode = 64
|
|
||||||
enableExtendedFlags = 128
|
|
||||||
enableAutoPosition = 256
|
|
||||||
enableProcessedOutput = 1
|
|
||||||
enableWrapAtEolOutput = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
var kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
||||||
|
|
||||||
var (
|
|
||||||
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
|
||||||
procSetConsoleMode = kernel32.NewProc("SetConsoleMode")
|
|
||||||
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
short int16
|
|
||||||
word uint16
|
|
||||||
|
|
||||||
coord struct {
|
|
||||||
x short
|
|
||||||
y short
|
|
||||||
}
|
|
||||||
smallRect struct {
|
|
||||||
left short
|
|
||||||
top short
|
|
||||||
right short
|
|
||||||
bottom short
|
|
||||||
}
|
|
||||||
consoleScreenBufferInfo struct {
|
|
||||||
size coord
|
|
||||||
cursorPosition coord
|
|
||||||
attributes word
|
|
||||||
window smallRect
|
|
||||||
maximumWindowSize coord
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type State struct {
|
type State struct {
|
||||||
|
|
@ -73,8 +27,8 @@ type State struct {
|
||||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||||
func IsTerminal(fd int) bool {
|
func IsTerminal(fd int) bool {
|
||||||
var st uint32
|
var st uint32
|
||||||
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
|
err := windows.GetConsoleMode(windows.Handle(fd), &st)
|
||||||
return r != 0 && e == 0
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeRaw put the terminal connected to the given file descriptor into raw
|
// MakeRaw put the terminal connected to the given file descriptor into raw
|
||||||
|
|
@ -82,14 +36,12 @@ func IsTerminal(fd int) bool {
|
||||||
// restored.
|
// restored.
|
||||||
func MakeRaw(fd int) (*State, error) {
|
func MakeRaw(fd int) (*State, error) {
|
||||||
var st uint32
|
var st uint32
|
||||||
_, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
|
if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
|
||||||
if e != 0 {
|
return nil, err
|
||||||
return nil, error(e)
|
|
||||||
}
|
}
|
||||||
raw := st &^ (enableEchoInput | enableProcessedInput | enableLineInput | enableProcessedOutput)
|
raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
|
||||||
_, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(raw), 0)
|
if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil {
|
||||||
if e != 0 {
|
return nil, err
|
||||||
return nil, error(e)
|
|
||||||
}
|
}
|
||||||
return &State{st}, nil
|
return &State{st}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -98,9 +50,8 @@ func MakeRaw(fd int) (*State, error) {
|
||||||
// restore the terminal after a signal.
|
// restore the terminal after a signal.
|
||||||
func GetState(fd int) (*State, error) {
|
func GetState(fd int) (*State, error) {
|
||||||
var st uint32
|
var st uint32
|
||||||
_, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
|
if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
|
||||||
if e != 0 {
|
return nil, err
|
||||||
return nil, error(e)
|
|
||||||
}
|
}
|
||||||
return &State{st}, nil
|
return &State{st}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -108,25 +59,23 @@ func GetState(fd int) (*State, error) {
|
||||||
// Restore restores the terminal connected to the given file descriptor to a
|
// Restore restores the terminal connected to the given file descriptor to a
|
||||||
// previous state.
|
// previous state.
|
||||||
func Restore(fd int, state *State) error {
|
func Restore(fd int, state *State) error {
|
||||||
_, _, err := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(state.mode), 0)
|
return windows.SetConsoleMode(windows.Handle(fd), state.mode)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSize returns the dimensions of the given terminal.
|
// GetSize returns the dimensions of the given terminal.
|
||||||
func GetSize(fd int) (width, height int, err error) {
|
func GetSize(fd int) (width, height int, err error) {
|
||||||
var info consoleScreenBufferInfo
|
var info windows.ConsoleScreenBufferInfo
|
||||||
_, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&info)), 0)
|
if err := windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info); err != nil {
|
||||||
if e != 0 {
|
return 0, 0, err
|
||||||
return 0, 0, error(e)
|
|
||||||
}
|
}
|
||||||
return int(info.size.x), int(info.size.y), nil
|
return int(info.Size.X), int(info.Size.Y), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// passwordReader is an io.Reader that reads from a specific Windows HANDLE.
|
// passwordReader is an io.Reader that reads from a specific Windows HANDLE.
|
||||||
type passwordReader int
|
type passwordReader int
|
||||||
|
|
||||||
func (r passwordReader) Read(buf []byte) (int, error) {
|
func (r passwordReader) Read(buf []byte) (int, error) {
|
||||||
return syscall.Read(syscall.Handle(r), buf)
|
return windows.Read(windows.Handle(r), buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadPassword reads a line of input from a terminal without local echo. This
|
// ReadPassword reads a line of input from a terminal without local echo. This
|
||||||
|
|
@ -134,21 +83,19 @@ func (r passwordReader) Read(buf []byte) (int, error) {
|
||||||
// returned does not include the \n.
|
// returned does not include the \n.
|
||||||
func ReadPassword(fd int) ([]byte, error) {
|
func ReadPassword(fd int) ([]byte, error) {
|
||||||
var st uint32
|
var st uint32
|
||||||
_, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
|
if err := windows.GetConsoleMode(windows.Handle(fd), &st); err != nil {
|
||||||
if e != 0 {
|
return nil, err
|
||||||
return nil, error(e)
|
|
||||||
}
|
}
|
||||||
old := st
|
old := st
|
||||||
|
|
||||||
st &^= (enableEchoInput)
|
st &^= (windows.ENABLE_ECHO_INPUT)
|
||||||
st |= (enableProcessedInput | enableLineInput | enableProcessedOutput)
|
st |= (windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT)
|
||||||
_, _, e = syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(st), 0)
|
if err := windows.SetConsoleMode(windows.Handle(fd), st); err != nil {
|
||||||
if e != 0 {
|
return nil, err
|
||||||
return nil, error(e)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(fd), uintptr(old), 0)
|
windows.SetConsoleMode(windows.Handle(fd), old)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return readPasswordLine(passwordReader(fd))
|
return readPasswordLine(passwordReader(fd))
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/ssh/transport.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/transport.go
generated
vendored
|
|
@ -254,7 +254,7 @@ func newPacketCipher(d direction, algs directionAlgorithms, kex *kexResult) (pac
|
||||||
iv, key, macKey := generateKeys(d, algs, kex)
|
iv, key, macKey := generateKeys(d, algs, kex)
|
||||||
|
|
||||||
if algs.Cipher == gcmCipherID {
|
if algs.Cipher == gcmCipherID {
|
||||||
return newGCMCipher(iv, key, macKey)
|
return newGCMCipher(iv, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
if algs.Cipher == aes128cbcID {
|
if algs.Cipher == aes128cbcID {
|
||||||
|
|
|
||||||
173
vendor/golang.org/x/sys/unix/README.md
generated
vendored
Normal file
173
vendor/golang.org/x/sys/unix/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,173 @@
|
||||||
|
# Building `sys/unix`
|
||||||
|
|
||||||
|
The sys/unix package provides access to the raw system call interface of the
|
||||||
|
underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
|
||||||
|
|
||||||
|
Porting Go to a new architecture/OS combination or adding syscalls, types, or
|
||||||
|
constants to an existing architecture/OS pair requires some manual effort;
|
||||||
|
however, there are tools that automate much of the process.
|
||||||
|
|
||||||
|
## Build Systems
|
||||||
|
|
||||||
|
There are currently two ways we generate the necessary files. We are currently
|
||||||
|
migrating the build system to use containers so the builds are reproducible.
|
||||||
|
This is being done on an OS-by-OS basis. Please update this documentation as
|
||||||
|
components of the build system change.
|
||||||
|
|
||||||
|
### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
|
||||||
|
|
||||||
|
The old build system generates the Go files based on the C header files
|
||||||
|
present on your system. This means that files
|
||||||
|
for a given GOOS/GOARCH pair must be generated on a system with that OS and
|
||||||
|
architecture. This also means that the generated code can differ from system
|
||||||
|
to system, based on differences in the header files.
|
||||||
|
|
||||||
|
To avoid this, if you are using the old build system, only generate the Go
|
||||||
|
files on an installation with unmodified header files. It is also important to
|
||||||
|
keep track of which version of the OS the files were generated from (ex.
|
||||||
|
Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
|
||||||
|
and have each OS upgrade correspond to a single change.
|
||||||
|
|
||||||
|
To build the files for your current OS and architecture, make sure GOOS and
|
||||||
|
GOARCH are set correctly and run `mkall.sh`. This will generate the files for
|
||||||
|
your specific system. Running `mkall.sh -n` shows the commands that will be run.
|
||||||
|
|
||||||
|
Requirements: bash, perl, go
|
||||||
|
|
||||||
|
### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
|
||||||
|
|
||||||
|
The new build system uses a Docker container to generate the go files directly
|
||||||
|
from source checkouts of the kernel and various system libraries. This means
|
||||||
|
that on any platform that supports Docker, all the files using the new build
|
||||||
|
system can be generated at once, and generated files will not change based on
|
||||||
|
what the person running the scripts has installed on their computer.
|
||||||
|
|
||||||
|
The OS specific files for the new build system are located in the `${GOOS}`
|
||||||
|
directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
|
||||||
|
the kernel or system library updates, modify the Dockerfile at
|
||||||
|
`${GOOS}/Dockerfile` to checkout the new release of the source.
|
||||||
|
|
||||||
|
To build all the files under the new build system, you must be on an amd64/Linux
|
||||||
|
system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
|
||||||
|
then generate all of the files for all of the GOOS/GOARCH pairs in the new build
|
||||||
|
system. Running `mkall.sh -n` shows the commands that will be run.
|
||||||
|
|
||||||
|
Requirements: bash, perl, go, docker
|
||||||
|
|
||||||
|
## Component files
|
||||||
|
|
||||||
|
This section describes the various files used in the code generation process.
|
||||||
|
It also contains instructions on how to modify these files to add a new
|
||||||
|
architecture/OS or to add additional syscalls, types, or constants. Note that
|
||||||
|
if you are using the new build system, the scripts cannot be called normally.
|
||||||
|
They must be called from within the docker container.
|
||||||
|
|
||||||
|
### asm files
|
||||||
|
|
||||||
|
The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
|
||||||
|
call dispatch. There are three entry points:
|
||||||
|
```
|
||||||
|
func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
|
||||||
|
func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
|
||||||
|
func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
|
||||||
|
```
|
||||||
|
The first and second are the standard ones; they differ only in how many
|
||||||
|
arguments can be passed to the kernel. The third is for low-level use by the
|
||||||
|
ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
|
||||||
|
let it know that a system call is running.
|
||||||
|
|
||||||
|
When porting Go to an new architecture/OS, this file must be implemented for
|
||||||
|
each GOOS/GOARCH pair.
|
||||||
|
|
||||||
|
### mksysnum
|
||||||
|
|
||||||
|
Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl`
|
||||||
|
for the old system). This script takes in a list of header files containing the
|
||||||
|
syscall number declarations and parses them to produce the corresponding list of
|
||||||
|
Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
|
||||||
|
constants.
|
||||||
|
|
||||||
|
Adding new syscall numbers is mostly done by running the build on a sufficiently
|
||||||
|
new installation of the target OS (or updating the source checkouts for the
|
||||||
|
new build system). However, depending on the OS, you make need to update the
|
||||||
|
parsing in mksysnum.
|
||||||
|
|
||||||
|
### mksyscall.pl
|
||||||
|
|
||||||
|
The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
|
||||||
|
hand-written Go files which implement system calls (for unix, the specific OS,
|
||||||
|
or the specific OS/Architecture pair respectively) that need special handling
|
||||||
|
and list `//sys` comments giving prototypes for ones that can be generated.
|
||||||
|
|
||||||
|
The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts
|
||||||
|
them into syscalls. This requires the name of the prototype in the comment to
|
||||||
|
match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
|
||||||
|
prototype can be exported (capitalized) or not.
|
||||||
|
|
||||||
|
Adding a new syscall often just requires adding a new `//sys` function prototype
|
||||||
|
with the desired arguments and a capitalized name so it is exported. However, if
|
||||||
|
you want the interface to the syscall to be different, often one will make an
|
||||||
|
unexported `//sys` prototype, an then write a custom wrapper in
|
||||||
|
`syscall_${GOOS}.go`.
|
||||||
|
|
||||||
|
### types files
|
||||||
|
|
||||||
|
For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
|
||||||
|
`types_${GOOS}.go` on the old system). This file includes standard C headers and
|
||||||
|
creates Go type aliases to the corresponding C types. The file is then fed
|
||||||
|
through godef to get the Go compatible definitions. Finally, the generated code
|
||||||
|
is fed though mkpost.go to format the code correctly and remove any hidden or
|
||||||
|
private identifiers. This cleaned-up code is written to
|
||||||
|
`ztypes_${GOOS}_${GOARCH}.go`.
|
||||||
|
|
||||||
|
The hardest part about preparing this file is figuring out which headers to
|
||||||
|
include and which symbols need to be `#define`d to get the actual data
|
||||||
|
structures that pass through to the kernel system calls. Some C libraries
|
||||||
|
preset alternate versions for binary compatibility and translate them on the
|
||||||
|
way in and out of system calls, but there is almost always a `#define` that can
|
||||||
|
get the real ones.
|
||||||
|
See `types_darwin.go` and `linux/types.go` for examples.
|
||||||
|
|
||||||
|
To add a new type, add in the necessary include statement at the top of the
|
||||||
|
file (if it is not already there) and add in a type alias line. Note that if
|
||||||
|
your type is significantly different on different architectures, you may need
|
||||||
|
some `#if/#elif` macros in your include statements.
|
||||||
|
|
||||||
|
### mkerrors.sh
|
||||||
|
|
||||||
|
This script is used to generate the system's various constants. This doesn't
|
||||||
|
just include the error numbers and error strings, but also the signal numbers
|
||||||
|
an a wide variety of miscellaneous constants. The constants come from the list
|
||||||
|
of include files in the `includes_${uname}` variable. A regex then picks out
|
||||||
|
the desired `#define` statements, and generates the corresponding Go constants.
|
||||||
|
The error numbers and strings are generated from `#include <errno.h>`, and the
|
||||||
|
signal numbers and strings are generated from `#include <signal.h>`. All of
|
||||||
|
these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
|
||||||
|
`_errors.c`, which prints out all the constants.
|
||||||
|
|
||||||
|
To add a constant, add the header that includes it to the appropriate variable.
|
||||||
|
Then, edit the regex (if necessary) to match the desired constant. Avoid making
|
||||||
|
the regex too broad to avoid matching unintended constants.
|
||||||
|
|
||||||
|
|
||||||
|
## Generated files
|
||||||
|
|
||||||
|
### `zerror_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
|
A file containing all of the system's generated error numbers, error strings,
|
||||||
|
signal numbers, and constants. Generated by `mkerrors.sh` (see above).
|
||||||
|
|
||||||
|
### `zsyscall_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
|
A file containing all the generated syscalls for a specific GOOS and GOARCH.
|
||||||
|
Generated by `mksyscall.pl` (see above).
|
||||||
|
|
||||||
|
### `zsysnum_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
|
A list of numeric constants for all the syscall number of the specific GOOS
|
||||||
|
and GOARCH. Generated by mksysnum (see above).
|
||||||
|
|
||||||
|
### `ztypes_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
|
A file containing Go types for passing into (or returning from) syscalls.
|
||||||
|
Generated by godefs and the types file (see above).
|
||||||
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-52
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-28
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
|
||||||
|
B syscall·RawSyscall6(SB)
|
||||||
4
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
4
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
|
|
@ -10,8 +10,8 @@
|
||||||
// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
|
// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
|
||||||
//
|
//
|
||||||
|
|
||||||
TEXT ·sysvicall6(SB),NOSPLIT,$0-64
|
TEXT ·sysvicall6(SB),NOSPLIT,$0-88
|
||||||
JMP syscall·sysvicall6(SB)
|
JMP syscall·sysvicall6(SB)
|
||||||
|
|
||||||
TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64
|
TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
|
||||||
JMP syscall·rawSysvicall6(SB)
|
JMP syscall·rawSysvicall6(SB)
|
||||||
|
|
|
||||||
195
vendor/golang.org/x/sys/unix/cap_freebsd.go
generated
vendored
Normal file
195
vendor/golang.org/x/sys/unix/cap_freebsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,195 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build freebsd
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
errorspkg "errors"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
|
||||||
|
|
||||||
|
const (
|
||||||
|
// This is the version of CapRights this package understands. See C implementation for parallels.
|
||||||
|
capRightsGoVersion = CAP_RIGHTS_VERSION_00
|
||||||
|
capArSizeMin = CAP_RIGHTS_VERSION_00 + 2
|
||||||
|
capArSizeMax = capRightsGoVersion + 2
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
bit2idx = []int{
|
||||||
|
-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func capidxbit(right uint64) int {
|
||||||
|
return int((right >> 57) & 0x1f)
|
||||||
|
}
|
||||||
|
|
||||||
|
func rightToIndex(right uint64) (int, error) {
|
||||||
|
idx := capidxbit(right)
|
||||||
|
if idx < 0 || idx >= len(bit2idx) {
|
||||||
|
return -2, fmt.Errorf("index for right 0x%x out of range", right)
|
||||||
|
}
|
||||||
|
return bit2idx[idx], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func caprver(right uint64) int {
|
||||||
|
return int(right >> 62)
|
||||||
|
}
|
||||||
|
|
||||||
|
func capver(rights *CapRights) int {
|
||||||
|
return caprver(rights.Rights[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
func caparsize(rights *CapRights) int {
|
||||||
|
return capver(rights) + 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsSet sets the permissions in setrights in rights.
|
||||||
|
func CapRightsSet(rights *CapRights, setrights []uint64) error {
|
||||||
|
// This is essentially a copy of cap_rights_vset()
|
||||||
|
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return fmt.Errorf("bad rights version %d", capver(rights))
|
||||||
|
}
|
||||||
|
|
||||||
|
n := caparsize(rights)
|
||||||
|
if n < capArSizeMin || n > capArSizeMax {
|
||||||
|
return errorspkg.New("bad rights size")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, right := range setrights {
|
||||||
|
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return errorspkg.New("bad right version")
|
||||||
|
}
|
||||||
|
i, err := rightToIndex(right)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if i >= n {
|
||||||
|
return errorspkg.New("index overflow")
|
||||||
|
}
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errorspkg.New("index mismatch")
|
||||||
|
}
|
||||||
|
rights.Rights[i] |= right
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errorspkg.New("index mismatch (after assign)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsClear clears the permissions in clearrights from rights.
|
||||||
|
func CapRightsClear(rights *CapRights, clearrights []uint64) error {
|
||||||
|
// This is essentially a copy of cap_rights_vclear()
|
||||||
|
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return fmt.Errorf("bad rights version %d", capver(rights))
|
||||||
|
}
|
||||||
|
|
||||||
|
n := caparsize(rights)
|
||||||
|
if n < capArSizeMin || n > capArSizeMax {
|
||||||
|
return errorspkg.New("bad rights size")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, right := range clearrights {
|
||||||
|
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return errorspkg.New("bad right version")
|
||||||
|
}
|
||||||
|
i, err := rightToIndex(right)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if i >= n {
|
||||||
|
return errorspkg.New("index overflow")
|
||||||
|
}
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errorspkg.New("index mismatch")
|
||||||
|
}
|
||||||
|
rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return errorspkg.New("index mismatch (after assign)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
|
||||||
|
func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
|
||||||
|
// This is essentially a copy of cap_rights_is_vset()
|
||||||
|
if capver(rights) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return false, fmt.Errorf("bad rights version %d", capver(rights))
|
||||||
|
}
|
||||||
|
|
||||||
|
n := caparsize(rights)
|
||||||
|
if n < capArSizeMin || n > capArSizeMax {
|
||||||
|
return false, errorspkg.New("bad rights size")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, right := range setrights {
|
||||||
|
if caprver(right) != CAP_RIGHTS_VERSION_00 {
|
||||||
|
return false, errorspkg.New("bad right version")
|
||||||
|
}
|
||||||
|
i, err := rightToIndex(right)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if i >= n {
|
||||||
|
return false, errorspkg.New("index overflow")
|
||||||
|
}
|
||||||
|
if capidxbit(rights.Rights[i]) != capidxbit(right) {
|
||||||
|
return false, errorspkg.New("index mismatch")
|
||||||
|
}
|
||||||
|
if (rights.Rights[i] & right) != right {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func capright(idx uint64, bit uint64) uint64 {
|
||||||
|
return ((1 << (57 + idx)) | bit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
|
||||||
|
// See man cap_rights_init(3) and rights(4).
|
||||||
|
func CapRightsInit(rights []uint64) (*CapRights, error) {
|
||||||
|
var r CapRights
|
||||||
|
r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
|
||||||
|
r.Rights[1] = capright(1, 0)
|
||||||
|
|
||||||
|
err := CapRightsSet(&r, rights)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &r, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
|
||||||
|
// The capability rights on fd can never be increased by CapRightsLimit.
|
||||||
|
// See man cap_rights_limit(2) and rights(4).
|
||||||
|
func CapRightsLimit(fd uintptr, rights *CapRights) error {
|
||||||
|
return capRightsLimit(int(fd), rights)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
|
||||||
|
// See man cap_rights_get(3) and rights(4).
|
||||||
|
func CapRightsGet(fd uintptr) (*CapRights, error) {
|
||||||
|
r, err := CapRightsInit(nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = capRightsGet(capRightsGoVersion, int(fd), r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return r, nil
|
||||||
|
}
|
||||||
24
vendor/golang.org/x/sys/unix/dev_darwin.go
generated
vendored
Normal file
24
vendor/golang.org/x/sys/unix/dev_darwin.go
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in Darwin's sys/types.h header.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Darwin device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 24) & 0xff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Darwin device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffffff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Darwin device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return (uint64(major) << 24) | uint64(minor)
|
||||||
|
}
|
||||||
30
vendor/golang.org/x/sys/unix/dev_dragonfly.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/dev_dragonfly.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in Dragonfly's sys/types.h header.
|
||||||
|
//
|
||||||
|
// The information below is extracted and adapted from sys/types.h:
|
||||||
|
//
|
||||||
|
// Minor gives a cookie instead of an index since in order to avoid changing the
|
||||||
|
// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
|
||||||
|
// devices that don't use them.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a DragonFlyBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 8) & 0xff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a DragonFlyBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffff00ff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a DragonFlyBSD device number generated from the given major and
|
||||||
|
// minor components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return (uint64(major) << 8) | uint64(minor)
|
||||||
|
}
|
||||||
30
vendor/golang.org/x/sys/unix/dev_freebsd.go
generated
vendored
Normal file
30
vendor/golang.org/x/sys/unix/dev_freebsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in FreeBSD's sys/types.h header.
|
||||||
|
//
|
||||||
|
// The information below is extracted and adapted from sys/types.h:
|
||||||
|
//
|
||||||
|
// Minor gives a cookie instead of an index since in order to avoid changing the
|
||||||
|
// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
|
||||||
|
// devices that don't use them.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a FreeBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev >> 8) & 0xff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a FreeBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
return uint32(dev & 0xffff00ff)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a FreeBSD device number generated from the given major and
|
||||||
|
// minor components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
return (uint64(major) << 8) | uint64(minor)
|
||||||
|
}
|
||||||
42
vendor/golang.org/x/sys/unix/dev_linux.go
generated
vendored
Normal file
42
vendor/golang.org/x/sys/unix/dev_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used by the Linux kernel and glibc.
|
||||||
|
//
|
||||||
|
// The information below is extracted and adapted from bits/sysmacros.h in the
|
||||||
|
// glibc sources:
|
||||||
|
//
|
||||||
|
// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
|
||||||
|
// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
|
||||||
|
// number and m is a hex digit of the minor number. This is backward compatible
|
||||||
|
// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
|
||||||
|
// backward compatible with the Linux kernel, which for some architectures uses
|
||||||
|
// 32-bit dev_t, encoded as mmmM MMmm.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a Linux device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
major := uint32((dev & 0x00000000000fff00) >> 8)
|
||||||
|
major |= uint32((dev & 0xfffff00000000000) >> 32)
|
||||||
|
return major
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a Linux device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
minor := uint32((dev & 0x00000000000000ff) >> 0)
|
||||||
|
minor |= uint32((dev & 0x00000ffffff00000) >> 12)
|
||||||
|
return minor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a Linux device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
dev := (uint64(major) & 0x00000fff) << 8
|
||||||
|
dev |= (uint64(major) & 0xfffff000) << 32
|
||||||
|
dev |= (uint64(minor) & 0x000000ff) << 0
|
||||||
|
dev |= (uint64(minor) & 0xffffff00) << 12
|
||||||
|
return dev
|
||||||
|
}
|
||||||
29
vendor/golang.org/x/sys/unix/dev_netbsd.go
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/dev_netbsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in NetBSD's sys/types.h header.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of a NetBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x000fff00) >> 8)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of a NetBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
minor := uint32((dev & 0x000000ff) >> 0)
|
||||||
|
minor |= uint32((dev & 0xfff00000) >> 12)
|
||||||
|
return minor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns a NetBSD device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
dev := (uint64(major) << 8) & 0x000fff00
|
||||||
|
dev |= (uint64(minor) << 12) & 0xfff00000
|
||||||
|
dev |= (uint64(minor) << 0) & 0x000000ff
|
||||||
|
return dev
|
||||||
|
}
|
||||||
29
vendor/golang.org/x/sys/unix/dev_openbsd.go
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/dev_openbsd.go
generated
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Functions to access/create device major and minor numbers matching the
|
||||||
|
// encoding used in OpenBSD's sys/types.h header.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Major returns the major component of an OpenBSD device number.
|
||||||
|
func Major(dev uint64) uint32 {
|
||||||
|
return uint32((dev & 0x0000ff00) >> 8)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Minor returns the minor component of an OpenBSD device number.
|
||||||
|
func Minor(dev uint64) uint32 {
|
||||||
|
minor := uint32((dev & 0x000000ff) >> 0)
|
||||||
|
minor |= uint32((dev & 0xffff0000) >> 8)
|
||||||
|
return minor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mkdev returns an OpenBSD device number generated from the given major and minor
|
||||||
|
// components.
|
||||||
|
func Mkdev(major, minor uint32) uint64 {
|
||||||
|
dev := (uint64(major) << 8) & 0x0000ff00
|
||||||
|
dev |= (uint64(minor) << 8) & 0xffff0000
|
||||||
|
dev |= (uint64(minor) << 0) & 0x000000ff
|
||||||
|
return dev
|
||||||
|
}
|
||||||
102
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
Normal file
102
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// readInt returns the size-bytes unsigned integer in native byte order at offset off.
|
||||||
|
func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
|
||||||
|
if len(b) < int(off+size) {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
if isBigEndian {
|
||||||
|
return readIntBE(b[off:], size), true
|
||||||
|
}
|
||||||
|
return readIntLE(b[off:], size), true
|
||||||
|
}
|
||||||
|
|
||||||
|
func readIntBE(b []byte, size uintptr) uint64 {
|
||||||
|
switch size {
|
||||||
|
case 1:
|
||||||
|
return uint64(b[0])
|
||||||
|
case 2:
|
||||||
|
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[1]) | uint64(b[0])<<8
|
||||||
|
case 4:
|
||||||
|
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
|
||||||
|
case 8:
|
||||||
|
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
|
||||||
|
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
||||||
|
default:
|
||||||
|
panic("syscall: readInt with unsupported size")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func readIntLE(b []byte, size uintptr) uint64 {
|
||||||
|
switch size {
|
||||||
|
case 1:
|
||||||
|
return uint64(b[0])
|
||||||
|
case 2:
|
||||||
|
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[0]) | uint64(b[1])<<8
|
||||||
|
case 4:
|
||||||
|
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
|
||||||
|
case 8:
|
||||||
|
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
|
||||||
|
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
|
||||||
|
default:
|
||||||
|
panic("syscall: readInt with unsupported size")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
|
// appending the names to names. It returns the number of
|
||||||
|
// bytes consumed from buf, the number of entries added
|
||||||
|
// to names, and the new names slice.
|
||||||
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
|
origlen := len(buf)
|
||||||
|
count = 0
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
reclen, ok := direntReclen(buf)
|
||||||
|
if !ok || reclen > uint64(len(buf)) {
|
||||||
|
return origlen, count, names
|
||||||
|
}
|
||||||
|
rec := buf[:reclen]
|
||||||
|
buf = buf[reclen:]
|
||||||
|
ino, ok := direntIno(rec)
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if ino == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
|
||||||
|
namlen, ok := direntNamlen(rec)
|
||||||
|
if !ok || namoff+namlen > uint64(len(rec)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
name := rec[namoff : namoff+namlen]
|
||||||
|
for i, c := range name {
|
||||||
|
if c == 0 {
|
||||||
|
name = name[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check for useless names before allocating a string.
|
||||||
|
if string(name) == "." || string(name) == ".." {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, string(name))
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
|
}
|
||||||
9
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
Normal file
9
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// +build ppc64 s390x mips mips64
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const isBigEndian = true
|
||||||
9
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
Normal file
9
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const isBigEndian = false
|
||||||
227
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
Normal file
227
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
Normal file
|
|
@ -0,0 +1,227 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
||||||
|
// them here for backwards compatibility.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
IFF_SMART = 0x20
|
||||||
|
IFT_1822 = 0x2
|
||||||
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
IFT_AAL2 = 0xbb
|
||||||
|
IFT_AAL5 = 0x31
|
||||||
|
IFT_ADSL = 0x5e
|
||||||
|
IFT_AFLANE8023 = 0x3b
|
||||||
|
IFT_AFLANE8025 = 0x3c
|
||||||
|
IFT_ARAP = 0x58
|
||||||
|
IFT_ARCNET = 0x23
|
||||||
|
IFT_ARCNETPLUS = 0x24
|
||||||
|
IFT_ASYNC = 0x54
|
||||||
|
IFT_ATM = 0x25
|
||||||
|
IFT_ATMDXI = 0x69
|
||||||
|
IFT_ATMFUNI = 0x6a
|
||||||
|
IFT_ATMIMA = 0x6b
|
||||||
|
IFT_ATMLOGICAL = 0x50
|
||||||
|
IFT_ATMRADIO = 0xbd
|
||||||
|
IFT_ATMSUBINTERFACE = 0x86
|
||||||
|
IFT_ATMVCIENDPT = 0xc2
|
||||||
|
IFT_ATMVIRTUAL = 0x95
|
||||||
|
IFT_BGPPOLICYACCOUNTING = 0xa2
|
||||||
|
IFT_BSC = 0x53
|
||||||
|
IFT_CCTEMUL = 0x3d
|
||||||
|
IFT_CEPT = 0x13
|
||||||
|
IFT_CES = 0x85
|
||||||
|
IFT_CHANNEL = 0x46
|
||||||
|
IFT_CNR = 0x55
|
||||||
|
IFT_COFFEE = 0x84
|
||||||
|
IFT_COMPOSITELINK = 0x9b
|
||||||
|
IFT_DCN = 0x8d
|
||||||
|
IFT_DIGITALPOWERLINE = 0x8a
|
||||||
|
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
||||||
|
IFT_DLSW = 0x4a
|
||||||
|
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
||||||
|
IFT_DOCSCABLEMACLAYER = 0x7f
|
||||||
|
IFT_DOCSCABLEUPSTREAM = 0x81
|
||||||
|
IFT_DS0 = 0x51
|
||||||
|
IFT_DS0BUNDLE = 0x52
|
||||||
|
IFT_DS1FDL = 0xaa
|
||||||
|
IFT_DS3 = 0x1e
|
||||||
|
IFT_DTM = 0x8c
|
||||||
|
IFT_DVBASILN = 0xac
|
||||||
|
IFT_DVBASIOUT = 0xad
|
||||||
|
IFT_DVBRCCDOWNSTREAM = 0x93
|
||||||
|
IFT_DVBRCCMACLAYER = 0x92
|
||||||
|
IFT_DVBRCCUPSTREAM = 0x94
|
||||||
|
IFT_ENC = 0xf4
|
||||||
|
IFT_EON = 0x19
|
||||||
|
IFT_EPLRS = 0x57
|
||||||
|
IFT_ESCON = 0x49
|
||||||
|
IFT_ETHER = 0x6
|
||||||
|
IFT_FAITH = 0xf2
|
||||||
|
IFT_FAST = 0x7d
|
||||||
|
IFT_FASTETHER = 0x3e
|
||||||
|
IFT_FASTETHERFX = 0x45
|
||||||
|
IFT_FDDI = 0xf
|
||||||
|
IFT_FIBRECHANNEL = 0x38
|
||||||
|
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
||||||
|
IFT_FRAMERELAYMPI = 0x5c
|
||||||
|
IFT_FRDLCIENDPT = 0xc1
|
||||||
|
IFT_FRELAY = 0x20
|
||||||
|
IFT_FRELAYDCE = 0x2c
|
||||||
|
IFT_FRF16MFRBUNDLE = 0xa3
|
||||||
|
IFT_FRFORWARD = 0x9e
|
||||||
|
IFT_G703AT2MB = 0x43
|
||||||
|
IFT_G703AT64K = 0x42
|
||||||
|
IFT_GIF = 0xf0
|
||||||
|
IFT_GIGABITETHERNET = 0x75
|
||||||
|
IFT_GR303IDT = 0xb2
|
||||||
|
IFT_GR303RDT = 0xb1
|
||||||
|
IFT_H323GATEKEEPER = 0xa4
|
||||||
|
IFT_H323PROXY = 0xa5
|
||||||
|
IFT_HDH1822 = 0x3
|
||||||
|
IFT_HDLC = 0x76
|
||||||
|
IFT_HDSL2 = 0xa8
|
||||||
|
IFT_HIPERLAN2 = 0xb7
|
||||||
|
IFT_HIPPI = 0x2f
|
||||||
|
IFT_HIPPIINTERFACE = 0x39
|
||||||
|
IFT_HOSTPAD = 0x5a
|
||||||
|
IFT_HSSI = 0x2e
|
||||||
|
IFT_HY = 0xe
|
||||||
|
IFT_IBM370PARCHAN = 0x48
|
||||||
|
IFT_IDSL = 0x9a
|
||||||
|
IFT_IEEE80211 = 0x47
|
||||||
|
IFT_IEEE80212 = 0x37
|
||||||
|
IFT_IEEE8023ADLAG = 0xa1
|
||||||
|
IFT_IFGSN = 0x91
|
||||||
|
IFT_IMT = 0xbe
|
||||||
|
IFT_INTERLEAVE = 0x7c
|
||||||
|
IFT_IP = 0x7e
|
||||||
|
IFT_IPFORWARD = 0x8e
|
||||||
|
IFT_IPOVERATM = 0x72
|
||||||
|
IFT_IPOVERCDLC = 0x6d
|
||||||
|
IFT_IPOVERCLAW = 0x6e
|
||||||
|
IFT_IPSWITCH = 0x4e
|
||||||
|
IFT_IPXIP = 0xf9
|
||||||
|
IFT_ISDN = 0x3f
|
||||||
|
IFT_ISDNBASIC = 0x14
|
||||||
|
IFT_ISDNPRIMARY = 0x15
|
||||||
|
IFT_ISDNS = 0x4b
|
||||||
|
IFT_ISDNU = 0x4c
|
||||||
|
IFT_ISO88022LLC = 0x29
|
||||||
|
IFT_ISO88023 = 0x7
|
||||||
|
IFT_ISO88024 = 0x8
|
||||||
|
IFT_ISO88025 = 0x9
|
||||||
|
IFT_ISO88025CRFPINT = 0x62
|
||||||
|
IFT_ISO88025DTR = 0x56
|
||||||
|
IFT_ISO88025FIBER = 0x73
|
||||||
|
IFT_ISO88026 = 0xa
|
||||||
|
IFT_ISUP = 0xb3
|
||||||
|
IFT_L3IPXVLAN = 0x89
|
||||||
|
IFT_LAPB = 0x10
|
||||||
|
IFT_LAPD = 0x4d
|
||||||
|
IFT_LAPF = 0x77
|
||||||
|
IFT_LOCALTALK = 0x2a
|
||||||
|
IFT_LOOP = 0x18
|
||||||
|
IFT_MEDIAMAILOVERIP = 0x8b
|
||||||
|
IFT_MFSIGLINK = 0xa7
|
||||||
|
IFT_MIOX25 = 0x26
|
||||||
|
IFT_MODEM = 0x30
|
||||||
|
IFT_MPC = 0x71
|
||||||
|
IFT_MPLS = 0xa6
|
||||||
|
IFT_MPLSTUNNEL = 0x96
|
||||||
|
IFT_MSDSL = 0x8f
|
||||||
|
IFT_MVL = 0xbf
|
||||||
|
IFT_MYRINET = 0x63
|
||||||
|
IFT_NFAS = 0xaf
|
||||||
|
IFT_NSIP = 0x1b
|
||||||
|
IFT_OPTICALCHANNEL = 0xc3
|
||||||
|
IFT_OPTICALTRANSPORT = 0xc4
|
||||||
|
IFT_OTHER = 0x1
|
||||||
|
IFT_P10 = 0xc
|
||||||
|
IFT_P80 = 0xd
|
||||||
|
IFT_PARA = 0x22
|
||||||
|
IFT_PFLOG = 0xf6
|
||||||
|
IFT_PFSYNC = 0xf7
|
||||||
|
IFT_PLC = 0xae
|
||||||
|
IFT_POS = 0xab
|
||||||
|
IFT_PPPMULTILINKBUNDLE = 0x6c
|
||||||
|
IFT_PROPBWAP2MP = 0xb8
|
||||||
|
IFT_PROPCNLS = 0x59
|
||||||
|
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
||||||
|
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
||||||
|
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
||||||
|
IFT_PROPMUX = 0x36
|
||||||
|
IFT_PROPWIRELESSP2P = 0x9d
|
||||||
|
IFT_PTPSERIAL = 0x16
|
||||||
|
IFT_PVC = 0xf1
|
||||||
|
IFT_QLLC = 0x44
|
||||||
|
IFT_RADIOMAC = 0xbc
|
||||||
|
IFT_RADSL = 0x5f
|
||||||
|
IFT_REACHDSL = 0xc0
|
||||||
|
IFT_RFC1483 = 0x9f
|
||||||
|
IFT_RS232 = 0x21
|
||||||
|
IFT_RSRB = 0x4f
|
||||||
|
IFT_SDLC = 0x11
|
||||||
|
IFT_SDSL = 0x60
|
||||||
|
IFT_SHDSL = 0xa9
|
||||||
|
IFT_SIP = 0x1f
|
||||||
|
IFT_SLIP = 0x1c
|
||||||
|
IFT_SMDSDXI = 0x2b
|
||||||
|
IFT_SMDSICIP = 0x34
|
||||||
|
IFT_SONET = 0x27
|
||||||
|
IFT_SONETOVERHEADCHANNEL = 0xb9
|
||||||
|
IFT_SONETPATH = 0x32
|
||||||
|
IFT_SONETVT = 0x33
|
||||||
|
IFT_SRP = 0x97
|
||||||
|
IFT_SS7SIGLINK = 0x9c
|
||||||
|
IFT_STACKTOSTACK = 0x6f
|
||||||
|
IFT_STARLAN = 0xb
|
||||||
|
IFT_STF = 0xd7
|
||||||
|
IFT_T1 = 0x12
|
||||||
|
IFT_TDLC = 0x74
|
||||||
|
IFT_TERMPAD = 0x5b
|
||||||
|
IFT_TR008 = 0xb0
|
||||||
|
IFT_TRANSPHDLC = 0x7b
|
||||||
|
IFT_TUNNEL = 0x83
|
||||||
|
IFT_ULTRA = 0x1d
|
||||||
|
IFT_USB = 0xa0
|
||||||
|
IFT_V11 = 0x40
|
||||||
|
IFT_V35 = 0x2d
|
||||||
|
IFT_V36 = 0x41
|
||||||
|
IFT_V37 = 0x78
|
||||||
|
IFT_VDSL = 0x61
|
||||||
|
IFT_VIRTUALIPADDRESS = 0x70
|
||||||
|
IFT_VOICEEM = 0x64
|
||||||
|
IFT_VOICEENCAP = 0x67
|
||||||
|
IFT_VOICEFXO = 0x65
|
||||||
|
IFT_VOICEFXS = 0x66
|
||||||
|
IFT_VOICEOVERATM = 0x98
|
||||||
|
IFT_VOICEOVERFRAMERELAY = 0x99
|
||||||
|
IFT_VOICEOVERIP = 0x68
|
||||||
|
IFT_X213 = 0x5d
|
||||||
|
IFT_X25 = 0x5
|
||||||
|
IFT_X25DDN = 0x4
|
||||||
|
IFT_X25HUNTGROUP = 0x7a
|
||||||
|
IFT_X25MLP = 0x79
|
||||||
|
IFT_X25PLE = 0x28
|
||||||
|
IFT_XETHER = 0x1a
|
||||||
|
IPPROTO_MAXID = 0x34
|
||||||
|
IPV6_FAITH = 0x1d
|
||||||
|
IP_FAITH = 0x16
|
||||||
|
MAP_NORESERVE = 0x40
|
||||||
|
MAP_RENAME = 0x20
|
||||||
|
NET_RT_MAXID = 0x6
|
||||||
|
RTF_PRCLONING = 0x10000
|
||||||
|
RTM_OLDADD = 0x9
|
||||||
|
RTM_OLDDEL = 0xa
|
||||||
|
SIOCADDRT = 0x8030720a
|
||||||
|
SIOCALIFADDR = 0x8118691b
|
||||||
|
SIOCDELRT = 0x8030720b
|
||||||
|
SIOCDLIFADDR = 0x8118691d
|
||||||
|
SIOCGLIFADDR = 0xc118691c
|
||||||
|
SIOCGLIFPHYADDR = 0xc118694b
|
||||||
|
SIOCSLIFPHYADDR = 0x8118694a
|
||||||
|
)
|
||||||
227
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
Normal file
227
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,227 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
||||||
|
// them here for backwards compatibility.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
IFF_SMART = 0x20
|
||||||
|
IFT_1822 = 0x2
|
||||||
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
IFT_AAL2 = 0xbb
|
||||||
|
IFT_AAL5 = 0x31
|
||||||
|
IFT_ADSL = 0x5e
|
||||||
|
IFT_AFLANE8023 = 0x3b
|
||||||
|
IFT_AFLANE8025 = 0x3c
|
||||||
|
IFT_ARAP = 0x58
|
||||||
|
IFT_ARCNET = 0x23
|
||||||
|
IFT_ARCNETPLUS = 0x24
|
||||||
|
IFT_ASYNC = 0x54
|
||||||
|
IFT_ATM = 0x25
|
||||||
|
IFT_ATMDXI = 0x69
|
||||||
|
IFT_ATMFUNI = 0x6a
|
||||||
|
IFT_ATMIMA = 0x6b
|
||||||
|
IFT_ATMLOGICAL = 0x50
|
||||||
|
IFT_ATMRADIO = 0xbd
|
||||||
|
IFT_ATMSUBINTERFACE = 0x86
|
||||||
|
IFT_ATMVCIENDPT = 0xc2
|
||||||
|
IFT_ATMVIRTUAL = 0x95
|
||||||
|
IFT_BGPPOLICYACCOUNTING = 0xa2
|
||||||
|
IFT_BSC = 0x53
|
||||||
|
IFT_CCTEMUL = 0x3d
|
||||||
|
IFT_CEPT = 0x13
|
||||||
|
IFT_CES = 0x85
|
||||||
|
IFT_CHANNEL = 0x46
|
||||||
|
IFT_CNR = 0x55
|
||||||
|
IFT_COFFEE = 0x84
|
||||||
|
IFT_COMPOSITELINK = 0x9b
|
||||||
|
IFT_DCN = 0x8d
|
||||||
|
IFT_DIGITALPOWERLINE = 0x8a
|
||||||
|
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
||||||
|
IFT_DLSW = 0x4a
|
||||||
|
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
||||||
|
IFT_DOCSCABLEMACLAYER = 0x7f
|
||||||
|
IFT_DOCSCABLEUPSTREAM = 0x81
|
||||||
|
IFT_DS0 = 0x51
|
||||||
|
IFT_DS0BUNDLE = 0x52
|
||||||
|
IFT_DS1FDL = 0xaa
|
||||||
|
IFT_DS3 = 0x1e
|
||||||
|
IFT_DTM = 0x8c
|
||||||
|
IFT_DVBASILN = 0xac
|
||||||
|
IFT_DVBASIOUT = 0xad
|
||||||
|
IFT_DVBRCCDOWNSTREAM = 0x93
|
||||||
|
IFT_DVBRCCMACLAYER = 0x92
|
||||||
|
IFT_DVBRCCUPSTREAM = 0x94
|
||||||
|
IFT_ENC = 0xf4
|
||||||
|
IFT_EON = 0x19
|
||||||
|
IFT_EPLRS = 0x57
|
||||||
|
IFT_ESCON = 0x49
|
||||||
|
IFT_ETHER = 0x6
|
||||||
|
IFT_FAITH = 0xf2
|
||||||
|
IFT_FAST = 0x7d
|
||||||
|
IFT_FASTETHER = 0x3e
|
||||||
|
IFT_FASTETHERFX = 0x45
|
||||||
|
IFT_FDDI = 0xf
|
||||||
|
IFT_FIBRECHANNEL = 0x38
|
||||||
|
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
||||||
|
IFT_FRAMERELAYMPI = 0x5c
|
||||||
|
IFT_FRDLCIENDPT = 0xc1
|
||||||
|
IFT_FRELAY = 0x20
|
||||||
|
IFT_FRELAYDCE = 0x2c
|
||||||
|
IFT_FRF16MFRBUNDLE = 0xa3
|
||||||
|
IFT_FRFORWARD = 0x9e
|
||||||
|
IFT_G703AT2MB = 0x43
|
||||||
|
IFT_G703AT64K = 0x42
|
||||||
|
IFT_GIF = 0xf0
|
||||||
|
IFT_GIGABITETHERNET = 0x75
|
||||||
|
IFT_GR303IDT = 0xb2
|
||||||
|
IFT_GR303RDT = 0xb1
|
||||||
|
IFT_H323GATEKEEPER = 0xa4
|
||||||
|
IFT_H323PROXY = 0xa5
|
||||||
|
IFT_HDH1822 = 0x3
|
||||||
|
IFT_HDLC = 0x76
|
||||||
|
IFT_HDSL2 = 0xa8
|
||||||
|
IFT_HIPERLAN2 = 0xb7
|
||||||
|
IFT_HIPPI = 0x2f
|
||||||
|
IFT_HIPPIINTERFACE = 0x39
|
||||||
|
IFT_HOSTPAD = 0x5a
|
||||||
|
IFT_HSSI = 0x2e
|
||||||
|
IFT_HY = 0xe
|
||||||
|
IFT_IBM370PARCHAN = 0x48
|
||||||
|
IFT_IDSL = 0x9a
|
||||||
|
IFT_IEEE80211 = 0x47
|
||||||
|
IFT_IEEE80212 = 0x37
|
||||||
|
IFT_IEEE8023ADLAG = 0xa1
|
||||||
|
IFT_IFGSN = 0x91
|
||||||
|
IFT_IMT = 0xbe
|
||||||
|
IFT_INTERLEAVE = 0x7c
|
||||||
|
IFT_IP = 0x7e
|
||||||
|
IFT_IPFORWARD = 0x8e
|
||||||
|
IFT_IPOVERATM = 0x72
|
||||||
|
IFT_IPOVERCDLC = 0x6d
|
||||||
|
IFT_IPOVERCLAW = 0x6e
|
||||||
|
IFT_IPSWITCH = 0x4e
|
||||||
|
IFT_IPXIP = 0xf9
|
||||||
|
IFT_ISDN = 0x3f
|
||||||
|
IFT_ISDNBASIC = 0x14
|
||||||
|
IFT_ISDNPRIMARY = 0x15
|
||||||
|
IFT_ISDNS = 0x4b
|
||||||
|
IFT_ISDNU = 0x4c
|
||||||
|
IFT_ISO88022LLC = 0x29
|
||||||
|
IFT_ISO88023 = 0x7
|
||||||
|
IFT_ISO88024 = 0x8
|
||||||
|
IFT_ISO88025 = 0x9
|
||||||
|
IFT_ISO88025CRFPINT = 0x62
|
||||||
|
IFT_ISO88025DTR = 0x56
|
||||||
|
IFT_ISO88025FIBER = 0x73
|
||||||
|
IFT_ISO88026 = 0xa
|
||||||
|
IFT_ISUP = 0xb3
|
||||||
|
IFT_L3IPXVLAN = 0x89
|
||||||
|
IFT_LAPB = 0x10
|
||||||
|
IFT_LAPD = 0x4d
|
||||||
|
IFT_LAPF = 0x77
|
||||||
|
IFT_LOCALTALK = 0x2a
|
||||||
|
IFT_LOOP = 0x18
|
||||||
|
IFT_MEDIAMAILOVERIP = 0x8b
|
||||||
|
IFT_MFSIGLINK = 0xa7
|
||||||
|
IFT_MIOX25 = 0x26
|
||||||
|
IFT_MODEM = 0x30
|
||||||
|
IFT_MPC = 0x71
|
||||||
|
IFT_MPLS = 0xa6
|
||||||
|
IFT_MPLSTUNNEL = 0x96
|
||||||
|
IFT_MSDSL = 0x8f
|
||||||
|
IFT_MVL = 0xbf
|
||||||
|
IFT_MYRINET = 0x63
|
||||||
|
IFT_NFAS = 0xaf
|
||||||
|
IFT_NSIP = 0x1b
|
||||||
|
IFT_OPTICALCHANNEL = 0xc3
|
||||||
|
IFT_OPTICALTRANSPORT = 0xc4
|
||||||
|
IFT_OTHER = 0x1
|
||||||
|
IFT_P10 = 0xc
|
||||||
|
IFT_P80 = 0xd
|
||||||
|
IFT_PARA = 0x22
|
||||||
|
IFT_PFLOG = 0xf6
|
||||||
|
IFT_PFSYNC = 0xf7
|
||||||
|
IFT_PLC = 0xae
|
||||||
|
IFT_POS = 0xab
|
||||||
|
IFT_PPPMULTILINKBUNDLE = 0x6c
|
||||||
|
IFT_PROPBWAP2MP = 0xb8
|
||||||
|
IFT_PROPCNLS = 0x59
|
||||||
|
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
||||||
|
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
||||||
|
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
||||||
|
IFT_PROPMUX = 0x36
|
||||||
|
IFT_PROPWIRELESSP2P = 0x9d
|
||||||
|
IFT_PTPSERIAL = 0x16
|
||||||
|
IFT_PVC = 0xf1
|
||||||
|
IFT_QLLC = 0x44
|
||||||
|
IFT_RADIOMAC = 0xbc
|
||||||
|
IFT_RADSL = 0x5f
|
||||||
|
IFT_REACHDSL = 0xc0
|
||||||
|
IFT_RFC1483 = 0x9f
|
||||||
|
IFT_RS232 = 0x21
|
||||||
|
IFT_RSRB = 0x4f
|
||||||
|
IFT_SDLC = 0x11
|
||||||
|
IFT_SDSL = 0x60
|
||||||
|
IFT_SHDSL = 0xa9
|
||||||
|
IFT_SIP = 0x1f
|
||||||
|
IFT_SLIP = 0x1c
|
||||||
|
IFT_SMDSDXI = 0x2b
|
||||||
|
IFT_SMDSICIP = 0x34
|
||||||
|
IFT_SONET = 0x27
|
||||||
|
IFT_SONETOVERHEADCHANNEL = 0xb9
|
||||||
|
IFT_SONETPATH = 0x32
|
||||||
|
IFT_SONETVT = 0x33
|
||||||
|
IFT_SRP = 0x97
|
||||||
|
IFT_SS7SIGLINK = 0x9c
|
||||||
|
IFT_STACKTOSTACK = 0x6f
|
||||||
|
IFT_STARLAN = 0xb
|
||||||
|
IFT_STF = 0xd7
|
||||||
|
IFT_T1 = 0x12
|
||||||
|
IFT_TDLC = 0x74
|
||||||
|
IFT_TERMPAD = 0x5b
|
||||||
|
IFT_TR008 = 0xb0
|
||||||
|
IFT_TRANSPHDLC = 0x7b
|
||||||
|
IFT_TUNNEL = 0x83
|
||||||
|
IFT_ULTRA = 0x1d
|
||||||
|
IFT_USB = 0xa0
|
||||||
|
IFT_V11 = 0x40
|
||||||
|
IFT_V35 = 0x2d
|
||||||
|
IFT_V36 = 0x41
|
||||||
|
IFT_V37 = 0x78
|
||||||
|
IFT_VDSL = 0x61
|
||||||
|
IFT_VIRTUALIPADDRESS = 0x70
|
||||||
|
IFT_VOICEEM = 0x64
|
||||||
|
IFT_VOICEENCAP = 0x67
|
||||||
|
IFT_VOICEFXO = 0x65
|
||||||
|
IFT_VOICEFXS = 0x66
|
||||||
|
IFT_VOICEOVERATM = 0x98
|
||||||
|
IFT_VOICEOVERFRAMERELAY = 0x99
|
||||||
|
IFT_VOICEOVERIP = 0x68
|
||||||
|
IFT_X213 = 0x5d
|
||||||
|
IFT_X25 = 0x5
|
||||||
|
IFT_X25DDN = 0x4
|
||||||
|
IFT_X25HUNTGROUP = 0x7a
|
||||||
|
IFT_X25MLP = 0x79
|
||||||
|
IFT_X25PLE = 0x28
|
||||||
|
IFT_XETHER = 0x1a
|
||||||
|
IPPROTO_MAXID = 0x34
|
||||||
|
IPV6_FAITH = 0x1d
|
||||||
|
IP_FAITH = 0x16
|
||||||
|
MAP_NORESERVE = 0x40
|
||||||
|
MAP_RENAME = 0x20
|
||||||
|
NET_RT_MAXID = 0x6
|
||||||
|
RTF_PRCLONING = 0x10000
|
||||||
|
RTM_OLDADD = 0x9
|
||||||
|
RTM_OLDDEL = 0xa
|
||||||
|
SIOCADDRT = 0x8040720a
|
||||||
|
SIOCALIFADDR = 0x8118691b
|
||||||
|
SIOCDELRT = 0x8040720b
|
||||||
|
SIOCDLIFADDR = 0x8118691d
|
||||||
|
SIOCGLIFADDR = 0xc118691c
|
||||||
|
SIOCGLIFPHYADDR = 0xc118694b
|
||||||
|
SIOCSLIFPHYADDR = 0x8118694a
|
||||||
|
)
|
||||||
226
vendor/golang.org/x/sys/unix/errors_freebsd_arm.go
generated
vendored
Normal file
226
vendor/golang.org/x/sys/unix/errors_freebsd_arm.go
generated
vendored
Normal file
|
|
@ -0,0 +1,226 @@
|
||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
const (
|
||||||
|
IFT_1822 = 0x2
|
||||||
|
IFT_A12MPPSWITCH = 0x82
|
||||||
|
IFT_AAL2 = 0xbb
|
||||||
|
IFT_AAL5 = 0x31
|
||||||
|
IFT_ADSL = 0x5e
|
||||||
|
IFT_AFLANE8023 = 0x3b
|
||||||
|
IFT_AFLANE8025 = 0x3c
|
||||||
|
IFT_ARAP = 0x58
|
||||||
|
IFT_ARCNET = 0x23
|
||||||
|
IFT_ARCNETPLUS = 0x24
|
||||||
|
IFT_ASYNC = 0x54
|
||||||
|
IFT_ATM = 0x25
|
||||||
|
IFT_ATMDXI = 0x69
|
||||||
|
IFT_ATMFUNI = 0x6a
|
||||||
|
IFT_ATMIMA = 0x6b
|
||||||
|
IFT_ATMLOGICAL = 0x50
|
||||||
|
IFT_ATMRADIO = 0xbd
|
||||||
|
IFT_ATMSUBINTERFACE = 0x86
|
||||||
|
IFT_ATMVCIENDPT = 0xc2
|
||||||
|
IFT_ATMVIRTUAL = 0x95
|
||||||
|
IFT_BGPPOLICYACCOUNTING = 0xa2
|
||||||
|
IFT_BSC = 0x53
|
||||||
|
IFT_CCTEMUL = 0x3d
|
||||||
|
IFT_CEPT = 0x13
|
||||||
|
IFT_CES = 0x85
|
||||||
|
IFT_CHANNEL = 0x46
|
||||||
|
IFT_CNR = 0x55
|
||||||
|
IFT_COFFEE = 0x84
|
||||||
|
IFT_COMPOSITELINK = 0x9b
|
||||||
|
IFT_DCN = 0x8d
|
||||||
|
IFT_DIGITALPOWERLINE = 0x8a
|
||||||
|
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
|
||||||
|
IFT_DLSW = 0x4a
|
||||||
|
IFT_DOCSCABLEDOWNSTREAM = 0x80
|
||||||
|
IFT_DOCSCABLEMACLAYER = 0x7f
|
||||||
|
IFT_DOCSCABLEUPSTREAM = 0x81
|
||||||
|
IFT_DS0 = 0x51
|
||||||
|
IFT_DS0BUNDLE = 0x52
|
||||||
|
IFT_DS1FDL = 0xaa
|
||||||
|
IFT_DS3 = 0x1e
|
||||||
|
IFT_DTM = 0x8c
|
||||||
|
IFT_DVBASILN = 0xac
|
||||||
|
IFT_DVBASIOUT = 0xad
|
||||||
|
IFT_DVBRCCDOWNSTREAM = 0x93
|
||||||
|
IFT_DVBRCCMACLAYER = 0x92
|
||||||
|
IFT_DVBRCCUPSTREAM = 0x94
|
||||||
|
IFT_ENC = 0xf4
|
||||||
|
IFT_EON = 0x19
|
||||||
|
IFT_EPLRS = 0x57
|
||||||
|
IFT_ESCON = 0x49
|
||||||
|
IFT_ETHER = 0x6
|
||||||
|
IFT_FAST = 0x7d
|
||||||
|
IFT_FASTETHER = 0x3e
|
||||||
|
IFT_FASTETHERFX = 0x45
|
||||||
|
IFT_FDDI = 0xf
|
||||||
|
IFT_FIBRECHANNEL = 0x38
|
||||||
|
IFT_FRAMERELAYINTERCONNECT = 0x3a
|
||||||
|
IFT_FRAMERELAYMPI = 0x5c
|
||||||
|
IFT_FRDLCIENDPT = 0xc1
|
||||||
|
IFT_FRELAY = 0x20
|
||||||
|
IFT_FRELAYDCE = 0x2c
|
||||||
|
IFT_FRF16MFRBUNDLE = 0xa3
|
||||||
|
IFT_FRFORWARD = 0x9e
|
||||||
|
IFT_G703AT2MB = 0x43
|
||||||
|
IFT_G703AT64K = 0x42
|
||||||
|
IFT_GIF = 0xf0
|
||||||
|
IFT_GIGABITETHERNET = 0x75
|
||||||
|
IFT_GR303IDT = 0xb2
|
||||||
|
IFT_GR303RDT = 0xb1
|
||||||
|
IFT_H323GATEKEEPER = 0xa4
|
||||||
|
IFT_H323PROXY = 0xa5
|
||||||
|
IFT_HDH1822 = 0x3
|
||||||
|
IFT_HDLC = 0x76
|
||||||
|
IFT_HDSL2 = 0xa8
|
||||||
|
IFT_HIPERLAN2 = 0xb7
|
||||||
|
IFT_HIPPI = 0x2f
|
||||||
|
IFT_HIPPIINTERFACE = 0x39
|
||||||
|
IFT_HOSTPAD = 0x5a
|
||||||
|
IFT_HSSI = 0x2e
|
||||||
|
IFT_HY = 0xe
|
||||||
|
IFT_IBM370PARCHAN = 0x48
|
||||||
|
IFT_IDSL = 0x9a
|
||||||
|
IFT_IEEE80211 = 0x47
|
||||||
|
IFT_IEEE80212 = 0x37
|
||||||
|
IFT_IEEE8023ADLAG = 0xa1
|
||||||
|
IFT_IFGSN = 0x91
|
||||||
|
IFT_IMT = 0xbe
|
||||||
|
IFT_INTERLEAVE = 0x7c
|
||||||
|
IFT_IP = 0x7e
|
||||||
|
IFT_IPFORWARD = 0x8e
|
||||||
|
IFT_IPOVERATM = 0x72
|
||||||
|
IFT_IPOVERCDLC = 0x6d
|
||||||
|
IFT_IPOVERCLAW = 0x6e
|
||||||
|
IFT_IPSWITCH = 0x4e
|
||||||
|
IFT_ISDN = 0x3f
|
||||||
|
IFT_ISDNBASIC = 0x14
|
||||||
|
IFT_ISDNPRIMARY = 0x15
|
||||||
|
IFT_ISDNS = 0x4b
|
||||||
|
IFT_ISDNU = 0x4c
|
||||||
|
IFT_ISO88022LLC = 0x29
|
||||||
|
IFT_ISO88023 = 0x7
|
||||||
|
IFT_ISO88024 = 0x8
|
||||||
|
IFT_ISO88025 = 0x9
|
||||||
|
IFT_ISO88025CRFPINT = 0x62
|
||||||
|
IFT_ISO88025DTR = 0x56
|
||||||
|
IFT_ISO88025FIBER = 0x73
|
||||||
|
IFT_ISO88026 = 0xa
|
||||||
|
IFT_ISUP = 0xb3
|
||||||
|
IFT_L3IPXVLAN = 0x89
|
||||||
|
IFT_LAPB = 0x10
|
||||||
|
IFT_LAPD = 0x4d
|
||||||
|
IFT_LAPF = 0x77
|
||||||
|
IFT_LOCALTALK = 0x2a
|
||||||
|
IFT_LOOP = 0x18
|
||||||
|
IFT_MEDIAMAILOVERIP = 0x8b
|
||||||
|
IFT_MFSIGLINK = 0xa7
|
||||||
|
IFT_MIOX25 = 0x26
|
||||||
|
IFT_MODEM = 0x30
|
||||||
|
IFT_MPC = 0x71
|
||||||
|
IFT_MPLS = 0xa6
|
||||||
|
IFT_MPLSTUNNEL = 0x96
|
||||||
|
IFT_MSDSL = 0x8f
|
||||||
|
IFT_MVL = 0xbf
|
||||||
|
IFT_MYRINET = 0x63
|
||||||
|
IFT_NFAS = 0xaf
|
||||||
|
IFT_NSIP = 0x1b
|
||||||
|
IFT_OPTICALCHANNEL = 0xc3
|
||||||
|
IFT_OPTICALTRANSPORT = 0xc4
|
||||||
|
IFT_OTHER = 0x1
|
||||||
|
IFT_P10 = 0xc
|
||||||
|
IFT_P80 = 0xd
|
||||||
|
IFT_PARA = 0x22
|
||||||
|
IFT_PFLOG = 0xf6
|
||||||
|
IFT_PFSYNC = 0xf7
|
||||||
|
IFT_PLC = 0xae
|
||||||
|
IFT_POS = 0xab
|
||||||
|
IFT_PPPMULTILINKBUNDLE = 0x6c
|
||||||
|
IFT_PROPBWAP2MP = 0xb8
|
||||||
|
IFT_PROPCNLS = 0x59
|
||||||
|
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5
|
||||||
|
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4
|
||||||
|
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6
|
||||||
|
IFT_PROPMUX = 0x36
|
||||||
|
IFT_PROPWIRELESSP2P = 0x9d
|
||||||
|
IFT_PTPSERIAL = 0x16
|
||||||
|
IFT_PVC = 0xf1
|
||||||
|
IFT_QLLC = 0x44
|
||||||
|
IFT_RADIOMAC = 0xbc
|
||||||
|
IFT_RADSL = 0x5f
|
||||||
|
IFT_REACHDSL = 0xc0
|
||||||
|
IFT_RFC1483 = 0x9f
|
||||||
|
IFT_RS232 = 0x21
|
||||||
|
IFT_RSRB = 0x4f
|
||||||
|
IFT_SDLC = 0x11
|
||||||
|
IFT_SDSL = 0x60
|
||||||
|
IFT_SHDSL = 0xa9
|
||||||
|
IFT_SIP = 0x1f
|
||||||
|
IFT_SLIP = 0x1c
|
||||||
|
IFT_SMDSDXI = 0x2b
|
||||||
|
IFT_SMDSICIP = 0x34
|
||||||
|
IFT_SONET = 0x27
|
||||||
|
IFT_SONETOVERHEADCHANNEL = 0xb9
|
||||||
|
IFT_SONETPATH = 0x32
|
||||||
|
IFT_SONETVT = 0x33
|
||||||
|
IFT_SRP = 0x97
|
||||||
|
IFT_SS7SIGLINK = 0x9c
|
||||||
|
IFT_STACKTOSTACK = 0x6f
|
||||||
|
IFT_STARLAN = 0xb
|
||||||
|
IFT_STF = 0xd7
|
||||||
|
IFT_T1 = 0x12
|
||||||
|
IFT_TDLC = 0x74
|
||||||
|
IFT_TERMPAD = 0x5b
|
||||||
|
IFT_TR008 = 0xb0
|
||||||
|
IFT_TRANSPHDLC = 0x7b
|
||||||
|
IFT_TUNNEL = 0x83
|
||||||
|
IFT_ULTRA = 0x1d
|
||||||
|
IFT_USB = 0xa0
|
||||||
|
IFT_V11 = 0x40
|
||||||
|
IFT_V35 = 0x2d
|
||||||
|
IFT_V36 = 0x41
|
||||||
|
IFT_V37 = 0x78
|
||||||
|
IFT_VDSL = 0x61
|
||||||
|
IFT_VIRTUALIPADDRESS = 0x70
|
||||||
|
IFT_VOICEEM = 0x64
|
||||||
|
IFT_VOICEENCAP = 0x67
|
||||||
|
IFT_VOICEFXO = 0x65
|
||||||
|
IFT_VOICEFXS = 0x66
|
||||||
|
IFT_VOICEOVERATM = 0x98
|
||||||
|
IFT_VOICEOVERFRAMERELAY = 0x99
|
||||||
|
IFT_VOICEOVERIP = 0x68
|
||||||
|
IFT_X213 = 0x5d
|
||||||
|
IFT_X25 = 0x5
|
||||||
|
IFT_X25DDN = 0x4
|
||||||
|
IFT_X25HUNTGROUP = 0x7a
|
||||||
|
IFT_X25MLP = 0x79
|
||||||
|
IFT_X25PLE = 0x28
|
||||||
|
IFT_XETHER = 0x1a
|
||||||
|
|
||||||
|
// missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go
|
||||||
|
IFF_SMART = 0x20
|
||||||
|
IFT_FAITH = 0xf2
|
||||||
|
IFT_IPXIP = 0xf9
|
||||||
|
IPPROTO_MAXID = 0x34
|
||||||
|
IPV6_FAITH = 0x1d
|
||||||
|
IP_FAITH = 0x16
|
||||||
|
MAP_NORESERVE = 0x40
|
||||||
|
MAP_RENAME = 0x20
|
||||||
|
NET_RT_MAXID = 0x6
|
||||||
|
RTF_PRCLONING = 0x10000
|
||||||
|
RTM_OLDADD = 0x9
|
||||||
|
RTM_OLDDEL = 0xa
|
||||||
|
SIOCADDRT = 0x8030720a
|
||||||
|
SIOCALIFADDR = 0x8118691b
|
||||||
|
SIOCDELRT = 0x8030720b
|
||||||
|
SIOCDLIFADDR = 0x8118691d
|
||||||
|
SIOCGLIFADDR = 0xc118691c
|
||||||
|
SIOCGLIFPHYADDR = 0xc118694b
|
||||||
|
SIOCSLIFPHYADDR = 0x8118694a
|
||||||
|
)
|
||||||
2
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
2
vendor/golang.org/x/sys/unix/flock.go
generated
vendored
|
|
@ -1,5 +1,3 @@
|
||||||
// +build linux darwin freebsd openbsd netbsd dragonfly
|
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
|
||||||
20
vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go
generated
vendored
20
vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go
generated
vendored
|
|
@ -1,20 +0,0 @@
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build gccgo,linux,sparc64
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
//extern sysconf
|
|
||||||
func realSysconf(name int) int64
|
|
||||||
|
|
||||||
func sysconf(name int) (n int64, err syscall.Errno) {
|
|
||||||
r := realSysconf(name)
|
|
||||||
if r < 0 {
|
|
||||||
return 0, syscall.GetErrno()
|
|
||||||
}
|
|
||||||
return r, 0
|
|
||||||
}
|
|
||||||
166
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
166
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
|
|
@ -3,75 +3,9 @@
|
||||||
# Use of this source code is governed by a BSD-style
|
# Use of this source code is governed by a BSD-style
|
||||||
# license that can be found in the LICENSE file.
|
# license that can be found in the LICENSE file.
|
||||||
|
|
||||||
# The unix package provides access to the raw system call
|
# This script runs or (given -n) prints suggested commands to generate files for
|
||||||
# interface of the underlying operating system. Porting Go to
|
# the Architecture/OS specified by the GOARCH and GOOS environment variables.
|
||||||
# a new architecture/operating system combination requires
|
# See README.md for more information about how the build system works.
|
||||||
# some manual effort, though there are tools that automate
|
|
||||||
# much of the process. The auto-generated files have names
|
|
||||||
# beginning with z.
|
|
||||||
#
|
|
||||||
# This script runs or (given -n) prints suggested commands to generate z files
|
|
||||||
# for the current system. Running those commands is not automatic.
|
|
||||||
# This script is documentation more than anything else.
|
|
||||||
#
|
|
||||||
# * asm_${GOOS}_${GOARCH}.s
|
|
||||||
#
|
|
||||||
# This hand-written assembly file implements system call dispatch.
|
|
||||||
# There are three entry points:
|
|
||||||
#
|
|
||||||
# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
|
||||||
# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
|
|
||||||
# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
|
||||||
#
|
|
||||||
# The first and second are the standard ones; they differ only in
|
|
||||||
# how many arguments can be passed to the kernel.
|
|
||||||
# The third is for low-level use by the ForkExec wrapper;
|
|
||||||
# unlike the first two, it does not call into the scheduler to
|
|
||||||
# let it know that a system call is running.
|
|
||||||
#
|
|
||||||
# * syscall_${GOOS}.go
|
|
||||||
#
|
|
||||||
# This hand-written Go file implements system calls that need
|
|
||||||
# special handling and lists "//sys" comments giving prototypes
|
|
||||||
# for ones that can be auto-generated. Mksyscall reads those
|
|
||||||
# comments to generate the stubs.
|
|
||||||
#
|
|
||||||
# * syscall_${GOOS}_${GOARCH}.go
|
|
||||||
#
|
|
||||||
# Same as syscall_${GOOS}.go except that it contains code specific
|
|
||||||
# to ${GOOS} on one particular architecture.
|
|
||||||
#
|
|
||||||
# * types_${GOOS}.c
|
|
||||||
#
|
|
||||||
# This hand-written C file includes standard C headers and then
|
|
||||||
# creates typedef or enum names beginning with a dollar sign
|
|
||||||
# (use of $ in variable names is a gcc extension). The hardest
|
|
||||||
# part about preparing this file is figuring out which headers to
|
|
||||||
# include and which symbols need to be #defined to get the
|
|
||||||
# actual data structures that pass through to the kernel system calls.
|
|
||||||
# Some C libraries present alternate versions for binary compatibility
|
|
||||||
# and translate them on the way in and out of system calls, but
|
|
||||||
# there is almost always a #define that can get the real ones.
|
|
||||||
# See types_darwin.c and types_linux.c for examples.
|
|
||||||
#
|
|
||||||
# * zerror_${GOOS}_${GOARCH}.go
|
|
||||||
#
|
|
||||||
# This machine-generated file defines the system's error numbers,
|
|
||||||
# error strings, and signal numbers. The generator is "mkerrors.sh".
|
|
||||||
# Usually no arguments are needed, but mkerrors.sh will pass its
|
|
||||||
# arguments on to godefs.
|
|
||||||
#
|
|
||||||
# * zsyscall_${GOOS}_${GOARCH}.go
|
|
||||||
#
|
|
||||||
# Generated by mksyscall.pl; see syscall_${GOOS}.go above.
|
|
||||||
#
|
|
||||||
# * zsysnum_${GOOS}_${GOARCH}.go
|
|
||||||
#
|
|
||||||
# Generated by mksysnum_${GOOS}.
|
|
||||||
#
|
|
||||||
# * ztypes_${GOOS}_${GOARCH}.go
|
|
||||||
#
|
|
||||||
# Generated by godefs; see types_${GOOS}.c above.
|
|
||||||
|
|
||||||
GOOSARCH="${GOOS}_${GOARCH}"
|
GOOSARCH="${GOOS}_${GOARCH}"
|
||||||
|
|
||||||
|
|
@ -84,6 +18,7 @@ zsysctl="zsysctl_$GOOSARCH.go"
|
||||||
mksysnum=
|
mksysnum=
|
||||||
mktypes=
|
mktypes=
|
||||||
run="sh"
|
run="sh"
|
||||||
|
cmd=""
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-syscalls)
|
-syscalls)
|
||||||
|
|
@ -98,6 +33,7 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
-n)
|
-n)
|
||||||
run="cat"
|
run="cat"
|
||||||
|
cmd="echo"
|
||||||
shift
|
shift
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
@ -109,6 +45,14 @@ case "$#" in
|
||||||
exit 2
|
exit 2
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
|
||||||
|
# Use then new build system
|
||||||
|
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
||||||
|
$cmd docker build --tag generate:$GOOS $GOOS
|
||||||
|
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
GOOSARCH_in=syscall_$GOOSARCH.go
|
GOOSARCH_in=syscall_$GOOSARCH.go
|
||||||
case "$GOOSARCH" in
|
case "$GOOSARCH" in
|
||||||
_* | *_ | _)
|
_* | *_ | _)
|
||||||
|
|
@ -128,7 +72,7 @@ darwin_amd64)
|
||||||
;;
|
;;
|
||||||
darwin_arm)
|
darwin_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksysnum="./mksysnum_darwin.pl /usr/include/sys/syscall.h"
|
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
darwin_arm64)
|
darwin_arm64)
|
||||||
|
|
@ -164,65 +108,7 @@ freebsd_arm)
|
||||||
mksyscall="./mksyscall.pl -l32 -arm"
|
mksyscall="./mksyscall.pl -l32 -arm"
|
||||||
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
||||||
# Let the type of C char be signed for making the bare syscall
|
# Let the type of C char be signed for making the bare syscall
|
||||||
# API consistent across over platforms.
|
# API consistent across platforms.
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
|
||||||
;;
|
|
||||||
linux_386)
|
|
||||||
mkerrors="$mkerrors -m32"
|
|
||||||
mksyscall="./mksyscall.pl -l32"
|
|
||||||
mksysnum="./mksysnum_linux.pl /usr/include/asm/unistd_32.h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
linux_amd64)
|
|
||||||
unistd_h=$(ls -1 /usr/include/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h 2>/dev/null | head -1)
|
|
||||||
if [ "$unistd_h" = "" ]; then
|
|
||||||
echo >&2 cannot find unistd_64.h
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="./mksysnum_linux.pl $unistd_h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
linux_arm)
|
|
||||||
mkerrors="$mkerrors"
|
|
||||||
mksyscall="./mksyscall.pl -l32 -arm"
|
|
||||||
mksysnum="curl -s 'http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/arch/arm/include/uapi/asm/unistd.h' | ./mksysnum_linux.pl -"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
linux_arm64)
|
|
||||||
unistd_h=$(ls -1 /usr/include/asm/unistd.h /usr/include/asm-generic/unistd.h 2>/dev/null | head -1)
|
|
||||||
if [ "$unistd_h" = "" ]; then
|
|
||||||
echo >&2 cannot find unistd_64.h
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
mksysnum="./mksysnum_linux.pl $unistd_h"
|
|
||||||
# Let the type of C char be signed for making the bare syscall
|
|
||||||
# API consistent across over platforms.
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
|
||||||
;;
|
|
||||||
linux_ppc64)
|
|
||||||
GOOSARCH_in=syscall_linux_ppc64x.go
|
|
||||||
unistd_h=/usr/include/asm/unistd.h
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="./mksysnum_linux.pl $unistd_h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
linux_ppc64le)
|
|
||||||
GOOSARCH_in=syscall_linux_ppc64x.go
|
|
||||||
unistd_h=/usr/include/powerpc64le-linux-gnu/asm/unistd.h
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="./mksysnum_linux.pl $unistd_h"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
linux_s390x)
|
|
||||||
GOOSARCH_in=syscall_linux_s390x.go
|
|
||||||
unistd_h=/usr/include/asm/unistd.h
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksysnum="./mksysnum_linux.pl $unistd_h"
|
|
||||||
# Let the type of C char be signed to make the bare sys
|
|
||||||
# API more consistent between platforms.
|
|
||||||
# This is a deliberate departure from the way the syscall
|
|
||||||
# package generates its version of the types file.
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
;;
|
;;
|
||||||
linux_sparc64)
|
linux_sparc64)
|
||||||
|
|
@ -244,11 +130,18 @@ netbsd_amd64)
|
||||||
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
|
netbsd_arm)
|
||||||
|
mkerrors="$mkerrors"
|
||||||
|
mksyscall="./mksyscall.pl -l32 -netbsd -arm"
|
||||||
|
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
||||||
|
# Let the type of C char be signed for making the bare syscall
|
||||||
|
# API consistent across platforms.
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
|
;;
|
||||||
openbsd_386)
|
openbsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="./mksyscall.pl -l32 -openbsd"
|
mksyscall="./mksyscall.pl -l32 -openbsd"
|
||||||
mksysctl="./mksysctl_openbsd.pl"
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
zsysctl="zsysctl_openbsd.go"
|
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
|
|
@ -256,10 +149,18 @@ openbsd_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksyscall="./mksyscall.pl -openbsd"
|
mksyscall="./mksyscall.pl -openbsd"
|
||||||
mksysctl="./mksysctl_openbsd.pl"
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
zsysctl="zsysctl_openbsd.go"
|
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
|
openbsd_arm)
|
||||||
|
mkerrors="$mkerrors"
|
||||||
|
mksyscall="./mksyscall.pl -l32 -openbsd -arm"
|
||||||
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
|
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
||||||
|
# Let the type of C char be signed for making the bare syscall
|
||||||
|
# API consistent across platforms.
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
|
;;
|
||||||
solaris_amd64)
|
solaris_amd64)
|
||||||
mksyscall="./mksyscall_solaris.pl"
|
mksyscall="./mksyscall_solaris.pl"
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
|
|
@ -288,7 +189,6 @@ esac
|
||||||
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
||||||
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
||||||
if [ -n "$mktypes" ]; then
|
if [ -n "$mktypes" ]; then
|
||||||
echo "echo // +build $GOARCH,$GOOS > ztypes_$GOOSARCH.go";
|
echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
|
||||||
echo "$mktypes types_$GOOS.go | go run mkpost.go >>ztypes_$GOOSARCH.go";
|
|
||||||
fi
|
fi
|
||||||
) | $run
|
) | $run
|
||||||
|
|
|
||||||
99
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
99
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
|
|
@ -16,9 +16,18 @@ if test -z "$GOARCH" -o -z "$GOOS"; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check that we are using the new build system if we should
|
||||||
|
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
|
||||||
|
if [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
|
||||||
|
echo 1>&2 "In the new build system, mkerrors should not be called directly."
|
||||||
|
echo 1>&2 "See README.md"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
CC=${CC:-cc}
|
CC=${CC:-cc}
|
||||||
|
|
||||||
if [[ "$GOOS" -eq "solaris" ]]; then
|
if [[ "$GOOS" = "solaris" ]]; then
|
||||||
# Assumes GNU versions of utilities in PATH.
|
# Assumes GNU versions of utilities in PATH.
|
||||||
export PATH=/usr/gnu/bin:$PATH
|
export PATH=/usr/gnu/bin:$PATH
|
||||||
fi
|
fi
|
||||||
|
|
@ -29,6 +38,8 @@ includes_Darwin='
|
||||||
#define _DARWIN_C_SOURCE
|
#define _DARWIN_C_SOURCE
|
||||||
#define KERNEL
|
#define KERNEL
|
||||||
#define _DARWIN_USE_64_BIT_INODE
|
#define _DARWIN_USE_64_BIT_INODE
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/attr.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
|
|
@ -36,6 +47,7 @@ includes_Darwin='
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
|
@ -66,6 +78,7 @@ includes_DragonFly='
|
||||||
'
|
'
|
||||||
|
|
||||||
includes_FreeBSD='
|
includes_FreeBSD='
|
||||||
|
#include <sys/capability.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
|
|
@ -73,6 +86,7 @@ includes_FreeBSD='
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
|
|
@ -102,8 +116,39 @@ includes_Linux='
|
||||||
#endif
|
#endif
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
|
||||||
|
// these structures. We just include them copied from <bits/termios.h>.
|
||||||
|
#if defined(__powerpc__)
|
||||||
|
struct sgttyb {
|
||||||
|
char sg_ispeed;
|
||||||
|
char sg_ospeed;
|
||||||
|
char sg_erase;
|
||||||
|
char sg_kill;
|
||||||
|
short sg_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct tchars {
|
||||||
|
char t_intrc;
|
||||||
|
char t_quitc;
|
||||||
|
char t_startc;
|
||||||
|
char t_stopc;
|
||||||
|
char t_eofc;
|
||||||
|
char t_brkc;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ltchars {
|
||||||
|
char t_suspc;
|
||||||
|
char t_dsuspc;
|
||||||
|
char t_rprntc;
|
||||||
|
char t_flushc;
|
||||||
|
char t_werasc;
|
||||||
|
char t_lnextc;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <bits/sockaddr.h>
|
#include <bits/sockaddr.h>
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
|
#include <sys/eventfd.h>
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
@ -113,6 +158,7 @@ includes_Linux='
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/xattr.h>
|
||||||
#include <linux/if.h>
|
#include <linux/if.h>
|
||||||
#include <linux/if_alg.h>
|
#include <linux/if_alg.h>
|
||||||
#include <linux/if_arp.h>
|
#include <linux/if_arp.h>
|
||||||
|
|
@ -122,15 +168,25 @@ includes_Linux='
|
||||||
#include <linux/if_addr.h>
|
#include <linux/if_addr.h>
|
||||||
#include <linux/falloc.h>
|
#include <linux/falloc.h>
|
||||||
#include <linux/filter.h>
|
#include <linux/filter.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
|
#include <linux/keyctl.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
|
#include <linux/perf_event.h>
|
||||||
|
#include <linux/random.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
#include <linux/rtnetlink.h>
|
#include <linux/rtnetlink.h>
|
||||||
#include <linux/ptrace.h>
|
#include <linux/ptrace.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
|
#include <linux/seccomp.h>
|
||||||
|
#include <linux/sockios.h>
|
||||||
#include <linux/wait.h>
|
#include <linux/wait.h>
|
||||||
#include <linux/icmpv6.h>
|
#include <linux/icmpv6.h>
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
#include <linux/can.h>
|
#include <linux/can.h>
|
||||||
|
#include <linux/vm_sockets.h>
|
||||||
|
#include <linux/taskstats.h>
|
||||||
|
#include <linux/genetlink.h>
|
||||||
|
#include <linux/watchdog.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
#include <asm/termbits.h>
|
#include <asm/termbits.h>
|
||||||
|
|
||||||
|
|
@ -146,11 +202,20 @@ includes_Linux='
|
||||||
#define PTRACE_SETREGS 0xd
|
#define PTRACE_SETREGS 0xd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef SOL_NETLINK
|
||||||
|
#define SOL_NETLINK 270
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SOL_BLUETOOTH
|
#ifdef SOL_BLUETOOTH
|
||||||
// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
|
// SPARC includes this in /usr/include/sparc64-linux-gnu/bits/socket.h
|
||||||
// but it is already in bluetooth_linux.go
|
// but it is already in bluetooth_linux.go
|
||||||
#undef SOL_BLUETOOTH
|
#undef SOL_BLUETOOTH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Certain constants are missing from the fs/crypto UAPI
|
||||||
|
#define FS_KEY_DESC_PREFIX "fscrypt:"
|
||||||
|
#define FS_KEY_DESC_PREFIX_SIZE 8
|
||||||
|
#define FS_MAX_KEY_SIZE 64
|
||||||
'
|
'
|
||||||
|
|
||||||
includes_NetBSD='
|
includes_NetBSD='
|
||||||
|
|
@ -222,6 +287,7 @@ includes_SunOS='
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mkdev.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/if_arp.h>
|
#include <net/if_arp.h>
|
||||||
|
|
@ -286,6 +352,7 @@ ccflags="$@"
|
||||||
$2 !~ /^EXPR_/ &&
|
$2 !~ /^EXPR_/ &&
|
||||||
$2 ~ /^E[A-Z0-9_]+$/ ||
|
$2 ~ /^E[A-Z0-9_]+$/ ||
|
||||||
$2 ~ /^B[0-9_]+$/ ||
|
$2 ~ /^B[0-9_]+$/ ||
|
||||||
|
$2 ~ /^(OLD|NEW)DEV$/ ||
|
||||||
$2 == "BOTHER" ||
|
$2 == "BOTHER" ||
|
||||||
$2 ~ /^CI?BAUD(EX)?$/ ||
|
$2 ~ /^CI?BAUD(EX)?$/ ||
|
||||||
$2 == "IBSHIFT" ||
|
$2 == "IBSHIFT" ||
|
||||||
|
|
@ -321,9 +388,9 @@ ccflags="$@"
|
||||||
$2 == "IFNAMSIZ" ||
|
$2 == "IFNAMSIZ" ||
|
||||||
$2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
|
$2 ~ /^CTL_(MAXNAME|NET|QUERY)$/ ||
|
||||||
$2 ~ /^SYSCTL_VERS/ ||
|
$2 ~ /^SYSCTL_VERS/ ||
|
||||||
$2 ~ /^(MS|MNT)_/ ||
|
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
||||||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
||||||
$2 ~ /^(O|F|FD|NAME|S|PTRACE|PT)_/ ||
|
$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
||||||
$2 !~ "NLA_TYPE_MASK" &&
|
$2 !~ "NLA_TYPE_MASK" &&
|
||||||
|
|
@ -337,16 +404,34 @@ ccflags="$@"
|
||||||
$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
|
$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
|
||||||
$2 ~ /^BIOC/ ||
|
$2 ~ /^BIOC/ ||
|
||||||
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
||||||
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
|
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
||||||
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
||||||
$2 ~ /^CLONE_[A-Z_]+/ ||
|
$2 ~ /^CLONE_[A-Z_]+/ ||
|
||||||
$2 !~ /^(BPF_TIMEVAL)$/ &&
|
$2 !~ /^(BPF_TIMEVAL)$/ &&
|
||||||
$2 ~ /^(BPF|DLT)_/ ||
|
$2 ~ /^(BPF|DLT)_/ ||
|
||||||
$2 ~ /^CLOCK_/ ||
|
$2 ~ /^CLOCK_/ ||
|
||||||
$2 ~ /^CAN_/ ||
|
$2 ~ /^CAN_/ ||
|
||||||
|
$2 ~ /^CAP_/ ||
|
||||||
$2 ~ /^ALG_/ ||
|
$2 ~ /^ALG_/ ||
|
||||||
|
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
|
||||||
|
$2 ~ /^GRND_/ ||
|
||||||
|
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
||||||
|
$2 ~ /^KEYCTL_/ ||
|
||||||
|
$2 ~ /^PERF_EVENT_IOC_/ ||
|
||||||
|
$2 ~ /^SECCOMP_MODE_/ ||
|
||||||
|
$2 ~ /^SPLICE_/ ||
|
||||||
|
$2 ~ /^(VM|VMADDR)_/ ||
|
||||||
|
$2 ~ /^IOCTL_VM_SOCKETS_/ ||
|
||||||
|
$2 ~ /^(TASKSTATS|TS)_/ ||
|
||||||
|
$2 ~ /^GENL_/ ||
|
||||||
|
$2 ~ /^UTIME_/ ||
|
||||||
|
$2 ~ /^XATTR_(CREATE|REPLACE)/ ||
|
||||||
|
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
||||||
|
$2 ~ /^FSOPT_/ ||
|
||||||
|
$2 ~ /^WDIOC_/ ||
|
||||||
$2 !~ "WMESGLEN" &&
|
$2 !~ "WMESGLEN" &&
|
||||||
$2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
|
$2 ~ /^W[A-Z0-9]+$/ ||
|
||||||
|
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
|
||||||
$2 ~ /^__WCOREFLAG$/ {next}
|
$2 ~ /^__WCOREFLAG$/ {next}
|
||||||
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
||||||
|
|
||||||
|
|
@ -381,7 +466,7 @@ echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
sort >_signal.grep
|
sort >_signal.grep
|
||||||
|
|
||||||
echo '// mkerrors.sh' "$@"
|
echo '// mkerrors.sh' "$@"
|
||||||
echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
|
echo '// Code generated by the command above; see README.md. DO NOT EDIT.'
|
||||||
echo
|
echo
|
||||||
echo "// +build ${GOARCH},${GOOS}"
|
echo "// +build ${GOARCH},${GOOS}"
|
||||||
echo
|
echo
|
||||||
|
|
@ -443,7 +528,7 @@ intcmp(const void *a, const void *b)
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
int i, j, e;
|
int i, e;
|
||||||
char buf[1024], *p;
|
char buf[1024], *p;
|
||||||
|
|
||||||
printf("\n\n// Error table\n");
|
printf("\n\n// Error table\n");
|
||||||
|
|
|
||||||
62
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
62
vendor/golang.org/x/sys/unix/mkpost.go
generated
vendored
|
|
@ -1,62 +0,0 @@
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// mkpost processes the output of cgo -godefs to
|
|
||||||
// modify the generated types. It is used to clean up
|
|
||||||
// the sys API in an architecture specific manner.
|
|
||||||
//
|
|
||||||
// mkpost is run after cgo -godefs by mkall.sh.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"go/format"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"regexp"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
b, err := ioutil.ReadAll(os.Stdin)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
s := string(b)
|
|
||||||
|
|
||||||
goarch := os.Getenv("GOARCH")
|
|
||||||
goos := os.Getenv("GOOS")
|
|
||||||
if goarch == "s390x" && goos == "linux" {
|
|
||||||
// Export the types of PtraceRegs fields.
|
|
||||||
re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)")
|
|
||||||
s = re.ReplaceAllString(s, "Ptrace$1")
|
|
||||||
|
|
||||||
// Replace padding fields inserted by cgo with blank identifiers.
|
|
||||||
re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*")
|
|
||||||
s = re.ReplaceAllString(s, "_")
|
|
||||||
|
|
||||||
// Replace other unwanted fields with blank identifiers.
|
|
||||||
re = regexp.MustCompile("X_[A-Za-z0-9_]*")
|
|
||||||
s = re.ReplaceAllString(s, "_")
|
|
||||||
|
|
||||||
// Replace the control_regs union with a blank identifier for now.
|
|
||||||
re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64")
|
|
||||||
s = re.ReplaceAllString(s, "_ [0]uint64")
|
|
||||||
}
|
|
||||||
|
|
||||||
// gofmt
|
|
||||||
b, err = format.Source([]byte(s))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append this command to the header to show where the new file
|
|
||||||
// came from.
|
|
||||||
re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)")
|
|
||||||
b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go"))
|
|
||||||
|
|
||||||
fmt.Printf("%s", b)
|
|
||||||
}
|
|
||||||
12
vendor/golang.org/x/sys/unix/mksyscall.pl
generated
vendored
12
vendor/golang.org/x/sys/unix/mksyscall.pl
generated
vendored
|
|
@ -69,6 +69,16 @@ if($ARGV[0] =~ /^-/) {
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check that we are using the new build system if we should
|
||||||
|
if($ENV{'GOOS'} eq "linux" && $ENV{'GOARCH'} ne "sparc64") {
|
||||||
|
if($ENV{'GOLANG_SYS_BUILD'} ne "docker") {
|
||||||
|
print STDERR "In the new build system, mksyscall should not be called directly.\n";
|
||||||
|
print STDERR "See README.md\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub parseparamlist($) {
|
sub parseparamlist($) {
|
||||||
my ($list) = @_;
|
my ($list) = @_;
|
||||||
$list =~ s/^\s*//;
|
$list =~ s/^\s*//;
|
||||||
|
|
@ -300,7 +310,7 @@ if($errors) {
|
||||||
|
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
// $cmdline
|
// $cmdline
|
||||||
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
// +build $tags
|
// +build $tags
|
||||||
|
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
2
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl
generated
vendored
|
|
@ -258,7 +258,7 @@ if($errors) {
|
||||||
|
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
// $cmdline
|
// $cmdline
|
||||||
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
|
// Code generated by the command above; see README.md. DO NOT EDIT.
|
||||||
|
|
||||||
// +build $tags
|
// +build $tags
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue