From 526709ff0442e985edd498e14c736de8302dc867 Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Tue, 3 Sep 2019 17:02:04 +0200 Subject: prog: move all flag mutation logic into flags() (#1362) This makes it a bit easier to understand. Also fix an issue with using flag value as bit number. --- prog/mutation.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'prog/mutation.go') diff --git a/prog/mutation.go b/prog/mutation.go index 8a33c3e2e..6c356c4b4 100644 --- a/prog/mutation.go +++ b/prog/mutation.go @@ -236,29 +236,9 @@ func (t *IntType) mutate(r *randGen, s *state, arg Arg, ctx ArgCtx) (calls []*Ca func (t *FlagsType) mutate(r *randGen, s *state, arg Arg, ctx ArgCtx) (calls []*Call, retry, preserve bool) { a := arg.(*ConstArg) - for oldVal := a.Val; oldVal == a.Val; { - // Generate a new value. - if r.nOutOf(1, 5) { - a.Val = r.flags(t.Vals, t.BitMask, 0) - continue - } - - if !t.BitMask || (t.BitMask && r.nOutOf(1, 4)) { - a.Val = r.flags(t.Vals, t.BitMask, a.Val) - continue - } - - for stop := false; !stop; stop = r.oneOf(3) { - idx := r.rand(len(t.Vals)) - if r.bin() { - a.Val |= 1 << t.Vals[idx] - } else { - a.Val &= ^(1 << t.Vals[idx]) - } - } + a.Val = r.flags(t.Vals, t.BitMask, a.Val) } - return } -- cgit mrf-deployment