diff options
author | Khaled Yakdan <yakdan@code-intelligence.com> | 2022-12-22 03:55:46 +0100 |
---|---|---|
committer | Khaled Yakdan <yakdan@code-intelligence.de> | 2022-12-22 03:18:39 -0800 |
commit | e5f3fba18a6e81081da563c769929ed1ab6e524d (patch) | |
tree | db514a11bdc072f3e19cf4faa2f5af2a37d2b714 /src/test/java/com/code_intelligence/jazzer/instrumentor | |
parent | cb162addfeda3f2573e7bd5da169ef31ed2af3b7 (diff) | |
download | jazzer-api-e5f3fba18a6e81081da563c769929ed1ab6e524d.tar.gz |
format: update scripts and docs, and rerun the scripts
Diffstat (limited to 'src/test/java/com/code_intelligence/jazzer/instrumentor')
4 files changed, 18 insertions, 15 deletions
diff --git a/src/test/java/com/code_intelligence/jazzer/instrumentor/CoverageInstrumentationTest.kt b/src/test/java/com/code_intelligence/jazzer/instrumentor/CoverageInstrumentationTest.kt index f2cf2f08..3e3ba0d7 100644 --- a/src/test/java/com/code_intelligence/jazzer/instrumentor/CoverageInstrumentationTest.kt +++ b/src/test/java/com/code_intelligence/jazzer/instrumentor/CoverageInstrumentationTest.kt @@ -32,7 +32,7 @@ private fun makeTestable(strategy: EdgeCoverageStrategy): EdgeCoverageStrategy = mv: MethodVisitor, edgeId: Int, variable: Int, - coverageMapInternalClassName: String + coverageMapInternalClassName: String, ) { strategy.instrumentControlFlowEdge(mv, edgeId, variable, coverageMapInternalClassName) mv.visitMethodInsn(Opcodes.INVOKESTATIC, coverageMapInternalClassName, "updated", "()V", false) @@ -43,7 +43,7 @@ private fun applyInstrumentation(bytecode: ByteArray): ByteArray { return EdgeCoverageInstrumentor( makeTestable(ClassInstrumentor.defaultEdgeCoverageStrategy), MockCoverageMap::class.java, - 0 + 0, ).instrument(bytecode) } @@ -123,14 +123,16 @@ class CoverageInstrumentationTest { }.toList() val forControlFlow = forFirstRunControlFlow + forSecondRunControlFlow val fooCallControlFlow = listOf( - barAfterPutInvocation, fooAfterBarInvocation, afterFooInvocation + barAfterPutInvocation, + fooAfterBarInvocation, + afterFooInvocation, ) assertControlFlow( listOf(constructorReturn) + mapControlFlow + ifControlFlow + forControlFlow + - fooCallControlFlow + fooCallControlFlow, ) } @@ -166,7 +168,7 @@ class CoverageInstrumentationTest { val outDir = System.getenv("TEST_UNDECLARED_OUTPUTS_DIR") File("$outDir/${CoverageInstrumentationSpecialCasesTarget::class.simpleName}.class").writeBytes(originalBytecode) File("$outDir/${CoverageInstrumentationSpecialCasesTarget::class.simpleName}.patched.class").writeBytes( - patchedBytecode + patchedBytecode, ) val patchedClass = bytecodeToClass(CoverageInstrumentationSpecialCasesTarget::class.java.name, patchedBytecode) // Trigger a class load diff --git a/src/test/java/com/code_intelligence/jazzer/instrumentor/DescriptorUtilsTest.kt b/src/test/java/com/code_intelligence/jazzer/instrumentor/DescriptorUtilsTest.kt index 87389d5b..c1a3584e 100644 --- a/src/test/java/com/code_intelligence/jazzer/instrumentor/DescriptorUtilsTest.kt +++ b/src/test/java/com/code_intelligence/jazzer/instrumentor/DescriptorUtilsTest.kt @@ -40,28 +40,28 @@ class DescriptorUtilsTest { Triple( String::class.java.getMethod("equals", Object::class.java), listOf("Ljava/lang/Object;"), - "Z" + "Z", ), Triple( String::class.java.getMethod("regionMatches", Boolean::class.javaPrimitiveType, Int::class.javaPrimitiveType, String::class.java, Int::class.javaPrimitiveType, Integer::class.javaPrimitiveType), listOf("Z", "I", "Ljava/lang/String;", "I", "I"), - "Z" + "Z", ), Triple( String::class.java.getMethod("getChars", Integer::class.javaPrimitiveType, Int::class.javaPrimitiveType, CharArray::class.java, Int::class.javaPrimitiveType), listOf("I", "I", "[C", "I"), - "V" + "V", ), Triple( String::class.java.getMethod("subSequence", Integer::class.javaPrimitiveType, Integer::class.javaPrimitiveType), listOf("I", "I"), - "Ljava/lang/CharSequence;" + "Ljava/lang/CharSequence;", ), Triple( String::class.java.getConstructor(), emptyList(), - "V" - ) + "V", + ), ) for ((executable, parameterDescriptors, returnTypeDescriptor) in testCases) { val descriptor = executable.descriptor diff --git a/src/test/java/com/code_intelligence/jazzer/instrumentor/PatchTestUtils.kt b/src/test/java/com/code_intelligence/jazzer/instrumentor/PatchTestUtils.kt index 00279c35..de2cc187 100644 --- a/src/test/java/com/code_intelligence/jazzer/instrumentor/PatchTestUtils.kt +++ b/src/test/java/com/code_intelligence/jazzer/instrumentor/PatchTestUtils.kt @@ -33,7 +33,7 @@ object PatchTestUtils { } @JvmStatic - public fun dumpBytecode(outDir: String, name: String, originalBytecode: ByteArray) { + fun dumpBytecode(outDir: String, name: String, originalBytecode: ByteArray) { FileOutputStream("$outDir/$name.class").use { fos -> fos.write(originalBytecode) } } @@ -44,8 +44,9 @@ object PatchTestUtils { class BytecodeClassLoader(val className: String, private val classBytecode: ByteArray) : ClassLoader(BytecodeClassLoader::class.java.classLoader) { override fun loadClass(name: String): Class<*> { - if (name != className) + if (name != className) { return super.loadClass(name) + } return defineClass(className, classBytecode, 0, classBytecode.size) } } diff --git a/src/test/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentationTest.kt b/src/test/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentationTest.kt index 11fc5197..e30d3e28 100644 --- a/src/test/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentationTest.kt +++ b/src/test/java/com/code_intelligence/jazzer/instrumentor/TraceDataFlowInstrumentationTest.kt @@ -24,9 +24,9 @@ private fun applyInstrumentation(bytecode: ByteArray): ByteArray { setOf( InstrumentationType.CMP, InstrumentationType.DIV, - InstrumentationType.GEP + InstrumentationType.GEP, ), - MockTraceDataFlowCallbacks::class.java.name.replace('.', '/') + MockTraceDataFlowCallbacks::class.java.name.replace('.', '/'), ).instrument(bytecode) } |