Skip to content

Commit 10c35f6

Browse files
committed
SystemTests: insert suite name into output file names
this should avoid clashes where test suites try to write to the same output file. SystemTestsBAP and SystemTestsGTIRB are overriden to have no suffix, to maintain compatibility with the update-expected sbt/mill jobs.
1 parent 9e65f20 commit 10c35f6

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/test/scala/SystemTests.scala

+21-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import test_util.TestCustomisation
1818
*/
1919

2020
trait SystemTests extends AnyFunSuite, BASILTest, Retries, TestCustomisation {
21+
22+
/**
23+
* A suffix appended to output file names, in order to avoid clashes between test suites.
24+
*/
25+
def testSuiteSuffix = "_" + this.getClass.getSimpleName
26+
2127
case class TestResult(
2228
name: String,
2329
passed: Boolean,
@@ -154,15 +160,23 @@ trait SystemTests extends AnyFunSuite, BASILTest, Retries, TestCustomisation {
154160
def runTest(path: String, name: String, variation: String, conf: TestConfig): Unit = {
155161
val directoryPath = path + "/" + name + "/"
156162
val variationPath = directoryPath + variation + "/" + name
157-
val inputPath = if conf.useBAPFrontend then variationPath + ".adt" else variationPath + ".gts"
158-
val BPLPath = if conf.useBAPFrontend then variationPath + "_bap.bpl" else variationPath + "_gtirb.bpl"
163+
val suiteSuffix = testSuiteSuffix
164+
165+
// input files:
166+
val inputPath = variationPath + (if conf.useBAPFrontend then ".adt" else ".gts")
159167
val specPath = directoryPath + name + ".spec"
160168
val RELFPath = variationPath + ".relf"
161-
val resultPath =
162-
if conf.useBAPFrontend then variationPath + "_bap_result.txt" else variationPath + "_gtirb_result.txt"
163-
val testSuffix = if conf.useBAPFrontend then ":BAP" else ":GTIRB"
169+
170+
// output files:
171+
val lifterString = if conf.useBAPFrontend then s"_bap" else s"_gtirb"
172+
val BPLPath = variationPath + lifterString + suiteSuffix + ".bpl"
173+
val resultPath = variationPath + lifterString + suiteSuffix + "_result.txt"
174+
175+
// reference file:
164176
val expectedOutPath = if conf.useBAPFrontend then variationPath + ".expected" else variationPath + "_gtirb.expected"
165177

178+
val testSuffix = if conf.useBAPFrontend then ":BAP" else ":GTIRB"
179+
166180
Logger.info(s"$name/$variation$testSuffix")
167181
val timer = PerformanceTimer(s"test $name/$variation$testSuffix")
168182
runBASIL(inputPath, RELFPath, Some(specPath), BPLPath, conf.staticAnalysisConfig, conf.simplify)
@@ -250,6 +264,7 @@ trait SystemTests extends AnyFunSuite, BASILTest, Retries, TestCustomisation {
250264

251265
@test_util.tags.StandardSystemTest
252266
class SystemTestsBAP extends SystemTests {
267+
override def testSuiteSuffix = ""
253268
runTests("correct", TestConfig(useBAPFrontend = true, expectVerify = true, checkExpected = true, logResults = true))
254269
runTests(
255270
"incorrect",
@@ -262,6 +277,7 @@ class SystemTestsBAP extends SystemTests {
262277

263278
@test_util.tags.StandardSystemTest
264279
class SystemTestsGTIRB extends SystemTests {
280+
override def testSuiteSuffix = ""
265281
runTests("correct", TestConfig(useBAPFrontend = false, expectVerify = true, checkExpected = true, logResults = true))
266282
runTests(
267283
"incorrect",

0 commit comments

Comments
 (0)