Loading ravenwood/scripts/add-annotations.sh 0 → 100755 +84 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright (C) 2025 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. # # Use "ravehleper mm" to create a shell script which: # - Reads read a list of methods from STDIN # Which basically looks like a list of 'com.android.ravenwoodtest.tests.Test1#testA' # - Add @DisabledOnRavenwood to them # # Example usage: # # ./add-annotations.sh $ANDROID_BUILD_TOP/frameworks/base/ravenwood/tests <METHOD-LIST.txt # # Use a different annotation instead. (Note, in order to use an at, you need to use a double-at.) # ./add-annotations.sh -t '@@Ignore' $ANDROID_BUILD_TOP/frameworks/base/ravenwood/tests <METHOD-LIST.txt # set -e # Uncomment it to always build ravenhelper (slow) # ${BUILD_CMD:-m} ravenhelper # We add this line to each methods found. # Note, if we used a single @, that'd be handled as an at file. Use # the double-at instead. annotation="@@android.platform.test.annotations.DisabledOnRavenwood" while getopts "t:" opt; do case "$opt" in t) annotation="$OPTARG" ;; '?') exit 1 ;; esac done shift $(($OPTIND - 1)) source_dirs="$@" OUT_SCRIPT="${OUT_SCRIPT:-/tmp/add-annotations.sh}" rm -f "$OUT_SCRIPT" with_flag() { local flag="$1" shift for arg in "$@"; do echo "$flag $arg" done } run() { echo "Running: $*" "$@" } run ${RAVENHELPER_CMD:-ravenhelper mm} \ --output-script $OUT_SCRIPT \ --text "$annotation" \ $(with_flag --src $source_dirs) if ! [[ -f $OUT_SCRIPT ]] ; then # no operations generated. exit 0 fi echo echo "Created script at $OUT_SCRIPT. Run it with: sh $OUT_SCRIPT" ravenwood/scripts/pta-framework.sh +1 −1 Original line number Diff line number Diff line #!/bin/bash # Copyright (C) 2024 The Android Open Source Project # Copyright (C) 2025 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. Loading ravenwood/tools/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt +6 −1 Original line number Diff line number Diff line Loading @@ -354,6 +354,8 @@ class ArgIterator( * Scan the arguments, and if any of them starts with an `@`, then load from the file * and use its content as arguments. * * In order to pass an argument that starts with an '@', use '@@' instead. * * In this file, each line is treated as a single argument. * * The file can contain '#' as comments. Loading @@ -362,7 +364,10 @@ private fun expandAtFiles(args: Array<String>): List<String> { val ret = mutableListOf<String>() args.forEach { arg -> if (!arg.startsWith('@')) { if (arg.startsWith("@@")) { ret += arg.substring(1) return@forEach } else if (!arg.startsWith('@')) { ret += arg return@forEach } Loading ravenwood/tools/ravenhelper/src/com/android/platform/test/ravenwood/ravenhelper/RavenHelperMain.kt +6 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.hoststubgen.executableName import com.android.hoststubgen.log import com.android.hoststubgen.runMainWithBoilerplate import com.android.platform.test.ravenwood.ravenhelper.policytoannot.PtaProcessor import com.android.platform.test.ravenwood.ravenhelper.sourcemap.MarkMethodHandler interface SubcommandHandler { fun handle(args: List<String>) Loading @@ -39,7 +40,10 @@ fun usage() { Subcommands: pta: "policy-to-annotations" Convert policy file to annotations. (See the pta-framework.sh script for usage.) 1 (See the pta-framework.sh script for usage.) mm: "mark methods" Used to add annotations (such as @DisabledOnRavenwood) to methods. """.trimIndent()) } Loading @@ -60,6 +64,7 @@ fun main(args: Array<String>) { val subcommand = args[0] val handler: SubcommandHandler = when (subcommand) { "pta" -> PtaProcessor() "mm" -> MarkMethodHandler() else -> { usage() throw GeneralUserErrorException("Unknown subcommand '$subcommand'") Loading ravenwood/tools/ravenhelper/src/com/android/platform/test/ravenwood/ravenhelper/policytoannot/Operations.kt +24 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ package com.android.platform.test.ravenwood.ravenhelper.policytoannot import com.android.hoststubgen.log import java.io.BufferedWriter import java.io.File import java.io.FileOutputStream import java.io.OutputStreamWriter enum class SourceOperationType { /** Insert a line */ Loading Loading @@ -199,3 +201,25 @@ private fun toSedScript(ops: List<SourceOperation>, writer: BufferedWriter) { } } } fun createShellScript(ops: SourceOperations, scriptFile: String?): Boolean { if (ops.size == 0) { log.i("No files need to be updated.") return false } val scriptWriter = BufferedWriter( OutputStreamWriter( scriptFile?.let { file -> FileOutputStream(file) } ?: System.out )) scriptWriter.use { writer -> scriptFile?.let { log.i("Creating script file at $it ...") } createShellScript(ops, writer) } return true } No newline at end of file Loading
ravenwood/scripts/add-annotations.sh 0 → 100755 +84 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright (C) 2025 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. # # Use "ravehleper mm" to create a shell script which: # - Reads read a list of methods from STDIN # Which basically looks like a list of 'com.android.ravenwoodtest.tests.Test1#testA' # - Add @DisabledOnRavenwood to them # # Example usage: # # ./add-annotations.sh $ANDROID_BUILD_TOP/frameworks/base/ravenwood/tests <METHOD-LIST.txt # # Use a different annotation instead. (Note, in order to use an at, you need to use a double-at.) # ./add-annotations.sh -t '@@Ignore' $ANDROID_BUILD_TOP/frameworks/base/ravenwood/tests <METHOD-LIST.txt # set -e # Uncomment it to always build ravenhelper (slow) # ${BUILD_CMD:-m} ravenhelper # We add this line to each methods found. # Note, if we used a single @, that'd be handled as an at file. Use # the double-at instead. annotation="@@android.platform.test.annotations.DisabledOnRavenwood" while getopts "t:" opt; do case "$opt" in t) annotation="$OPTARG" ;; '?') exit 1 ;; esac done shift $(($OPTIND - 1)) source_dirs="$@" OUT_SCRIPT="${OUT_SCRIPT:-/tmp/add-annotations.sh}" rm -f "$OUT_SCRIPT" with_flag() { local flag="$1" shift for arg in "$@"; do echo "$flag $arg" done } run() { echo "Running: $*" "$@" } run ${RAVENHELPER_CMD:-ravenhelper mm} \ --output-script $OUT_SCRIPT \ --text "$annotation" \ $(with_flag --src $source_dirs) if ! [[ -f $OUT_SCRIPT ]] ; then # no operations generated. exit 0 fi echo echo "Created script at $OUT_SCRIPT. Run it with: sh $OUT_SCRIPT"
ravenwood/scripts/pta-framework.sh +1 −1 Original line number Diff line number Diff line #!/bin/bash # Copyright (C) 2024 The Android Open Source Project # Copyright (C) 2025 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. Loading
ravenwood/tools/hoststubgen/src/com/android/hoststubgen/HostStubGenOptions.kt +6 −1 Original line number Diff line number Diff line Loading @@ -354,6 +354,8 @@ class ArgIterator( * Scan the arguments, and if any of them starts with an `@`, then load from the file * and use its content as arguments. * * In order to pass an argument that starts with an '@', use '@@' instead. * * In this file, each line is treated as a single argument. * * The file can contain '#' as comments. Loading @@ -362,7 +364,10 @@ private fun expandAtFiles(args: Array<String>): List<String> { val ret = mutableListOf<String>() args.forEach { arg -> if (!arg.startsWith('@')) { if (arg.startsWith("@@")) { ret += arg.substring(1) return@forEach } else if (!arg.startsWith('@')) { ret += arg return@forEach } Loading
ravenwood/tools/ravenhelper/src/com/android/platform/test/ravenwood/ravenhelper/RavenHelperMain.kt +6 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.hoststubgen.executableName import com.android.hoststubgen.log import com.android.hoststubgen.runMainWithBoilerplate import com.android.platform.test.ravenwood.ravenhelper.policytoannot.PtaProcessor import com.android.platform.test.ravenwood.ravenhelper.sourcemap.MarkMethodHandler interface SubcommandHandler { fun handle(args: List<String>) Loading @@ -39,7 +40,10 @@ fun usage() { Subcommands: pta: "policy-to-annotations" Convert policy file to annotations. (See the pta-framework.sh script for usage.) 1 (See the pta-framework.sh script for usage.) mm: "mark methods" Used to add annotations (such as @DisabledOnRavenwood) to methods. """.trimIndent()) } Loading @@ -60,6 +64,7 @@ fun main(args: Array<String>) { val subcommand = args[0] val handler: SubcommandHandler = when (subcommand) { "pta" -> PtaProcessor() "mm" -> MarkMethodHandler() else -> { usage() throw GeneralUserErrorException("Unknown subcommand '$subcommand'") Loading
ravenwood/tools/ravenhelper/src/com/android/platform/test/ravenwood/ravenhelper/policytoannot/Operations.kt +24 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ package com.android.platform.test.ravenwood.ravenhelper.policytoannot import com.android.hoststubgen.log import java.io.BufferedWriter import java.io.File import java.io.FileOutputStream import java.io.OutputStreamWriter enum class SourceOperationType { /** Insert a line */ Loading Loading @@ -199,3 +201,25 @@ private fun toSedScript(ops: List<SourceOperation>, writer: BufferedWriter) { } } } fun createShellScript(ops: SourceOperations, scriptFile: String?): Boolean { if (ops.size == 0) { log.i("No files need to be updated.") return false } val scriptWriter = BufferedWriter( OutputStreamWriter( scriptFile?.let { file -> FileOutputStream(file) } ?: System.out )) scriptWriter.use { writer -> scriptFile?.let { log.i("Creating script file at $it ...") } createShellScript(ops, writer) } return true } No newline at end of file