Re-plumb fuzz corpora.
Re-plumb the fuzz corpora through an intermediates directory. Previously, due to the way that LOCAL_TEST_DATA is implemented, we would break when corpora were included: a) outside of a corpus/ directory, or b) not directly under the module directory (i.e. my_module/subdir/corpus) Corpora are now written into an intermediates directory so that they play nice with LOCAL_TEST_DATA, because unfortunately the key-value pair required there is not as simple as source:destination. Test: m example_fuzzer && ls \ $ANDROID_PRODUCT_OUT/data/fuzz/arm64/example_fuzzer/corpus Bug: N/A Change-Id: I5888b06ed349781c6712f1ae77cc3582283a9552
This commit is contained in:
@@ -308,15 +308,13 @@ func (fuzz *fuzzBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa
|
|||||||
|
|
||||||
var fuzzFiles []string
|
var fuzzFiles []string
|
||||||
for _, d := range fuzz.corpus {
|
for _, d := range fuzz.corpus {
|
||||||
rel := d.Rel()
|
fuzzFiles = append(fuzzFiles,
|
||||||
path := d.String()
|
filepath.Dir(fuzz.corpusIntermediateDir.String())+":corpus/"+d.Base())
|
||||||
path = strings.TrimSuffix(path, rel)
|
|
||||||
fuzzFiles = append(fuzzFiles, path+":corpus/"+d.Base())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if fuzz.dictionary != nil {
|
if fuzz.dictionary != nil {
|
||||||
path := strings.TrimSuffix(fuzz.dictionary.String(), fuzz.dictionary.Rel())
|
fuzzFiles = append(fuzzFiles,
|
||||||
fuzzFiles = append(fuzzFiles, path+":"+fuzz.dictionary.Base())
|
filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(fuzzFiles) > 0 {
|
if len(fuzzFiles) > 0 {
|
||||||
|
13
cc/fuzz.go
13
cc/fuzz.go
@@ -54,8 +54,9 @@ type fuzzBinary struct {
|
|||||||
*baseCompiler
|
*baseCompiler
|
||||||
|
|
||||||
Properties FuzzProperties
|
Properties FuzzProperties
|
||||||
corpus android.Paths
|
|
||||||
dictionary android.Path
|
dictionary android.Path
|
||||||
|
corpus android.Paths
|
||||||
|
corpusIntermediateDir android.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fuzz *fuzzBinary) linkerProps() []interface{} {
|
func (fuzz *fuzzBinary) linkerProps() []interface{} {
|
||||||
@@ -103,6 +104,16 @@ func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) {
|
|||||||
fuzz.binaryDecorator.baseInstaller.install(ctx, file)
|
fuzz.binaryDecorator.baseInstaller.install(ctx, file)
|
||||||
|
|
||||||
fuzz.corpus = android.PathsForModuleSrc(ctx, fuzz.Properties.Corpus)
|
fuzz.corpus = android.PathsForModuleSrc(ctx, fuzz.Properties.Corpus)
|
||||||
|
builder := android.NewRuleBuilder()
|
||||||
|
intermediateDir := android.PathForModuleOut(ctx, "corpus")
|
||||||
|
for _, entry := range fuzz.corpus {
|
||||||
|
builder.Command().Text("cp").
|
||||||
|
Input(entry).
|
||||||
|
Output(intermediateDir.Join(ctx, entry.Base()))
|
||||||
|
}
|
||||||
|
builder.Build(pctx, ctx, "copy_corpus", "copy corpus")
|
||||||
|
fuzz.corpusIntermediateDir = intermediateDir
|
||||||
|
|
||||||
if fuzz.Properties.Dictionary != nil {
|
if fuzz.Properties.Dictionary != nil {
|
||||||
fuzz.dictionary = android.PathForModuleSrc(ctx, *fuzz.Properties.Dictionary)
|
fuzz.dictionary = android.PathForModuleSrc(ctx, *fuzz.Properties.Dictionary)
|
||||||
if fuzz.dictionary.Ext() != ".dict" {
|
if fuzz.dictionary.Ext() != ".dict" {
|
||||||
|
Reference in New Issue
Block a user