From 68c31ac03dd88bb0aef9fd38219e56968fcf05b5 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Thu, 2 Nov 2023 16:44:07 +0100 Subject: [PATCH] Added more xcfa2c tests --- .../mit/theta/xcfa/cli/XcfaCliParseTest.kt | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt index 4cb12efd10..c639fe37be 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt +++ b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt @@ -57,6 +57,23 @@ class XcfaCliParseTest { ) } + @JvmStatic + fun simpleCFiles(): Stream { + return Stream.of( + Arguments.of("/c/litmustest/singlethread/00assignment.c"), + Arguments.of("/c/litmustest/singlethread/01cast.c"), + Arguments.of("/c/litmustest/singlethread/02types.c"), + Arguments.of("/c/litmustest/singlethread/03bitwise.c"), + Arguments.of("/c/litmustest/singlethread/14ushort.c"), + Arguments.of("/c/litmustest/singlethread/15addition.c"), + Arguments.of("/c/litmustest/singlethread/16loop.c"), + Arguments.of("/c/litmustest/singlethread/17recursive.c"), + Arguments.of("/c/litmustest/singlethread/21namecollision.c"), + Arguments.of("/c/litmustest/singlethread/22nondet.c"), + Arguments.of("/c/litmustest/singlethread/23overflow.c"), + ) + } + @JvmStatic fun llvmFiles(): Stream { return Stream.of( @@ -225,4 +242,26 @@ class XcfaCliParseTest { temp.toFile().deleteRecursively() } + @ParameterizedTest + @MethodSource("simpleCFiles") + fun testCParseRoundTrip(filePath: String) { + val temp = createTempDirectory() + main(arrayOf( + "--input-type", "C", + "--input", javaClass.getResource(filePath)!!.path, + "--parse-only", + "--stacktrace", + "--output-results", + "--output-directory", temp.toAbsolutePath().toString(), + )) + val xcfaC = temp.resolve("xcfa.c").toFile() + main(arrayOf( + "--input-type", "C", + "--input", xcfaC.absolutePath.toString(), + "--parse-only", + "--stacktrace", + )) + temp.toFile().deleteRecursively() + } + }