================
@@ -26,4 +57,37 @@ TEST(SerializationFormatRegistryTest,
EnumeratingRegistryEntries) {
EXPECT_EQ(Formats.begin()->getName(), "MockSerializationFormat");
}
+TEST(SerializationFormatRegistryTest, Roundtrip) {
+ StringLiteral FancyAnalysisFileData = "FancyAnalysisData{\n"
+ " SomeInternalList: zed, vayne, lux\n"
+ "}\n";
+
+ auto Inputs = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
+ Inputs->addFile("input/analyses.txt", /*ModificationTime=*/{},
+ MemoryBuffer::getMemBufferCopy("FancyAnalysis\n"));
+ Inputs->addFile("input/FancyAnalysis.special", /*ModificationTime=*/{},
+ MemoryBuffer::getMemBufferCopy(FancyAnalysisFileData));
+
+ std::unique_ptr<SerializationFormat> Format =
+ makeFormat(Inputs, "MockSerializationFormat");
+ ASSERT_TRUE(Format);
+
+ TUSummary LoadedSummary = Format->readTUSummary("input");
+
+ // Create a temporary output directory
+ SmallString<128> OutputDir;
+ std::error_code EC = sys::fs::createUniqueDirectory("ssaf-test", OutputDir);
----------------
aviralg wrote:
My initial thought was:
1. Use `sys::fs::createUniqueDirectory` to create a directory and populate it
with the two input files.
2. Use readTUSummary to read from this input directory.
3. Use `sys::fs::createUniqueDirectory` to create an output directory
4. Use writeTUSummary to populate this output directory.
5. Check that the file contents in the output directory match the data used to
populate the corresponding input files.
However, I realized later that you want to use InMemoryFileSystem here by
design since we are introducing support for virtualizing input-reading in the
other PR. So what you have is reasonable.
https://github.com/llvm/llvm-project/pull/179517
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits