[llvm-profdata] Add more unit tests to check --output-size-limit feature when compression is enabled
Add unit tests for ExtBinary format with compression. This patch doesn't imply there's a bug in the existing implementation, but as a precaution that planned changes to SampleProfileReader may cause it to break. Reviewed By: snehasish Differential Revision: https://reviews.llvm.org/D144524
This commit is contained in:
parent
8aaefa9243
commit
d8690bc1ea
|
@ -77,7 +77,8 @@ public:
|
|||
/// 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<void *> 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 @@ static ExpectedErrorOr<void *> RunTest(StringRef Input, size_t SizeLimit,
|
|||
{
|
||||
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 @@ TEST(TestOutputSizeLimit, TestOutputSizeLimitText) {
|
|||
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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user