aboutsummaryrefslogtreecommitdiffstats
path: root/prog/prog_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-19 19:35:04 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-19 21:48:20 +0100
commit75a7c5e2d1f09a4a58e7e1f1f4ef0b0f55a33413 (patch)
treed44c2457c44b53192005f0b89cd6633a2a2b0ff9 /prog/prog_test.go
parent90fd6503136121e9494761a460898e83bc0b6b3e (diff)
prog: rework address allocation
1. mmap all memory always, without explicit mmap calls in the program. This makes lots of things much easier and removes lots of code. Makes mmap not a special syscall and allows to fuzz without mmap enabled. 2. Change address assignment algorithm. Current algorithm allocates unmapped addresses too frequently and allows collisions between arguments of a single syscall. The new algorithm analyzes actual allocations in the program and places new arguments at unused locations.
Diffstat (limited to 'prog/prog_test.go')
-rw-r--r--prog/prog_test.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/prog/prog_test.go b/prog/prog_test.go
index 146694f45..1dc310456 100644
--- a/prog/prog_test.go
+++ b/prog/prog_test.go
@@ -25,7 +25,7 @@ func TestDefault(t *testing.T) {
target, _, _ := initTest(t)
for _, meta := range target.SyscallMap {
for _, t := range meta.Args {
- defaultArg(t)
+ target.defaultArg(t)
}
}
}
@@ -91,16 +91,18 @@ func TestVmaType(t *testing.T) {
if !ok {
t.Fatalf("len has bad type: %v", l)
}
- if va.PagesNum < min || va.PagesNum > max {
- t.Fatalf("vma has bad number of pages: %v, want [%v-%v]", va.PagesNum, min, max)
+ if va.VmaSize < min || va.VmaSize > max {
+ t.Fatalf("vma has bad size: %v, want [%v-%v]",
+ va.VmaSize, min, max)
}
- if la.Val/pageSize < min || la.Val/pageSize > max {
- t.Fatalf("len has bad number of pages: %v, want [%v-%v]", la.Val/pageSize, min, max)
+ if la.Val < min || la.Val > max {
+ t.Fatalf("len has bad value: %v, want [%v-%v]",
+ la.Val, min, max)
}
}
- check(c.Args[0], c.Args[1], 1, 1e5)
- check(c.Args[2], c.Args[3], 5, 5)
- check(c.Args[4], c.Args[5], 7, 9)
+ check(c.Args[0], c.Args[1], 1*pageSize, 1e5*pageSize)
+ check(c.Args[2], c.Args[3], 5*pageSize, 5*pageSize)
+ check(c.Args[4], c.Args[5], 7*pageSize, 9*pageSize)
}
}