diff --git a/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp b/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp --- a/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp +++ b/llvm/unittests/tools/llvm-profdata/OutputSizeLimitTest.cpp @@ -77,7 +77,8 @@ /// Note that even though by default samples with fewest total count are dropped /// first, this is not a requirement. Samples can be dropped by any order. static ExpectedErrorOr RunTest(StringRef Input, size_t SizeLimit, - SampleProfileFormat Format) { + SampleProfileFormat Format, + bool Compress = false) { // Read Input profile. auto FS = vfs::getRealFileSystem(); LLVMContext Context; @@ -93,6 +94,8 @@ { DEF_VAR_RETURN_IF_ERROR(Writer, SampleProfileWriter::create(Temp.path(), Format)); + if (Compress) + Writer->setToCompressAllSections(); std::error_code EC = Writer->writeWithSizeLimit(OldProfiles, SizeLimit); // too_large means no sample could be written because SizeLimit is too // small. Otherwise any other error code indicates unexpected failure. @@ -180,3 +183,11 @@ RunTest(Input1, OutputSizeLimit, llvm::sampleprof::SPF_Text), Succeeded()); } + +TEST(TestOutputSizeLimit, TestOutputSizeLimitExtBinaryCompressed) { + for (size_t OutputSizeLimit : + {507, 506, 505, 494, 493, 492, 483, 482, 481, 480}) + ASSERT_THAT_EXPECTED(RunTest(Input1, OutputSizeLimit, + llvm::sampleprof::SPF_Ext_Binary, true), + Succeeded()); +}