update_makefiles.py removes stale auto-gened files.
Test: manual
Change-Id: Id4a8e67e0f492bc78e77b3be5c6d796f7c0272d1
diff --git a/func_fuzzer/utils/Android.bp b/func_fuzzer/utils/Android.bp
index bbc9b5a..f96e6ac 100644
--- a/func_fuzzer/utils/Android.bp
+++ b/func_fuzzer/utils/Android.bp
@@ -1,3 +1,19 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
cc_library_shared {
name: "libvts_func_fuzzer_utils",
srcs: ["FuncFuzzerUtils.cpp"],
diff --git a/script/build/func_fuzzer_build_rule_gen.py b/script/build/func_fuzzer_build_rule_gen.py
index 50ebc56..eea5e12 100644
--- a/script/build/func_fuzzer_build_rule_gen.py
+++ b/script/build/func_fuzzer_build_rule_gen.py
@@ -21,7 +21,7 @@
class FuncFuzzerBuildRuleGen(object):
- """Build rule generator for test/vts-testcase/fuzz.
+ """Build rule generator for test/vts-testcase/fuzz/func_fuzzer.
Attributes:
_android_build_top: string, equal to environment variable ANDROID_BUILD_TOP.
@@ -32,6 +32,7 @@
_vts_spec_parser: tools that generates and parses vts spec with hidl-gen.
_warning_header: string, warning header for every generated file.
"""
+
def __init__(self, warning_header):
"""BuildRuleGen constructor.
@@ -58,20 +59,23 @@
self._warning_header = warning_header
def UpdateBuildRule(self):
- """Updates build rules under test/vts-testcase/fuzz."""
+ """Updates build rules under test/vts-testcase/fuzz/func_fuzzer."""
+ self._utils.RemoveFilesInDirIf(
+ self._func_fuzzer_dir,
+ lambda x: self._IsAutoGenerated(x))
hal_list = self._vts_spec_parser.HalNamesAndVersions()
self.UpdateTopLevelBuildRule()
self.UpdateSecondLevelBuildRule(hal_list)
self.UpdateHalDirBuildRule(hal_list)
def UpdateTopLevelBuildRule(self):
- """Updates test/vts-testcase/fuzz/Android.bp"""
+ """Updates test/vts-testcase/fuzz/func_fuzzer/Android.bp"""
self._utils.WriteBuildRule(
os.path.join(self._func_fuzzer_dir, 'Android.bp'),
self._utils.OnlySubdirsBpRule(self._warning_header, ['*']))
def UpdateSecondLevelBuildRule(self, hal_list):
- """Updates test/vts-testcase/fuzz/<hal_name>/Android.bp"""
+ """Updates test/vts-testcase/fuzz/func_fuzzer/<hal_name>/Android.bp"""
top_level_dirs = dict()
for target in hal_list:
hal_dir = os.path.join(
@@ -160,7 +164,21 @@
build_rule = build_rule.replace('{HAL_IFACE_NAME}', hal_iface_name)
return build_rule
- def _IsFuzzable(self, component_name):
+ def _IsAutoGenerated(self, abs_file_path):
+ """Checks if file was auto-generated.
+
+ Args:
+ abs_file_path: string, absolute file path.
+
+ Returns:
+ True iff file was auto-generated by FuncFuzzerBuildRuleGen.
+ """
+ with open(abs_file_path) as myfile:
+ header = ''.join([next(myfile) for x in xrange(2)])
+ return header == self._warning_header
+
+ @staticmethod
+ def _IsFuzzable(component_name):
"""Checks if component is fuzzable.
Args:
diff --git a/script/config/config_gen.py b/script/config/config_gen.py
index 7879cb7..81e4242 100644
--- a/script/config/config_gen.py
+++ b/script/config/config_gen.py
@@ -32,7 +32,7 @@
"""
def __init__(self):
- """BuildRuleGen constructor. """
+ """ConfigGen constructor. """
self._android_build_top = os.environ.get('ANDROID_BUILD_TOP')
if not self._android_build_top:
print 'Run "lunch" command first.'
@@ -58,8 +58,11 @@
hal_list: list of tuple of strings. For example,
[('vibrator', '1.3'), ('sensors', '1.7')]
"""
- hal_list = self._vts_spec_parser.HalNamesAndVersions()
config_dir = os.path.join(self._project_path, 'config')
+ self._utils.RemoveFilesInDirIf(
+ config_dir,
+ lambda x: x == 'AndroidTest.xml' or 'Android.mk')
+
mk_template_path = os.path.join(self._template_dir, 'template.mk')
xml_template_path = os.path.join(self._template_dir, 'template.xml')
with open(mk_template_path) as template_file:
@@ -67,6 +70,7 @@
with open(xml_template_path) as template_file:
xml_template = str(template_file.read())
+ hal_list = self._vts_spec_parser.HalNamesAndVersions()
for hal_name, hal_version in hal_list:
if not self._IsTestable(hal_name, hal_version):
continue
diff --git a/script/update_makefiles.py b/script/update_makefiles.py
index e5ec60d..97ffeb5 100644
--- a/script/update_makefiles.py
+++ b/script/update_makefiles.py
@@ -26,7 +26,7 @@
2. files matching: test/vts-testcase/fuzz/<hal_name>/<hal_version>/func_fuzzer/AndroidTest.xml
Usage:
- python test/vts-testcase/fuzz/update_makefiles.py --build --config
+ python test/vts-testcase/fuzz/update_makefiles.py
"""
import argparse
@@ -53,6 +53,11 @@
help='Whether to create update config files.')
args = parser.parse_args()
+ if not args.build and not args.config:
+ print 'Updating build rules and config files.'
+ args.build = True
+ args.config = True
+
if args.build:
print 'Updating build rules.'
warning_header = (