diff --git a/.gitignore b/.gitignore index d6ebaeb..3040959 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ bin *_temp *.prof *.pprof -*.svg \ No newline at end of file +*.svg +*.txt +*.out \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5355466..88638f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,10 @@ install: before_script: script: - cd $HOME/gopath/src/github.com/ICKelin/opennotr + - chmod +x coverage.sh + - ./coverage.sh - chmod +x build_exec.sh - ./build_exec.sh +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/README.md b/README.md index d1bf49a..ed0cff0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@

+ + + go report diff --git a/coverage.sh b/coverage.sh new file mode 100755 index 0000000..7d7a59a --- /dev/null +++ b/coverage.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +echo "" > coverage.txt + +for d in $(go list ./... | grep -v vendor); do + go test -race -coverprofile=profile.out -covermode=atomic $d -v + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done \ No newline at end of file diff --git a/opennotrd/test/plugin_test.go b/opennotrd/test/plugin_test.go index 71aec73..54476bd 100644 --- a/opennotrd/test/plugin_test.go +++ b/opennotrd/test/plugin_test.go @@ -9,6 +9,12 @@ import ( _ "github.com/ICKelin/opennotr/opennotrd/plugin/tcpproxy" ) +var listener net.Listener + +func init() { + +} + func runTCPServer(bufsize int) net.Listener { lis, err := net.Listen("tcp", "127.0.0.1:2345") if err != nil { @@ -37,16 +43,18 @@ func onconn(conn net.Conn, bufsize int) { } func runEcho(t *testing.T, bufsize, numconn int) { - item := &plugin.ProxyItem{ - Protocol: "tcp", - From: "127.0.0.1:1234", - To: "127.0.0.1:2345", + item := &plugin.PluginMeta{ + Protocol: "tcp", + From: "127.0.0.1:1234", + To: "127.0.0.1:2345", + RecycleSignal: make(chan struct{}), } - err := plugin.DefaultStream().AddProxy(item) + err := plugin.DefaultPluginManager().AddProxy(item) if err != nil { t.Error(err) return } + defer plugin.DefaultPluginManager().DelProxy(item) lis := runTCPServer(bufsize) @@ -68,8 +76,8 @@ func runEcho(t *testing.T, bufsize, numconn int) { } tick := time.NewTicker(time.Second * 60) <-tick.C - lis.Close() + time.Sleep(time.Second) } func TestTCPEcho128B(t *testing.T) {