diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-11-22 11:42:10 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-11-24 13:56:20 +0100 |
| commit | ddf7b3e0655cf6dfeacfe509e477c1486d2cc7db (patch) | |
| tree | dd3ce89e4c92cdb4ddaaae566222ec8cbd177676 /prog | |
| parent | d19770f1b9c6f1cb953b4a6e767aa914009deb20 (diff) | |
sys/linux: improve AF_ALG alg name generation
There is effectively infinite number of possible crypto
algorithm names due to templates. Plus there is tricky
relation between algorithms and algorithm type names.
This change adds custom mutator for sockaddr_alg struct
to improve variance in generated algorithms.
Diffstat (limited to 'prog')
| -rw-r--r-- | prog/export_test.go | 18 | ||||
| -rw-r--r-- | prog/prog.go | 4 | ||||
| -rw-r--r-- | prog/target.go | 11 |
3 files changed, 15 insertions, 18 deletions
diff --git a/prog/export_test.go b/prog/export_test.go index e6c384c7a..f3fc16997 100644 --- a/prog/export_test.go +++ b/prog/export_test.go @@ -17,25 +17,9 @@ func init() { var ( CalcChecksumsCall = calcChecksumsCall - //AssignSizesCall = assignSizesCall - //DefaultArg = defaultArg - InitTest = initTest + InitTest = initTest ) -/* -func PtrSize() uint64 { - return ptrSize -} - -func DataOffset() uint64 { - return dataOffset -} - -func PageSize() uint64 { - return pageSize -} -*/ - func initTest(t *testing.T) (*Target, rand.Source, int) { t.Parallel() iters := 10000 diff --git a/prog/prog.go b/prog/prog.go index f8335b240..20711266c 100644 --- a/prog/prog.go +++ b/prog/prog.go @@ -343,8 +343,10 @@ func (p *Prog) replaceArg(c *Call, arg, arg1 Arg, calls []*Call) { *a = *arg1.(*PointerArg) case *UnionArg: *a = *arg1.(*UnionArg) + case *DataArg: + *a = *arg1.(*DataArg) default: - panic(fmt.Sprintf("replaceArg: bad arg kind %v", arg)) + panic(fmt.Sprintf("replaceArg: bad arg kind %#v", arg)) } p.Target.SanitizeCall(c) } diff --git a/prog/target.go b/prog/target.go index 45a3e9c3d..4563f107d 100644 --- a/prog/target.go +++ b/prog/target.go @@ -5,6 +5,7 @@ package prog import ( "fmt" + "math/rand" "sort" ) @@ -152,6 +153,10 @@ type Gen struct { s *state } +func (g *Gen) Rand() *rand.Rand { + return g.r.Rand +} + func (g *Gen) NOutOf(n, outOf int) bool { return g.r.nOutOf(n, outOf) } @@ -159,3 +164,9 @@ func (g *Gen) NOutOf(n, outOf int) bool { func (g *Gen) Alloc(ptrType Type, data Arg) (Arg, []*Call) { return g.r.addr(g.s, ptrType, data.Size(), data) } + +func (g *Gen) GenerateArg(typ Type, pcalls *[]*Call) Arg { + arg, calls := g.r.generateArg(g.s, typ) + *pcalls = append(*pcalls, calls...) + return arg +} |
