• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (C) 2025 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16#
17# Use "ravehleper mm" to create a shell script which:
18# - Reads read a list of methods from STDIN
19#   Which basically looks like a list of 'com.android.ravenwoodtest.tests.Test1#testA'
20# - Add @DisabledOnRavenwood to them
21#
22# Example usage:
23#
24# ./add-annotations.sh $ANDROID_BUILD_TOP/frameworks/base/ravenwood/tests <METHOD-LIST.txt
25#
26# Use a different annotation instead. (Note, in order to use an at, you need to use a double-at.)
27# ./add-annotations.sh -t '@@Ignore' $ANDROID_BUILD_TOP/frameworks/base/ravenwood/tests <METHOD-LIST.txt
28#
29
30set -e
31
32# Uncomment it to always build ravenhelper (slow)
33# ${BUILD_CMD:-m} ravenhelper
34
35# We add this line to each methods found.
36# Note, if we used a single @, that'd be handled as an at file. Use
37# the double-at instead.
38annotation="@@android.platform.test.annotations.DisabledOnRavenwood(reason = \"bulk-disabled by script\")"
39while getopts "t:" opt; do
40case "$opt" in
41    t)
42        annotation="$OPTARG"
43        ;;
44    '?')
45        exit 1
46        ;;
47esac
48done
49shift $(($OPTIND - 1))
50
51source_dirs="$@"
52
53OUT_SCRIPT="${OUT_SCRIPT:-/tmp/add-annotations.sh}"
54
55rm -f "$OUT_SCRIPT"
56
57
58with_flag() {
59    local flag="$1"
60    shift
61
62    for arg in "$@"; do
63        echo "$flag $arg"
64    done
65}
66
67run() {
68    echo "Running: $*"
69    "$@"
70}
71
72run ${RAVENHELPER_CMD:-ravenhelper mm} \
73    --output-script $OUT_SCRIPT \
74    --text "$annotation" \
75    $(with_flag --src $source_dirs)
76
77
78if ! [[ -f $OUT_SCRIPT ]] ; then
79    # no operations generated.
80    exit 0
81fi
82
83echo
84echo "Created script at $OUT_SCRIPT. Run it with: sh $OUT_SCRIPT"
85