Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JVM test framework #48

Merged
merged 179 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 177 commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
5b78042
Init
DaniilStepanov May 25, 2023
0ee3af5
Nested refs added
DaniilStepanov May 25, 2023
9e9ab4c
RD calls wrappers
DaniilStepanov May 25, 2023
3301eac
Result and initial descriptors refs are same if didnt change during e…
DaniilStepanov May 25, 2023
f5ce32f
cyclic ref fix
DaniilStepanov May 25, 2023
4361f89
UTest executor
DaniilStepanov May 30, 2023
d761645
new tests;
DaniilStepanov May 30, 2023
e853418
Statics field descriptors building and optimizations
DaniilStepanov May 30, 2023
a8bfdfe
Java constructor to jcdb constructor conversion fixed
DaniilStepanov May 31, 2023
5f80b4c
minor bug fixes
DaniilStepanov Jun 1, 2023
e9fb9ff
minor
DaniilStepanov Jun 7, 2023
532eac2
Runner minor fixes
DaniilStepanov Jun 7, 2023
a8cb25c
Different improvements
DaniilStepanov Jun 21, 2023
d170d27
trash remove
DaniilStepanov Jun 21, 2023
a48231d
new test
DaniilStepanov Jun 22, 2023
be4202b
rd gen fix
DaniilStepanov Jun 23, 2023
556f00f
Update jacodb version and some comments
DaniilStepanov Jun 23, 2023
e7558eb
Removing Instrumenter.kt
DaniilStepanov Jun 23, 2023
f9b73d0
Descriptor building bug fix
DaniilStepanov Jun 23, 2023
a1e4c1c
Fix with non-public constructor call
DaniilStepanov Jun 23, 2023
e32063b
Exception handling fix
DaniilStepanov Jun 23, 2023
12fcc14
README added
DaniilStepanov Jun 23, 2023
1b616db
More reliable static rollback
DaniilStepanov Jun 23, 2023
572db5f
Mock implementation
DaniilStepanov Jun 27, 2023
d06d0b2
Mock implementation almost work
DaniilStepanov Jun 28, 2023
6ea1c54
Instrumentation bug fix
DaniilStepanov Jun 29, 2023
f39f7dc
Static methods mocking added
DaniilStepanov Jun 29, 2023
88e9890
UTestArithmeticExpression added
DaniilStepanov Jul 6, 2023
4fb5ed4
Java 11 patch
DaniilStepanov Jul 7, 2023
9715cdd
field logic fix
DaniilStepanov Jul 10, 2023
b1f6c78
Global mock support
DaniilStepanov Jul 12, 2023
13949d4
Executor added to jvm module
DaniilStepanov Jul 19, 2023
4f17ba2
Refactorings
DaniilStepanov Jul 20, 2023
1af5ff7
unused class removed
DaniilStepanov Jul 20, 2023
bee6406
Rebased
DaniilStepanov Aug 9, 2023
123da33
Virtual calls supported
DaniilStepanov Aug 9, 2023
cdbb193
Init
DaniilStepanov May 25, 2023
95fc78b
Nested refs added
DaniilStepanov May 25, 2023
22786d5
RD calls wrappers
DaniilStepanov May 25, 2023
30ed5f7
Result and initial descriptors refs are same if didnt change during e…
DaniilStepanov May 25, 2023
638c6cc
cyclic ref fix
DaniilStepanov May 25, 2023
496454b
UTest executor
DaniilStepanov May 30, 2023
8decbe8
new tests;
DaniilStepanov May 30, 2023
bf6a17f
Statics field descriptors building and optimizations
DaniilStepanov May 30, 2023
3010b79
Java constructor to jcdb constructor conversion fixed
DaniilStepanov May 31, 2023
abcd75a
minor bug fixes
DaniilStepanov Jun 1, 2023
aea4ca9
minor
DaniilStepanov Jun 7, 2023
3a1e1d5
Runner minor fixes
DaniilStepanov Jun 7, 2023
b7f3e9d
Different improvements
DaniilStepanov Jun 21, 2023
081a970
trash remove
DaniilStepanov Jun 21, 2023
ea45e29
new test
DaniilStepanov Jun 22, 2023
6a4a657
rd gen fix
DaniilStepanov Jun 23, 2023
bee1ac2
Update jacodb version and some comments
DaniilStepanov Jun 23, 2023
cbcc150
Removing Instrumenter.kt
DaniilStepanov Jun 23, 2023
e2fc94a
Descriptor building bug fix
DaniilStepanov Jun 23, 2023
890532d
Fix with non-public constructor call
DaniilStepanov Jun 23, 2023
3e8cea8
Exception handling fix
DaniilStepanov Jun 23, 2023
cb205b1
README added
DaniilStepanov Jun 23, 2023
b0256dc
More reliable static rollback
DaniilStepanov Jun 23, 2023
170bf0e
Mock implementation
DaniilStepanov Jun 27, 2023
b33c677
Mock implementation almost work
DaniilStepanov Jun 28, 2023
29becb1
Instrumentation bug fix
DaniilStepanov Jun 29, 2023
5ae414b
Static methods mocking added
DaniilStepanov Jun 29, 2023
f104fe6
UTestArithmeticExpression added
DaniilStepanov Jul 6, 2023
9fd4bee
Java 11 patch
DaniilStepanov Jul 7, 2023
388510e
field logic fix
DaniilStepanov Jul 10, 2023
1513eb0
Global mock support
DaniilStepanov Jul 12, 2023
2e3704b
Executor added to jvm module
DaniilStepanov Jul 19, 2023
e4aab3d
Refactorings
DaniilStepanov Jul 20, 2023
8260219
unused class removed
DaniilStepanov Jul 20, 2023
ccbfc79
minor
DaniilStepanov Aug 9, 2023
18f9e11
java.reflect.Class support
DaniilStepanov Aug 10, 2023
832502f
Updated usage of jacodb findMethodOrNull method
DaniilStepanov Aug 10, 2023
22ee0d5
Rebased and updated according to new kernel functionality
DaniilStepanov Aug 15, 2023
67bee28
Init
DaniilStepanov May 25, 2023
ffcdf21
Nested refs added
DaniilStepanov May 25, 2023
eba9658
RD calls wrappers
DaniilStepanov May 25, 2023
6275f5e
Result and initial descriptors refs are same if didnt change during e…
DaniilStepanov May 25, 2023
0e64295
cyclic ref fix
DaniilStepanov May 25, 2023
c3df401
UTest executor
DaniilStepanov May 30, 2023
1be23cb
new tests;
DaniilStepanov May 30, 2023
31379b4
Statics field descriptors building and optimizations
DaniilStepanov May 30, 2023
c6421ca
Java constructor to jcdb constructor conversion fixed
DaniilStepanov May 31, 2023
b4f4655
minor bug fixes
DaniilStepanov Jun 1, 2023
11ea40b
minor
DaniilStepanov Jun 7, 2023
bc85a3a
Runner minor fixes
DaniilStepanov Jun 7, 2023
06ea110
Different improvements
DaniilStepanov Jun 21, 2023
dc2f00b
trash remove
DaniilStepanov Jun 21, 2023
253e6a7
new test
DaniilStepanov Jun 22, 2023
f47cc3b
rd gen fix
DaniilStepanov Jun 23, 2023
a6959be
Update jacodb version and some comments
DaniilStepanov Jun 23, 2023
d2d252b
Removing Instrumenter.kt
DaniilStepanov Jun 23, 2023
1c10ef1
Descriptor building bug fix
DaniilStepanov Jun 23, 2023
1f83308
Fix with non-public constructor call
DaniilStepanov Jun 23, 2023
b256d73
Exception handling fix
DaniilStepanov Jun 23, 2023
6bb7894
README added
DaniilStepanov Jun 23, 2023
dfcf089
More reliable static rollback
DaniilStepanov Jun 23, 2023
2ba3fc0
Mock implementation
DaniilStepanov Jun 27, 2023
b38868e
Mock implementation almost work
DaniilStepanov Jun 28, 2023
0be8b17
Instrumentation bug fix
DaniilStepanov Jun 29, 2023
6cd9c64
Static methods mocking added
DaniilStepanov Jun 29, 2023
cf49843
UTestArithmeticExpression added
DaniilStepanov Jul 6, 2023
7f90bc9
Java 11 patch
DaniilStepanov Jul 7, 2023
838d891
field logic fix
DaniilStepanov Jul 10, 2023
6ef20f2
Global mock support
DaniilStepanov Jul 12, 2023
4cae866
Executor added to jvm module
DaniilStepanov Jul 19, 2023
75738ad
Refactorings
DaniilStepanov Jul 20, 2023
a045189
unused class removed
DaniilStepanov Jul 20, 2023
4d45529
Rebased
DaniilStepanov Aug 9, 2023
b2fffed
Virtual calls supported
DaniilStepanov Aug 9, 2023
e8a202a
Init
DaniilStepanov May 25, 2023
ca1f2aa
Nested refs added
DaniilStepanov May 25, 2023
3869636
RD calls wrappers
DaniilStepanov May 25, 2023
13ee031
Result and initial descriptors refs are same if didnt change during e…
DaniilStepanov May 25, 2023
3c0ee1d
cyclic ref fix
DaniilStepanov May 25, 2023
8935206
UTest executor
DaniilStepanov May 30, 2023
181dd67
new tests;
DaniilStepanov May 30, 2023
c112942
Statics field descriptors building and optimizations
DaniilStepanov May 30, 2023
9897e9a
Java constructor to jcdb constructor conversion fixed
DaniilStepanov May 31, 2023
c3d1904
minor bug fixes
DaniilStepanov Jun 1, 2023
1df0997
minor
DaniilStepanov Jun 7, 2023
ba3633a
Runner minor fixes
DaniilStepanov Jun 7, 2023
68da2c2
Different improvements
DaniilStepanov Jun 21, 2023
fd84845
trash remove
DaniilStepanov Jun 21, 2023
71a0f4c
new test
DaniilStepanov Jun 22, 2023
580012a
rd gen fix
DaniilStepanov Jun 23, 2023
98b44e9
Update jacodb version and some comments
DaniilStepanov Jun 23, 2023
98d20bb
Removing Instrumenter.kt
DaniilStepanov Jun 23, 2023
67a2dd7
Descriptor building bug fix
DaniilStepanov Jun 23, 2023
d1041e4
Fix with non-public constructor call
DaniilStepanov Jun 23, 2023
1c6e0a4
Exception handling fix
DaniilStepanov Jun 23, 2023
df005f5
README added
DaniilStepanov Jun 23, 2023
ab7862a
More reliable static rollback
DaniilStepanov Jun 23, 2023
bb6225d
Mock implementation
DaniilStepanov Jun 27, 2023
a0fa905
Mock implementation almost work
DaniilStepanov Jun 28, 2023
b703c79
Instrumentation bug fix
DaniilStepanov Jun 29, 2023
8bf7b9e
Static methods mocking added
DaniilStepanov Jun 29, 2023
fdf2fcb
UTestArithmeticExpression added
DaniilStepanov Jul 6, 2023
4148f15
Java 11 patch
DaniilStepanov Jul 7, 2023
453cb04
field logic fix
DaniilStepanov Jul 10, 2023
3df23ee
Global mock support
DaniilStepanov Jul 12, 2023
fbee305
Executor added to jvm module
DaniilStepanov Jul 19, 2023
284a791
Refactorings
DaniilStepanov Jul 20, 2023
a810b53
unused class removed
DaniilStepanov Jul 20, 2023
55f6750
minor
DaniilStepanov Aug 9, 2023
e7ef30d
java.reflect.Class support
DaniilStepanov Aug 10, 2023
54cdf30
guava and bcel libraries removed from tests
DaniilStepanov Aug 15, 2023
53895ee
Trace serialization boost
DaniilStepanov Aug 16, 2023
46f4ded
minor
DaniilStepanov Aug 16, 2023
fa3f890
Timeout increased
DaniilStepanov Aug 17, 2023
a7d542a
minor
DaniilStepanov Aug 17, 2023
c0deb47
Improvements according to PR requests
DaniilStepanov Aug 18, 2023
36b1487
minor
DaniilStepanov Aug 18, 2023
22a32d7
More fixes according to PR changes request:
DaniilStepanov Aug 23, 2023
74c6ea4
package renaming
DaniilStepanov Aug 24, 2023
2b8b0d6
minor
DaniilStepanov Aug 24, 2023
6903819
minor
DaniilStepanov Aug 24, 2023
f90230a
Renaming according to USVM code style
DaniilStepanov Aug 24, 2023
a4ab1ef
no instrumentation mode added
DaniilStepanov Sep 28, 2023
3a58c05
Executor module updated to actual usvm with some improvements and fixes
DaniilStepanov Oct 5, 2023
c89beca
Executor module updated to actual usvm with some improvements and fixes
DaniilStepanov Oct 9, 2023
41d1f86
Added ValueDescriptor to UTestInst concept
DaniilStepanov Oct 27, 2023
47b205d
OriginUTestInst built for every field
DaniilStepanov Oct 30, 2023
1392083
Result execution state builds for exception result
DaniilStepanov Oct 30, 2023
d7374d0
Added max depth for object construction and generic removing when pas…
DaniilStepanov Oct 30, 2023
b1c7c24
minor
DaniilStepanov Oct 30, 2023
d3644d7
minor
DaniilStepanov Oct 30, 2023
5847035
Some tests are disabled for a some time...
DaniilStepanov Oct 30, 2023
4d86a74
Fixes w.r.t PR request
DaniilStepanov Nov 1, 2023
0111fd3
Tests fixes
DaniilStepanov Nov 1, 2023
14c7afd
removed unused policy file
DaniilStepanov Nov 1, 2023
b091164
minor
DaniilStepanov Nov 1, 2023
1d52569
Added test resolving option
DaniilStepanov Nov 1, 2023
38345c9
Added bounding on exceptions descriptors
DaniilStepanov Nov 2, 2023
871182b
Void type considered in jacodb as primitive
DaniilStepanov Nov 2, 2023
443fce9
Bug with wrong construction of arrays from descriptor fixed
DaniilStepanov Nov 2, 2023
a07bd65
Bug with wrong serialization of array types fixed
DaniilStepanov Nov 2, 2023
b5655c7
minor fixes
DaniilStepanov Nov 2, 2023
88ddd96
Little style fixes according to PR request
DaniilStepanov Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ object Versions {
const val samplesJavaxValidation = "2.0.0.Final"
const val samplesFindBugs = "1.3.9-1"
const val samplesJetbrainsAnnotations = "16.0.2"
const val rd = "2023.2.0"
const val ini4j = "0.5.4"
}
25 changes: 25 additions & 0 deletions docs/proposals/instrumentation-prosal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Instrumentation proposal

