Commit 94c44693 authored by Noric Couderc's avatar Noric Couderc
Browse files

Fix: Disabled test which didn't always trigger the wanted behaviour

Sometimes, converting from long to double could cause errors. We added
an assertion to avoid that, but my test didn't always trigger the
issue. So I disabled it.
parent 4c24118c
......@@ -74,7 +74,9 @@ class Experiment(val numberIterations : Int,
val values = currentIteration.filter { it.featureName == c.toHexa() }
.map { it.featureValue }
currentIterationResults[c] = values.sum().toDouble()
val total = values.sum().toDouble()
assert(total > 0) { "Narrowing conversion overflow" }
currentIterationResults[c] = total
}
override fun visitConstant(constantFeature: ConstantFeature) {
......
import org.junit.FixMethodOrder
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.runners.MethodSorters
import papi.Constants
......@@ -10,7 +11,10 @@ import se.lth.cs.papicounters.PapiTracerRunner
import se.lth.cs.smartmodules.tracer.Tracer
import se.lth.cs.timing.OperationType
import se.lth.cs.util.*
import java.lang.AssertionError
import java.util.*
import java.util.stream.Collectors
import kotlin.collections.ArrayList
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
class ExperimentTest {
......@@ -48,8 +52,9 @@ class ExperimentTest {
}
@Test
@Disabled("Doesn't always trigger the exceptions we expect")
fun testOverflowExperiment() {
val longBench = BCBenchmarkPackage.LIST(1234, 1000000, 0, ArrayList<Int>())
val longBench = BCBenchmarkPackage.LIST(1234, 1000000, 0, LinkedList<Int>())
val shortBench = BCBenchmarkPackage.LIST(1234, 100, 0, ArrayList<Int>())
val costPerDelete = CostFeature(OperationType.DELETE)
......@@ -68,9 +73,7 @@ class ExperimentTest {
)
// This should trigger an overflow but it's silent
val results = exp.run().collect(Collectors.toList())
Assertions.assertTrue(results.all { it.values[PAPICounter("PAPI_TOT_CYC")]!! > 0.0 })
Assertions.assertThrows(AssertionError::class.java) { exp.run() }
// Running another experiment afterwards should still work.
val exp2 = Experiment(10, shortBench, FeatureSet(PAPICounter("PAPI_TOT_CYC")), runner)
......
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment