mirror of
https://github.com/soypat/lneto.git
synced 2026-09-10 00:29:34 +00:00
rigurously fix all tests
This commit is contained in:
+4
-1
@@ -179,11 +179,14 @@ func (rtx *ringTx) RecvACK(ack Value) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rtx *ringTx) sentAndUnsentBuffer() internal.Ring {
|
func (rtx *ringTx) sentAndUnsentBuffer() internal.Ring {
|
||||||
|
off := rtx.sentoff
|
||||||
end := rtx.unsentend
|
end := rtx.unsentend
|
||||||
if end == 0 {
|
if end == 0 {
|
||||||
end = rtx.sentend
|
end = rtx.sentend
|
||||||
|
} else if rtx.sentend == 0 {
|
||||||
|
off = rtx.unsentoff
|
||||||
}
|
}
|
||||||
return internal.Ring{Buf: rtx.rawbuf, Off: rtx.sentoff, End: end}
|
return internal.Ring{Buf: rtx.rawbuf, Off: off, End: end}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rtx *ringTx) unsentRing() (internal.Ring, int) {
|
func (rtx *ringTx) unsentRing() (internal.Ring, int) {
|
||||||
|
|||||||
+12
-1
@@ -13,7 +13,7 @@ import (
|
|||||||
func TestRingTx_op(t *testing.T) {
|
func TestRingTx_op(t *testing.T) {
|
||||||
const maxBuf = 32
|
const maxBuf = 32
|
||||||
const maxpkt = 3
|
const maxpkt = 3
|
||||||
const Nops = 33
|
const Nops = 6
|
||||||
const log = false
|
const log = false
|
||||||
type op uint8
|
type op uint8
|
||||||
const (
|
const (
|
||||||
@@ -116,6 +116,17 @@ func TestRingTx_op(t *testing.T) {
|
|||||||
default:
|
default:
|
||||||
panic("unknown op")
|
panic("unknown op")
|
||||||
}
|
}
|
||||||
|
wantFree := bufsize - nsent - nunsent
|
||||||
|
gotFree := rtx.Free()
|
||||||
|
if wantFree != gotFree {
|
||||||
|
t.Fatalf("free mismatch got=%d want=%d size=%d sent=%d nunsent=%d", gotFree, wantFree, bufsize, nsent, nunsent)
|
||||||
|
}
|
||||||
|
minlen := min(len(dataSent), len(dataWritten))
|
||||||
|
matched := bytes.Equal(dataSent[:minlen], dataWritten[:minlen])
|
||||||
|
if !matched {
|
||||||
|
t.Fatal("mismatched data written\n", dataSent, "\n", dataWritten)
|
||||||
|
}
|
||||||
|
testQueueSanity(t, &rtx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user