blob: 5daed99829c631019b7fe8a9c12f948200055217 [file] [log] [blame]
Nikita Koval515e86a2020-04-28 11:30:04 +03001/*
2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5@file:Suppress("unused")
6
Aurimas Liutikasc8879d62021-05-12 21:56:16 +00007package kotlinx.coroutines.linearizability
Nikita Koval515e86a2020-04-28 11:30:04 +03008
9import kotlinx.coroutines.*
10import kotlinx.coroutines.internal.*
11import org.jetbrains.kotlinx.lincheck.annotations.*
Aurimas Liutikasc8879d62021-05-12 21:56:16 +000012import org.jetbrains.kotlinx.lincheck.annotations.Operation
Nikita Koval515e86a2020-04-28 11:30:04 +030013import org.jetbrains.kotlinx.lincheck.paramgen.*
Aurimas Liutikasc8879d62021-05-12 21:56:16 +000014import org.jetbrains.kotlinx.lincheck.verifier.*
15import org.junit.*
Nikita Koval515e86a2020-04-28 11:30:04 +030016
Aurimas Liutikasc8879d62021-05-12 21:56:16 +000017
18class SegmentListRemoveLCStressTest : VerifierState() {
Nikita Koval515e86a2020-04-28 11:30:04 +030019 private val q = SegmentBasedQueue<Int>()
20 private val segments: Array<OneElementSegment<Int>>
21
22 init {
23 segments = (0..5).map { q.enqueue(it)!! }.toTypedArray()
24 q.enqueue(6)
25 }
26
27 @Operation
28 fun removeSegment(@Param(gen = IntGen::class, conf = "1:5") index: Int) {
29 segments[index].removeSegment()
30 }
31
32 override fun extractState() = segments.map { it.logicallyRemoved }
33
34 @Validate
35 fun checkAllRemoved() {
36 q.checkHeadPrevIsCleaned()
37 q.checkAllSegmentsAreNotLogicallyRemoved()
38 }
39
Aurimas Liutikasc8879d62021-05-12 21:56:16 +000040 @Test
41 fun test() = LCStressOptionsDefault()
42 .actorsBefore(0)
43 .actorsAfter(0)
44 .check(this::class)
Nikita Koval515e86a2020-04-28 11:30:04 +030045}