rigurously fix all tests

This commit is contained in:
Patricio Whittingslow
2025-11-05 20:12:02 -03:00
parent f5157e7e4a
commit e3c6d68288
2 changed files with 16 additions and 2 deletions
+4 -1
View File
@@ -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
View File
@@ -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)
} }
} }
} }