[llvm-branch-commits] [clang] [clang][ssaf] Add FormatInfo sub-registry and tests [2/2] (PR #179517)
Aviral Goel via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Feb 4 13:52:46 PST 2026
================
@@ -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
More information about the llvm-branch-commits
mailing list