-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from vokomarov/feature/travis-ci
TravisCI integration
- Loading branch information
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*.so | ||
*.dylib | ||
.idea | ||
coverage.out | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
language: go | ||
|
||
go: | ||
- '1.14' | ||
|
||
before_install: | ||
- sudo apt-get install libpcap-dev | ||
|
||
install: | ||
- go get golang.org/x/tools/cmd/cover | ||
- go get github.com/mattn/goveralls | ||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.6 | ||
|
||
script: | ||
- go test ./... -v -covermode=count -coverprofile=coverage.out | ||
- cat coverage.out | grep -v "main.go" | grep -v "hosts.go" | grep -v "ports.go" > cover.out | ||
- goveralls -coverprofile=cover.out -service=travis-ci | ||
- golangci-lint run | ||
|
||
- export PCAPV=1.9.1 | ||
- wget http://www.tcpdump.org/release/libpcap-$PCAPV.tar.gz | ||
- tar xvf libpcap-$PCAPV.tar.gz | ||
- cd libpcap-$PCAPV | ||
- ./configure --with-pcap=linux | ||
- make | ||
- cd .. | ||
|
||
- CGO_ENABLED=1 GOARCH=amd64 GOOS=linux CGO_LDFLAGS+="-L./libpcap-$PCAPV" go build -ldflags="-s -w" -o out/netshark_linux_x86-64 . | ||
|
||
# TODO. MacOS build | ||
# - GOARCH=amd64 GOOS=darwin go build -o out/netshark_osx . | ||
|
||
- GOARCH=386 GOOS=windows go build -o out/netshark_win32.exe . | ||
- GOARCH=amd64 GOOS=windows go build -o out/netshark_win64.exe . | ||
|
||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: $GITHUB_API_KEY_SECURE | ||
file_glob: true | ||
file: out/* | ||
skip_cleanup: true | ||
on: | ||
tags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package host | ||
|
||
import "testing" | ||
|
||
func TestHost_ID(t *testing.T) { | ||
for _, test := range []struct { | ||
IP string | ||
MAC string | ||
ID string | ||
}{ | ||
{ | ||
ID: "d41d8cd98f00b204e9800998ecf8427e", | ||
}, | ||
{ | ||
IP: "192.168.1.1", | ||
ID: "66efff4c945d3c3b87fc271b47d456db", | ||
}, | ||
{ | ||
MAC: "28:6c:07:48:66:be", | ||
ID: "924a7370c8df57b5b3f0a2e0d9d91598", | ||
}, | ||
{ | ||
IP: "192.168.1.1", | ||
MAC: "28:6c:07:48:66:be", | ||
ID: "7a48a7ba6494c7eb4c06e4787e9a6a88", | ||
}, | ||
} { | ||
host := Host{ | ||
IP: test.IP, | ||
MAC: test.MAC, | ||
} | ||
|
||
if host.id != "" { | ||
t.Errorf("initial Host ID is not empty") | ||
} | ||
|
||
if host.ID() != test.ID { | ||
t.Errorf("test Host ID [%s] is not equal to actual Host ID [%s]", test.ID, host.ID()) | ||
} | ||
|
||
if host.id == "" { | ||
t.Errorf("Host ID is not cached") | ||
} | ||
} | ||
} |