## Test-framework:
* Input: UTest (assemble models, concrete values, additional information) +
* Runner accept serialized UTest, assemble concrete values and run instrumented code on it +
* Dynamic instrumentation +

## Instrumentation
Requirements:
* Instrumentation:
* trace
* at the first stage only jacodb statements +
* concolic?
* statics rollback
* redefine classes in classloader
* non-deterministic functions mocks ?
* stdlib mocks ?
* at the first stage just ignore ?
* Run with timeout +
* Sandbox ?
* Result, diff +
* smth like UResult (assemble models?) +
* diffs between input and output +
* Static fields links -
* for what?
11 changes: 11 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ rootProject.name = "usvm"
include("usvm-core")
include("usvm-jvm")
include("usvm-util")
include("usvm-jvm-instrumentation")
include("usvm-sample-language")

pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.name == "rdgen") {
useModule("com.jetbrains.rd:rd-gen:${requested.version}")
}
}
}
}
20 changes: 20 additions & 0 deletions usvm-jvm-instrumentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Instrumentation module of the usvm project

Features:
* Execution and state building for target method
* Trace in jacodb instruction via dynamic instrumentation
* Static rollback
* Run with timeout

TODO:
* Mocks
* Sandbox
* Concolic trace

Input:
* classpath of analyzing project + UTest (see Tests and org.usvm.instrumentation.testcase.api.api.kt)

