-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add representation tests for trace debugger native calls
- Loading branch information
1 parent
c1768d4
commit 98421d4
Showing
5 changed files
with
144 additions
and
10 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...etbrains/kotlinx/lincheck_test/representation/trace_debugger/RandomRepresentationTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Lincheck | ||
* | ||
* Copyright (C) 2019 - 2025 JetBrains s.r.o. | ||
* | ||
* This Source Code Form is subject to the terms of the | ||
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed | ||
* with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package org.jetbrains.kotlinx.lincheck_test.representation.trace_debugger | ||
|
||
import org.jetbrains.kotlinx.lincheck.annotations.Operation | ||
import org.jetbrains.kotlinx.lincheck.isInTraceDebuggerMode | ||
import org.jetbrains.kotlinx.lincheck_test.representation.BaseTraceRepresentationTest | ||
import org.jetbrains.kotlinx.lincheck_test.trace_debugger.NotRandom | ||
import org.junit.Assume.assumeTrue | ||
import org.junit.Before | ||
|
||
class SuccessfulCustomRandomCallRepresentationTest : BaseTraceRepresentationTest("trace_debugger/successful_nextInt") { | ||
@Before | ||
fun setUp() { | ||
assumeTrue(isInTraceDebuggerMode) | ||
} | ||
|
||
@Operation | ||
override fun operation() { | ||
NotRandom.nextInt(0, 1) | ||
} | ||
} | ||
|
||
class FailingCustomRandomCallRepresentationTest : BaseTraceRepresentationTest("trace_debugger/failing_nextInt") { | ||
@Before | ||
fun setUp() { | ||
assumeTrue(isInTraceDebuggerMode) | ||
} | ||
|
||
@Operation | ||
override fun operation() { | ||
NotRandom.nextInt(1, 1) | ||
} | ||
} | ||
|
||
class CustomRandomBytesCallRepresentationTest : BaseTraceRepresentationTest("trace_debugger/random_bytes") { | ||
@Before | ||
fun setUp() { | ||
assumeTrue(isInTraceDebuggerMode) | ||
} | ||
|
||
@Operation | ||
override fun operation() { | ||
NotRandom.nextBytes(ByteArray(10)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/jvm/test/resources/expected_logs/trace_debugger/failing_nextInt.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
= Invalid execution results = | ||
| ---------------------------------------- | | ||
| Thread 1 | | ||
| ---------------------------------------- | | ||
| operation(): IllegalArgumentException #1 | | ||
| ---------------------------------------- | | ||
|
||
--- | ||
The number next to an exception name helps you find its stack trace provided after the interleaving section | ||
--- | ||
|
||
The following interleaving leads to the error: | ||
| ---------------------------------------- | | ||
| Thread 1 | | ||
| ---------------------------------------- | | ||
| operation(): IllegalArgumentException #1 | | ||
| ---------------------------------------- | | ||
|
||
Exception stack traces: | ||
#1: java.lang.IllegalArgumentException: Random range is empty: [1, 1). | ||
at kotlin.random.RandomKt.checkRangeBounds(Random.kt:378) | ||
at kotlin.random.Random.nextInt(Random.kt:65) | ||
at org.jetbrains.kotlinx.lincheck_test.representation.trace_debugger.FailingCustomRandomCallRepresentationTest.operation(RandomRepresentationTests.kt:40) | ||
at java.base/java.lang.Thread.run(Thread.java:840) | ||
|
||
Detailed trace: | ||
| ---------------------------------------- | | ||
| Thread 1 | | ||
| ---------------------------------------- | | ||
| operation(): IllegalArgumentException #1 | | ||
| ---------------------------------------- | |
33 changes: 33 additions & 0 deletions
33
src/jvm/test/resources/expected_logs/trace_debugger/random_bytes.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
= Invalid execution results = | ||
| ----------------- | | ||
| Thread 1 | | ||
| ----------------- | | ||
| operation(): void | | ||
| ----------------- | | ||
|
||
The following interleaving leads to the error: | ||
| ----------- | | ||
| Thread 1 | | ||
| ----------- | | ||
| operation() | | ||
| ----------- | | ||
|
||
Detailed trace: | ||
| --------------------------------------------------------------------------------------------------------------------------------------- | | ||
| Thread 1 | | ||
| --------------------------------------------------------------------------------------------------------------------------------------- | | ||
| operation() | | ||
| NotRandom#1.nextBytes(ByteArray#1): ByteArray#1 at CustomRandomBytesCallRepresentationTest.operation(RandomRepresentationTests.kt:52) | | ||
| nextBytes(ByteArray#1, 0, 10): ByteArray#1 at Random.nextBytes(Random.kt:253) | | ||
| ByteArray#1[0] = 0 at Random.nextBytes(Random.kt:230) | | ||
| ByteArray#1[1] = 0 at Random.nextBytes(Random.kt:231) | | ||
| ByteArray#1[2] = 0 at Random.nextBytes(Random.kt:232) | | ||
| ByteArray#1[3] = 0 at Random.nextBytes(Random.kt:233) | | ||
| ByteArray#1[4] = 0 at Random.nextBytes(Random.kt:230) | | ||
| ByteArray#1[5] = 0 at Random.nextBytes(Random.kt:231) | | ||
| ByteArray#1[6] = 0 at Random.nextBytes(Random.kt:232) | | ||
| ByteArray#1[7] = 0 at Random.nextBytes(Random.kt:233) | | ||
| ByteArray#1[8] = 0 at Random.nextBytes(Random.kt:240) | | ||
| ByteArray#1[9] = 0 at Random.nextBytes(Random.kt:240) | | ||
| result: void | | ||
| --------------------------------------------------------------------------------------------------------------------------------------- | |
20 changes: 20 additions & 0 deletions
20
src/jvm/test/resources/expected_logs/trace_debugger/successful_nextInt.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
= Invalid execution results = | ||
| ----------------- | | ||
| Thread 1 | | ||
| ----------------- | | ||
| operation(): void | | ||
| ----------------- | | ||
|
||
The following interleaving leads to the error: | ||
| ----------- | | ||
| Thread 1 | | ||
| ----------- | | ||
| operation() | | ||
| ----------- | | ||
|
||
Detailed trace: | ||
| ----------- | | ||
| Thread 1 | | ||
| ----------- | | ||
| operation() | | ||
| ----------- | |