Skip to content

Commit a955818

Browse files
author
dave.seddon
committed
TestLongRunningSkipSend
1 parent 33fc4f8 commit a955818

File tree

2 files changed

+92
-4
lines changed

2 files changed

+92
-4
lines changed

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ long:
1313
LONG=true go test -v -run TestLongRunningLoop
1414

1515
lw:
16-
LONG=true go test -v -run TestLongRunningWindow -test.timeout=30m
16+
LONG=true go test -v -run TestLongRunningWindow
17+
#-test.timeout=30m
1718

18-
j:
19-
LONG=true go test -v -run TestLongRunningJumps -test.timeout=30m
19+
db:
20+
LONG=true go test -v -run TestLongRunningBackwardDuplicates
21+
22+
ss:
23+
LONG=true go test -v -run TestLongRunningSkipSend
2024

2125
# math tests
2226
math: l d

trackRTP_test.go

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func TestLongRunningWindow(t *testing.T) {
273273
}
274274
}
275275

276-
func TestLongRunningJumps(t *testing.T) {
276+
func TestLongRunningBackwardDuplicates(t *testing.T) {
277277

278278
type test struct {
279279
aw uint16
@@ -382,6 +382,90 @@ func TestLongRunningJumps(t *testing.T) {
382382
}
383383
}
384384

385+
func TestLongRunningSkipSend(t *testing.T) {
386+
387+
type test struct {
388+
aw uint16
389+
bw uint16
390+
ab uint16
391+
bb uint16
392+
dl int
393+
start uint16
394+
err error
395+
loops int64
396+
SkipMod int
397+
MaxSkip int
398+
Len int
399+
}
400+
401+
debugL := 11
402+
403+
tests := []test{
404+
{10, 10, 10, 10, debugL, 0, nil, 10, 2, 3, 10},
405+
{10, 10, 10, 10, debugL, 0, nil, 10, 3, 3, 10},
406+
{10, 10, 10, 10, debugL, maxUint16 - 10, nil, 10, 5, 3, 10},
407+
{100, 100, 100, 100, debugL, 0, nil, 100, 2, 3, 100},
408+
{100, 100, 100, 100, debugL, 0, nil, 100, 3, 3, 100},
409+
{100, 100, 100, 100, debugL, maxUint16 - 100, nil, 100, 5, 3, 100},
410+
{1000, 1000, 1000, 1000, debugL, 0, nil, 1000, 10, 2, 1000},
411+
{1000, 1000, 1000, 1000, debugL, 0, nil, 1000, 20, 3, 1000},
412+
{1000, 1000, 1000, 1000, debugL, maxUint16 - 1000, nil, 1000, 50, 10, 1000},
413+
}
414+
415+
if os.Getenv("LONG") != "true" {
416+
t.Skip("Skipping long test. Set 'LONG=true' env var to run this")
417+
}
418+
419+
for i, tc := range tests {
420+
421+
t.Logf("%s i:%d, tc: %v\n", t.Name(), i, tc)
422+
423+
tr, err := New(tc.aw, tc.bw, tc.ab, tc.bb, tc.dl)
424+
if err != tc.err {
425+
t.Fatalf("%s, err:%v != tc.err:%v", t.Name(), err, tc.err)
426+
}
427+
428+
var tax *Taxonomy
429+
var e error
430+
var loops int64
431+
var j uint16 = tc.start
432+
var skip int
433+
for {
434+
if tc.dl > 10 {
435+
t.Logf("%s i:%d, tc: %v, j:%d, loops:%d", t.Name(), i, tc, j, loops)
436+
}
437+
if loops%int64(tc.SkipMod) == 0 && skip < tc.MaxSkip {
438+
t.Logf("%s i:%d, loops:%d, j:%d, skip:%d", t.Name(), i, loops, j, skip)
439+
skip++
440+
} else {
441+
tax, e = tr.PacketArrival(j)
442+
if e != nil {
443+
t.Fatalf("%s, e != nil:%v", t.Name(), e)
444+
}
445+
}
446+
447+
j++
448+
loops++
449+
if loops > tc.loops {
450+
t.Logf("loops:%d > tc.Loops:%d, tr.Max():%d, tax.Len:%d, tr.Min():%d", loops, tc.loops, tr.Max(), tax.Len, tr.Min())
451+
if tc.dl > 110 {
452+
t.Logf("items:%v", tr.itemsDescending())
453+
}
454+
break
455+
}
456+
457+
if tc.dl > 10 {
458+
if loops%int64(maxUint16) == 0 {
459+
t.Logf("loops:%d > tc.Loops:%d, tr.Max():%d, tax.Len:%d, tr.Min():%d", loops, tc.loops, tr.Max(), tax.Len, tr.Min())
460+
}
461+
}
462+
}
463+
if !reflect.DeepEqual(tax.Len-1, tc.Len-skip) {
464+
t.Fatalf("%s, test:%d !reflect.DeepEqual(tax.Len-1:%v, tc.Len:%v), skip:%d", t.Name(), i, tax.Len-1, tc.Len-skip, skip)
465+
}
466+
}
467+
}
468+
385469
//go:linkname FastRand runtime.fastrand
386470
func FastRand() uint32
387471

0 commit comments

Comments
 (0)