Loading ravenwood/scripts/remove-ravenizer-output.sh 0 → 100755 +25 −0 Original line number Diff line number Diff line #!/bin/bash # 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. # Delete all the ravenizer output jar files from Soong's intermediate directory. # `-a -prune` is needed because otherwise find would be confused if the directory disappears. find "${ANDROID_BUILD_TOP:?}/out/soong/.intermediates/" \ -type d \ -name 'ravenizer' \ -print \ -exec rm -fr \{\} \; \ -a -prune ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/Exceptions.kt +7 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,14 @@ package com.android.platform.test.ravenwood.ravenizer import com.android.hoststubgen.UserErrorException /** * Use it for internal exception that really shouldn't happen. */ class RavenizerInternalException(message: String) : Exception(message) /** * Thrown when an invalid test is detected in the target jar. (e.g. JUni3 tests) */ class RavenizerInvalidTestException(message: String) : Exception(message), UserErrorException ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/Ravenizer.kt +34 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ data class RavenizerStats( /** Time took to build [ClasNodes] */ var loadStructureTime: Double = .0, /** Time took to validate the classes */ var validationTime: Double = .0, /** Total real time spent for converting the jar file */ var totalProcessTime: Double = .0, Loading @@ -67,6 +70,7 @@ data class RavenizerStats( RavenizerStats{ totalTime=$totalTime, loadStructureTime=$loadStructureTime, validationTime=$validationTime, totalProcessTime=$totalProcessTime, totalConversionTime=$totalConversionTime, totalCopyTime=$totalCopyTime, Loading @@ -84,16 +88,44 @@ data class RavenizerStats( class Ravenizer(val options: RavenizerOptions) { fun run() { val stats = RavenizerStats() val fatalValidation = options.fatalValidation.get stats.totalTime = log.nTime { process(options.inJar.get, options.outJar.get, stats) process( options.inJar.get, options.outJar.get, options.enableValidation.get, fatalValidation, stats, ) } log.i(stats.toString()) } private fun process(inJar: String, outJar: String, stats: RavenizerStats) { private fun process( inJar: String, outJar: String, enableValidation: Boolean, fatalValidation: Boolean, stats: RavenizerStats, ) { var allClasses = ClassNodes.loadClassStructures(inJar) { time -> stats.loadStructureTime = time } if (enableValidation) { stats.validationTime = log.iTime("Validating classes") { if (!validateClasses(allClasses)) { var message = "Invalid test class(es) detected." + " See error log for details." if (fatalValidation) { throw RavenizerInvalidTestException(message) } else { log.w("Warning: $message") } } } } stats.totalProcessTime = log.iTime("$executableName processing $inJar") { ZipFile(inJar).use { inZip -> Loading ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/RavenizerOptions.kt +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,12 @@ class RavenizerOptions( /** Output jar file */ var outJar: SetOnce<String> = SetOnce(""), /** Whether to enable test validation. */ var enableValidation: SetOnce<Boolean> = SetOnce(true), /** Whether the validation failure is fatal or not. */ var fatalValidation: SetOnce<Boolean> = SetOnce(false), ) { companion object { fun parseArgs(args: Array<String>): RavenizerOptions { Loading @@ -52,6 +58,12 @@ class RavenizerOptions( "--in-jar" -> ret.inJar.set(nextArg()).ensureFileExists() "--out-jar" -> ret.outJar.set(nextArg()) "--enable-validation" -> ret.enableValidation.set(true) "--disable-validation" -> ret.enableValidation.set(false) "--fatal-validation" -> ret.fatalValidation.set(true) "--no-fatal-validation" -> ret.fatalValidation.set(false) else -> throw ArgumentsException("Unknown option: $arg") } } catch (e: SetOnce.SetMoreThanOnceException) { Loading @@ -74,6 +86,8 @@ class RavenizerOptions( RavenizerOptions{ inJar=$inJar, outJar=$outJar, enableValidation=$enableValidation, fatalValidation=$fatalValidation, } """.trimIndent() } Loading ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/Utils.kt +3 −0 Original line number Diff line number Diff line Loading @@ -87,9 +87,12 @@ fun String.shouldByBypassed(): Boolean { return this.startsWithAny( "java/", // just in case... "javax/", "junit/", "org/junit/", "org/mockito/", "kotlin/", "androidx/", "android/support/", // TODO -- anything else? ) } Loading
ravenwood/scripts/remove-ravenizer-output.sh 0 → 100755 +25 −0 Original line number Diff line number Diff line #!/bin/bash # 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. # Delete all the ravenizer output jar files from Soong's intermediate directory. # `-a -prune` is needed because otherwise find would be confused if the directory disappears. find "${ANDROID_BUILD_TOP:?}/out/soong/.intermediates/" \ -type d \ -name 'ravenizer' \ -print \ -exec rm -fr \{\} \; \ -a -prune
ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/Exceptions.kt +7 −0 Original line number Diff line number Diff line Loading @@ -17,7 +17,14 @@ package com.android.platform.test.ravenwood.ravenizer import com.android.hoststubgen.UserErrorException /** * Use it for internal exception that really shouldn't happen. */ class RavenizerInternalException(message: String) : Exception(message) /** * Thrown when an invalid test is detected in the target jar. (e.g. JUni3 tests) */ class RavenizerInvalidTestException(message: String) : Exception(message), UserErrorException
ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/Ravenizer.kt +34 −2 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ data class RavenizerStats( /** Time took to build [ClasNodes] */ var loadStructureTime: Double = .0, /** Time took to validate the classes */ var validationTime: Double = .0, /** Total real time spent for converting the jar file */ var totalProcessTime: Double = .0, Loading @@ -67,6 +70,7 @@ data class RavenizerStats( RavenizerStats{ totalTime=$totalTime, loadStructureTime=$loadStructureTime, validationTime=$validationTime, totalProcessTime=$totalProcessTime, totalConversionTime=$totalConversionTime, totalCopyTime=$totalCopyTime, Loading @@ -84,16 +88,44 @@ data class RavenizerStats( class Ravenizer(val options: RavenizerOptions) { fun run() { val stats = RavenizerStats() val fatalValidation = options.fatalValidation.get stats.totalTime = log.nTime { process(options.inJar.get, options.outJar.get, stats) process( options.inJar.get, options.outJar.get, options.enableValidation.get, fatalValidation, stats, ) } log.i(stats.toString()) } private fun process(inJar: String, outJar: String, stats: RavenizerStats) { private fun process( inJar: String, outJar: String, enableValidation: Boolean, fatalValidation: Boolean, stats: RavenizerStats, ) { var allClasses = ClassNodes.loadClassStructures(inJar) { time -> stats.loadStructureTime = time } if (enableValidation) { stats.validationTime = log.iTime("Validating classes") { if (!validateClasses(allClasses)) { var message = "Invalid test class(es) detected." + " See error log for details." if (fatalValidation) { throw RavenizerInvalidTestException(message) } else { log.w("Warning: $message") } } } } stats.totalProcessTime = log.iTime("$executableName processing $inJar") { ZipFile(inJar).use { inZip -> Loading
ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/RavenizerOptions.kt +14 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,12 @@ class RavenizerOptions( /** Output jar file */ var outJar: SetOnce<String> = SetOnce(""), /** Whether to enable test validation. */ var enableValidation: SetOnce<Boolean> = SetOnce(true), /** Whether the validation failure is fatal or not. */ var fatalValidation: SetOnce<Boolean> = SetOnce(false), ) { companion object { fun parseArgs(args: Array<String>): RavenizerOptions { Loading @@ -52,6 +58,12 @@ class RavenizerOptions( "--in-jar" -> ret.inJar.set(nextArg()).ensureFileExists() "--out-jar" -> ret.outJar.set(nextArg()) "--enable-validation" -> ret.enableValidation.set(true) "--disable-validation" -> ret.enableValidation.set(false) "--fatal-validation" -> ret.fatalValidation.set(true) "--no-fatal-validation" -> ret.fatalValidation.set(false) else -> throw ArgumentsException("Unknown option: $arg") } } catch (e: SetOnce.SetMoreThanOnceException) { Loading @@ -74,6 +86,8 @@ class RavenizerOptions( RavenizerOptions{ inJar=$inJar, outJar=$outJar, enableValidation=$enableValidation, fatalValidation=$fatalValidation, } """.trimIndent() } Loading
ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/Utils.kt +3 −0 Original line number Diff line number Diff line Loading @@ -87,9 +87,12 @@ fun String.shouldByBypassed(): Boolean { return this.startsWithAny( "java/", // just in case... "javax/", "junit/", "org/junit/", "org/mockito/", "kotlin/", "androidx/", "android/support/", // TODO -- anything else? ) }