Output:
* Execution state (see org.usvm.instrumentation.testcase.api.response.kt)

Example of module usage for simple classes and guava located in tests
175 changes: 175 additions & 0 deletions usvm-jvm-instrumentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import com.jetbrains.rd.generator.gradle.RdGenExtension
import com.jetbrains.rd.generator.gradle.RdGenTask
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.sourceSets
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("usvm.kotlin-conventions")
id("com.jetbrains.rdgen") version Versions.rd
application
java
}

val rdgenModelsCompileClasspath by configurations.creating {
extendsFrom(configurations.compileClasspath.get())
}

sourceSets {
val samples by creating {
java {
srcDir("src/samples/java")
}
}

val collectors by creating {
java {
srcDir("src/collectors/java")
}
}

test {
compileClasspath += samples.output
runtimeClasspath += samples.output
}
}

kotlin {
sourceSets.create("rdgenModels").apply {
kotlin.srcDir("src/main/rdgen")
}
}

dependencies {
implementation("org.jacodb:jacodb-core:${Versions.jcdb}")
implementation("org.jacodb:jacodb-analysis:${Versions.jcdb}")

implementation("com.jetbrains.rd:rd-framework:${Versions.rd}")
implementation("org.ini4j:ini4j:${Versions.ini4j}")
implementation("com.jetbrains.rd:rd-core:${Versions.rd}")
implementation("commons-cli:commons-cli:1.5.0")
implementation("com.jetbrains.rd:rd-gen:${Versions.rd}")
implementation(files(buildDir.resolve("libs").resolve("usvm-jvm-instrumentation-collectors.jar").absolutePath))
}

