Test: remove all Logf/Log (#547)
Move some of them to Errorf and friends, but most of them are just gone: This make go test -v actually readable. Remove a bunch of test that used ipv6 on localhost as this does not work on Travis.
This commit is contained in:
parent
145266a717
commit
348c84f37e
|
@ -15,7 +15,7 @@ func TestDialUDP(t *testing.T) {
|
|||
HandleFunc("miek.nl.", HelloServer)
|
||||
defer HandleRemove("miek.nl.")
|
||||
|
||||
s, addrstr, err := RunLocalUDPServer("[::1]:0")
|
||||
s, addrstr, err := RunLocalUDPServer("127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to run test server: %v", err)
|
||||
}
|
||||
|
@ -162,65 +162,6 @@ func TestClientTLSSyncV4(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestClientTLSSyncV6(t *testing.T) {
|
||||
HandleFunc("miek.nl.", HelloServer)
|
||||
defer HandleRemove("miek.nl.")
|
||||
|
||||
cert, err := tls.X509KeyPair(CertPEMBlock, KeyPEMBlock)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to build certificate: %v", err)
|
||||
}
|
||||
|
||||
config := tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
}
|
||||
|
||||
s, addrstr, err := RunLocalTLSServer("[::1]:0", &config)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to run test server: %v", err)
|
||||
}
|
||||
defer s.Shutdown()
|
||||
|
||||
m := new(Msg)
|
||||
m.SetQuestion("miek.nl.", TypeSOA)
|
||||
|
||||
c := new(Client)
|
||||
|
||||
// test tcp-tls
|
||||
c.Net = "tcp-tls"
|
||||
c.TLSConfig = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
|
||||
r, _, err := c.Exchange(m, addrstr)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to exchange: %v", err)
|
||||
}
|
||||
if r == nil {
|
||||
t.Fatal("response is nil")
|
||||
}
|
||||
if r.Rcode != RcodeSuccess {
|
||||
t.Errorf("failed to get an valid answer\n%v", r)
|
||||
}
|
||||
|
||||
// test tcp6-tls
|
||||
c.Net = "tcp6-tls"
|
||||
c.TLSConfig = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
|
||||
r, _, err = c.Exchange(m, addrstr)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to exchange: %v", err)
|
||||
}
|
||||
if r == nil {
|
||||
t.Fatal("response is nil")
|
||||
}
|
||||
if r.Rcode != RcodeSuccess {
|
||||
t.Errorf("failed to get an valid answer\n%v", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientSyncBadID(t *testing.T) {
|
||||
HandleFunc("miek.nl.", HelloServerBadID)
|
||||
defer HandleRemove("miek.nl.")
|
||||
|
@ -321,7 +262,6 @@ func TestClientEDNS0Local(t *testing.T) {
|
|||
}
|
||||
if r.Rcode != RcodeSuccess {
|
||||
t.Fatal("failed to get a valid answer")
|
||||
t.Logf("%v\n", r)
|
||||
}
|
||||
|
||||
txt := r.Extra[0].(*TXT).Txt[0]
|
||||
|
@ -333,41 +273,11 @@ func TestClientEDNS0Local(t *testing.T) {
|
|||
got := r.Extra[1].(*OPT).Option[0].(*EDNS0_LOCAL).String()
|
||||
if got != optStr1 {
|
||||
t.Errorf("failed to get local edns0 answer; got %s, expected %s", got, optStr1)
|
||||
t.Logf("%v\n", r)
|
||||
}
|
||||
|
||||
got = r.Extra[1].(*OPT).Option[1].(*EDNS0_LOCAL).String()
|
||||
if got != optStr2 {
|
||||
t.Errorf("failed to get local edns0 answer; got %s, expected %s", got, optStr2)
|
||||
t.Logf("%v\n", r)
|
||||
}
|
||||
}
|
||||
|
||||
// ExampleTsigSecret_updateLeaseTSIG shows how to update a lease signed with TSIG
|
||||
func ExampleTsigSecret_updateLeaseTSIG() {
|
||||
m := new(Msg)
|
||||
m.SetUpdate("t.local.ip6.io.")
|
||||
rr, _ := NewRR("t.local.ip6.io. 30 A 127.0.0.1")
|
||||
rrs := make([]RR, 1)
|
||||
rrs[0] = rr
|
||||
m.Insert(rrs)
|
||||
|
||||
leaseRr := new(OPT)
|
||||
leaseRr.Hdr.Name = "."
|
||||
leaseRr.Hdr.Rrtype = TypeOPT
|
||||
e := new(EDNS0_UL)
|
||||
e.Code = EDNS0UL
|
||||
e.Lease = 120
|
||||
leaseRr.Option = append(leaseRr.Option, e)
|
||||
m.Extra = append(m.Extra, leaseRr)
|
||||
|
||||
c := new(Client)
|
||||
m.SetTsig("polvi.", HmacMD5, 300, time.Now().Unix())
|
||||
c.TsigSecret = map[string]string{"polvi.": "pRZgBrBvI4NAHZYhxmhs/Q=="}
|
||||
|
||||
_, _, err := c.Exchange(m, "127.0.0.1:53")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -673,8 +583,7 @@ func TestConcurrentExchanges(t *testing.T) {
|
|||
wg.Wait()
|
||||
|
||||
if r[0] == r[1] {
|
||||
t.Log("Got same response object, expected non-shared responses")
|
||||
t.Fail()
|
||||
t.Errorf("Got same response object, expected non-shared responses")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,8 +178,6 @@ func TestPackNAPTR(t *testing.T) {
|
|||
if off, err := PackRR(rr, msg, 0, nil, false); err != nil {
|
||||
t.Errorf("packing failed: %v", err)
|
||||
t.Errorf("length %d, need more than %d", rr.len(), off)
|
||||
} else {
|
||||
t.Logf("buf size needed: %d", off)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -372,11 +370,9 @@ func TestNoRdataUnpack(t *testing.T) {
|
|||
t.Errorf("failed to pack RR: %v", err)
|
||||
continue
|
||||
}
|
||||
rr, _, err := UnpackRR(data[:off], 0)
|
||||
if err != nil {
|
||||
if _, _, err := UnpackRR(data[:off], 0); err != nil {
|
||||
t.Errorf("failed to unpack RR with zero rdata: %s: %v", TypeToString[typ], err)
|
||||
}
|
||||
t.Log(rr)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -448,6 +444,5 @@ func TestMsgPackBuffer(t *testing.T) {
|
|||
t.Errorf("packet %d failed to unpack", i)
|
||||
continue
|
||||
}
|
||||
t.Logf("packet %d %s", i, m.String())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,57 +35,6 @@ func getSoa() *SOA {
|
|||
return soa
|
||||
}
|
||||
|
||||
func TestGenerateEC(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test in short mode.")
|
||||
}
|
||||
key := new(DNSKEY)
|
||||
key.Hdr.Rrtype = TypeDNSKEY
|
||||
key.Hdr.Name = "miek.nl."
|
||||
key.Hdr.Class = ClassINET
|
||||
key.Hdr.Ttl = 14400
|
||||
key.Flags = 256
|
||||
key.Protocol = 3
|
||||
key.Algorithm = ECDSAP256SHA256
|
||||
privkey, _ := key.Generate(256)
|
||||
t.Log(key.String())
|
||||
t.Log(key.PrivateKeyString(privkey))
|
||||
}
|
||||
|
||||
func TestGenerateDSA(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test in short mode.")
|
||||
}
|
||||
key := new(DNSKEY)
|
||||
key.Hdr.Rrtype = TypeDNSKEY
|
||||
key.Hdr.Name = "miek.nl."
|
||||
key.Hdr.Class = ClassINET
|
||||
key.Hdr.Ttl = 14400
|
||||
key.Flags = 256
|
||||
key.Protocol = 3
|
||||
key.Algorithm = DSA
|
||||
privkey, _ := key.Generate(1024)
|
||||
t.Log(key.String())
|
||||
t.Log(key.PrivateKeyString(privkey))
|
||||
}
|
||||
|
||||
func TestGenerateRSA(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test in short mode.")
|
||||
}
|
||||
key := new(DNSKEY)
|
||||
key.Hdr.Rrtype = TypeDNSKEY
|
||||
key.Hdr.Name = "miek.nl."
|
||||
key.Hdr.Class = ClassINET
|
||||
key.Hdr.Ttl = 14400
|
||||
key.Flags = 256
|
||||
key.Protocol = 3
|
||||
key.Algorithm = RSASHA256
|
||||
privkey, _ := key.Generate(1024)
|
||||
t.Log(key.String())
|
||||
t.Log(key.PrivateKeyString(privkey))
|
||||
}
|
||||
|
||||
func TestSecure(t *testing.T) {
|
||||
soa := getSoa()
|
||||
|
||||
|
@ -211,10 +160,9 @@ func TestSignVerify(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
if err := sig.Verify(key, []RR{r}); err != nil {
|
||||
t.Error("failure to validate")
|
||||
t.Errorf("failure to validate: %s", r.Header().Name)
|
||||
continue
|
||||
}
|
||||
t.Logf("validated: %s", r.Header().Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,9 +196,7 @@ func Test65534(t *testing.T) {
|
|||
}
|
||||
if err := sig.Verify(key, []RR{t6}); err != nil {
|
||||
t.Error(err)
|
||||
t.Error("failure to validate")
|
||||
} else {
|
||||
t.Logf("validated: %s", t6.Header().Name)
|
||||
t.Errorf("failure to validate %s", t6.Header().Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,7 +457,7 @@ func TestSignVerifyECDSA2(t *testing.T) {
|
|||
|
||||
err = sig.Verify(key, []RR{srv})
|
||||
if err != nil {
|
||||
t.Logf("failure to validate:\n%s\n%s\n%s\n\n%s\n\n%v",
|
||||
t.Errorf("failure to validate:\n%s\n%s\n%s\n\n%s\n\n%v",
|
||||
key.String(),
|
||||
srv.String(),
|
||||
sig.String(),
|
||||
|
|
|
@ -54,8 +54,6 @@ func TestSplit(t *testing.T) {
|
|||
for s, i := range splitter {
|
||||
if x := len(Split(s)); x != i {
|
||||
t.Errorf("labels should be %d, got %d: %s %v", i, x, s, Split(s))
|
||||
} else {
|
||||
t.Logf("%s %v", s, Split(s))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
"testing/quick"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDotInName(t *testing.T) {
|
||||
|
@ -53,14 +52,10 @@ func TestTooLongDomainName(t *testing.T) {
|
|||
_, err := NewRR(dom + " IN A 127.0.0.1")
|
||||
if err == nil {
|
||||
t.Error("should be too long")
|
||||
} else {
|
||||
t.Logf("error is %v", err)
|
||||
}
|
||||
_, err = NewRR("..com. IN A 127.0.0.1")
|
||||
if err == nil {
|
||||
t.Error("should fail")
|
||||
} else {
|
||||
t.Logf("error is %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,8 +344,6 @@ func TestParseDirectiveMisc(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -372,8 +365,6 @@ func TestNSEC(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,8 +382,6 @@ func TestParseLOC(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -409,8 +398,6 @@ func TestParseDS(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -443,8 +430,6 @@ func TestQuotes(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is\n`%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -466,8 +451,6 @@ func TestParseClass(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is\n`%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,8 +500,6 @@ func TestBrace(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -544,34 +525,6 @@ func TestParseFailure(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestZoneParsing(t *testing.T) {
|
||||
// parse_test.db
|
||||
db := `
|
||||
a.example.com. IN A 127.0.0.1
|
||||
8db7._openpgpkey.example.com. IN OPENPGPKEY mQCNAzIG
|
||||
$ORIGIN a.example.com.
|
||||
test IN A 127.0.0.1
|
||||
IN SSHFP 1 2 (
|
||||
BC6533CDC95A79078A39A56EA7635984ED655318ADA9
|
||||
B6159E30723665DA95BB )
|
||||
$ORIGIN b.example.com.
|
||||
test IN CNAME test.a.example.com.
|
||||
`
|
||||
start := time.Now().UnixNano()
|
||||
to := ParseZone(strings.NewReader(db), "", "parse_test.db")
|
||||
var i int
|
||||
for x := range to {
|
||||
i++
|
||||
if x.Error != nil {
|
||||
t.Error(x.Error)
|
||||
continue
|
||||
}
|
||||
t.Log(x.RR)
|
||||
}
|
||||
delta := time.Now().UnixNano() - start
|
||||
t.Logf("%d RRs parsed in %.2f s (%.2f RR/s)", i, float32(delta)/1e9, float32(i)/(float32(delta)/1e9))
|
||||
}
|
||||
|
||||
func TestOmittedTTL(t *testing.T) {
|
||||
zone := `
|
||||
$ORIGIN example.com.
|
||||
|
@ -667,7 +620,6 @@ b1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D
|
|||
if err != nil {
|
||||
t.Fatalf("failed to parse RR: %v", err)
|
||||
}
|
||||
t.Logf("RR: %s", rr)
|
||||
msg := new(Msg)
|
||||
msg.Answer = []RR{rr, rr}
|
||||
bytes, err := msg.Pack()
|
||||
|
@ -682,7 +634,6 @@ b1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D
|
|||
}
|
||||
for i, rr := range msg.Answer {
|
||||
rr := rr.(*HIP)
|
||||
t.Logf("RR: %s", rr)
|
||||
if l := len(rr.RendezvousServers); l != 2 {
|
||||
t.Fatalf("2 servers expected, only %d in record %d:\n%v", l, i, msg)
|
||||
}
|
||||
|
@ -827,20 +778,14 @@ func TestSRVPacking(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestParseBackslash(t *testing.T) {
|
||||
if r, err := NewRR("nul\\000gap.test.globnix.net. 600 IN A 192.0.2.10"); err != nil {
|
||||
if _, err := NewRR("nul\\000gap.test.globnix.net. 600 IN A 192.0.2.10"); err != nil {
|
||||
t.Errorf("could not create RR with \\000 in it")
|
||||
} else {
|
||||
t.Logf("parsed %s", r.String())
|
||||
}
|
||||
if r, err := NewRR(`nul\000gap.test.globnix.net. 600 IN TXT "Hello\123"`); err != nil {
|
||||
if _, err := NewRR(`nul\000gap.test.globnix.net. 600 IN TXT "Hello\123"`); err != nil {
|
||||
t.Errorf("could not create RR with \\000 in it")
|
||||
} else {
|
||||
t.Logf("parsed %s", r.String())
|
||||
}
|
||||
if r, err := NewRR(`m\ @\ iek.nl. IN 3600 A 127.0.0.1`); err != nil {
|
||||
if _, err := NewRR(`m\ @\ iek.nl. IN 3600 A 127.0.0.1`); err != nil {
|
||||
t.Errorf("could not create RR with \\ and \\@ in it")
|
||||
} else {
|
||||
t.Logf("parsed %s", r.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -887,8 +832,6 @@ func TestGposEidNimloc(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -906,8 +849,6 @@ func TestPX(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1053,7 +994,6 @@ func TestTXT(t *testing.T) {
|
|||
if rr.(*TXT).Txt[1] != "b" {
|
||||
t.Errorf("Txt should have two chunk, last one my be 'b', but is %s", rr.(*TXT).Txt[1])
|
||||
}
|
||||
t.Log(rr.String())
|
||||
}
|
||||
|
||||
func TestTypeXXXX(t *testing.T) {
|
||||
|
@ -1095,7 +1035,6 @@ func TestDigit(t *testing.T) {
|
|||
t.Fatalf("failed to parse %v", err)
|
||||
}
|
||||
PackRR(r, buf, 0, nil, false)
|
||||
t.Log(buf)
|
||||
if buf[5] != i {
|
||||
t.Fatalf("5 pos must be %d, is %d", i, buf[5])
|
||||
}
|
||||
|
@ -1128,7 +1067,6 @@ func TestTxtEqual(t *testing.T) {
|
|||
// This is not an error, but keep this test.
|
||||
t.Errorf("these two TXT records should match:\n%s\n%s", rr1.String(), rr2.String())
|
||||
}
|
||||
t.Logf("%s\n%s", rr1.String(), rr2.String())
|
||||
}
|
||||
|
||||
func TestTxtLong(t *testing.T) {
|
||||
|
@ -1155,12 +1093,8 @@ func TestMalformedPackets(t *testing.T) {
|
|||
// com = 63 6f 6d
|
||||
for _, packet := range packets {
|
||||
data, _ := hex.DecodeString(packet)
|
||||
// for _, v := range data {
|
||||
// t.Log(v)
|
||||
// }
|
||||
var msg Msg
|
||||
msg.Unpack(data)
|
||||
// println(msg.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1317,7 +1251,6 @@ func TestParseTokenOverflow(t *testing.T) {
|
|||
if err == nil {
|
||||
t.Fatalf("token overflow should return an error")
|
||||
}
|
||||
t.Logf("err: %s\n", err)
|
||||
}
|
||||
|
||||
func TestParseTLSA(t *testing.T) {
|
||||
|
@ -1334,8 +1267,6 @@ func TestParseTLSA(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", o, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1355,8 +1286,6 @@ func TestParseSMIMEA(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", o, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1377,8 +1306,6 @@ func TestParseSSHFP(t *testing.T) {
|
|||
}
|
||||
if rr.String() != result {
|
||||
t.Errorf("`%s' should be equal to\n\n`%s', but is \n`%s'", o, result, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1402,8 +1329,6 @@ func TestParseHINFO(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1424,8 +1349,6 @@ func TestParseCAA(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1472,8 +1395,6 @@ func TestParseURI(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1490,8 +1411,6 @@ func TestParseAVC(t *testing.T) {
|
|||
}
|
||||
if rr.String() != o {
|
||||
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", avc, o, rr.String())
|
||||
} else {
|
||||
t.Logf("RR is OK: `%s'", rr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,6 @@ func TestPrivateText(t *testing.T) {
|
|||
}
|
||||
if rr.String() != testrecord {
|
||||
t.Errorf("record string representation did not match original %#v != %#v", rr.String(), testrecord)
|
||||
} else {
|
||||
t.Log(rr.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,8 +94,6 @@ func TestPrivateByteSlice(t *testing.T) {
|
|||
|
||||
if rr1.String() != testrecord {
|
||||
t.Errorf("record string representation did not match original %#v != %#v", rr1.String(), testrecord)
|
||||
} else {
|
||||
t.Log(rr1.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,6 +162,5 @@ func TestPrivateZoneParser(t *testing.T) {
|
|||
if err := x.Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(x.RR)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ func TestNormalizedString(t *testing.T) {
|
|||
func newRR(t *testing.T, s string) RR {
|
||||
r, err := NewRR(s)
|
||||
if err != nil {
|
||||
t.Logf("newRR: %v", err)
|
||||
t.Errorf("newRR: %v", err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
|
|
@ -553,7 +553,7 @@ func TestHandlerCloseTCP(t *testing.T) {
|
|||
exchange:
|
||||
_, _, err := c.Exchange(m, addr)
|
||||
if err != nil && err != io.EOF {
|
||||
t.Logf("exchange failed: %s\n", err)
|
||||
t.Errorf("exchange failed: %s\n", err)
|
||||
if tries == 3 {
|
||||
return
|
||||
}
|
||||
|
@ -687,43 +687,3 @@ zDCJkckCgYEAndqM5KXGk5xYo+MAA1paZcbTUXwaWwjLU+XSRSSoyBEi5xMtfvUb
|
|||
kFsxKCqxAnBVGEWAvVZAiiTOxleQFjz5RnL0BQp9Lg2cQe+dvuUmIAA=
|
||||
-----END RSA PRIVATE KEY-----`)
|
||||
)
|
||||
|
||||
func testShutdownBindPort(t *testing.T, protocol string, port string) {
|
||||
handler := NewServeMux()
|
||||
handler.HandleFunc(".", func(w ResponseWriter, r *Msg) {})
|
||||
startedCh := make(chan struct{})
|
||||
s := &Server{
|
||||
Addr: net.JoinHostPort("127.0.0.1", port),
|
||||
Net: protocol,
|
||||
Handler: handler,
|
||||
NotifyStartedFunc: func() {
|
||||
startedCh <- struct{}{}
|
||||
},
|
||||
}
|
||||
go func() {
|
||||
if err := s.ListenAndServe(); err != nil {
|
||||
t.Log(err)
|
||||
}
|
||||
}()
|
||||
<-startedCh
|
||||
t.Logf("DNS server is started on: %s", s.Addr)
|
||||
if err := s.Shutdown(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
go func() {
|
||||
if err := s.ListenAndServe(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
<-startedCh
|
||||
t.Logf("DNS server is started on: %s", s.Addr)
|
||||
}
|
||||
|
||||
func TestShutdownBindPortUDP(t *testing.T) {
|
||||
testShutdownBindPort(t, "udp", "1153")
|
||||
}
|
||||
|
||||
func TestShutdownBindPortTCP(t *testing.T) {
|
||||
testShutdownBindPort(t, "tcp", "1154")
|
||||
}
|
||||
|
|
|
@ -13,11 +13,8 @@ func TestDynamicUpdateParsing(t *testing.T) {
|
|||
typ == "Reserved" || typ == "None" || typ == "NXT" || typ == "MAILB" || typ == "MAILA" {
|
||||
continue
|
||||
}
|
||||
r, err := NewRR(prefix + typ)
|
||||
if err != nil {
|
||||
if _, err := NewRR(prefix + typ); err != nil {
|
||||
t.Errorf("failure to parse: %s %s: %v", prefix, typ, err)
|
||||
} else {
|
||||
t.Logf("parsed: %s", r.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestAXFR_Miek(t *testing.T) {
|
|||
break
|
||||
}
|
||||
for _, rr := range ex.RR {
|
||||
t.Log(rr.String())
|
||||
// Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func TestAXFR_Miek_Tsig(t *testing.T) {
|
|||
break
|
||||
}
|
||||
for _, rr := range ex.RR {
|
||||
t.Log(rr.String())
|
||||
// Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue