-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic verification of the interference results for MySys
- Loading branch information
1 parent
712864c
commit 320f87b
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
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,28 @@ | ||
< t13 || t26 > | ||
< t11 || t26 > | ||
< t13 || t22 > | ||
< t11 || t22 > | ||
< t11 || t23 > | ||
< t13 || t23 > | ||
< t14 || t26 > | ||
< t26 || t41 > | ||
< t11 || t41 > | ||
< t13 || t41 > | ||
< t13 || t24 > | ||
< t12 || t26 > | ||
< t11 || t24 > | ||
< t11 || t21 > | ||
< t13 || t21 > | ||
< t14 || t21 > | ||
< t12 || t21 > | ||
< t24 || t41 > | ||
< t12 || t41 > | ||
< t21 || t41 > | ||
< t12 || t31 > | ||
< t11 || t31 > | ||
< t13 || t31 > | ||
< t14 || t31 > | ||
< t13 || t25 > | ||
< t11 || t25 > | ||
< t14 || t22 > | ||
< t12 || t25 > |
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,8 @@ | ||
< t11 || t26 || t41 > | ||
< t13 || t26 || t41 > | ||
< t13 || t21 || t41 > | ||
< t11 || t21 || t41 > | ||
< t12 || t26 || t41 > | ||
< t11 || t24 || t41 > | ||
< t13 || t24 || t41 > | ||
< t12 || t21 || t41 > |
Empty file.
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,12 @@ | ||
< t14 || t23 > | ||
< t12 || t24 > | ||
< t21 || t31 > | ||
< t31 || t41 > | ||
< t22 || t41 > | ||
< t14 || t41 > | ||
< t23 || t41 > | ||
< t25 || t41 > | ||
< t14 || t25 > | ||
< t12 || t22 > | ||
< t14 || t24 > | ||
< t12 || t23 > |
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,8 @@ | ||
< t14 || t23 || t41 > | ||
< t14 || t22 || t41 > | ||
< t14 || t25 || t41 > | ||
< t12 || t23 || t41 > | ||
< t14 || t24 || t41 > | ||
< t12 || t22 || t41 > | ||
< t14 || t31 || t41 > | ||
< t21 || t31 || t41 > |
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 @@ | ||
< t14 || t21 || t31 || t41 > |
78 changes: 78 additions & 0 deletions
78
src/test/scala/onera/pmlanalyzer/views/interference/InterferenceTestExtension.scala
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,78 @@ | ||
/** ***************************************************************************** | ||
* Copyright (c) 2021. ONERA | ||
* This file is part of PML Analyzer | ||
* | ||
* PML Analyzer is free software ; | ||
* you can redistribute it and/or modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation ; | ||
* either version 2 of the License, or (at your option) any later version. | ||
* | ||
* PML Analyzer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with this program ; | ||
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* **************************************************************************** */ | ||
|
||
package onera.pmlanalyzer.views.interference | ||
|
||
import onera.pmlanalyzer.pml.exporters.FileManager | ||
import onera.pmlanalyzer.pml.operators.* | ||
import onera.pmlanalyzer.views.interference.operators.* | ||
import onera.pmlanalyzer.views.interference.operators.Analyse.ConfiguredPlatform | ||
|
||
import scala.concurrent.ExecutionContext.Implicits.* | ||
import scala.concurrent.Future | ||
import scala.io.Source | ||
import scala.language.postfixOps | ||
|
||
object InterferenceTestExtension { | ||
|
||
extension (x:ConfiguredPlatform) { | ||
|
||
def test(max: Int, expectedResultsDirectoryPath: String): Future[Seq[Seq[ScenarioComparison]]] = { | ||
x.computeKInterference(List(max, x.initiators.size).min, ignoreExistingAnalysisFiles = true, verboseResultFile = false) map { | ||
resultFiles => { | ||
for { | ||
i <- 2 to List(max, x.initiators.size).min | ||
fileITF <- FileManager.extractResource(s"$expectedResultsDirectoryPath/${x.fullName}_itf_$i.txt") | ||
fileFree <- FileManager.extractResource(s"$expectedResultsDirectoryPath/${x.fullName}_free_$i.txt") | ||
rITFFile <- resultFiles.find(_.getName == s"${x.fullName}_itf_$i.txt") | ||
rFreeFile <- resultFiles.find(_.getName == s"${x.fullName}_free_$i.txt") | ||
} yield { | ||
List(fileITF, fileFree) | ||
.zip(List(rITFFile, rFreeFile)) | ||
.flatMap(p => { | ||
val expected = PostProcess.parseScenarioFile(p._1) | ||
val found = PostProcess.parseScenarioFile(Source.fromFile(p._2)) | ||
expected.diff(found).map(s => Missing(s)) ++ found.diff(expected).map(s => Unknown(s)) | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
def failureMessage(diff: Seq[ScenarioComparison]): String = { | ||
if (diff.nonEmpty) | ||
s"""${diff.size} scenarios of size ${diff.head.s.size} are incorrect: | ||
|${diff.mkString("\n")} | ||
|
||
|""".stripMargin | ||
else | ||
"" | ||
} | ||
} | ||
|
||
sealed trait ScenarioComparison { | ||
val s: Seq[String] | ||
} | ||
|
||
case class Missing(s: Seq[String]) extends ScenarioComparison { | ||
override def toString: String = s.mkString("||") + " not found" | ||
} | ||
|
||
case class Unknown(s: Seq[String]) extends ScenarioComparison { | ||
override def toString: String = s.mkString("||") + " not expected" | ||
} |
24 changes: 24 additions & 0 deletions
24
...est/scala/onera/pmlanalyzer/views/interference/examples/mySys/MySysInterferenceTest.scala
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,24 @@ | ||
package onera.pmlanalyzer.views.interference.examples.mySys | ||
|
||
import onera.pmlanalyzer.pml.examples.mySys.MySysExport.MySys | ||
import onera.pmlanalyzer.views.interference.InterferenceTestExtension | ||
import onera.pmlanalyzer.views.interference.operators.* | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should | ||
import onera.pmlanalyzer.views.interference.InterferenceTestExtension.* | ||
|
||
import scala.concurrent.Await | ||
import scala.concurrent.duration.DurationInt | ||
import scala.language.postfixOps | ||
|
||
class MySysInterferenceTest extends AnyFlatSpec with should.Matchers { | ||
|
||
private val expectedResultsDirectoryPath = "mySys" | ||
|
||
"For MySys, the interference analysis" should "find the verified interference" in { | ||
val diff = Await.result(MySys.test(4, expectedResultsDirectoryPath), 10 minutes) | ||
if (diff.exists(_.nonEmpty)) { | ||
fail(diff.map(InterferenceTestExtension.failureMessage).mkString("\n")) | ||
} | ||
} | ||
} |