tasks {
withType<KotlinCompile> {
kotlinOptions {
allWarningsAsErrors = false
}
}
}

val sourcesBaseDir = projectDir.resolve("src/main/kotlin")

val generatedPackage = "org.usvm.instrumentation.generated"
val generatedSourceDir = sourcesBaseDir.resolve(generatedPackage.replace('.', '/'))

val generatedModelsPackage = "$generatedPackage.models"
val generatedModelsSourceDir = sourcesBaseDir.resolve(generatedModelsPackage.replace('.', '/'))


val generateModels = tasks.register<RdGenTask>("generateProtocolModels") {
dependsOn.addAll(listOf("compileKotlin"))
val rdParams = extensions.getByName("params") as RdGenExtension
val sourcesDir = projectDir.resolve("src/main/rdgen").resolve("org/usvm/instrumentation/models")

group = "rdgen"
rdParams.verbose = true
rdParams.sources(sourcesDir)
rdParams.hashFolder = buildDir.resolve("rdgen/hashes").absolutePath
// where to search roots
rdParams.packages = "org.usvm.instrumentation.models"

rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.usvm.instrumentation.models.InstrumentedProcessRoot"

directory = generatedModelsSourceDir.absolutePath
namespace = generatedModelsPackage
}

rdParams.generator {
language = "kotlin"
transform = "symmetric"
root = "org.usvm.instrumentation.models.SyncProtocolRoot"

directory = generatedModelsSourceDir.absolutePath
namespace = generatedModelsPackage
}

}


