aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-05-10 12:48:10 +0200
committerDmitry Vyukov <dvyukov@google.com>2021-05-10 13:20:57 +0200
commite1e5c79fdc5d97de74f449dfb42a8a8ddfb2e728 (patch)
treed114e6ef87191f4d970b076b7805f264e139fee6 /prog
parentbc5434be1a615eca6d901c20b026712bd9697fd4 (diff)
prog: extend TestEnabledCalls test
Enable random set of syscalls to test more combinations.
Diffstat (limited to 'prog')
-rw-r--r--prog/rand_test.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/prog/rand_test.go b/prog/rand_test.go
index 60cf28a1c..629dffaf5 100644
--- a/prog/rand_test.go
+++ b/prog/rand_test.go
@@ -80,11 +80,18 @@ func generateProg(t *testing.T, target *Target, rs rand.Source, ct *ChoiceTable,
// Checks that a generated program contains only enabled syscalls.
func TestEnabledCalls(t *testing.T) {
target, rs, iters := initTest(t)
- enabledCalls := map[string]bool{"open": true, "read": true, "dup3": true, "write": true, "close": true}
+ enabledCalls := make(map[string]bool)
enabled := make(map[*Syscall]bool)
- for c := range enabledCalls {
- enabled[target.SyscallMap[c]] = true
+ rnd := rand.New(rs)
+ for i := 0; i < len(target.Syscalls)/10; i++ {
+ c := target.Syscalls[rnd.Intn(len(target.Syscalls))]
+ enabled[c] = true
+ enabledCalls[c.Name] = true
}
+ c := target.SyscallMap["clock_gettime"]
+ enabled[c] = true
+ enabledCalls[c.Name] = true
+
ct := target.BuildChoiceTable(nil, enabled)
const tries = 10
for i := 0; i < tries; i++ {