Merge changes I8b5e2642,I0520ab0f into main
* changes: check-flagged-apis: add script to run tool on actual data check-flagged-apis: simplify unit test dependencies
This commit is contained in:
@@ -46,6 +46,6 @@ java_test_host {
|
|||||||
"src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt",
|
"src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt",
|
||||||
],
|
],
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"tradefed",
|
"junit",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
69
tools/check-flagged-apis/check-flagged-apis.sh
Normal file
69
tools/check-flagged-apis/check-flagged-apis.sh
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# Copyright (C) 2024 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.
|
||||||
|
|
||||||
|
# Run check-flagged-apis for public APIs and the three @SystemApi flavours
|
||||||
|
# Usage: lunch <your-target> && source <this script>
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
m sdk dist && m \
|
||||||
|
check-flagged-apis \
|
||||||
|
all_aconfig_declarations \
|
||||||
|
frameworks-base-api-current.txt \
|
||||||
|
frameworks-base-api-system-current.txt \
|
||||||
|
frameworks-base-api-system-server-current.txt \
|
||||||
|
frameworks-base-api-module-lib-current.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
function run() {
|
||||||
|
local errors=0
|
||||||
|
|
||||||
|
echo "# current"
|
||||||
|
check-flagged-apis \
|
||||||
|
--api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-current.txt_intermediates/frameworks-base-api-current.txt \
|
||||||
|
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
|
||||||
|
--api-versions $(gettop)/out/dist/data/api-versions.xml
|
||||||
|
(( errors += $? ))
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "# system-current"
|
||||||
|
check-flagged-apis \
|
||||||
|
--api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-system-current.txt_intermediates/frameworks-base-api-system-current.txt \
|
||||||
|
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
|
||||||
|
--api-versions $(gettop)/out/dist/system-data/api-versions.xml
|
||||||
|
(( errors += $? ))
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "# system-server-current"
|
||||||
|
check-flagged-apis \
|
||||||
|
--api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-system-server-current.txt_intermediates/frameworks-base-api-system-server-current.txt \
|
||||||
|
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
|
||||||
|
--api-versions $(gettop)/out/dist/system-server-data/api-versions.xml
|
||||||
|
(( errors += $? ))
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "# module-lib"
|
||||||
|
check-flagged-apis \
|
||||||
|
--api-signature $(gettop)/out/target/product/mainline_x86/obj/ETC/frameworks-base-api-module-lib-current.txt_intermediates/frameworks-base-api-module-lib-current.txt \
|
||||||
|
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
|
||||||
|
--api-versions $(gettop)/out/dist/module-lib-data/api-versions.xml
|
||||||
|
(( errors += $? ))
|
||||||
|
|
||||||
|
return $errors
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$1" != "--skip-build" ]]; then
|
||||||
|
build && run
|
||||||
|
else
|
||||||
|
run
|
||||||
|
fi
|
@@ -16,14 +16,13 @@
|
|||||||
package com.android.checkflaggedapis
|
package com.android.checkflaggedapis
|
||||||
|
|
||||||
import android.aconfig.Aconfig
|
import android.aconfig.Aconfig
|
||||||
import com.android.tradefed.testtype.DeviceJUnit4ClassRunner
|
|
||||||
import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test
|
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.JUnit4
|
||||||
|
|
||||||
private val API_SIGNATURE =
|
private val API_SIGNATURE =
|
||||||
"""
|
"""
|
||||||
@@ -64,8 +63,8 @@ private fun generateFlagsProto(fooState: Aconfig.flag_state): InputStream {
|
|||||||
return ByteArrayInputStream(binaryProto.toByteArray())
|
return ByteArrayInputStream(binaryProto.toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
@RunWith(DeviceJUnit4ClassRunner::class)
|
@RunWith(JUnit4::class)
|
||||||
class CheckFlaggedApisTest : BaseHostJUnit4Test() {
|
class CheckFlaggedApisTest {
|
||||||
@Test
|
@Test
|
||||||
fun testParseApiSignature() {
|
fun testParseApiSignature() {
|
||||||
val expected = setOf(Pair(Symbol("android.Clazz.FOO"), Flag("android.flag.foo")))
|
val expected = setOf(Pair(Symbol("android.Clazz.FOO"), Flag("android.flag.foo")))
|
||||||
|
Reference in New Issue
Block a user