tasks {
register<Jar>("instrumentationJar") {
group = "jar"
dependsOn.addAll(listOf("compileJava", "compileKotlin", "processResources"))
archiveClassifier.set("1.0")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
mapOf(
"Main-Class" to "org.usvm.instrumentation.rd.InstrumentedProcessKt",
"Premain-Class" to "org.usvm.instrumentation.agent.Agent",
"Can-Retransform-Classes" to "true",
"Can-Redefine-Classes" to "true"
)
)
}

val contents = configurations.runtimeClasspath.get()
.map { if (it.isDirectory) it else zipTree(it) }

from(contents)
with(jar.get() as CopySpec)
}
}


tasks {
register<Jar>("testJar") {
group = "jar"
shouldRunAfter("compileTestKotlin")
archiveClassifier.set("test")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

val contents = sourceSets.getByName("samples").output

from(contents)
dependsOn(getByName("compileSamplesJava"), configurations.testCompileClasspath)
dependsOn(configurations.compileClasspath)
}
}

tasks {
register<Jar>("collectorsJar") {
group = "jar"
shouldRunAfter("compileKotlin")
archiveClassifier.set("collectors")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

val contents = sourceSets.getByName("collectors").output

from(contents)
dependsOn(getByName("compileCollectorsJava"), configurations.compileClasspath)
dependsOn(configurations.compileClasspath)
}
}

tasks.withType<Test> {
environment(
"usvm-jvm-instrumentation-jar",
buildDir.resolve("libs").resolve("usvm-jvm-instrumentation-1.0.jar").absolutePath
)
environment(
"usvm-jvm-collectors-jar",
buildDir.resolve("libs").resolve("usvm-jvm-instrumentation-collectors.jar").absolutePath
)
}


tasks.getByName("compileKotlin").dependsOn("collectorsJar")//.mustRunAfter("collectorsJar")
tasks.getByName("compileKotlin").finalizedBy("instrumentationJar")
tasks.getByName("compileTestKotlin").finalizedBy("testJar")
Loading
Loading