Skip to content

Commit

Permalink
WIP on getting coverage working for smoke tests
Browse files Browse the repository at this point in the history
$ cd prog/weaver
$ go test -c -o weaver -ldflags "-extldflags \"-static\"" -tags netgo -v -covermode=count -coverpkg .,../../router .
$ ./weaver -test.coverprofile=/tmp/cover.prof -name d2:50:3d:dd:0c:45

hit ^C

$ go tool cover -html /tmp/cover.prof -o /tmp/coverage.html
  • Loading branch information
rade committed Jun 14, 2015
1 parent a844797 commit a9af595
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 34 deletions.
73 changes: 39 additions & 34 deletions prog/weaver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,28 @@ import (

var version = "(unreleased version)"

func main() {

log.SetPrefix(weave.Protocol + " ")
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds)

procs := runtime.NumCPU()
// packet sniffing can block an OS thread, so we need one thread
// for that plus at least one more.
if procs < 2 {
procs = 2
}
runtime.GOMAXPROCS(procs)

var (
config weave.Config
justVersion bool
ifaceName string
routerName string
nickName string
password string
wait int
debug bool
pktdebug bool
prof string
bufSzMB int
noDiscovery bool
httpAddr string
iprangeCIDR string
ipsubnetCIDR string
peerCount int
apiPath string
peers []string
)
var (
config weave.Config
justVersion bool
ifaceName string
routerName string
nickName string
password string
wait int
debug bool
pktdebug bool
prof string
bufSzMB int
noDiscovery bool
httpAddr string
iprangeCIDR string
ipsubnetCIDR string
peerCount int
apiPath string
peers []string
)

func init() {
flag.BoolVar(&justVersion, "version", false, "print version and exit")
flag.IntVar(&config.Port, "port", weave.Port, "router port")
flag.StringVar(&ifaceName, "iface", "", "name of interface to capture/inject from (disabled if blank)")
Expand All @@ -76,7 +64,24 @@ func main() {
flag.StringVar(&ipsubnetCIDR, "ipsubnet", "", "subnet to allocate within by default, in CIDR notation")
flag.IntVar(&peerCount, "initpeercount", 0, "number of peers in network (for IP address allocation)")
flag.StringVar(&apiPath, "api", "unix:///var/run/docker.sock", "Path to Docker API socket")
flag.Parse()
}

func main() {

log.SetPrefix(weave.Protocol + " ")
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds)

procs := runtime.NumCPU()
// packet sniffing can block an OS thread, so we need one thread
// for that plus at least one more.
if procs < 2 {
procs = 2
}
runtime.GOMAXPROCS(procs)

if !flag.Parsed() {
flag.Parse()
}
peers = flag.Args()

InitDefaultLogging(debug)
Expand Down
9 changes: 9 additions & 0 deletions prog/weaver/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"testing"
)

func TestMain(t *testing.T) {
main()
}

0 comments on commit a9af595

Please sign in to comment.