<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 7, 2017 at 2:03 PM David Blaikie via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Fri Jul 7 14:02:59 2017<br>
New Revision: 307440<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=307440&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=307440&view=rev</a><br>
Log:<br>
ProfData: Fix some unchecked Errors in unit tests<br>
<br>
The 'NoError' function was meant to be used as the input to<br>
ASSERT/EXPECT_TRUE, but it is easy to forget this (it could be annotated<br>
with nodiscard to help this) so many sites that look like they're checked<br>
are not (& silently discard the failure). Only one site actually has an<br>
Error sneaking out this way and I've replaced that one with a<br>
FIXME+consumeError.<br>
<br>
The rest of the code has been modified to use the EXPECT_THAT_ERROR<br>
macros Zach introduced a while back. Between the options available this<br>
seems OK/good/something to standardize on - though it's difficult to<br>
build a matcher that could handle checking for a specific llvm::Error<br>
result, so those remain using the custom ErrorEquals (& the nodiscard<br>
added to ensure it is not misused as it was previous to this patch). It<br>
could still be generalized a bit further (even not as far as a matcher,<br>
but at least support multiple kinds of Error, etc) & added to the<br>
general Error utility header.<br>
<br>
Modified:<br>
llvm/trunk/unittests/ProfileData/CMakeLists.txt<br>
llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp<br>
llvm/trunk/unittests/ProfileData/InstrProfTest.cpp<br>
<br>
Modified: llvm/trunk/unittests/ProfileData/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CMakeLists.txt?rev=307440&r1=307439&r2=307440&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CMakeLists.txt?rev=307440&r1=307439&r2=307440&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ProfileData/CMakeLists.txt (original)<br>
+++ llvm/trunk/unittests/ProfileData/CMakeLists.txt Fri Jul 7 14:02:59 2017<br>
@@ -10,3 +10,5 @@ add_llvm_unittest(ProfileDataTests<br>
InstrProfTest.cpp<br>
SampleProfTest.cpp<br>
)<br>
+<br>
+target_link_libraries(ProfileDataTests LLVMTestingSupport)<br>
<br>
Modified: llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp?rev=307440&r1=307439&r2=307440&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp?rev=307440&r1=307439&r2=307440&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp (original)<br>
+++ llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp Fri Jul 7 14:02:59 2017<br>
@@ -13,6 +13,8 @@<br>
#include "llvm/ProfileData/InstrProfReader.h"<br>
#include "llvm/ProfileData/InstrProfWriter.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
+#include "llvm/Testing/Support/Error.h"<br>
+#include "llvm/Testing/Support/SupportHelpers.h"<br>
#include "gtest/gtest.h"<br>
<br>
#include <ostream><br>
@@ -21,15 +23,8 @@<br>
using namespace llvm;<br>
using namespace coverage;<br>
<br>
-static ::testing::AssertionResult NoError(Error E) {<br>
- if (!E)<br>
- return ::testing::AssertionSuccess();<br>
- return ::testing::AssertionFailure() << "error: " << toString(std::move(E))<br>
- << "\n";<br>
-}<br>
-<br>
-static ::testing::AssertionResult ErrorEquals(coveragemap_error Expected,<br>
- Error E) {<br>
+LLVM_NODISCARD static ::testing::AssertionResult<br>
+ErrorEquals(coveragemap_error Expected, Error E) {<br>
coveragemap_error Found;<br>
std::string FoundMsg;<br>
handleAllErrors(std::move(E), [&](const CoverageMapError &CME) {<br>
@@ -209,7 +204,7 @@ struct CoverageMappingTest : ::testing::<br>
std::vector<CounterExpression> Expressions;<br>
RawCoverageMappingReader Reader(Coverage, Filenames, Data.Filenames,<br>
Expressions, Data.Regions);<br>
- ASSERT_TRUE(NoError(Reader.read()));<br>
+ EXPECT_THAT_ERROR(Reader.read(), Succeeded());<br>
}<br>
<br>
void writeAndReadCoverageRegions(bool EmitFilenames = true) {<br>
@@ -227,7 +222,7 @@ struct CoverageMappingTest : ::testing::<br>
void readProfCounts() {<br>
auto Profile = ProfileWriter.writeBuffer();<br>
auto ReaderOrErr = IndexedInstrProfReader::create(std::move(Profile));<br>
- ASSERT_TRUE(NoError(ReaderOrErr.takeError()));<br>
+ EXPECT_THAT_ERROR(ReaderOrErr.takeError(), Succeeded());<br>
ProfileReader = std::move(ReaderOrErr.get());<br>
}<br>
<br>
@@ -309,7 +304,8 @@ TEST_P(CoverageMappingTest, correct_dese<br>
}<br>
<br>
TEST_P(CoverageMappingTest, load_coverage_for_more_than_two_files) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {0}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {0}}),<br>
+ Succeeded());<br>
<br>
const char *FileNames[] = {"bar", "baz", "foo"};<br>
static const unsigned N = array_lengthof(FileNames);<br>
@@ -320,7 +316,7 @@ TEST_P(CoverageMappingTest, load_coverag<br>
// in order to preserve that information during possible sorting of CMRs.<br>
addCMR(Counter::getCounter(0), FileNames[I], I, 1, I, 1);<br>
<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
for (unsigned I = 0; I < N; ++I) {<br>
CoverageData Data = LoadedCoverage->getCoverageForFile(FileNames[I]);<br>
@@ -330,15 +326,17 @@ TEST_P(CoverageMappingTest, load_coverag<br>
}<br>
<br>
TEST_P(CoverageMappingTest, load_coverage_with_bogus_function_name) {<br>
- NoError(ProfileWriter.addRecord({"", 0x1234, {10}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"", 0x1234, {10}}), Succeeded());<br>
startFunction("", 0x1234);<br>
addCMR(Counter::getCounter(0), "foo", 1, 1, 5, 5);<br>
- ErrorEquals(coveragemap_error::malformed, loadCoverageMapping());<br>
+ EXPECT_TRUE(ErrorEquals(coveragemap_error::malformed, loadCoverageMapping()));<br>
}<br>
<br>
TEST_P(CoverageMappingTest, load_coverage_for_several_functions) {<br>
- NoError(ProfileWriter.addRecord({"func1", 0x1234, {10}}));<br>
- NoError(ProfileWriter.addRecord({"func2", 0x2345, {20}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func1", 0x1234, {10}}),<br>
+ Succeeded());<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func2", 0x2345, {20}}),<br>
+ Succeeded());<br>
<br>
startFunction("func1", 0x1234);<br>
addCMR(Counter::getCounter(0), "foo", 1, 1, 5, 5);<br>
@@ -346,7 +344,7 @@ TEST_P(CoverageMappingTest, load_coverag<br>
startFunction("func2", 0x2345);<br>
addCMR(Counter::getCounter(0), "bar", 2, 2, 6, 6);<br>
<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
const auto FunctionRecords = LoadedCoverage->getCoveredFunctions();<br>
EXPECT_EQ(2, std::distance(FunctionRecords.begin(), FunctionRecords.end()));<br>
@@ -382,14 +380,15 @@ TEST_P(CoverageMappingTest, expansion_ge<br>
}<br>
<br>
TEST_P(CoverageMappingTest, basic_coverage_iteration) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {30, 20, 10, 0}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {30, 20, 10, 0}}),<br>
+ Succeeded());<br>
<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
addCMR(Counter::getCounter(1), "file1", 1, 1, 4, 7);<br>
addCMR(Counter::getCounter(2), "file1", 5, 8, 9, 1);<br>
addCMR(Counter::getCounter(3), "file1", 10, 10, 11, 11);<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -406,7 +405,7 @@ TEST_P(CoverageMappingTest, basic_covera<br>
TEST_P(CoverageMappingTest, uncovered_function) {<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getZero(), "file1", 1, 2, 3, 4);<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -419,7 +418,7 @@ TEST_P(CoverageMappingTest, uncovered_fu<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
addCMR(Counter::getCounter(1), "file1", 1, 1, 4, 7);<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -430,13 +429,14 @@ TEST_P(CoverageMappingTest, uncovered_fu<br>
}<br>
<br>
TEST_P(CoverageMappingTest, combine_regions) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {10, 20, 30}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {10, 20, 30}}),<br>
+ Succeeded());<br>
<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
addCMR(Counter::getCounter(1), "file1", 3, 3, 4, 4);<br>
addCMR(Counter::getCounter(2), "file1", 3, 3, 4, 4);<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -448,13 +448,14 @@ TEST_P(CoverageMappingTest, combine_regi<br>
}<br>
<br>
TEST_P(CoverageMappingTest, restore_combined_counter_after_nested_region) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {10, 20, 40}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {10, 20, 40}}),<br>
+ Succeeded());<br>
<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
addCMR(Counter::getCounter(1), "file1", 1, 1, 9, 9);<br>
addCMR(Counter::getCounter(2), "file1", 3, 3, 5, 5);<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -468,15 +469,17 @@ TEST_P(CoverageMappingTest, restore_comb<br>
// If CodeRegions and ExpansionRegions cover the same area,<br>
// only counts of CodeRegions should be used.<br>
TEST_P(CoverageMappingTest, dont_combine_expansions) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {10, 20}}));<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {0, 0}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {10, 20}}),<br>
+ Succeeded());<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {0, 0}}),<br>
+ Succeeded());<br>
<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
addCMR(Counter::getCounter(1), "file1", 3, 3, 4, 4);<br>
addCMR(Counter::getCounter(1), "include1", 6, 6, 7, 7);<br>
addExpansionCMR("file1", "include1", 3, 3, 4, 4);<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("file1");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -489,7 +492,8 @@ TEST_P(CoverageMappingTest, dont_combine<br>
<br>
// If an area is covered only by ExpansionRegions, they should be combinated.<br>
TEST_P(CoverageMappingTest, combine_expansions) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {2, 3, 7}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {2, 3, 7}}),<br>
+ Succeeded());<br>
<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(1), "include1", 1, 1, 1, 10);<br>
@@ -498,7 +502,7 @@ TEST_P(CoverageMappingTest, combine_expa<br>
addExpansionCMR("file", "include1", 3, 1, 3, 5);<br>
addExpansionCMR("file", "include2", 3, 1, 3, 5);<br>
<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("file");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -510,11 +514,12 @@ TEST_P(CoverageMappingTest, combine_expa<br>
}<br>
<br>
TEST_P(CoverageMappingTest, strip_filename_prefix) {<br>
- NoError(ProfileWriter.addRecord({"file1:func", 0x1234, {0}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"file1:func", 0x1234, {0}}),<br>
+ Succeeded());<br>
<br>
startFunction("file1:func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
std::vector<std::string> Names;<br>
for (const auto &Func : LoadedCoverage->getCoveredFunctions())<br>
@@ -524,11 +529,12 @@ TEST_P(CoverageMappingTest, strip_filena<br>
}<br>
<br>
TEST_P(CoverageMappingTest, strip_unknown_filename_prefix) {<br>
- NoError(ProfileWriter.addRecord({"<unknown>:func", 0x1234, {0}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"<unknown>:func", 0x1234, {0}}),<br>
+ Succeeded());<br>
<br>
startFunction("<unknown>:func", 0x1234);<br>
addCMR(Counter::getCounter(0), "", 1, 1, 9, 9);<br>
- NoError(loadCoverageMapping(/*EmitFilenames=*/false));<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(/*EmitFilenames=*/false), Succeeded());<br>
<br>
std::vector<std::string> Names;<br>
for (const auto &Func : LoadedCoverage->getCoveredFunctions())<br>
@@ -538,8 +544,10 @@ TEST_P(CoverageMappingTest, strip_unknow<br>
}<br>
<br>
TEST_P(CoverageMappingTest, dont_detect_false_instantiations) {<br>
- NoError(ProfileWriter.addRecord({"foo", 0x1234, {10}}));<br>
- NoError(ProfileWriter.addRecord({"bar", 0x2345, {20}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"foo", 0x1234, {10}}),<br>
+ Succeeded());<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"bar", 0x2345, {20}}),<br>
+ Succeeded());<br>
<br>
startFunction("foo", 0x1234);<br>
addCMR(Counter::getCounter(0), "expanded", 1, 1, 1, 10);<br>
@@ -549,7 +557,7 @@ TEST_P(CoverageMappingTest, dont_detect_<br>
addCMR(Counter::getCounter(0), "expanded", 1, 1, 1, 10);<br>
addExpansionCMR("main", "expanded", 9, 1, 9, 5);<br>
<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
std::vector<const FunctionRecord *> Instantiations =<br>
LoadedCoverage->getInstantiations("expanded");<br>
@@ -557,13 +565,14 @@ TEST_P(CoverageMappingTest, dont_detect_<br>
}<br>
<br>
TEST_P(CoverageMappingTest, load_coverage_for_expanded_file) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {10}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {10}}),<br>
+ Succeeded());<br>
<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "expanded", 1, 1, 1, 10);<br>
addExpansionCMR("main", "expanded", 4, 1, 4, 5);<br>
<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
CoverageData Data = LoadedCoverage->getCoverageForFile("expanded");<br>
std::vector<CoverageSegment> Segments(Data.begin(), Data.end());<br>
@@ -573,7 +582,8 @@ TEST_P(CoverageMappingTest, load_coverag<br>
}<br>
<br>
TEST_P(CoverageMappingTest, skip_duplicate_function_record) {<br>
- NoError(ProfileWriter.addRecord({"func", 0x1234, {1}}));<br>
+ EXPECT_THAT_ERROR(ProfileWriter.addRecord({"func", 0x1234, {1}}),<br>
+ Succeeded());<br>
<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
@@ -581,7 +591,7 @@ TEST_P(CoverageMappingTest, skip_duplica<br>
startFunction("func", 0x1234);<br>
addCMR(Counter::getCounter(0), "file1", 1, 1, 9, 9);<br>
<br>
- NoError(loadCoverageMapping());<br>
+ EXPECT_THAT_ERROR(loadCoverageMapping(), Succeeded());<br>
<br>
auto Funcs = LoadedCoverage->getCoveredFunctions();<br>
unsigned NumFuncs = std::distance(Funcs.begin(), Funcs.end());<br>
<br>
Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=307440&r1=307439&r2=307440&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=307440&r1=307439&r2=307440&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)<br>
+++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Fri Jul 7 14:02:59 2017<br>
@@ -14,20 +14,15 @@<br>
#include "llvm/ProfileData/InstrProfReader.h"<br>
#include "llvm/ProfileData/InstrProfWriter.h"<br>
#include "llvm/Support/Compression.h"<br>
+#include "llvm/Testing/Support/Error.h"<br>
+#include "llvm/Testing/Support/SupportHelpers.h"<br>
#include "gtest/gtest.h"<br>
#include <cstdarg><br>
<br>
using namespace llvm;<br>
<br>
-static ::testing::AssertionResult NoError(Error E) {<br>
- if (!E)<br>
- return ::testing::AssertionSuccess();<br>
- return ::testing::AssertionFailure() << "error: " << toString(std::move(E))<br>
- << "\n";<br>
-}<br>
-<br>
-static ::testing::AssertionResult ErrorEquals(instrprof_error Expected,<br>
- Error E) {<br>
+LLVM_NODISCARD static ::testing::AssertionResult<br>
+ErrorEquals(instrprof_error Expected, Error E) {<br>
instrprof_error Found;<br>
std::string FoundMsg;<br>
handleAllErrors(std::move(E), [&](const InstrProfError &IPE) {<br>
@@ -49,7 +44,7 @@ struct InstrProfTest : ::testing::Test {<br>
<br>
void readProfile(std::unique_ptr<MemoryBuffer> Profile) {<br>
auto ReaderOrErr = IndexedInstrProfReader::create(std::move(Profile));<br>
- ASSERT_TRUE(NoError(ReaderOrErr.takeError()));<br>
+ EXPECT_THAT_ERROR(ReaderOrErr.takeError(), Succeeded());<br>
Reader = std::move(ReaderOrErr.get());<br>
}<br>
};<br>
@@ -70,7 +65,8 @@ TEST_P(MaybeSparseInstrProfTest, write_a<br>
}<br>
<br>
TEST_P(MaybeSparseInstrProfTest, write_and_read_one_function) {<br>
- NoError(Writer.addRecord({"foo", 0x1234, {1, 2, 3, 4}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1234, {1, 2, 3, 4}}),<br>
+ Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
@@ -87,19 +83,19 @@ TEST_P(MaybeSparseInstrProfTest, write_a<br>
}<br>
<br>
TEST_P(MaybeSparseInstrProfTest, get_instr_prof_record) {<br>
- NoError(Writer.addRecord({"foo", 0x1234, {1, 2}}));<br>
- NoError(Writer.addRecord({"foo", 0x1235, {3, 4}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1234, {1, 2}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1235, {3, 4}}), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("foo", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(2U, R->Counts.size());<br>
ASSERT_EQ(1U, R->Counts[0]);<br>
ASSERT_EQ(2U, R->Counts[1]);<br>
<br>
R = Reader->getInstrProfRecord("foo", 0x1235);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(2U, R->Counts.size());<br>
ASSERT_EQ(3U, R->Counts[0]);<br>
ASSERT_EQ(4U, R->Counts[1]);<br>
@@ -112,18 +108,20 @@ TEST_P(MaybeSparseInstrProfTest, get_ins<br>
}<br>
<br>
TEST_P(MaybeSparseInstrProfTest, get_function_counts) {<br>
- NoError(Writer.addRecord({"foo", 0x1234, {1, 2}}));<br>
- NoError(Writer.addRecord({"foo", 0x1235, {3, 4}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1234, {1, 2}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1235, {3, 4}}), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
std::vector<uint64_t> Counts;<br>
- ASSERT_TRUE(NoError(Reader->getFunctionCounts("foo", 0x1234, Counts)));<br>
+ EXPECT_THAT_ERROR(Reader->getFunctionCounts("foo", 0x1234, Counts),<br>
+ Succeeded());<br>
ASSERT_EQ(2U, Counts.size());<br>
ASSERT_EQ(1U, Counts[0]);<br>
ASSERT_EQ(2U, Counts[1]);<br>
<br>
- ASSERT_TRUE(NoError(Reader->getFunctionCounts("foo", 0x1235, Counts)));<br>
+ EXPECT_THAT_ERROR(Reader->getFunctionCounts("foo", 0x1235, Counts),<br>
+ Succeeded());<br>
ASSERT_EQ(2U, Counts.size());<br>
ASSERT_EQ(3U, Counts[0]);<br>
ASSERT_EQ(4U, Counts[1]);<br>
@@ -137,14 +135,15 @@ TEST_P(MaybeSparseInstrProfTest, get_fun<br>
<br>
// Profile data is copied from general.proftext<br>
TEST_F(InstrProfTest, get_profile_summary) {<br>
- NoError(Writer.addRecord({"func1", 0x1234, {97531}}));<br>
- NoError(Writer.addRecord({"func2", 0x1234, {0, 0}}));<br>
- NoError(Writer.addRecord(<br>
- {"func3",<br>
- 0x1234,<br>
- {2305843009213693952, 1152921504606846976, 576460752303423488,<br>
- 288230376151711744, 144115188075855872, 72057594037927936}}));<br>
- NoError(Writer.addRecord({"func4", 0x1234, {0}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"func1", 0x1234, {97531}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"func2", 0x1234, {0, 0}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"func3",<br>
+ 0x1234,<br>
+ {2305843009213693952, 1152921504606846976,<br>
+ 576460752303423488, 288230376151711744,<br>
+ 144115188075855872, 72057594037927936}}),<br>
+ Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"func4", 0x1234, {0}}), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
@@ -195,23 +194,24 @@ TEST_F(InstrProfTest, get_profile_summar<br>
}<br>
<br>
TEST_F(InstrProfTest, test_writer_merge) {<br>
- NoError(Writer.addRecord({"func1", 0x1234, {42}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"func1", 0x1234, {42}}), Succeeded());<br>
<br>
InstrProfWriter Writer2;<br>
- NoError(Writer2.addRecord({"func2", 0x1234, {0, 0}}));<br>
+ EXPECT_THAT_ERROR(Writer2.addRecord({"func2", 0x1234, {0, 0}}), Succeeded());<br>
<br>
- NoError(Writer.mergeRecordsFromWriter(std::move(Writer2)));<br>
+ EXPECT_THAT_ERROR(Writer.mergeRecordsFromWriter(std::move(Writer2)),<br>
+ Succeeded());<br>
<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("func1", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(1U, R->Counts.size());<br>
ASSERT_EQ(42U, R->Counts[0]);<br>
<br>
R = Reader->getInstrProfRecord("func2", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(2U, R->Counts.size());<br>
ASSERT_EQ(0U, R->Counts[0]);<br>
ASSERT_EQ(0U, R->Counts[1]);<br>
@@ -239,15 +239,15 @@ TEST_P(MaybeSparseInstrProfTest, get_ica<br>
InstrProfValueData VD3[] = {{(uint64_t)callee1, 1}};<br>
Record1.addValueData(IPVK_IndirectCallTarget, 3, VD3, 1, nullptr);<br>
<br>
- NoError(Writer.addRecord(std::move(Record1)));<br>
- NoError(Writer.addRecord({"callee1", 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({"callee2", 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({"callee3", 0x1235, {3, 4}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record1)), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee1", 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee2", 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee3", 0x1235, {3, 4}}), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(4U, R->getNumValueSites(IPVK_IndirectCallTarget));<br>
ASSERT_EQ(3U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 0));<br>
ASSERT_EQ(0U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 1));<br>
@@ -274,11 +274,11 @@ TEST_P(MaybeSparseInstrProfTest, annotat<br>
InstrProfValueData VD0[] = {{1000, 1}, {2000, 2}, {3000, 3}, {5000, 5},<br>
{4000, 4}, {6000, 6}};<br>
Record.addValueData(IPVK_IndirectCallTarget, 0, VD0, 6, nullptr);<br>
- NoError(Writer.addRecord(std::move(Record)));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record)), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
<br>
LLVMContext Ctx;<br>
std::unique_ptr<Module> M(new Module("MyModule", Ctx));<br>
@@ -379,15 +379,15 @@ TEST_P(MaybeSparseInstrProfTest, get_ica<br>
InstrProfValueData VD3[] = {{(uint64_t)callee1, 1}};<br>
Record1.addValueData(IPVK_IndirectCallTarget, 3, VD3, 1, nullptr);<br>
<br>
- NoError(Writer.addRecord(std::move(Record1), 10));<br>
- NoError(Writer.addRecord({"callee1", 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({"callee2", 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({"callee3", 0x1235, {3, 4}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record1), 10), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee1", 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee2", 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee3", 0x1235, {3, 4}}), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(4U, R->getNumValueSites(IPVK_IndirectCallTarget));<br>
ASSERT_EQ(3U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 0));<br>
ASSERT_EQ(0U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 1));<br>
@@ -422,10 +422,10 @@ TEST_P(MaybeSparseInstrProfTest, get_ica<br>
InstrProfValueData VD3[] = {{(uint64_t)callee1, 1}};<br>
Record1.addValueData(IPVK_IndirectCallTarget, 3, VD3, 1, nullptr);<br>
<br>
- NoError(Writer.addRecord(std::move(Record1)));<br>
- NoError(Writer.addRecord({"callee1", 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({"callee2", 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({"callee3", 0x1235, {3, 4}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record1)), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee1", 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee2", 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"callee3", 0x1235, {3, 4}}), Succeeded());<br>
<br>
// Set big endian output.<br>
Writer.setValueProfDataEndianness(support::big);<br>
@@ -437,7 +437,7 @@ TEST_P(MaybeSparseInstrProfTest, get_ica<br>
Reader->setValueProfDataEndianness(support::big);<br>
<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(4U, R->getNumValueSites(IPVK_IndirectCallTarget));<br>
ASSERT_EQ(3U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 0));<br>
ASSERT_EQ(0U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 1));<br>
@@ -501,20 +501,20 @@ TEST_P(MaybeSparseInstrProfTest, get_ica<br>
{uint64_t(callee3), 3}};<br>
Record12.addValueData(IPVK_IndirectCallTarget, 4, VD42, 3, nullptr);<br>
<br>
- NoError(Writer.addRecord(std::move(Record11)));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record11)), Succeeded());<br>
// Merge profile data.<br>
- NoError(Writer.addRecord(std::move(Record12)));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record12)), Succeeded());<br>
<br>
- NoError(Writer.addRecord({callee1, 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({callee2, 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({callee3, 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({callee3, 0x1235, {3, 4}}));<br>
- NoError(Writer.addRecord({callee4, 0x1235, {3, 5}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({callee1, 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({callee2, 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({callee3, 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({callee3, 0x1235, {3, 4}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({callee4, 0x1235, {3, 5}}), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
ASSERT_EQ(5U, R->getNumValueSites(IPVK_IndirectCallTarget));<br>
ASSERT_EQ(4U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 0));<br>
ASSERT_EQ(0U, R->getNumValueDataForSite(IPVK_IndirectCallTarget, 1));<br>
@@ -600,7 +600,7 @@ TEST_P(MaybeSparseInstrProfTest, get_ica<br>
// Verify saturation of counts.<br>
Expected<InstrProfRecord> ReadRecord1 =<br>
Reader->getInstrProfRecord("foo", 0x1234);<br>
- ASSERT_TRUE(NoError(ReadRecord1.takeError()));<br>
+ EXPECT_THAT_ERROR(ReadRecord1.takeError(), Succeeded());<br>
ASSERT_EQ(Max, ReadRecord1->Counts[0]);<br>
<br>
Expected<InstrProfRecord> ReadRecord2 =<br>
@@ -643,15 +643,15 @@ TEST_P(MaybeSparseInstrProfTest, get_ica<br>
Record12.addValueData(IPVK_IndirectCallTarget, 0, VD1, 255, nullptr);<br>
Record12.addValueData(IPVK_IndirectCallTarget, 1, nullptr, 0, nullptr);<br>
<br>
- NoError(Writer.addRecord(std::move(Record11)));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record11)), Succeeded());<br>
// Merge profile data.<br>
- NoError(Writer.addRecord(std::move(Record12)));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord(std::move(Record12)), Succeeded());<br>
<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
Expected<InstrProfRecord> R = Reader->getInstrProfRecord("caller", 0x1234);<br>
- ASSERT_TRUE(NoError(R.takeError()));<br>
+ EXPECT_THAT_ERROR(R.takeError(), Succeeded());<br>
std::unique_ptr<InstrProfValueData[]> VD(<br>
R->getValueForSite(IPVK_IndirectCallTarget, 0));<br>
ASSERT_EQ(2U, R->getNumValueSites(IPVK_IndirectCallTarget));<br>
@@ -790,9 +790,11 @@ TEST_P(MaybeSparseInstrProfTest, value_p<br>
}<br>
<br>
TEST_P(MaybeSparseInstrProfTest, get_max_function_count) {<br>
- NoError(Writer.addRecord({"foo", 0x1234, {1ULL << 31, 2}}));<br>
- NoError(Writer.addRecord({"bar", 0, {1ULL << 63}}));<br>
- NoError(Writer.addRecord({"baz", 0x5678, {0, 0, 0, 0}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1234, {1ULL << 31, 2}}),<br>
+ Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"bar", 0, {1ULL << 63}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"baz", 0x5678, {0, 0, 0, 0}}),<br>
+ Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
@@ -800,18 +802,20 @@ TEST_P(MaybeSparseInstrProfTest, get_max<br>
}<br>
<br>
TEST_P(MaybeSparseInstrProfTest, get_weighted_function_counts) {<br>
- NoError(Writer.addRecord({"foo", 0x1234, {1, 2}}, 3));<br>
- NoError(Writer.addRecord({"foo", 0x1235, {3, 4}}, 5));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1234, {1, 2}}, 3), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1235, {3, 4}}, 5), Succeeded());<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
std::vector<uint64_t> Counts;<br>
- ASSERT_TRUE(NoError(Reader->getFunctionCounts("foo", 0x1234, Counts)));<br>
+ EXPECT_THAT_ERROR(Reader->getFunctionCounts("foo", 0x1234, Counts),<br>
+ Succeeded());<br>
ASSERT_EQ(2U, Counts.size());<br>
ASSERT_EQ(3U, Counts[0]);<br>
ASSERT_EQ(6U, Counts[1]);<br>
<br>
- ASSERT_TRUE(NoError(Reader->getFunctionCounts("foo", 0x1235, Counts)));<br>
+ EXPECT_THAT_ERROR(Reader->getFunctionCounts("foo", 0x1235, Counts),<br>
+ Succeeded());<br>
ASSERT_EQ(2U, Counts.size());<br>
ASSERT_EQ(15U, Counts[0]);<br>
ASSERT_EQ(20U, Counts[1]);<br>
@@ -827,7 +831,7 @@ TEST_P(MaybeSparseInstrProfTest, instr_p<br>
FuncNames.push_back("bar2");<br>
FuncNames.push_back("bar3");<br>
InstrProfSymtab Symtab;<br>
- NoError(Symtab.create(FuncNames));<br>
+ EXPECT_THAT_ERROR(Symtab.create(FuncNames), Succeeded());<br>
StringRef R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func1"));<br>
ASSERT_EQ(StringRef("func1"), R);<br>
R = Symtab.getFuncName(IndexedInstrProf::ComputeHash("func2"));<br>
@@ -848,9 +852,9 @@ TEST_P(MaybeSparseInstrProfTest, instr_p<br>
ASSERT_EQ(StringRef(), R);<br>
<br>
// Now incrementally update the symtab<br>
- NoError(Symtab.addFuncName("blah_1"));<br>
- NoError(Symtab.addFuncName("blah_2"));<br>
- NoError(Symtab.addFuncName("blah_3"));<br>
+ EXPECT_THAT_ERROR(Symtab.addFuncName("blah_1"), Succeeded());<br>
+ EXPECT_THAT_ERROR(Symtab.addFuncName("blah_2"), Succeeded());<br>
+ EXPECT_THAT_ERROR(Symtab.addFuncName("blah_3"), Succeeded());<br>
// Finalize it<br>
Symtab.finalizeSymtab();<br>
<br>
@@ -878,7 +882,7 @@ TEST_P(MaybeSparseInstrProfTest, instr_p<br>
// Test that we get an error when creating a bogus symtab.<br>
TEST_P(MaybeSparseInstrProfTest, instr_prof_bogus_symtab_empty_func_name) {<br>
InstrProfSymtab Symtab;<br>
- ErrorEquals(instrprof_error::malformed, Symtab.addFuncName(""));<br>
+ EXPECT_TRUE(ErrorEquals(instrprof_error::malformed, Symtab.addFuncName("")));<br>
}<br>
<br>
// Testing symtab creator interface used by value profile transformer.<br>
@@ -901,7 +905,7 @@ TEST_P(MaybeSparseInstrProfTest, instr_p<br>
Function::Create(FTy, Function::WeakODRLinkage, "Wbar", M.get());<br>
<br>
InstrProfSymtab ProfSymtab;<br>
- NoError(ProfSymtab.create(*M));<br>
+ EXPECT_THAT_ERROR(ProfSymtab.create(*M), Succeeded());<br>
<br>
StringRef Funcs[] = {"Gfoo", "Gblah", "Gbar", "Ifoo", "Iblah", "Ibar",<br>
"Pfoo", "Pblah", "Pbar", "Wfoo", "Wblah", "Wbar"};<br>
@@ -941,13 +945,17 @@ TEST_P(MaybeSparseInstrProfTest, instr_p<br>
for (bool DoCompression : {false, true}) {<br>
// Compressing:<br>
std::string FuncNameStrings1;<br>
- NoError(collectPGOFuncNameStrings(<br>
- FuncNames1, (DoCompression && zlib::isAvailable()), FuncNameStrings1));<br>
+ EXPECT_THAT_ERROR(collectPGOFuncNameStrings(<br>
+ FuncNames1, (DoCompression && zlib::isAvailable()),<br>
+ FuncNameStrings1),<br>
+ Succeeded());<br>
<br>
// Compressing:<br>
std::string FuncNameStrings2;<br>
- NoError(collectPGOFuncNameStrings(<br>
- FuncNames2, (DoCompression && zlib::isAvailable()), FuncNameStrings2));<br>
+ EXPECT_THAT_ERROR(collectPGOFuncNameStrings(<br>
+ FuncNames2, (DoCompression && zlib::isAvailable()),<br>
+ FuncNameStrings2),<br>
+ Succeeded());<br>
<br>
for (int Padding = 0; Padding < 2; Padding++) {<br>
// Join with paddings :<br>
@@ -959,7 +967,7 @@ TEST_P(MaybeSparseInstrProfTest, instr_p<br>
<br>
// Now decompress:<br>
InstrProfSymtab Symtab;<br>
- NoError(Symtab.create(StringRef(FuncNameStrings)));<br>
+ EXPECT_THAT_ERROR(Symtab.create(StringRef(FuncNameStrings)), Succeeded());<br>
<br>
// Now do the checks:<br>
// First sampling some data points:<br>
@@ -983,9 +991,11 @@ TEST_P(MaybeSparseInstrProfTest, instr_p<br>
}<br>
<br>
TEST_F(SparseInstrProfTest, preserve_no_records) {<br>
- NoError(Writer.addRecord({"foo", 0x1234, {0}}));<br>
- NoError(Writer.addRecord({"bar", 0x4321, {0, 0}}));<br>
- NoError(Writer.addRecord({"bar", 0x4321, {0, 0, 0}}));<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"foo", 0x1234, {0}}), Succeeded());<br>
+ EXPECT_THAT_ERROR(Writer.addRecord({"bar", 0x4321, {0, 0}}), Succeeded());<br>
+ // FIXME: I'm guessing this data should be different, but the original author<br>
+ // should check/update this test so it doesn't produce errors.<br>
+ consumeError(Writer.addRecord({"bar", 0x4321, {0, 0, 0}}));<br></blockquote><div><br>Hey Vedant - could you fix this ^ I'm not sure what the right fix was, so left it this way to preserve existing behavior.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
auto Profile = Writer.writeBuffer();<br>
readProfile(std::move(Profile));<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>