diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/aapt2/SdkConstants.cpp | 2 | ||||
| -rw-r--r-- | tools/bit/adb.cpp | 4 | ||||
| -rw-r--r-- | tools/bit/main.cpp | 126 | ||||
| -rw-r--r-- | tools/localedata/OWNERS | 2 | ||||
| -rwxr-xr-x | tools/localedata/extract_icu_data.py | 68 | ||||
| -rw-r--r-- | tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java | 2 | ||||
| -rw-r--r-- | tools/processors/intdef_mappings/Android.bp | 22 | ||||
| -rw-r--r-- | tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt | 2 | ||||
| -rw-r--r-- | tools/processors/view_inspector/Android.bp | 18 | ||||
| -rw-r--r-- | tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt | 2 | ||||
| -rw-r--r-- | tools/validatekeymaps/Android.bp | 4 | ||||
| -rw-r--r-- | tools/validatekeymaps/Main.cpp | 5 | ||||
| -rw-r--r-- | tools/validatekeymaps/OWNERS | 3 |
13 files changed, 151 insertions, 109 deletions
diff --git a/tools/aapt2/SdkConstants.cpp b/tools/aapt2/SdkConstants.cpp index 8ea43abff895..34e8edb0a47f 100644 --- a/tools/aapt2/SdkConstants.cpp +++ b/tools/aapt2/SdkConstants.cpp @@ -27,7 +27,7 @@ namespace aapt { static ApiVersion sDevelopmentSdkLevel = 10000; static const auto sDevelopmentSdkCodeNames = - std::unordered_set<StringPiece>({"Q", "R", "S", "Sv2", "Tiramisu"}); + std::unordered_set<StringPiece>({"Q", "R", "S", "Sv2", "Tiramisu", "UpsideDownCake"}); static const std::vector<std::pair<uint16_t, ApiVersion>> sAttrIdMap = { {0x021c, 1}, diff --git a/tools/bit/adb.cpp b/tools/bit/adb.cpp index f521a63255e1..201028ba900a 100644 --- a/tools/bit/adb.cpp +++ b/tools/bit/adb.cpp @@ -73,7 +73,7 @@ string get_system_property(const string& name, int* err) { Command cmd("adb"); - cmd.AddArg("shell"); + cmd.AddArg("exec-out"); cmd.AddArg("getprop"); cmd.AddArg(name); @@ -278,7 +278,7 @@ run_instrumentation_test(const string& packageName, const string& runner, const InstrumentationCallbacks* callbacks) { Command cmd("adb"); - cmd.AddArg("shell"); + cmd.AddArg("exec-out"); cmd.AddArg("am"); cmd.AddArg("instrument"); cmd.AddArg("-w"); diff --git a/tools/bit/main.cpp b/tools/bit/main.cpp index fd184f50091a..0d48070fd0c6 100644 --- a/tools/bit/main.cpp +++ b/tools/bit/main.cpp @@ -52,24 +52,22 @@ struct Target { int testPassCount; int testFailCount; + int testIgnoreCount; int unknownFailureCount; // unknown failure == "Process crashed", etc. - bool actionsWithNoTests; Target(bool b, bool i, bool t, const string& p); }; Target::Target(bool b, bool i, bool t, const string& p) - :build(b), - install(i), - test(t), - pattern(p), - testActionCount(0), - testPassCount(0), - testFailCount(0), - unknownFailureCount(0), - actionsWithNoTests(false) -{ -} + : build(b), + install(i), + test(t), + pattern(p), + testActionCount(0), + testPassCount(0), + testFailCount(0), + testIgnoreCount(0), + unknownFailureCount(0) {} /** * Command line options. @@ -188,13 +186,12 @@ struct TestAction { // The number of tests that failed int failCount; + + // The number of tests that were ignored (because of @Ignore) + int ignoreCount; }; -TestAction::TestAction() - :passCount(0), - failCount(0) -{ -} +TestAction::TestAction() : passCount(0), failCount(0), ignoreCount(0) {} /** * Record for an activity that is going to be launched. @@ -278,7 +275,7 @@ TestResults::OnTestStatus(TestStatus& status) line << " of " << testCount; } } - line << ": " << m_currentAction->target->name << ':' << className << "\\#" << testName; + line << ": " << m_currentAction->target->name << ':' << className << "#" << testName; print_one_line("%s", line.str().c_str()); } else if ((resultCode == -1) || (resultCode == -2)) { // test failed @@ -286,9 +283,9 @@ TestResults::OnTestStatus(TestStatus& status) // all as "failures". m_currentAction->failCount++; m_currentAction->target->testFailCount++; - printf("%s\n%sFailed: %s:%s\\#%s%s\n", g_escapeClearLine, g_escapeRedBold, - m_currentAction->target->name.c_str(), className.c_str(), - testName.c_str(), g_escapeEndColor); + printf("%s\n%sFailed: %s:%s#%s%s\n", g_escapeClearLine, g_escapeRedBold, + m_currentAction->target->name.c_str(), className.c_str(), testName.c_str(), + g_escapeEndColor); bool stackFound; string stack = get_bundle_string(results, &stackFound, "stack", NULL); @@ -300,6 +297,13 @@ TestResults::OnTestStatus(TestStatus& status) } else if (stackFound) { printf("%s\n", stack.c_str()); } + } else if (resultCode == -3) { + // test ignored + m_currentAction->ignoreCount++; + m_currentAction->target->testIgnoreCount++; + printf("%s\n%sIgnored: %s:%s#%s%s\n", g_escapeClearLine, g_escapeYellowBold, + m_currentAction->target->name.c_str(), className.c_str(), testName.c_str(), + g_escapeEndColor); } } @@ -403,11 +407,14 @@ print_usage(FILE* out) { fprintf(out, " Builds and installs CtsProtoTestCases.apk, and runs all the\n"); fprintf(out, " tests in the ProtoOutputStreamBoolTest class.\n"); fprintf(out, "\n"); - fprintf(out, " bit CtsProtoTestCases:.ProtoOutputStreamBoolTest\\#testWrite\n"); + fprintf(out, " bit CtsProtoTestCases:.ProtoOutputStreamBoolTest#testWrite\n"); fprintf(out, " Builds and installs CtsProtoTestCases.apk, and runs the testWrite\n"); fprintf(out, " test method on that class.\n"); fprintf(out, "\n"); - fprintf(out, " bit CtsProtoTestCases:.ProtoOutputStreamBoolTest\\#testWrite,.ProtoOutputStreamBoolTest\\#testRepeated\n"); + fprintf(out, + " bit " + "CtsProtoTestCases:.ProtoOutputStreamBoolTest#testWrite,.ProtoOutputStreamBoolTest#" + "testRepeated\n"); fprintf(out, " Builds and installs CtsProtoTestCases.apk, and runs the testWrite\n"); fprintf(out, " and testRepeated test methods on that class.\n"); fprintf(out, "\n"); @@ -450,6 +457,35 @@ print_usage(FILE* out) { fprintf(out, "\n"); } +/** + * Prints a possibly color-coded summary of test results. Example output: + * + * "34 passed, 0 failed, 1 ignored\n" + */ +static void print_results(int passed, int failed, int ignored) { + char const* nothing = ""; + char const* cp = nothing; + char const* cf = nothing; + char const* ci = nothing; + + if (failed > 0) { + cf = g_escapeRedBold; + } else if (passed > 0 || ignored > 0) { + cp = passed > 0 ? g_escapeGreenBold : nothing; + ci = ignored > 0 ? g_escapeYellowBold : nothing; + } else { + cp = g_escapeYellowBold; + cf = g_escapeYellowBold; + } + + if (ignored > 0) { + printf("%s%d passed%s, %s%d failed%s, %s%d ignored%s\n", cp, passed, g_escapeEndColor, cf, + failed, g_escapeEndColor, ci, ignored, g_escapeEndColor); + } else { + printf("%s%d passed%s, %s%d failed%s\n", cp, passed, g_escapeEndColor, cf, failed, + g_escapeEndColor); + } +} /** * Sets the appropriate flag* variables. If there is a problem with the @@ -812,7 +848,7 @@ run_phases(vector<Target*> targets, const Options& options) // Stop & Sync if (!options.noRestart) { - err = run_adb("shell", "stop", NULL); + err = run_adb("exec-out", "stop", NULL); check_error(err); } err = run_adb("remount", NULL); @@ -831,9 +867,9 @@ run_phases(vector<Target*> targets, const Options& options) } else { print_status("Restarting the runtime"); - err = run_adb("shell", "setprop", "sys.boot_completed", "0", NULL); + err = run_adb("exec-out", "setprop", "sys.boot_completed", "0", NULL); check_error(err); - err = run_adb("shell", "start", NULL); + err = run_adb("exec-out", "start", NULL); check_error(err); } @@ -846,7 +882,7 @@ run_phases(vector<Target*> targets, const Options& options) sleep(2); } sleep(1); - err = run_adb("shell", "wm", "dismiss-keyguard", NULL); + err = run_adb("exec-out", "wm", "dismiss-keyguard", NULL); check_error(err); } } @@ -863,7 +899,7 @@ run_phases(vector<Target*> targets, const Options& options) continue; } // TODO: if (!apk.file.fileInfo.exists || apk.file.HasChanged()) - err = run_adb("shell", "mkdir", "-p", dir.c_str(), NULL); + err = run_adb("exec-out", "mkdir", "-p", dir.c_str(), NULL); check_error(err); err = run_adb("push", pushed.file.filename.c_str(), pushed.dest.c_str(), NULL); check_error(err); @@ -945,9 +981,9 @@ run_phases(vector<Target*> targets, const Options& options) } } if (runAll) { - err = run_adb("shell", installedPath.c_str(), NULL); + err = run_adb("exec-out", installedPath.c_str(), NULL); } else { - err = run_adb("shell", installedPath.c_str(), filterArg.c_str(), NULL); + err = run_adb("exec-out", installedPath.c_str(), filterArg.c_str(), NULL); } if (err == 0) { target->testPassCount++; @@ -1035,22 +1071,10 @@ run_phases(vector<Target*> targets, const Options& options) err = run_instrumentation_test(action.packageName, action.runner, action.className, &testResults); check_error(err); - if (action.passCount == 0 && action.failCount == 0) { - action.target->actionsWithNoTests = true; - } int total = action.passCount + action.failCount; printf("%sRan %d test%s for %s. ", g_escapeClearLine, total, total > 1 ? "s" : "", action.target->name.c_str()); - if (action.passCount == 0 && action.failCount == 0) { - printf("%s%d passed, %d failed%s\n", g_escapeYellowBold, action.passCount, - action.failCount, g_escapeEndColor); - } else if (action.failCount > 0) { - printf("%d passed, %s%d failed%s\n", action.passCount, g_escapeRedBold, - action.failCount, g_escapeEndColor); - } else { - printf("%s%d passed%s, %d failed\n", g_escapeGreenBold, action.passCount, - g_escapeEndColor, action.failCount); - } + print_results(action.passCount, action.failCount, action.ignoreCount); if (!testResults.IsSuccess()) { printf("\n%sTest didn't finish successfully: %s%s\n", g_escapeRedBold, testResults.GetErrorMessage().c_str(), g_escapeEndColor); @@ -1073,7 +1097,7 @@ run_phases(vector<Target*> targets, const Options& options) const ActivityAction& action = activityActions[0]; string componentName = action.packageName + "/" + action.className; - err = run_adb("shell", "am", "start", componentName.c_str(), NULL); + err = run_adb("exec-out", "am", "start", componentName.c_str(), NULL); check_error(err); } @@ -1147,17 +1171,11 @@ run_phases(vector<Target*> targets, const Options& options) printf(" %sUnknown failure, see above message.%s\n", g_escapeRedBold, g_escapeEndColor); hasErrors = true; - } else if (target->actionsWithNoTests) { - printf(" %s%d passed, %d failed%s\n", g_escapeYellowBold, - target->testPassCount, target->testFailCount, g_escapeEndColor); - hasErrors = true; - } else if (target->testFailCount > 0) { - printf(" %d passed, %s%d failed%s\n", target->testPassCount, - g_escapeRedBold, target->testFailCount, g_escapeEndColor); - hasErrors = true; } else { - printf(" %s%d passed%s, %d failed\n", g_escapeGreenBold, - target->testPassCount, g_escapeEndColor, target->testFailCount); + printf(" %s%s ", target->name.c_str(), + padding.c_str() + target->name.length()); + print_results(target->testPassCount, target->testFailCount, + target->testIgnoreCount); } } } diff --git a/tools/localedata/OWNERS b/tools/localedata/OWNERS new file mode 100644 index 000000000000..2501679784d6 --- /dev/null +++ b/tools/localedata/OWNERS @@ -0,0 +1,2 @@ +# Bug component: 24949 +include platform/external/icu:/OWNERS diff --git a/tools/localedata/extract_icu_data.py b/tools/localedata/extract_icu_data.py index ca1847af7d06..81ac897deae0 100755 --- a/tools/localedata/extract_icu_data.py +++ b/tools/localedata/extract_icu_data.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright 2016 The Android Open Source Project. All Rights Reserved. # @@ -61,7 +61,7 @@ def read_likely_subtags(input_file_name): # would be chosen.) } for line in input_file: - line = unicode(line, 'UTF-8').strip(u' \n\uFEFF').encode('UTF-8') + line = line.strip(u' \n\uFEFF') if line.startswith('//'): continue if '{' in line and '}' in line: @@ -118,26 +118,26 @@ def pack_to_uint32(locale): def dump_script_codes(all_scripts): """Dump the SCRIPT_CODES table.""" - print 'const char SCRIPT_CODES[][4] = {' + print('const char SCRIPT_CODES[][4] = {') for index, script in enumerate(all_scripts): - print " /* %-2d */ {'%c', '%c', '%c', '%c'}," % ( - index, script[0], script[1], script[2], script[3]) - print '};' - print + print(" /* %-2d */ {'%c', '%c', '%c', '%c'}," % ( + index, script[0], script[1], script[2], script[3])) + print('};') + print() def dump_script_data(likely_script_dict, all_scripts): """Dump the script data.""" - print - print 'const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({' + print() + print('const std::unordered_map<uint32_t, uint8_t> LIKELY_SCRIPTS({') for locale in sorted(likely_script_dict.keys()): script = likely_script_dict[locale] - print ' {0x%08Xu, %2du}, // %s -> %s' % ( + print(' {0x%08Xu, %2du}, // %s -> %s' % ( pack_to_uint32(locale), all_scripts.index(script), locale.replace('_', '-'), - script) - print '});' + script)) + print('});') def pack_to_uint64(locale): @@ -152,13 +152,13 @@ def pack_to_uint64(locale): def dump_representative_locales(representative_locales): """Dump the set of representative locales.""" - print - print 'std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({' + print() + print('std::unordered_set<uint64_t> REPRESENTATIVE_LOCALES({') for locale in sorted(representative_locales): - print ' 0x%08XLLU, // %s' % ( + print(' 0x%08XLLU, // %s' % ( pack_to_uint64(locale), - locale) - print '});' + locale)) + print('});') def read_and_dump_likely_data(icu_data_dir): @@ -220,30 +220,30 @@ def get_likely_script(locale, likely_script_dict): def dump_parent_data(script_organized_dict): """Dump information for parents of locales.""" sorted_scripts = sorted(script_organized_dict.keys()) - print + print() for script in sorted_scripts: parent_dict = script_organized_dict[script] print ('const std::unordered_map<uint32_t, uint32_t> %s_PARENTS({' % escape_script_variable_name(script.upper())) for locale in sorted(parent_dict.keys()): parent = parent_dict[locale] - print ' {0x%08Xu, 0x%08Xu}, // %s -> %s' % ( + print(' {0x%08Xu, 0x%08Xu}, // %s -> %s' % ( pack_to_uint32(locale), pack_to_uint32(parent), locale.replace('_', '-'), - parent.replace('_', '-')) - print '});' - print - - print 'const struct {' - print ' const char script[4];' - print ' const std::unordered_map<uint32_t, uint32_t>* map;' - print '} SCRIPT_PARENTS[] = {' + parent.replace('_', '-'))) + print('});') + print() + + print('const struct {') + print(' const char script[4];') + print(' const std::unordered_map<uint32_t, uint32_t>* map;') + print('} SCRIPT_PARENTS[] = {') for script in sorted_scripts: - print " {{'%c', '%c', '%c', '%c'}, &%s_PARENTS}," % ( + print(" {{'%c', '%c', '%c', '%c'}, &%s_PARENTS}," % ( script[0], script[1], script[2], script[3], - escape_script_variable_name(script.upper())) - print '};' + escape_script_variable_name(script.upper()))) + print('};') def dump_parent_tree_depth(parent_dict): @@ -256,8 +256,8 @@ def dump_parent_tree_depth(parent_dict): depth += 1 max_depth = max(max_depth, depth) assert max_depth < 5 # Our algorithms assume small max_depth - print - print 'const size_t MAX_PARENT_DEPTH = %d;' % max_depth + print() + print('const size_t MAX_PARENT_DEPTH = %d;' % max_depth) def read_and_dump_parent_data(icu_data_dir, likely_script_dict): @@ -281,8 +281,8 @@ def main(): source_root, 'external', 'icu', 'icu4c', 'source', 'data') - print '// Auto-generated by %s' % sys.argv[0] - print + print('// Auto-generated by %s' % sys.argv[0]) + print() likely_script_dict = read_and_dump_likely_data(icu_data_dir) read_and_dump_parent_data(icu_data_dir, likely_script_dict) diff --git a/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java b/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java index f1e84b1d8a33..b44e8b42f052 100644 --- a/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java +++ b/tools/locked_region_code_injection/src/lockedregioncodeinjection/Utils.java @@ -20,7 +20,7 @@ import java.util.List; public class Utils { - public static final int ASM_VERSION = Opcodes.ASM7; + public static final int ASM_VERSION = Opcodes.ASM9; /** * Reads a comma separated configuration similar to the Jack definition. diff --git a/tools/processors/intdef_mappings/Android.bp b/tools/processors/intdef_mappings/Android.bp index 82a5dac21160..7059c52ddc76 100644 --- a/tools/processors/intdef_mappings/Android.bp +++ b/tools/processors/intdef_mappings/Android.bp @@ -7,27 +7,33 @@ package { default_applicable_licenses: ["frameworks_base_license"], } -java_plugin { - name: "intdef-annotation-processor", - - processor_class: "android.processor.IntDefProcessor", +java_library_host { + name: "libintdef-annotation-processor", srcs: [ ":framework-annotations", "src/**/*.java", - "src/**/*.kt" + "src/**/*.kt", ], use_tools_jar: true, } +java_plugin { + name: "intdef-annotation-processor", + + processor_class: "android.processor.IntDefProcessor", + + static_libs: ["libintdef-annotation-processor"], +} + java_test_host { name: "intdef-annotation-processor-test", srcs: [ "test/**/*.java", - "test/**/*.kt" - ], + "test/**/*.kt", + ], java_resource_dirs: ["test/resources"], static_libs: [ @@ -35,7 +41,7 @@ java_test_host { "truth-prebuilt", "junit", "guava", - "intdef-annotation-processor" + "libintdef-annotation-processor", ], test_suites: ["general-tests"], diff --git a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt index 2e60f64b21e8..27a8853a2219 100644 --- a/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt +++ b/tools/processors/staledataclass/src/android/processor/staledataclass/StaleDataclassProcessor.kt @@ -97,7 +97,7 @@ class StaleDataclassProcessor: AbstractProcessor() { private fun elemToString(elem: Element): String { return buildString { - append(elem.modifiers.joinToString(" ") { it.name.toLowerCase() }) + append(elem.modifiers.joinToString(" ") { it.name.lowercase() }) append(" ") append(elem.annotationMirrors.joinToString(" ", transform = { annotationToString(it) })) append(" ") diff --git a/tools/processors/view_inspector/Android.bp b/tools/processors/view_inspector/Android.bp index ea9974f06a64..877a1d2b5fb3 100644 --- a/tools/processors/view_inspector/Android.bp +++ b/tools/processors/view_inspector/Android.bp @@ -7,10 +7,8 @@ package { default_applicable_licenses: ["frameworks_base_license"], } -java_plugin { - name: "view-inspector-annotation-processor", - - processor_class: "android.processor.view.inspector.PlatformInspectableProcessor", +java_library_host { + name: "libview-inspector-annotation-processor", srcs: ["src/java/**/*.java"], java_resource_dirs: ["src/resources"], @@ -23,6 +21,16 @@ java_plugin { use_tools_jar: true, } +java_plugin { + name: "view-inspector-annotation-processor", + + processor_class: "android.processor.view.inspector.PlatformInspectableProcessor", + + static_libs: [ + "libview-inspector-annotation-processor", + ], +} + java_test_host { name: "view-inspector-annotation-processor-test", @@ -32,7 +40,7 @@ java_test_host { static_libs: [ "junit", "guava", - "view-inspector-annotation-processor" + "libview-inspector-annotation-processor", ], test_suites: ["general-tests"], diff --git a/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt b/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt index a52c8042582b..451e514b8b33 100644 --- a/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt +++ b/tools/protologtool/src/com/android/protolog/tool/CodeUtils.kt @@ -29,7 +29,7 @@ object CodeUtils { */ fun hash(position: String, messageString: String, logLevel: LogLevel, logGroup: LogGroup): Int { return (position + messageString + logLevel.name + logGroup.name) - .map { c -> c.toInt() }.reduce { h, c -> h * 31 + c } + .map { c -> c.code }.reduce { h, c -> h * 31 + c } } fun checkWildcardStaticImported(code: CompilationUnit, className: String, fileName: String) { diff --git a/tools/validatekeymaps/Android.bp b/tools/validatekeymaps/Android.bp index ff24d160b917..25373f9e9e2f 100644 --- a/tools/validatekeymaps/Android.bp +++ b/tools/validatekeymaps/Android.bp @@ -21,6 +21,7 @@ cc_binary_host { cflags: [ "-Wall", "-Werror", + "-Wextra", ], static_libs: [ @@ -31,6 +32,9 @@ cc_binary_host { "liblog", "libui-types", ], + shared_libs: [ + "libvintf", + ], target: { host_linux: { static_libs: [ diff --git a/tools/validatekeymaps/Main.cpp b/tools/validatekeymaps/Main.cpp index 817effd24a2d..0d7d5f949a08 100644 --- a/tools/validatekeymaps/Main.cpp +++ b/tools/validatekeymaps/Main.cpp @@ -141,6 +141,11 @@ static bool validateFile(const char* filename) { } base::Result<std::shared_ptr<KeyLayoutMap>> ret = KeyLayoutMap::load(filename); if (!ret.ok()) { + if (ret.error().message() == "Missing kernel config") { + // It means the layout is valid, but won't be loaded on this device because + // this layout requires a certain kernel config. + return true; + } error("Error %s parsing key layout file.\n\n", ret.error().message().c_str()); return false; } diff --git a/tools/validatekeymaps/OWNERS b/tools/validatekeymaps/OWNERS index 0313a40f7270..4c20c4dc9d35 100644 --- a/tools/validatekeymaps/OWNERS +++ b/tools/validatekeymaps/OWNERS @@ -1,2 +1 @@ -michaelwr@google.com -svv@google.com +include /INPUT_OWNERS |