mirror of
https://github.com/go-ping/ping.git
synced 2025-06-26 06:01:40 +00:00
Add ability to set outgouing interface (only Linux support). Fix test
This commit is contained in:
parent
72dfce2120
commit
47c097f8b4
2
Makefile
2
Makefile
@ -24,7 +24,7 @@ style:
|
||||
.PHONY: test
|
||||
test:
|
||||
@echo ">> running all tests"
|
||||
GO111MODULE=$(GO111MODULE) $(GO) test -race -cover $(GOOPTS) $(pkgs)
|
||||
GO111MODULE=$(GO111MODULE) $(GO) test -race -cover -short $(GOOPTS) $(pkgs)
|
||||
|
||||
.PHONY: vet
|
||||
vet:
|
||||
|
11
ping_test.go
11
ping_test.go
@ -387,21 +387,26 @@ func TestSetIPAddr(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBindToDevice(t *testing.T) {
|
||||
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test in short mode.")
|
||||
}
|
||||
|
||||
// Create a localhost ipv4 pinger
|
||||
pinger := New("127.0.0.1")
|
||||
pinger.ipv4 = true
|
||||
pinger.Count = 1
|
||||
|
||||
// Set loopback interface: "lo"
|
||||
// Set loopback interface
|
||||
pinger.Iface = "lo"
|
||||
err := pinger.Run()
|
||||
if runtime.GOOS == "linux" {
|
||||
AssertNoError(t, err)
|
||||
} else {
|
||||
AssertError(t, err, "other platforms unsupported this feature")
|
||||
AssertError(t, err, "other platforms unsupport this feature")
|
||||
}
|
||||
|
||||
// Set fake interface: "L()0pB@cK"
|
||||
// Set fake interface
|
||||
pinger.Iface = "L()0pB@cK"
|
||||
err = pinger.Run()
|
||||
AssertError(t, err, "device not found")
|
||||
|
Loading…
Reference in New Issue
Block a user