prog: reduce size of -short tests

Reduce size of tests that run for more than 1s in short mode.
This commit is contained in:
Dmitry Vyukov 2020-05-17 10:24:13 +02:00
parent b6fa239fd5
commit 9d7b583eae
5 changed files with 18 additions and 20 deletions

View File

@ -18,11 +18,9 @@ func TestChecksumCalcRandom(t *testing.T) {
for _, call := range p.Calls {
CalcChecksumsCall(call)
}
for try := 0; try <= 10; try++ {
p.Mutate(rs, 10, ct, nil)
for _, call := range p.Calls {
CalcChecksumsCall(call)
}
p.Mutate(rs, 10, ct, nil)
for _, call := range p.Calls {
CalcChecksumsCall(call)
}
}
}

View File

@ -155,9 +155,9 @@ func TestSizeMutateArg(t *testing.T) {
target, rs, iters := initRandomTargetTest(t, "test", "64")
r := newRand(target, rs)
ct := target.DefaultChoiceTable()
for i := 0; i < 100; i++ {
for i := 0; i < iters; i++ {
p := target.Generate(rs, 10, ct)
for it := 0; it < iters; it++ {
for it := 0; it < 10; it++ {
p1 := p.Clone()
ctx := &mutator{
p: p1,
@ -441,9 +441,9 @@ func runMutationTests(t *testing.T, tests [][2]string, valid bool) {
t.Fatalf("failed to deserialize the program: %v", err)
}
want := goal.Serialize()
iters := int(1e6)
if !valid {
iters /= 10
iters := iterCount()
if valid {
iters = 1e6 // it will stop after reaching the goal
}
for i := 0; i < iters; i++ {
p1 := p.Clone()

View File

@ -30,12 +30,11 @@ func TestNormalizePrio(t *testing.T) {
// Test static priorities assigned based on argument direction.
func TestStaticPriorities(t *testing.T) {
target, rs, iters := initTest(t)
if iters < 100 {
// Both -short and -race reduce iters to 10 which is not enough
// for this probabilistic test.
iters = 100
}
target := initTargetTest(t, "linux", "amd64")
rs := rand.NewSource(0)
// The test is probabilistic and needs some sensible number of iterations to succeed.
// If it fails try to increase the number a bit.
const iters = 5e4
// The first call is the one that creates a resource and the rest are calls that can use that resource.
tests := [][]string{
{"open", "read", "write", "mmap"},
@ -49,7 +48,7 @@ func TestStaticPriorities(t *testing.T) {
referenceCall := syscalls[0]
for _, call := range syscalls {
count := 0
for it := 0; it < iters*10000; it++ {
for it := 0; it < iters; it++ {
chosenCall := target.Syscalls[ct.choose(r, target.SyscallMap[call].ID)].Name
if call == referenceCall {
counter[chosenCall]++

View File

@ -86,9 +86,10 @@ func TestEnabledCalls(t *testing.T) {
enabled[target.SyscallMap[c]] = true
}
ct := target.BuildChoiceTable(nil, enabled)
for i := 0; i < 100; i++ {
const tries = 10
for i := 0; i < tries; i++ {
p := target.Generate(rs, 50, ct)
for it := 0; it < iters/10; it++ {
for it := 0; it < iters/tries; it++ {
p.Mutate(rs, 50, ct, nil)
}
for _, c := range p.Calls {

View File

@ -50,7 +50,7 @@ func TestRotationCoverage(t *testing.T) {
counters[call.Name] = 0
}
rotator := MakeRotator(target, calls, rand.New(rs))
for iter := 0; iter < 5e3; iter++ {
for iter := 0; iter < 1e3; iter++ {
for call := range rotator.Select() {
counters[call.Name]++
}