diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-10-31 15:15:13 -0600 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2016-11-11 14:33:37 -0800 |
| commit | 588a542b2a23ba477031bf20b4c46b0f40a04b7d (patch) | |
| tree | 9e517866f45cdb903505e72c0fcbf821c0b00dcd /prog/mutation.go | |
| parent | 5ed6283b64f91c8aa036122b18974aabed4c5249 (diff) | |
sys: add string flags
Allow to define string flags in txt descriptions. E.g.:
filesystem = "ext2", "ext3", "ext4"
and then use it in string type:
ptr[in, string[filesystem]]
Diffstat (limited to 'prog/mutation.go')
| -rw-r--r-- | prog/mutation.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/prog/mutation.go b/prog/mutation.go index 72535f656..e861725c8 100644 --- a/prog/mutation.go +++ b/prog/mutation.go @@ -89,10 +89,8 @@ func (p *Prog) Mutate(rs rand.Source, ncalls int, ct *ChoiceTable) { if r.bin() { arg.Data = mutateData(r, append([]byte{}, arg.Data...), int(0), ^int(0)) } else { - arg.Data = r.randString(s) + arg.Data = r.randString(s, a.Values) } - case sys.BufferFilesystem: - arg.Data = r.filesystem(s) case sys.BufferFilename: arg.Data = []byte(r.filename(s)) case sys.BufferSockaddr: @@ -170,7 +168,7 @@ func (p *Prog) Mutate(rs rand.Source, ncalls int, ct *ChoiceTable) { p.replaceArg(c, arg, arg1, calls) case *sys.LenType: panic("bad arg returned by mutationArgs: LenType") - case *sys.ConstType, *sys.StrConstType: + case *sys.ConstType: panic("bad arg returned by mutationArgs: ConstType") default: panic(fmt.Sprintf("bad arg returned by mutationArgs: %#v, type=%#v", *arg, arg.Type)) @@ -322,9 +320,13 @@ func mutationArgs(c *Call) (args, bases []*Arg) { case *sys.LenType: // Size is updated when the size-of arg change. return - case *sys.ConstType, *sys.StrConstType: + case *sys.ConstType: // Well, this is const. return + case *sys.BufferType: + if typ.Kind == sys.BufferString && len(typ.Values) == 1 { + return // string const + } } if arg.Type.Dir() == sys.DirOut { return |
