[llvm] r240359 - InstrProf: Add a test for multiple copies of the same with different hashes

Justin Bogner mail at justinbogner.com
Mon Jun 22 16:56:54 PDT 2015


Author: bogner
Date: Mon Jun 22 18:56:53 2015
New Revision: 240359

URL: http://llvm.org/viewvc/llvm-project?rev=240359&view=rev
Log:
InstrProf: Add a test for multiple copies of the same with different hashes

This functionality wasn't being tested.

Patch by Betul Buyukkurt.

Modified:
    llvm/trunk/unittests/ProfileData/InstrProfTest.cpp

Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=240359&r1=240358&r2=240359&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Mon Jun 22 18:56:53 2015
@@ -68,6 +68,7 @@ TEST_F(InstrProfTest, write_and_read_one
 
 TEST_F(InstrProfTest, get_function_counts) {
   Writer.addFunctionCounts("foo", 0x1234, {1, 2});
+  Writer.addFunctionCounts("foo", 0x1235, {3, 4});
   auto Profile = Writer.writeBuffer();
   readProfile(std::move(Profile));
 
@@ -77,6 +78,11 @@ TEST_F(InstrProfTest, get_function_count
   ASSERT_EQ(1U, Counts[0]);
   ASSERT_EQ(2U, Counts[1]);
 
+  ASSERT_TRUE(NoError(Reader->getFunctionCounts("foo", 0x1235, Counts)));
+  ASSERT_EQ(2U, Counts.size());
+  ASSERT_EQ(3U, Counts[0]);
+  ASSERT_EQ(4U, Counts[1]);
+
   std::error_code EC;
   EC = Reader->getFunctionCounts("foo", 0x5678, Counts);
   ASSERT_TRUE(ErrorEquals(instrprof_error::hash_mismatch, EC));





More information about the llvm-commits mailing list